Ich habe eine frage:
Wie macht man das hier:
Danke!
Wie heißt dieses widget?
-
- User
- Beiträge: 59
- Registriert: Freitag 31. Mai 2013, 21:18
ImmmerEineGuteIdee
|=|=|=|=|=|=|=|
HardwareManager
|=|=|=|=|=|=|=|
HardwareManager
- Michael Schneider
- User
- Beiträge: 569
- Registriert: Samstag 8. April 2006, 12:31
- Wohnort: Brandenburg
So in etwa?
Code: Alles auswählen
import Tkinter as tk
itemslist = ["aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii",
"jjj", "kkk", "LLL", "mmm", "nnn", "ooo", "ppp", "qqq", "rrr",
"sss", "this is an example of a very long option which you may "
"or may not wish to choose."*2, "ttt", "uuu", "vvv", "www", "xxx"]
class ScrolledListbox(tk.Frame):
def __init__(self, *args, **kwds):
tk.Frame.__init__(self, *args, **kwds)
self._create_gui(**kwds)
def _create_gui(self, width=30, height=20, **kwds):
self.listbox = tk.Listbox(self, width=width, height=height, **kwds)
self.listbox.grid(row=1, column=1, sticky="nsew")
self.scrollx = tk.Scrollbar(self, orient="horizontal", command=self.listbox.xview)
self.scrollx.grid(row=2, column=1, sticky="ew")
self.scrolly = tk.Scrollbar(self, orient="vertical", command=self.listbox.yview)
self.scrolly.grid(row=1, column=2, sticky="ns")
self.listbox.config(xscrollcommand=self.scrollx.set, yscrollcommand=self.scrolly.set)
if __name__ == "__main__":
root = tk.Tk()
frame = ScrolledListbox(root, width=80, height=20)
frame.grid()
for item in itemslist:
frame.listbox.insert("end", item)
root.mainloop()
Diese Nachricht zersört sich in 5 Sekunden selbst ...
Tix had die ScrolledListbox schon mal eingebaut:
Code: Alles auswählen
''' Tix_ScrolledListBox2.py
Tkinter extension module tix comes with Python27 and Python31+
explore the tix.ScrolledListBox
vertical or horizontal scroll bars appear as needed (automatic)
for more info check ...
http://docs.python.org/library/tix.html
http://doc.astro-wise.org/Tix.html
actually Tix imports Tkinter so you can call it all tix
'''
try:
#import Tkinter as tk
import Tix as tix # Python27
except ImportError:
#import tkinter as tk
import tkinter.tix as tix # Python31 and higher
app = tix.Tk()
app.title('tix.ScrolledListBox')
scr_list = tix.ScrolledListBox(app, scrollbar='auto')
scr_list.pack(fill='both', expand=1)
s = 'line'
for ix, line in enumerate(range(20)):
line_text = s + str(ix+1)
scr_list.listbox.insert('end', line_text)
s = 'a very long line to demo the horizontal automatic scrollbar'
scr_list.listbox.insert('end', s)
app.mainloop()
Atomkraftwerkaktienbesitzer
- Michael Schneider
- User
- Beiträge: 569
- Registriert: Samstag 8. April 2006, 12:31
- Wohnort: Brandenburg
Stimmt. Aber das hatte ich als nicht-Standardbib damals nicht eingebaut und kam daher noch nicht dazu, mich damit zu beschäftigen. Da ist es gut, dass hier Experten aus allen Bereichen herumlaufen, die das aus dem FF sagen können.
Diese Nachricht zersört sich in 5 Sekunden selbst ...
-
- User
- Beiträge: 59
- Registriert: Freitag 31. Mai 2013, 21:18
Ja Danke
ImmmerEineGuteIdee
|=|=|=|=|=|=|=|
HardwareManager
|=|=|=|=|=|=|=|
HardwareManager