user interface - Python tkinter:Update label tag , Event and label in different classes -


i have problem want update label when push on button.but event , label in different classes make hard assign it.here how try it.first event class:

class eventsbinding(windowinhalt):     def test(self, event):         print("gedrückt")      def root_destroy(self, event):         self.root.destroy()      def credits(self, event):         window = windowinhalt()         window.label1.config(text="update") #here try update label 

and second here class label:

class windowinhalt():     def label4(self):         events_binding = eventsbinding()         label = label(self.root, text="credits", fg="black",bg="lightyellow", font=('arial', 14))         label.bind("<button-1>", events_binding.credits) #here assign event         label.place(x=200, y=280, width="400", height="20") 

and here full code if need them:

#mein erstes gui python programm mit tkinter #created: july,2017 #creator: yuto tkinter import *  #class für den inhalt des windows z.b. label class windowinhalt():     def label1(self):         events_binding = eventsbinding()         label = label(self.root, text="willkommen zu meinem text adventure", fg="black",bg="lightyellow", font=('arial', 14))         label.bind("<button-1>", events_binding.test)         label.place(x=200, y=50, width="400", height="20")      def label2(self):         events_binding = eventsbinding()         label = label(self.root, text="spielen", fg="black",bg="lightyellow", font=('arial', 14))         label.bind("<button-1>", events_binding.test)         label.place(x=200, y=120, width="400", height="20")      def label3(self):         events_binding = eventsbinding()         label = label(self.root, text="settings", fg="black",bg="lightyellow", font=('arial', 14))         label.bind("<button-1>", events_binding.test)         label.place(x=200, y=200, width="400", height="20")      def label4(self):         events_binding = eventsbinding()         label = label(self.root, text="credits", fg="black",bg="lightyellow", font=('arial', 14))         label.bind("<button-1>", events_binding.credits)         label.place(x=200, y=280, width="400", height="20")      def button(self):         events_binding = eventsbinding()         button = button(self.root, text="spiel verlassen", command=self.root.destroy)         button.place(x=680, y=340, width="110", height="40")    class eventsbinding(windowinhalt):     def test(self, event):         print("gedrückt")      def root_destroy(self, event):         self.root.destroy()      def credits(self, event):         window = windowinhalt()         window.label1.config(text="update")    #class für das window sich hier wird dann auch z.b. inhalt eingebunden class window(windowinhalt):     def __init__(self):         super().__init__()         self.root = tk()         self.label1()         self.label2()         self.label3()         self.label4()         self.button()         self.windowsettings()      #settings für das window z.b. größe     def windowsettings(self):         self.root.configure(background="lightyellow")         self.root.title("gui lalallalala")         self.root.wm_geometry("800x400+600+300")         self.root.mainloop()    #only ausführen wenn es nicht eingebunden ist if __name__ == "__main__":     print("starten")     w = window() else:     print("dise datei bitte nicht einbinden!") 

and here if need him error message:

    traceback (most recent call last):   file "d:\programme\python\lib\tkinter\__init__.py", line 1699, in __call__     return self.func(*args)   file "d:/programme/pycharm/pycharm community edition 2017.1.4/projekt/gui game.py", line 48, in credits     window.label1.config(text="update") attributeerror: 'function' object has no attribute 'config' 

i greatfull thank in advance :)

edit: have it.i have change variable so

label4 = label(text="update", fg="black", bg="lightyellow", font=('arial', 14))         label4.place(x=200, y=280, width="400", height="20") 

thank respectively hint bryan oakley , wish have nice day :)


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -