'import Tkinter as' macht aerger
Verfasst: Donnerstag 6. April 2006, 15:08
Folgender Code funktioniert einwandfrei:
Aber wenn ich anstelle von 'from Tkinter import *' 'import Tkinter as tk' benutze:
bekomme ich folgende Fehlermeldung:
Code: Alles auswählen
#!/usr/bin/python
from Tkinter import *
def ok(textfeld):
text = textfeld.get(1.0, END)
print text
def gui():
root = Tk()
textfeld = Text(root, width=45, height=6)
textfeld.grid()
button = Button(root, text="Get", command=lambda: ok(textfeld))
button.grid()
root.mainloop()
gui()
Code: Alles auswählen
#!/usr/bin/python
import Tkinter as tk
def ok(textfeld):
text = textfeld.get(1.0, END)
print text
def gui():
root = tk.Tk()
textfeld = tk.Text(root, width=45, height=6)
textfeld.grid()
button = tk.Button(root, text="Get", command=lambda: ok(textfeld))
button.grid()
root.mainloop()
gui()
was mache ich falsch????File "tkentry.py", line 5, in ok
text = textfeld.get(1.0, END)
NameError: global name 'END' is not defined