User Control Panel
Advertisements

HELP US, HELP YOU!

tk help

 
Post new topic   Reply to topic    Bot Depot Forum Index -> General Programming Questions
View unanswered posts
Author Message
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Sat Apr 30, 2005 12:57 pm    Post subject: Reply with quote

Code:
#!/usr/bin/perl<br /><br /><br />use Tk;<br /><br />my $main = MainWindow->new();<br />$main->minsize(qw(250 250));<br />$main->title("Toms TK experiment.");<br /><br /><br /><br /><br />my $menu_bar = $main->Frame( )->pack(-side => 'top', -fill => 'x');<br /><br /><br />my $file_mb = $menu_bar->Menubutton(-text => 'File', -activebackground => 'dark grey' )->pack(-side => 'left');<br />$file_mb->command(-label => 'Exit', -command => sub{$main->destroy});<br /><br />my $help_mb = $menu_bar->Menubutton(-text => 'Help', -activebackground => 'dark grey')->pack(-side => 'right');<br />$help_mb->command(-label => 'Help',  -command => \&help_txt);<br />$help_mb->command(-label => 'About',  -command => \&about_txt);<br /><br />my $disp_section = $main->Frame()->pack(-side => 'top', );<br />my $type_section = $main->Frame()->pack(-side => 'top', );<br />my $label_section = $main->Frame()->pack(-side => 'left',);<br />my $box_section = $main->Frame()->pack( );<br />my $button_section = $main->Frame()->pack(-side => 'right',);<br /><br /><br /><br />#Credits for scrollbox and STDOUT ties: <br /># Bot GUI.<br /># Copyright Ian G. 2005.<br /># $gui->{text} variable taken from the AiChaos Juggernaut<br /># GUI.<br /><br />my $disp_box = $disp_section->Scrolled (<br />        Text,<br />        -scrollbars => 'e',<br />        -wrap => 'word',<br />        )->pack (-fill => 'both', -expand => 1, -pady => 3, -padx => 3);<br />        my $realtext = $disp_box->Subwidget ('text');<br /><br />tie *STDOUT, ref $realtext, $realtext;<br /><br /><br /><br /><br /><br />my $t1 = $label_section->Label(-text => 'Message', )->pack(-side => 'left', -pady => 1, -fill => 'y');<br />my $msg_box = $box_section->Entry(-background => 'white', -textvariable => \$msg_out, -width => 50, )->pack(-pady => 1, -fill => 'x');<br />my $send_button = $button_section->Button(-text => 'Send', , -command => \&send)->pack(-side => 'right',  -fill => 'y');<br /><br />MainLoop;<br /><br /><br /><br />sub send {<br /><br />print $msg_out;<br /><br />}<br />


I decided to have a go at TK (no i am not making an msn messenger) and that is what i have so far, my only problem is that the bottom row doesnt line up and justify nicely:



any ideas?

thanks,
draget
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Sat Apr 30, 2005 2:00 pm    Post subject: Reply with quote

Well I can tell you why the "Message:" and text box aren't lined up: message is set to fill the Y axis, centering it vertically. The text box fills on the X axis, centering it horizontally, but it didn't say anything about centering itself vertically.

And as for the button, I dunno what's up with that one.

My advice:
Create three frames in the bottom frame, and that should make it easier to line everything up. Smile

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Sun May 01, 2005 2:08 am    Post subject: Reply with quote

Code:
#!/usr/bin/perl<br /><br /><br />use Tk;<br /><br />my $main = MainWindow->new();<br />$main->minsize(qw(250 250));<br />$main->title("Toms TK experiment.");<br /><br /><br /><br /><br />my $menu_bar = $main->Frame( )->pack(-side => 'top', -fill => 'x');<br /><br /><br />my $file_mb = $menu_bar->Menubutton(-text => 'File', -activebackground => 'dark grey' )->pack(-side => 'left');<br />$file_mb->command(-label => 'Exit', -command => sub{$main->destroy});<br /><br />my $help_mb = $menu_bar->Menubutton(-text => 'Help', -activebackground => 'dark grey')->pack(-side => 'right');<br />$help_mb->command(-label => 'Help',  -command => \&help_txt);<br />$help_mb->command(-label => 'About',  -command => \&about_txt);<br /><br />my $disp_section = $main->Frame()->pack(-side => 'top', );<br />my $type_section = $main->Frame()->pack(-side => 'top', );<br />my $label_section = $type_section->Frame()->pack();<br />my $box_section = $type_section->Frame()->pack( );<br />my $button_section = $type_section->Frame()->pack();<br /><br /><br /><br />#Credits for scrollbox and STDOUT ties: <br /># Bot GUI.<br /># Copyright Ian G. 2005.<br /># $gui->{text} variable taken from the AiChaos Juggernaut<br /># GUI.<br /><br />my $disp_box = $disp_section->Scrolled (<br />        Text,<br />        -scrollbars => 'e',<br />        -wrap => 'word',<br />        )->pack (-fill => 'both', -expand => 1, -pady => 3, -padx => 3);<br />        my $realtext = $disp_box->Subwidget ('text');<br /><br />tie *STDOUT, ref $realtext, $realtext;<br /><br /><br /><br /><br /><br />my $t1 = $label_section->Label(-text => 'Message', )->pack( );<br />my $msg_box = $box_section->Entry(-background => 'white', -textvariable => \$msg_out, -width => 50, )->pack( );<br />my $send_button = $button_section->Button(-text => 'Send', , -command => \&send)->pack(  );<br /><br />MainLoop;



I put in the frames, and cleared the pack options, and now the line up neatly, but not in a horizontal line, but on top of each other, stacked.

Where should I go from here?

Thanks!
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Sun May 01, 2005 2:45 am    Post subject: Reply with quote

For your three frames at the bottom, pack $label_section on the left and $button_section on the right. That should line them up horizontally a little more.

If not, try packing all of them to the left and see if that does anything, or pack the two left ones to the left and the other to the right. You might have to play around with it a little.

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Sun May 01, 2005 4:19 am    Post subject: Reply with quote

Well i put two left one right and its perfect! thanks Cer!
Back to top
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Sun May 01, 2005 6:34 am    Post subject: Reply with quote

Now that i've got that nasty issue sorted, i have another problem Sad


The window can of course be changed in size when its open, but when you shrink it, i need to be able to fix things so they dont shrink/disappear and that other parts do.

ie. the send button shouldn't dissappear, instead the msg box should get smaller and on the other axis the scroll box should shrink instead of the msgbox disappearing....

sorry for the annoying questions, but if you have any ideas that would be great!

thanks
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Sun May 01, 2005 5:02 pm    Post subject: Reply with quote

QUOTE(draget @ May 1 2005, 02:34 AM)
Now that i've got that nasty issue sorted, i have another problem Sad


The window can of course be changed in size when its open, but when you shrink it, i need to be able to fix things so they dont shrink/disappear and that other parts do.

ie. the send button shouldn't dissappear, instead the msg box should get smaller and on the other axis the scroll box should shrink instead of the msgbox disappearing....

sorry for the annoying questions, but if you have any ideas that would be great!

thanks
[right][snapback]48126[/snapback][/right]


I would think that $main->minsize wouldn't allow you to scale the window smaller than the size specified.

Anyway, to get things to resize automatically (like text boxes), add "-expand => 1" when you pack them. So when you start shrinking the window, all the things set to -expand should shrink first, and when they can't shrink any further then it would start making the other things disappear.

But there's not much you can do about it, any Tk window can be scaled down until just the title bar and menu bar are visible. Razz

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> General Programming Questions All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group