Re: Tk Buttons look
by kcott (Archbishop) on Jun 19, 2016 at 09:29 UTC
|
...
if ($bl eq $default_button) {
my $db = $bot->Frame(-relief => 'sunken', -bd => 1);
$b->raise($db);
$b->pack(-in => $db, -padx => '2', -pady => '2');
...
So, just create a Frame with a sunken border
and stuff a Button with extra padding in it.
You can, of course, use that code as is;
however, you may want to be a little more creative and design your own look-and-feel.
See Tk::options for other ways to affect your GUI presentation.
Individual widgets may have their own additional options which should be described in their documentation pages.
| [reply] [d/l] [select] |
Re: Tk Buttons look
by Marshall (Canon) on Jun 18, 2016 at 13:37 UTC
|
What version/platform of Perl are you using? I am on the road and can't run Perl at the moment, but I've seen this issue before. I use Active State Perl and it looks nice with all windows having close to the MS "look and feel" of the message box. The quality of the Tk graphics has to do with how much work went into the port. | [reply] |
|
|
| [reply] |
|
|
That's odd. The version shouldn't matter, the difference between strawberry and Active State could. It will be Monday before I can run your code on my Win XP machine and see what it looks like. The version of Windows may matter?
Update: I was finally able to run the code to see the issue. The MS button has slightly beveled corners whereas the Tk button has straight edges. The human eyeball picks up on this right away. although the difference is actually quite slight. The font style, spacing, border can all be dealt with and I see some code for that below. The result is "very close", but not exactly like the MS button. I don't know of any way to make a generic TK button with "rounded corners".
You can get a consistent look to your GUI. I've never had a complaint about "looks bad". I get complaints about "hey, I wanted to do X and I couldn't figure out to do it!". Great GUI design is hard to do, but if you succeed in making something non-trivial that is genuinely easy to use, nobody will care about squared edges.
| [reply] |
|
|
Re: Tk Buttons look
by Anonymous Monk on Jun 18, 2016 at 23:07 UTC
|
#!/usr/bin/perl
# http://perlmonks.org/?node_id=1166034
use strict;
use warnings;
use Tk;
my $mw = new MainWindow( -takefocus => 1 );
$mw->geometry( "300x300" );
my $label = $mw -> Label(-text=>"Hello World",
-takefocus => 0 ) -> pack();
my $buttonframe = $mw->Frame(
-relief => 'sunken',
-padx => 2, -pady => 2,
-takefocus => 0,
-bd => 1,
)->pack();
my $button = $buttonframe -> Button(-text => "Show",
-padx => 10, -pady => 6,
-takefocus => 1,
-command => sub { showmessage(); })
-> pack();
$button->focus;
MainLoop;
sub showmessage{
$mw->messageBox (-message=>"The glossary has been merged", -icon=> '
+info',
-type => 'YesNoCancel');
}
Note that the sunken frame is put around the default button in the messageBox,
the other buttons are just plain buttons.
| [reply] [d/l] |
Re: Tk Buttons look
by Anonymous Monk on Jun 18, 2016 at 18:49 UTC
|
I have notice the buttons creating by the standard Tk::Dialogbox look very nice, for example on my Windows 10 PC. Normal TK buttons created with Button... no. To me they look identical, one just has more padding than the other ...is that what you see?
| [reply] |
|
|
I confirm: the show button created with $mw->Button is square an old fashioned Tk one while the Ok button created by the $mw->messageBox is identical to other buttons of the oerating system.
#ver && perl -v
Microsoft Windows [Versione 6.1.7601] #aka win 7
This is perl 5, version 14, subversion 2 (v5.14.2) built for MSWin32-x
+86-multi-thread
The question is legitimate. But also my question is: how can I force $mw->messageBox to display good old squarish buttons as all other Tk functions?
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
| [reply] [d/l] [select] |
|
|
But also my question is: how can I force $mw->messageBox to display good old squarish buttons as all other Tk functions?
You can't, messageBox is a convenience function inside Tk.pm, so you have to write your own, kinda tricky
| [reply] [d/l] |
|
|
I confirm: the show button created with $mw->Button is square an old fashioned Tk one while the Ok button created by the $mw->messageBox is identical to other buttons of the oerating system. What does that mean? Can you put up a screenshot on imgur?
| [reply] |
Re: Tk Buttons look
by welleozean (Novice) on Jun 19, 2016 at 07:27 UTC
|
| [reply] |
|
|
Yeah, see Tk::Button you're looking for "relief", you can use Tk::WidgetDump to examine your program, I did, so I didn't have to hunt for docs to write this
See also Tk::Style
| [reply] [d/l] |