Newbiee has asked for the wisdom of the Perl Monks concerning the following question:

Hello all, I am new here and quite new to perl/tk, I just started with it a week ago and well I am having soe trouble. I want to have a drop down menu which I know how to make but how when I like on the menu item can I get a password box to come up. I have a screen shot and sample code I wrote for it but how do I get it to work. thanks screen shot is at http://www20.brinkster.com/schoolport/perltk.html please give me help on this. if you want any more info just ask you can also email me at damn_good_2000@hotmail.com thanks in advance.

Replies are listed 'Best First'.
Re: help with per/tk
by Necos (Friar) on Jan 26, 2002 at 00:57 UTC
    I took a look at the code that you wrote and the GUI. To do what you want, you might try this.

    $login_menubutton->bind(<Mouse-1>, \&login_procedure); my $password_box; my $password_box_frame; my $password_box_entry; my $password_box_exit; sub login_procedure { if ( not ( Tk::Exists( $password_box ) ) ) { $password_box = $login->Toplevel(); $password_box_frame = $password_box->Frame()->pack(); $password_box_entry = $password_box_frame->Entry(-show); $password_box_exit = $password_box_frame->Button(-text, +'Ok', -command, \&something_with_password)->pack(-side, 'bottom'); }
    The above code should make strict happy. One thing that's a pain with Tk, is that you might actually have to use globals or pay really close attention to the declaration of your variables. If this program is for you, you might just want to use globals.

    In any case, hope this helps...

    Theodore Charles III
    Network Administrator
    Los Angeles Senior High
    4650 W. Olympic Blvd.
    Los Angeles, CA 90019
    323-937-3210 ext. 224
    email->secon_kun@hotmail.com
Re: help with per/tk
by dhable (Monk) on Jan 26, 2002 at 01:00 UTC

    I just need a clarification. Do you want to know how to display the password box when you select an item from the menu? If so, you just need to use the -command parameter to set a subfunciton to call when the item is selected.

    For your reference in the future, please post the code inside a <CODE> block. We would like to keep everything on this site so we only need to answer questions once.

Re: help with per/tk
by TStanley (Canon) on Jan 25, 2002 at 23:52 UTC
    It would be helpful to us all, if you would please post some code, so that we have an idea of what you are trying to do.

    TStanley
    --------
    "Suppose you were an idiot... And suppose you were a
    member of Congress... But I repeat myself." -- Mark Twain