Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

title bar name in TK?

by nop (Hermit)
on Nov 07, 2001 at 09:45 UTC ( [id://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.
Thanks!

Replies are listed 'Best First'.
(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:

    $toplevel->title(?string?)
    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.

     
    ___crazyinsomniac_______________________________________
    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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-18 22:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found