I would like my shoes app to present a group of radio buttons and have one
of them selected by default.
I expected that the following code would select radio r3, but it doesn't.
Shoes.app do
r1 = radio; para "Radio 1\n"
r2 = radio; para "Radio 2\n"
r3 = radio; para "Radio 3\n"
r4 = radio; para "Radio 4\n"
r5 = radio; para "Radio 5\n"
para "\n\n\n"
para "r3.checked? = #{r3.checked?}\n\n"
para "Calling 'r3.checked = true'\n\n"
r3.checked = true
para "r3.checked? = #{r3.checked?}\n\n"
end
Is there a solution for this, or is this a bug?
Thanks,
Alan Jelden
I was able to mark Radio 3 checked with a button, like this: button "Mark Radio 3" do r3.checked = true end Hope that helps! On Thu, Feb 17, 2011 at 2:37 PM, Alan Jelden <alan.jelden@gmail.com> wrote: > I would like my shoes app to present a group of radio buttons and have one > of them selected by default. > I expected that the following code would select radio r3, but it doesn't. > Shoes.app do > r1 = radio; para "Radio 1\n" > r2 = radio; para "Radio 2\n" > r3 = radio; para "Radio 3\n" > r4 = radio; para "Radio 4\n" > r5 = radio; para "Radio 5\n" > > para "\n\n\n" > para "r3.checked? = #{r3.checked?}\n\n" > para "Calling 'r3.checked = true'\n\n" > r3.checked = true > para "r3.checked? = #{r3.checked?}\n\n" > end > Is there a solution for this, or is this a bug? > Thanks, > Alan Jelden -- Zachary Scott
That is interesting. I also was able to reproduce the behavior you saw, but I'm still curious about why r3 wasn't being marked by my code. We're both calling the same statement, "r3.checked = true". Thanks for the reply, Alan. On Thu, Feb 17, 2011 at 1:42 PM, Zachary Scott <zachary.s.scott@gmail.com>wrote: > I was able to mark Radio 3 checked with a button, like this: > > button "Mark Radio 3" do > r3.checked = true > end > > Hope that helps! > > On Thu, Feb 17, 2011 at 2:37 PM, Alan Jelden <alan.jelden@gmail.com> > wrote: > > I would like my shoes app to present a group of radio buttons and have > one > > of them selected by default. > > I expected that the following code would select radio r3, but it doesn't. > > Shoes.app do > > r1 = radio; para "Radio 1\n" > > r2 = radio; para "Radio 2\n" > > r3 = radio; para "Radio 3\n" > > r4 = radio; para "Radio 4\n" > > r5 = radio; para "Radio 5\n" > > > > para "\n\n\n" > > para "r3.checked? = #{r3.checked?}\n\n" > > para "Calling 'r3.checked = true'\n\n" > > r3.checked = true > > para "r3.checked? = #{r3.checked?}\n\n" > > end > > Is there a solution for this, or is this a bug? > > Thanks, > > Alan Jelden > > > > -- > Zachary Scott >
Just to followup, the problem is in radio.checked? Each time it is called, GTK spits out an error and presumable returns nil and Shoes calls that 'false'. It's a bug in checked? I believe. On Thu, 2011-02-17 at 17:11 -0800, Alan Jelden wrote: > That is interesting. I also was able to reproduce the behavior you > saw, but I'm still curious about why r3 wasn't being marked by my > code. We're both calling the same statement, "r3.checked = true". > > > Thanks for the reply, > Alan. > > On Thu, Feb 17, 2011 at 1:42 PM, Zachary Scott > <zachary.s.scott@gmail.com> wrote: > I was able to mark Radio 3 checked with a button, like this: > > button "Mark Radio 3" do > r3.checked = true > end > > Hope that helps! > > > On Thu, Feb 17, 2011 at 2:37 PM, Alan Jelden > <alan.jelden@gmail.com> wrote: > > I would like my shoes app to present a group of radio > buttons and have one > > of them selected by default. > > I expected that the following code would select radio r3, > but it doesn't. > > Shoes.app do > > r1 = radio; para "Radio 1\n" > > r2 = radio; para "Radio 2\n" > > r3 = radio; para "Radio 3\n" > > r4 = radio; para "Radio 4\n" > > r5 = radio; para "Radio 5\n" > > > > para "\n\n\n" > > para "r3.checked? = #{r3.checked?}\n\n" > > para "Calling 'r3.checked = true'\n\n" > > r3.checked = true > > para "r3.checked? = #{r3.checked?}\n\n" > > end > > Is there a solution for this, or is this a bug? > > Thanks, > > Alan Jelden > > > > > -- > Zachary Scott > >
Hey Cecil, I think you're right I saw that error message as well, might be worth another look. On Thu, Feb 17, 2011 at 9:05 PM, Cecil Coupe <ccoupe@cableone.net> wrote: > Just to followup, the problem is in radio.checked? Each time it is > called, GTK spits out an error and presumable returns nil and Shoes > calls that 'false'. > > It's a bug in checked? I believe. > > On Thu, 2011-02-17 at 17:11 -0800, Alan Jelden wrote: >> That is interesting. I also was able to reproduce the behavior you >> saw, but I'm still curious about why r3 wasn't being marked by my >> code. We're both calling the same statement, "r3.checked = true". >> >> >> Thanks for the reply, >> Alan. >> >> On Thu, Feb 17, 2011 at 1:42 PM, Zachary Scott >> <zachary.s.scott@gmail.com> wrote: >> I was able to mark Radio 3 checked with a button, like this: >> >> button "Mark Radio 3" do >> r3.checked = true >> end >> >> Hope that helps! >> >> >> On Thu, Feb 17, 2011 at 2:37 PM, Alan Jelden >> <alan.jelden@gmail.com> wrote: >> > I would like my shoes app to present a group of radio >> buttons and have one >> > of them selected by default. >> > I expected that the following code would select radio r3, >> but it doesn't. >> > Shoes.app do >> > r1 = radio; para "Radio 1\n" >> > r2 = radio; para "Radio 2\n" >> > r3 = radio; para "Radio 3\n" >> > r4 = radio; para "Radio 4\n" >> > r5 = radio; para "Radio 5\n" >> > >> > para "\n\n\n" >> > para "r3.checked? = #{r3.checked?}\n\n" >> > para "Calling 'r3.checked = true'\n\n" >> > r3.checked = true >> > para "r3.checked? = #{r3.checked?}\n\n" >> > end >> > Is there a solution for this, or is this a bug? >> > Thanks, >> > Alan Jelden >> >> >> >> >> -- >> Zachary Scott >> >> > > > -- Zachary Scott
Hi Alan, Zak, Cecil and folks,
Thank you for the findings. :)
As Cecil said, I think this is a bug. But not a simple bug.
The problem is timing, because Zak showed us a solution
using button method. So now, we have following two solutions
without using `checked=` method.
i) use :checked style
r3 = radio checked: true; para "Radio 3\n"
ii) use timer method
timer(0.001){r3.checked = true}
Regards,
ashbb
On Fri, 2011-02-18 at 21:33 +0900, ashbb wrote: > Hi Alan, Zak, Cecil and folks, > > Thank you for the findings. :) > > As Cecil said, I think this is a bug. But not a simple bug. For Red Shoes: around line 5003 in the file shoes/ruby.c is the definition of the methods for 'radio'. A few lines above is the definition for 'check'. 'checked?' for radios just calls the 'checked?' for 'check' which why linux/gtk is complaining. In some GUI toolkits, that might work? It's pretty clear that there needs to be a different hook for 'radio.checked?' That would be a problem if no one wants to write C code for gtk/osx/win. I've submitted an issue on red shoes. On the other hand, 'checked?' makes little sense for a radio group -- You would not normally process through a list of radios like you might a list of check's. However, Alan tried and the code is missing. If it was up to me, I'd remove 'radio.checked?' from the manual and comment it out the shoes/ruby.c file. Yes, it ruins symmetry but there are lot of non-symmetries in Shoes native widgets. One more won't the next release of Red Shoes.
Radio buttons are a pain, even if checked? worked. I've attached a example of how I use radios in Shoes including always use the group option. Maybe the green shoes folks can use the example for a test case. There is a larger bug than checked? not working. The manual does not mention that each radio button has a proc (do...end), just like a simple button, as shown in my example. On Thu, 2011-02-17 at 21:21 -0500, Zachary Scott wrote: > Hey Cecil, > > I think you're right I saw that error message as well, might be worth > another look. > > On Thu, Feb 17, 2011 at 9:05 PM, Cecil Coupe <ccoupe@cableone.net> wrote: > > Just to followup, the problem is in radio.checked? Each time it is > > called, GTK spits out an error and presumable returns nil and Shoes > > calls that 'false'. > > > > It's a bug in checked? I believe. > > > > On Thu, 2011-02-17 at 17:11 -0800, Alan Jelden wrote: > >> That is interesting. I also was able to reproduce the behavior you > >> saw, but I'm still curious about why r3 wasn't being marked by my > >> code. We're both calling the same statement, "r3.checked = true". > >> > >> > >> Thanks for the reply, > >> Alan. > >> > >> On Thu, Feb 17, 2011 at 1:42 PM, Zachary Scott > >> <zachary.s.scott@gmail.com> wrote: > >> I was able to mark Radio 3 checked with a button, like this: > >> > >> button "Mark Radio 3" do > >> r3.checked = true > >> end > >> > >> Hope that helps! > >> > >> > >> On Thu, Feb 17, 2011 at 2:37 PM, Alan Jelden > >> <alan.jelden@gmail.com> wrote: > >> > I would like my shoes app to present a group of radio > >> buttons and have one > >> > of them selected by default. > >> > I expected that the following code would select radio r3, > >> but it doesn't. > >> > Shoes.app do > >> > r1 = radio; para "Radio 1\n" > >> > r2 = radio; para "Radio 2\n" > >> > r3 = radio; para "Radio 3\n" > >> > r4 = radio; para "Radio 4\n" > >> > r5 = radio; para "Radio 5\n" > >> > > >> > para "\n\n\n" > >> > para "r3.checked? = #{r3.checked?}\n\n" > >> > para "Calling 'r3.checked = true'\n\n" > >> > r3.checked = true > >> > para "r3.checked? = #{r3.checked?}\n\n" > >> > end > >> > Is there a solution for this, or is this a bug? > >> > Thanks, > >> > Alan Jelden > >> > >> > >> > >> > >> -- > >> Zachary Scott > >> > >> > > > > > > > > >
Hi Cecil, Wow, nice example snippet! I'm now implementing `check box` and `radio button` in Green Shoes. After coding them, I'll try out your example! > The manual does not mention that each radio button has a proc > (do...end), just like a simple button, as shown in my example. You are right. But look at Elements.Button/Check/Radio pages. You can find `click` method on the all pages. ;-) Cheers, ashbb
Hi all, I implemented Check box and Radio button for Green Shoes. Look at sample48 which was written by Cecil and a little bit edited for the current Green Shoes. Code: https://github.com/ashbb/green_shoes/blob/master/samples/sample48.rb Snapshot: https://github.com/ashbb/green_shoes/blob/master/snapshots/sample48.png Update green_shoes gem and try it out. ;-) http://rubygems.org/gems/green_shoes Cheers, ashbb
Thanks, folks. I'll give your suggestions a try. I just subscribed to this list yesterday and am very happy that I did. Thanks a lot. Alan. On Fri, Feb 18, 2011 at 4:48 AM, ashbb <ashbbb@gmail.com> wrote: > Hi Cecil, > > Wow, nice example snippet! > > I'm now implementing `check box` and `radio button` in Green Shoes. > After coding them, I'll try out your example! > > > > The manual does not mention that each radio button has a proc > > (do...end), just like a simple button, as shown in my example. > You are right. > But look at Elements.Button/Check/Radio pages. You can find `click` > method on the all pages. ;-) > > Cheers, > ashbb >
You found a bug. Thank You. On Fri, 2011-02-18 at 12:11 -0800, Alan Jelden wrote: > Thanks, folks. I'll give your suggestions a try. > > > I just subscribed to this list yesterday and am very happy that I did. > Thanks a lot. > > > Alan. >
Alan, When I run your example, I get two identical error messages on the linux terminal: (<unknown>:7220): Gtk-CRITICAL **: IA__gtk_toggle_button_get_active: assertion `GTK_IS_TOGGLE_BUTTON (toggle_button)' failed Not a good sign. The GUI does have radio3 checked however. It's like checked? only returns false or nil On Thu, 2011-02-17 at 17:11 -0800, Alan Jelden wrote: > That is interesting. I also was able to reproduce the behavior you > saw, but I'm still curious about why r3 wasn't being marked by my > code. We're both calling the same statement, "r3.checked = true". > > > Thanks for the reply, > Alan. > > On Thu, Feb 17, 2011 at 1:42 PM, Zachary Scott > <zachary.s.scott@gmail.com> wrote: > I was able to mark Radio 3 checked with a button, like this: > > button "Mark Radio 3" do > r3.checked = true > end > > Hope that helps! > > > On Thu, Feb 17, 2011 at 2:37 PM, Alan Jelden > <alan.jelden@gmail.com> wrote: > > I would like my shoes app to present a group of radio > buttons and have one > > of them selected by default. > > I expected that the following code would select radio r3, > but it doesn't. > > Shoes.app do > > r1 = radio; para "Radio 1\n" > > r2 = radio; para "Radio 2\n" > > r3 = radio; para "Radio 3\n" > > r4 = radio; para "Radio 4\n" > > r5 = radio; para "Radio 5\n" > > > > para "\n\n\n" > > para "r3.checked? = #{r3.checked?}\n\n" > > para "Calling 'r3.checked = true'\n\n" > > r3.checked = true > > para "r3.checked? = #{r3.checked?}\n\n" > > end > > Is there a solution for this, or is this a bug? > > Thanks, > > Alan Jelden > > > > > -- > Zachary Scott > >