Hi,
I want a button to kick off processing, and for the button to be
disabled
while processing is going on. The code below does this. However,
I can’t click the button twice in a row, I need to click elsewhere
(within the
larger app, or outside it) and then come back to the button
for the click to work.
Why is this so? What am i missing? Or is there a better way to do
this?
Ruby 1.8.4, gtk-win32-2-8-18-rc1, ruby-gtk2-0-14-1
Thanks,
Martin
Here’s the code:
require ‘gtk2’
Gtk.init
win = Gtk::Window.new
button = Gtk::Button.new( “Do it” )
win.add( button )
button.signal_connect(“clicked”){
if( button.sensitive? )
button.sensitive=false
Thread.new{
puts "running process"
sleep 2
button.sensitive=true
}
end
}
win.show_all
Gtk.main
Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to make your job
easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Martin P. wrote:
try the modified one i attached, you might get the idea from it.
while the button is insensitive it wont accept your clicks.
balint
Dobai-Pataky Bálint wrote:
Why is this so? What am i missing? Or is there a better way to do this?
try the modified one i attached, you might get the idea from it.
while the button is insensitive it wont accept your clicks.
Thanks, but I didn’t explain myself clearly! That is exactly the
behaviour I
want!
However, once the processing is done, and the button becomes sensitive
again,
the button only responds to clicks once the app has lost focus. If I
click on the button, leave the mouse where it is, wait for the
processing to
finish and the button to become sensitive, and I click again, that click
and
all following clicks are ignored until I move the focus to another
window,
and then come back to the app and try to click again, which works.
I guess it’s a problem with threads and what button.sensitive=true does,
and when it does it, which I don’t understand (yet!).
Martin
Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to make your job
easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Martin P. wrote:
However, once the processing is done, and the button becomes sensitive again,
the button only responds to clicks once the app has lost focus. If I
click on the button, leave the mouse where it is, wait for the processing to
finish and the button to become sensitive, and I click again, that click and
all following clicks are ignored until I move the focus to another window,
and then come back to the app and try to click again, which works.
I guess it’s a problem with threads and what button.sensitive=true does,
and when it does it, which I don’t understand (yet!).
the example script we shared works as expected here.
dev-ruby/ruby-gtk2-0.16.0
dev-lang/ruby-1.8.5_p12
Gentoo Base System release 1.12.9
Dobai-Pataky Bálint wrote:
the example script we shared works as expected here.
dev-ruby/ruby-gtk2-0.16.0
dev-lang/ruby-1.8.5_p12
Gentoo Base System release 1.12.9
Ok, looks like I need to upgrade.
Thanks for your help,
Martin.
Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to make your job
easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642