Hi
I have written a per tk script, which first create a mainwindow and then starts a server program and client program. But the problem is if I shift the 'MainLoop' statement in the end of the script after the initiation of server and client , then the gui is not appearing although the server is getting started.
On the other hand if I put the 'MainLoop' before the server and client initiation statements then the gui is starting , but the execution control only goes to the server-client statement only after closing the gui. All I want is that the gui should start and simultaneously the server and client should also start in sequence.
For the server and client code you can refer to my code pasted in How to introduce threading in socket communication. Similar code is getting executed in Server::initServer() and Client::initClient() routines respectively.

## my script ##

use Tk; use Server; use Client; my $mw = MainWindow->new(); #MainLoop; #gui appears but the control goes below only after clos +ing the gui,hence server does not start when the gui is open print "after mainloop \n"; my $server = Server->new(parentWnd=>$mw); $server->initServer(); my $client = Client->new(parentWnd=>$mw); $client->initClient(); MainLoop; #does not bring up the gui but the server starts.

In reply to tk mainwindow not appearing by simonz

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.