Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Welcome to the Monastery

title bar name in TK?

by nop (Hermit)
on Nov 07, 2001 at 09:45 UTC ( #123772=perlquestion: print w/ replies, xml ) Need Help??
nop has asked for the wisdom of the Perl Monks concerning the following question:

How do I set the name in the title bar of a TK window? It defaults to the name of the perl script; I'd like to be able to specify it.

Comment on title bar name in TK?
(crazyinsomniac) Re: title bar name in TK?
by crazyinsomniac (Prior) on Nov 07, 2001 at 09:53 UTC
    Straight from crazy tk xbm thingy
    $GOB{W} = new MainWindow(-background => 'darkblue', -borderwidth => 1, -relief => 'groove', -width => 500, -height => 500, ,); $GOB{W}->title("crazy tk xbm thingy");
    which you could've also found somewhere in the pod (Tk::MainWindow I think, haven't checked)

    update: better yet, Tk::Internals led me to Tk::Wm which says:

    If string is specified, then it will be passed to the window manager for use as the title for $toplevel (the window manager should display this string in $toplevel's title bar). In this case the method returns an empty string. If string isn't specified then the method returns the current title for the $toplevel. The title for a window defaults to its name.

    update: I looked for it, and straight from Tk::Internals:

    Inside $top->title('Text demo');
    The package Tk::Toplevel defines a lot of subroutines on the fly on some list. All the commands from the list are converted to the corresponding subcommands of wm method of the widget. Here subcommand is a command with some particular second argument (in this case "title"). Recall that the first argument is $self.

    Now Tk::Toplevel @ISA Tk::Widget, that in turn @ISA Tk. So a call to $top->wm('title','Text demo') calls Tk::wm, that is defined during call to Tk_CreateMainWindow(). As it is described above, the XSUB associated to XStoSubCmd() is called.

    This C routine is defined in tkGlue.c. It gets the data part of XSUB, creates a SV with the name of the command, and calls Call_Tk() with the XSUB data as the first argument, and with the name of XSUB stuffed into the Perl stack in the place there tk expects it. (In fact it can also reorder the arguments if it thinks it is what you want).

    The latter procedure extracts name of tk procedure and clientData from the first argument and makes a call, using Perl stack as argv for the procedure. A lot of black magic is performed afterwards to convert result of the procedure to a Perl array return.

    Disclaimer: Don't blame. It came from inside the void

    perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://123772]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2014-04-21 06:33 GMT
Find Nodes?
    Voting Booth?

    April first is:

    Results (492 votes), past polls