Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: Re: Tk fontCreate, fontNames errors (and fontDelete seems messy)

by converter (Priest)
on Jul 24, 2003 at 01:40 UTC ( #277396=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Tk fontCreate, fontNames errors (and fontDelete seems messy)
in thread Tk fontCreate, fontNames errors (and fontDelete seems messy)

It sounds like you may be allocating this Toplevel each time you want to display it. You might consider allocating the Toplevel once and then mapping/unmapping it as needed. The relevant methods are withdraw and deiconify (see perldoc Tk::Wm), and raise (see perldoc Tk::Widget).

Here is an example from page 233 of Mastering Perl/Tk:

use Tk; $mw = MainWindow->new; $mw->title("MainWindow"); $mw->Button(-text => "Toplevel", -command => \&do_Toplevel)->pack(); MainLoop; sub do_Toplevel { if (! Exists($tl)) { $tl = $mw->Toplevel(); $tl->title("Toplevel"); $tl->Button(-text => "Close", -command => sub { $tl->withdraw })->pack; } else { $tl->deiconify(); $tl->raise(); } }

This would allow you to invoke fontCreate in the same scope as the widget in which the font is intended to be used. The font definition would still be visible to all children of the MainWindow, but you'd have the illusion of scope and maintenance would be a bit easier.

I've added links to several Perl/Tk-related resources to my home node (with more to come as I find time). Have a look around and you'll probably find a lot of useful information that you didn't know existed.

conv


Comment on Re: Re: Re: Tk fontCreate, fontNames errors (and fontDelete seems messy)
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://277396]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-09-21 08:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (168 votes), past polls