I am writing my first application in Perl/tk, and I'm having trouble dealing with screen transitions. Basically, I want a full-screen app. From the main menu, the user can move to a number of different screens and then eventually find their way back to the main menu.

Right now, I'm destroying the main window and re-creating it for each different screen layout.

$mw = new MainWindow;
to create it and
$mw->destroy;
to destroy it.

Then, for the next screen, I just create the main window again. I don't know if this is likely to cause me trouble in the future or not.

NOTE: This also means that I have multiple MainLoop calls - one for each screen. I don't know if this is very bad GUI programming style or not.

I'm currently having trouble giving focus to my "new" main window that appears after the user makes a selection from the main menu. The focus is transferred to my console window (probably when I destroy the main window), but I can't get it back to the main window once another one is created. I'm now experimenting with Toplevel windows and they appear to behave better, but this may introduce different problems.

I've been searching for guidance on this fundamental aspect of GUI programming, but I have not found any reference to it in Mastering Perk/Tk or on-line searches.

I'm stumbling around in the dark on this one. Could someone out there with Perl/tk experience please give me some advice?

Thank you very much for any suggestions.


In reply to Perl/tk - how to handle screen transitions - can I destroy the main window? by Theo_124

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.