From: Peter <lan...@fr...> - 2006-01-29 20:11:49
|
I figured it out myself. Turns out I needed to use the SetRange() and SetValue() methods. On Windows it works fine without them, on Linux/GTK it doesn't. ;) Regards, Peter On Mon, 23 Jan 2006 22:42:57 +0100, "Peter" <lan...@fr...> said: > L.S, > > I tried to get one of my wxPerl programs (Developed on Win32) to run on > Ubuntu (GTK) and most of it runs fine but I ran into a strange problem > with some spinbuttons. > > The TextCtl that belongs to the spinbuttons has a range of 1..10 but is > initialized to the value 5. (there's also an A..Z one that has the same > problem) > > After it is first shown the 'down' button is grayed out. I can't adjust > the value down. > After I go all the way up, hit the ceiling a few times and then move > down again, I can go beyond 5. > > I don't understand why the spinbutton should be grayed out at all. > There's nothing in my code that should cause that. > > Is this a bug in Wx or am I doing something wrong? > > Thanks, > Peter > > Minimal code follows: > > #!/usr/bin/perl > > package MyApp; > > use base qw( Wx::App ); > > use Wx ':everything'; > use Wx::Event ':everything'; > use warnings; > use strict; > > sub OnInit { > my( $this ) = @_; > > $this->{FRAME} = Wx::Frame->new( undef, -1,'SPINTEST', [-1,-1], [200,200] ); > $this->{FRAME}->Show(1); > my $ctl=$this->{CTL}={}; > > $ctl->{n1} = Wx::TextCtrl->new($this->{FRAME},-1,5,[50, 30],[20,-1],wxTE_READONLY); > $ctl->{n1s}=Wx::SpinButton->new( $this->{FRAME}, -1, [72, 30],[15, 20],wxSP_VERTICAL ); > EVT_SPIN_UP( $this->{FRAME}, $ctl->{n1s}, sub { OnSpin( $ctl->{n1}, +1, 9 ) } ); > EVT_SPIN_DOWN( $this->{FRAME}, $ctl->{n1s}, sub { OnSpin( $ctl->{n1}, -1, 1 ) } ); > > $ctl->{n2} = Wx::TextCtrl->new($this->{FRAME},-1,'D',[50, 60],[20,-1],wxTE_READONLY); > $ctl->{n2s}=Wx::SpinButton->new( $this->{FRAME}, -1, [72, 60],[15, 20],wxSP_VERTICAL ); > EVT_SPIN_UP( $this->{FRAME}, $ctl->{n2s}, sub { OnSpin( $ctl->{n2}, +1, 'Z' ) } ); > EVT_SPIN_DOWN( $this->{FRAME}, $ctl->{n2s}, sub { OnSpin( $ctl->{n2}, -1, 'A' ) } ); > > 1; > } > > sub OnSpin { > my( $ctl, $d, $limit ) = @_; > > my $v=$ctl->GetValue(); > if ($v ne $limit) { > $ctl->SetValue($v =~ /^\d+$/ ? $v + $d : chr(ord($v) + $d)); > } else { > printf "Can't go further %s\n", $d < 0 ? 'down' : 'up'; > } > } > > package main; > > MyApp->new()->MainLoop(); > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log > files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 > _______________________________________________ > wxperl-users mailing list > wxp...@li... > https://lists.sourceforge.net/lists/listinfo/wxperl-users |