title: How to register a @staticmethod password checker callback for a ttk.Entry widget?
body: <p>I have written a password strength checker that dynamically checks the strength of the password keyed into a <code>ttk.Entry</code> widget. I have applied the <a href="https://stackoverflow.com/a/32542964/5722359">criteria</a> by @ePi272314 and the <a href="https://stackoverflow.com/a/4140988/5722359">tutorial on adding validation</a> by @ByranOakley to a <code>ttk.Entry</code> widget. The python script for this password strength checking ttk.Entry widget is given below and it works.</p>
  
  <p>Presently, I like to express method <code>_passwordStrength()</code> as a <code>@staticmethod</code> so that other classes may use it. For this to happen, I need to pass <code>self.pwstrength</code>, a <code>tk.StringVar()</code>, into it. Also, I need to include this <code>tk.StringVar</code> when I register the <code>@staticmethod</code>. However, I am having difficulty implementing this. </p>
  
  <p>I tried something like:</p>
  
  <pre><code>vcmd = (self.register(lambda:App._passwordStrength(self.pwstrength),'%P')) 
  </code></pre>
  
  <p>but got the error msg:</p>
  
  <pre class="lang-none prettyprint-override"><code>Exception in Tkinter callback
  Traceback (most recent call last):
    File "/usr/lib/python3.5/tkinter/__init__.py", line 1552, in __call__
      args = self.subst(*args)
  TypeError: 'str' object is not callable
  </code></pre>
  
  <p>Appreciate guidance on how to register the <code>@staticmethod _passwordStrength()</code> when it contains a <code>tk.StringVar</code> input parameter.</p>
  
  <p><strong>Python Script:</strong></p>
  
  <pre><code>import tkinter as tk
  import tkinter.ttk as ttk
  import re
  
  
  class App(ttk.Frame):
  
      def __init__(self, parent=None, *args, **kwargs):
  
          ttk.Frame.__init__(self, parent, style='self.TFrame')
  
          self.style=ttk.Style()
          self.style.configure('self.TFrame', background='pink', borderwidth=10,
                               relief='raised')
  
          self.pwstrength = tk.StringVar()
  
          label = ttk.Label(self, text="Password:   ")
  
          vcmd = (self.register(self._passwordStrength), '%P')
          ePassword = ttk.Entry(self, validate="key", validatecommand=vcmd)
          warnLabel = ttk.Label(self, textvariable=self.pwstrength)
  
          label.grid(row=0, column=0, sticky='w', padx=20, pady=20)
          ePassword.grid(row=0, column=1, sticky='w')
          warnLabel.grid(row=1, column=1, sticky='w')      
  
  
      def _passwordStrength(self, P):
          '''Check password strength.
  
          A password is considered strong if:
              8 characters length or more
              1 digit or more
              1 symbol or more
              1 uppercase letter or more
              1 lowercase letter or more'''
  
          password = P
          print (password, len(password))
  
          # check length
          if password == '':
              self.pwstrength.set('')
              return True
  
          # check length
          if len(password) &lt; 8:
              self.pwstrength.set('Password is too short')
              return True
  
          # check for digits
          if not re.search(r"\d", password):
              self.pwstrength.set('Password missing a number.')
              return True
  
          # check for uppercase
          if not re.search(r"[A-Z]", password):
              self.pwstrength.set('Password missing upper case letter.')
              return True
  
          # check for lowercase
          if not re.search(r"[a-z]", password):
              self.pwstrength.set('Password missing lower case letter.')
              return True
  
          # check for symbols
          if not re.search(r"\W", password):
              self.pwstrength.set('Password missing a symbol.')
              return True
  
          # Passed all checks.
          self.pwstrength.set('Strong password provided.')
          return True
  
  
  
  if __name__=='__main__':
      root = tk.Tk()
      root.geometry('300x300+700+250')
      root.title('Password Strength Check')
  
      app=App(root)
      app.grid(row=0, column=0, sticky='nsew')
  
      root.rowconfigure(0, weight=1)
      root.columnconfigure(0, weight=1)
  
      root.mainloop()
  </code></pre>