nieako mi to nefunguje. skusil som to prerobit takto
Kód:
from tkinter import *
def volanafunkcia():
print (add.get())
def hello():
print ("hello")
#grafika
root = Tk()
#velkost okna
velkost = Canvas(root, width=500, height=500)
velkost.pack()
def vloz():
add = StringVar()
vstup = Entry(root, textvariable=add)
vstup.pack()
vstup.focus_set()
tlacitko = Button(root, text="Nacitaj", width=10, command=volanafunkcia, font="ArialNarrow 10")
tlacitko.pack()
menuLista = Menu(root)
menuLista.add_command(label="Add!", command=vloz)
menuLista.add_command(label="Exit!", command=root.destroy)
#zobrazenie menu
root.config(menu=menuLista)
mainloop()
ale stale to hadze
Kód:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python32\lib\tkinter\__init__.py", line 1399, in __call__
return self.func(*args)
File "C:\Documents and Settings\PLC\Desktop\DBConnector\mydbx.py", line 3, in volanafunkcia
print (add.get())
NameError: global name 'add' is not defined
ked dam funkciu volana funkcia za "grafiku" tak topadne hned.