Home > Archive > PerlTk > December 2005 > Suspected bug in Tk::DialogBox.pm
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Suspected bug in Tk::DialogBox.pm
|
|
|
| Hey guys,
Tk::DialogBox.pm version 3.032 (part of our Perl 5.8.6 installation), contains the following code in line 46:
if ($Tk::platform eq 'MSWin32')
{
$b->configure(-width => 10, -pady => 0);
}
I have no idea why would someone like to limit the button width to the hard-coded value of 10 under MSWin32.
On Unix everything works great and the buttons created are sized automatically to hold the label requested.
On Windows, we are doomed to use shorter labels in order to ensure we don't get the labels cut due to the hard-coded limitation.
There is no way to control the width of the buttons. It is 0 by default and the above code impacts it under Windows...
Any idea ?
Thanks,
Oded
| |
|
| the buttons arr advertised subwidgets of the DBox
you are able to configure the buttons in the following way:
$dialogbox->Subwidget("B_{buttontext}")->configure(-width => nn);
Pit
| |
|
| Thanks for the advice Pit.
Unfortunately it doesn't work for me.
I have $dialog1 as my dialogbox, and I have $b1 equals to "This is my text"
as one of the buttons.
The following doesn't work:
$dialog1->Subwidget("B_{$b1}")->configure(-width => 20);
I get:
Tk::Error: Can't call method "configure" without a package or object
reference at ....
Tk callback for .frame.button
Tk::Button::butUp at /usr/installs/97r1.3/lib/perl5/site_perl/Tk/Button.pm
line 111
(command bound to event)
Any other idea ?
Thanks,
Oded
"Pit" <pharrendorf@am-soft.de> wrote in message
news:b8b1e5d0355fa9f8cc108d6f9b9ae20c@lo
calhost.talkaboutprogramming.com...
> the buttons arr advertised subwidgets of the DBox
> you are able to configure the buttons in the following way:
>
> $dialogbox->Subwidget("B_{buttontext}")->configure(-width => nn);
>
> Pit
>
| |
|
| Hi,
try only this without the {}
$dialog1->Subwidget("B_$b1")->configure(-width => 20);
Pit
| |
|
| I still get an error message.
I even tried to explicitly refer to "B_OK" (one of the buttons is OK) and it
didn't work.
I'm actually using Dialog.pm (and not DialogBox.pm), but I saw in the
documentation that since it's derived from DialogBox.pm it should include
all DialogBox advertised widgets. The documentation supports the advice I
got from Pit, but apparently it doesn't work for me.
Quote: "Because Tk::Dialog is a subclass of Tk::DialogBox it inherits all
the advertised subwidgets of its superclass: e.g. "B_button-text", where
'button-text' is a Button's -text value. "
Apparently this doesn't work.
I still think that it is a bug in DialogBox.pm to have a hard-coded value.
*********************
Reminder of the issue:
"Oded" <dv@mailtag.com> wrote in message
news:<dmmuj6$qv7$1@news01.intel.com>...
Hey guys,
Tk::DialogBox.pm version 3.032 (part of our Perl 5.8.6 installation),
contains the following code in line 46:
if ($Tk::platform eq 'MSWin32')
{
$b->configure(-width => 10, -pady => 0);
}
I have no idea why would someone like to limit the button width to the
hard-coded value of 10 under MSWin32.
On Unix everything works great and the buttons created are sized
automatically to hold the label requested.
On Windows, we are doomed to use shorter labels in order to ensure we don't
get the labels cut due to the hard-coded limitation.
*********************
"Pit" <pharrendorf@am-soft.de> wrote in message
news:3dc89edb7b0b19e5206472abc794de28@lo
calhost.talkaboutprogramming.com...
> Hi,
>
> try only this without the {}
> $dialog1->Subwidget("B_$b1")->configure(-width => 20);
>
> Pit
>
>
| |
|
| I'm working with Win 32 and Tk-Version 5.8.4 and:
$db->Subwidget("B_$buttontext")->configure(-width => 20)
works both with Dialog.pm and with DialogBox.pm
Pit
| |
| Petr Vileta 2005-12-05, 7:01 pm |
| Oded wrote:
> I still get an error message.
>
> I even tried to explicitly refer to "B_OK" (one of the buttons is OK)
> and it didn't work.
>
> I'm actually using Dialog.pm (and not DialogBox.pm), but I saw in the
> documentation that since it's derived from DialogBox.pm it should
> include all DialogBox advertised widgets. The documentation supports
> the advice I got from Pit, but apparently it doesn't work for me.
>
> Quote: "Because Tk::Dialog is a subclass of Tk::DialogBox it
> inherits all the advertised subwidgets of its superclass: e.g.
> "B_button-text", where 'button-text' is a Button's -text value. "
>
> Apparently this doesn't work.
>
> I still think that it is a bug in DialogBox.pm to have a hard-coded
> value.
>
Try this code that work for me in Perl 5.6.1 on WinXP
use strict;
use Tk;
use Tk::DialogBox;
my $mw = MainWindow->new();
my $b1='This is text';
my $dialog=$mw->DialogBox(-title => 'Dialog test', -buttons => ['OK',$b1]);
$dialog->Subwidget("B_$b1")->configure(-width => 20);
my $h=$dialog->Show;
--
Petr Vileta, Czech republic
(My server reject all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
| |
|
| Oded <dv@mailtag.com> wrote:
> Thanks for the advice Pit.
> Unfortunately it doesn't work for me.
That's because you are not referencing the Button properly - loose the curlies:
ADVERTISED WIDGETS
top The subwidget reference to the top half of the DialogBox widget,
the Frame containing widgets added by the add method.
bottom
The subwidget reference to the bottom half of the DialogBox widget,
the Frame containing the Button widgets.
B_"button-text"
Individual subwidget references to the Buttons in the DialogBox
widget. The subwidget name is the string B_ concatenated with the
Button's -text value.
> I have $dialog1 as my dialogbox, and I have $b1 equals to "This is my text"
> as one of the buttons.
> The following doesn't work:
>
> $dialog1->Subwidget("B_{$b1}")->configure(-width => 20);
try:
.... Subwidget( "B_${b1}" ) ...
or
.... Subwidget( 'B_' . $b1 ) ...
>
> I get:
>
> Tk::Error: Can't call method "configure" without a package or object
> reference at ....
> Tk callback for .frame.button
> Tk::Button::butUp at /usr/installs/97r1.3/lib/perl5/site_perl/Tk/Button.pm
> line 111
> (command bound to event)
>
> Any other idea ?
>
> Thanks,
> Oded
>
> "Pit" <pharrendorf@am-soft.de> wrote in message
> news:b8b1e5d0355fa9f8cc108d6f9b9ae20c@lo
calhost.talkaboutprogramming.com...
>
>
--
--
@_=map{eval"100${_}"}split/!/,'/5!*2!+$]!/10+$]';use Tk;$m=tkinit;$t='just an'.
'other perl hacker';$z='createText';$c=$m->Canvas(-wi,$_[1],-he,25)->grid;$c->$
z(@_[2,3],-te,$t,-fi,'gray50');$c->$z($_[2]-$],$_[3]-$],-te,$t);$m->bind('<En'.
'ter>',sub{$y=int(rand($m->screenheight));$m->geometry("+$y+$y")});MainLoop;
| |
|
| Ok, I managed to resolve it.
The thing is that I need the code to run both on Unix and Windows (sorry for
not mentioning this earlier).
Apparently what you suggested works well on Windows but gives a run-time
error message on Unix. I actually first checked on Unix to see how it
behaves there...
Since I have the issue only on Windows, I worked around this by enabling
this code only if $^O is equal to MSWin32.
Thanks for all the help !
Oded
"Pit" <pharrendorf@am-soft.de> wrote in message
news:cac8bc8a0b8b9e14ddc563781441a5ce@lo
calhost.talkaboutprogramming.com...
> I'm working with Win 32 and Tk-Version 5.8.4 and:
>
> $db->Subwidget("B_$buttontext")->configure(-width => 20)
>
> works both with Dialog.pm and with DialogBox.pm
>
> Pit
>
|
|
|
|
|