Re: Tkinter menu question--how to pass arguments



Dave Opstad wrote:
In article <85c10$460d65c8$4275d90a$19337@xxxxxxxx>,
Kevin Walzer <kw@xxxxxxxxxxxxxxx> wrote:

I'm having difficulty structuring a Tkinter menu entry. Here is the command in question:

self.finkmenu.add_command(label='Update List of Packages', command=self.authorizeCommand(self.scanPackages))

When I start my program, it crashes because it's trying to run the command self.authorizeCommand. The reason I'm structuring it in this fashion is that this command takes another command as an argument--in this case, self.ScanPackages.

The basic structure of the program is that the self.authorizeCommand function pops up a dialog box for a password; it then feeds the password to the function that it takes as an argument, i.e. self.scanPackages.

I tried setting up the menu entry without the additional parameter, i.e. command=self.authorizeCommand, but then when I try to run the command from the menu, it complains there are not enough arguments. Unsurprising, since self.authorizeCommand takes another function name as an argument.

How can I structure the menu item to reflect the correct number of arguments without it trying to execute the command?

If self.scanPackages exists as an attribute of self, why do you need to pass it in? If your command is just self.authorizeCommand, and that method makes use of self.scanPackages when it runs, then it all should work without your having to specify it here.

Dave
self.AuthorizeCommand is a generic dialog to feed a password to several different commands. So, the specific function needs to be specified as a parameter.

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
.



Relevant Pages

  • Re: Tk application hangs
    ... KW> explicitly reached eof and it hangs? ... KW> | Kevin Walzer wrote: ... KW> |>after running just one command. ... KW> |>"List Packages" is supposed to list all available DarwinPorts packages ...
    (comp.lang.tcl)
  • Re: Pipe command output to listbox
    ... Kevin Walzer wrote: ... >when the command isn't showing up on my path for some reason. ... That puts ... >the full path to port in the pipe, and then the rest of the sequence ...
    (comp.lang.tcl)
  • Re: Pipe command output to listbox
    ... Kevin Walzer wrote: ... >when the command isn't showing up on my path for some reason. ... That puts ... >the full path to port in the pipe, and then the rest of the sequence ...
    (comp.unix.shell)
  • Re: Unix "find" vs. ::fileutil::find
    ... Based on my unscientific testing, it seems that the Unix tool is much faster, but I'm curious as to other experiences. ... I'm currently using::filetuil::find in an application and it blocks unacceptably, locking up the GUI, and I am thinking that piping in the Unix "find" command with the appropriate fileevent handles might yield smoother performance. ... I think I will stick with tcllib. ... Kevin Walzer, PhD ...
    (comp.lang.tcl)
  • Re: Tk application hangs
    ... Khamis Abuelkomboz wrote: ... | especially when a command is piped using the the open command. ... Kevin Walzer, PhD ...
    (comp.lang.tcl)