On 18 Dec 2006 14:57:13 -0800, "deadpickle" <>
wrote:
>What I want to do is create an interface using Tk. What I have so far
>is:
>The program this is for sets up a server that listens for a client to
>connect. I have a few questions:
I don't feel like rewriting your script for you, and that is what
I would have to do, to do it right. So I will just point out some
basics, and point you to an existing example which I previously have
written.
>
>1. How do I set this up so that 'use strict' will work?
use strict;
#then put 'my' in front of your variables
>2. I want to be able to enter a value into the "PORT" widget that is
>then stored in the variable $port, am I doing this correctly?
# declare and set default port , then use $port in your socket setup
my $port = 2230;
my $port_entry = $left->LabEntry(
-label => "PORT",
-labelPack => [ -side => "left", -anchor => "w" ],
-textvariable => \$port,
-width => 5,
)->pack;
>3. I want to create a text box at the bottm that will echo what port is
>being used and whether or not a client has connected, any hints on how
>to do this would be valueble?
Well you read the socket, then enter what is read into the text widget.
Use fileevent to read the socket.
>4. When it is ready I want to be able to hit a button on the bottom
>that runs the script until the button is hit again, then the script
>stops. Here is the script I want to run:
Make a button that will launch your socket code when first pressed,
then alter it's callback so it will do a $socket->close on the second
press.
>>Any help is appreciated. Thanks.
I'm not entirely sure what you are trying to do with this script.
Here is a similar script, that opens a socket( on startup without
a button) and collects data. It has a label at the bottom to show
when the client is connected or not.
See:
http://perlmonks.org?node_id=577181
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html