python - Compare contents of Entry widget every time a key is pressed -


i have here code snippet python 2.7 , tkinter:

i trying compare contents of 2 entry widgets every time typing character in 1 of 2 entry widgets.

class mainapp():  def __init__(self, master):     """constructor"""      frame = frame(master)     frame.bind("<key>", self.key)     frame.pack()      ...      self.instruction = label(frame,             text="press 'show new word', start typing word",             wraplength=250)     self.instruction.pack(padx=10, pady=10)      self.word = stringvar()      self.new_word = entry(frame, justify=center,             textvariable=self.word, bg="green", fg="yellow",             font="arial 24 bold", relief=flat)     self.new_word.pack(padx=10, pady=5)      self.input_word = entry(frame, font="monospace 12")     self.input_word.pack(padx=10, pady=5)      self.create_word = button(frame, text="new word (press enter)",             command=self.generate_word)     self.create_word.pack(padx=10, pady=10)      self.input_word.focus_set()  def generate_word(self):     """new word generator"""      ...   def key(self, event):     """enter char in input_word"""      ...     self.check()  def check(self):     """checks entered char"""      = self.new_word.get()     b = self.input_word.get()      if != b:         ...     else:         ... 

with code tkinter event handler cannot detect typing new characters or won't run method compare entry widgets.

i can't seem figure out solution yet still trying so.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -