Re: Gtk2::SpinButton For Hex
- From: Robert Wilkinson <bob fourtheye org>
- To: "Williams, James P2" <james p2 williams lmco com>
- Cc: "'gtk-perl-list gnome org'" <gtk-perl-list gnome org>
- Subject: Re: Gtk2::SpinButton For Hex
- Date: Wed, 20 May 2015 10:12:22 +0200
On Tue, May 19, 2015 at 10:22:51PM +0000, Williams, James P2 wrote:
How can I use a Gtk2::SpinButton to prompt for an integer expressed in hex? I've tried the following, but
it fails.
use strict;
use warnings;
use Glib qw(TRUE FALSE);
use Gtk2 qw(-init);
my($spin)=Gtk2::SpinButton->new_with_range(0,1000,1);
$spin->set_numeric(FALSE);
$spin->signal_connect(output => \&outputCB);
my($win)=new Gtk2::Window();
$win->add($spin);
$win->show_all();
Gtk2->main();
sub outputCB
{
my($spin)= _;
my($value)=$spin->get_adjustment()->get_value();
$spin->set_text(sprint '%X',$value);
}
The text appears to be correct while I hold either arrow button down; I see hex values incrementing.
However, single clicks of an arrow button fail if the displayed text contains A-F. Hitting the Enter key
also fails on the same values. In both cases, the text changes to a decimal integer.
Thanks.
Jim
Hi Jim
What do the '$value's look like in the outputCB (either in a
debugger or ...).
sprint - should be sprintf?
Maybe try set_value or set_digits rather than set_text?
How are any of these impacted by the set_numeric statement?
Bob
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]