[ wraith46 @ 31.03.2017. 17:09 ] @
Pravim jednostavan GUI program u Pythonu, imam problem sa accessovanjem funkcije iz funkcije (ako me razumete). Hoću da pristupim funkciji addItem() iz funkcije display(). Code: # priorities.py # GUI program to manage priorities from tkinter import * class Priority: def __init__(self, subject, priority): self.subject = subject self.priority = priority def subject(self): return self.subject def priority(self): return self.priority class GuiPart: def __init__(self): self.root = self.createWindow() def createWindow(self): root = Tk() root.resizable(width = False, height = False) root.title("Priorities") return root def display(self): listBox = Listbox().grid(row=1) buttonAdd = Button(text = "Add").grid(row = 2, column = 0, sticky = W, command = g.addItem) buttonRemove = Button(text="Remove").grid(row = 2, column = 0, sticky = W, command = g.removeItem) buttonEdit = Button(text="Edit").grid(row = 2, column = 0, sticky = E, command = g.editItem) textBox = Text().grid(row = 3) def addItem(self): item = Priority(self.subject, self.priority) item.subject = g.textBox.get("1.0", 'end-1c') g.listBox.insert(END, self) class Client: pass if __name__ == "__main__": g = GuiPart() g.display() g.root.mainloop() Evo šta javlja: Citat: /usr/bin/python3.5 /home/cali/PycharmProjects/priorities/priorities.py Traceback (most recent call last): File "/home/cali/PycharmProjects/priorities/priorities.py", line 70, in <module> g.display() File "/home/cali/PycharmProjects/priorities/priorities.py", line 39, in display command = g.addItem) File "/usr/lib/python3.5/tkinter/__init__.py", line 2077, in grid_configure + self._options(cnf, kw)) _tkinter.TclError: bad option "-command": must be -column, -columnspan, -in, -ipadx, -ipady, -padx, -pady, -row, -rowspan, or -sticky Process finished with exit code 1 |