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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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


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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-26 03:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found