Home > Mobile >  Open a Toplevel by pressing a butten with functools.partial
Open a Toplevel by pressing a butten with functools.partial

Time:10-19

I'm openng a Toplevel window by pressing a butten with

command=lambda: PasswordWindow(self).grab_set()

but i want to use functools.partial to do this. Is there a way to do this?

CodePudding user response:

functools.partial requires a callable, so you can't have it both create an instance of PasswordWindow and call a method on that object. You'll either need to move the call to grab_set inside PasswordWindow.__init__, or create a separate function that does what you want. Though, if you create a separate function, there's no need for functools.partial.

  • Related