![Bild](http://img212.imageshack.us/img212/5165/greenshot20071202130604ei2.jpg)
bin aber immer noch auf der suche
![Sad :(](./images/smilies/icon_sad.gif)
zur not steig ich auf wxPython um wenn:
1. sowas dort möglich ist (?)
2. ich die GUI hauptsächlich in Tkinter aufbaue und die Dropdownbox mit wxPython einfach "zwischenquetsche" kann (?)
Code: Alles auswählen
listbox.place(x=30, y=600, width=80, height=50)
Guck mal hier.sorgenlos hat geschrieben:Was versteht man unter Layout-Manager?
Code: Alles auswählen
from Tkinter import *
class test_GUI:
def __init__(self):
fenster=Tk()
fenster.geometry("110x75")
#Die Listbox
lb = Listbox(fenster, selectmode=EXTENDED)
lb.pack()
lb.place(x=18, y=10, width=80, height=35)
lb.insert(END, "Peter")
lb.insert(END, "Hans")
#Der Button
test_button=Button(fenster,text="test", command=self.read)
test_button.place(x=6, y=50, width=100, height=20)
#die Methode
def read(event):
text = lb.get(lb.curselection())
print text
__name__ == '__main__'
dasFenster = test_GUI()
mainloop()
Code: Alles auswählen
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
return self.func(*args)
File "C:\123.py", line 19, in read
text = lb.get(lb.curselection())
NameError: global name 'lb' is not defined
Code: Alles auswählen
def read(self, event):
text = self.lb.get(lb.curselection())
print text
Code: Alles auswählen
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
return self.func(*args)
TypeError: read() takes exactly 2 arguments (1 given)
Code: Alles auswählen
import Tkinter as tk
class test_GUI:
def __init__(self):
fenster = tk.Tk()
fenster.geometry("110x75")
#Die Listbox
self.lb = tk.Listbox(fenster, selectmode=tk.EXTENDED)
self.lb.pack()
self.lb.place(x=18, y=10, width=80, height=35)
self.lb.insert(tk.END, "Peter")
self.lb.insert(tk.END, "Hans")
#Der Button
test_button = tk.Button(fenster, text="test", command=self.read)
test_button.place(x=6, y=50, width=100, height=20)
#die Methode
def read(self):
for i in self.lb.curselection():
text = self.lb.get(i)
print text
__name__ == '__main__'
dasFenster = test_GUI()
tk.mainloop()
Code: Alles auswählen
import Tkinter as tk
class TestGUI:
def __init__(self):
fenster = tk.Tk()
self.listbox = tk.Listbox(fenster,
selectmode=tk.EXTENDED,
width=10,
height=2)
for name in ('Peter', 'Hans'):
self.listbox.insert(tk.END, name)
self.listbox.pack()
test_button = tk.Button(fenster, text='test', command=self.read)
test_button.pack()
def read(self):
print self.listbox.get(self.listbox.curselection())
if __name__ == '__main__':
das_fenster = TestGUI()
tk.mainloop()