python - Changing text of label does not work -


i have problem following python script. later, catch data barcode scanner , display text label. whenever text should changed label (highlighted line), program crashes. absolute beginner python , can not explain that. comment out line, program works.

from tkinter import * import pyhook  class application(frame):     def __init__(self):         frame.__init__(self)         self.master.title("sc4nn0r")         self.variable = "start variable"          self.master.geometry("363x200")         self.master.resizable(0,0)          self.master.rowconfigure( 0, weight = 1)         self.master.columnconfigure( 0, weight = 1 )         self.grid( sticky = w+e+n+s )          self.label4string = stringvar()         self.label4 = label(self, textvariable=self.label4string)         self.label4.grid( row = 2, column = 1, columnspan = 2, sticky = w+e+n+s)         self.label4string.set("variable1")          self.string = ''         hook = pyhook.hookmanager()         hook.keydown = self.read         hook.hookkeyboard()      def read(self, event):         print(event.ascii);         if event.ascii != 13:             self.string = self.string + chr(event.ascii)         else:             self.post(self.string.strip(' \0'))             self.string = ''         return true      def post(self,string):         self.label4string.set(string) # line mean ##########         print(string)   def main():     application().mainloop()  if __name__ == '__main__':     main() 

i hope can me.

i suggest getting rid of stringvar in entirety. instead, use self.label4 = label(self, text = "variable1"). then, whenever wish change label, can use self.label4.config(text = string).


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -