1. EuGTK - CheckAll, UncheckAll
- Posted by Jerry_Story Nov 02, 2010
- 1612 views
-- This is supposed to put a check mark on all 25 food groups in the menu bar. function onMenu_CheckAll(atom ctl) for fg = 1 to length(MenuG) do -- But this checks those that are unchecked, and unchecks those that are checked. -- And it seems to trigger an event for each one; that is my guess why it takes a long time. set(MenuG[fg],"activate",1) SelectedGroups[fg] = 1 end for update_foods() return(0) end function constant ev_CheckAll = call_back(routine_id("onMenu_CheckAll")) connect(MenuG_CheckAll,"activate",ev_CheckAll) -- This is supposed to uncheck all 25 food groups. function onMenu_UncheckAll(atom ctl) for fg = 1 to length(MenuG) do set(MenuG[fg],"activate",0) -- This does the same as above. SelectedGroups[fg] = 0 end for update_foods() return(0) end function constant ev_UncheckAll = call_back(routine_id("onMenu_UncheckAll")) connect(MenuG_UncheckAll,"activate",ev_UncheckAll)
Question 1: Is set_active supposed to toggle between active and inactive? Then what is the purpose of the 1 or 0? And that's not what the documentation says.
http://www.pygtk.org/docs/pygtk/class-gtkcheckmenuitem.html#method-gtkcheckmenuitem--set-active
Question 2: Is there any way to use
set(MenuG[fg],"activate",1) and set(MenuG[fg],"activate",0)
without triggering an event?
2. Re: EuGTK - CheckAll, UncheckAll
- Posted by irv Nov 02, 2010
- 1499 views
From GtkMenuItem:docs
gtk_menu_item_activate () Emits the "activate" signal on the given itemNote that no parameter other than the handle for the menu item is required. EuGTK provides this object handle transparently, so there's no parameter needed.
From GtkCheckMenuItem:docs
gtk_check_menu_item_set_active () Sets the active state of the menu item's check box.Note that this call requires an additional parameter (boolean).
So, the first does the same thing as clicking on the item, calling whatever routine you have attached...
The second sets the state - active or not active, depending upon whether you send it TRUE (active) or FALSE (not active).
Q1: No. And the Python docs confirm this:
The set_active() method sets the active state of the menu item's check box according to the value of is_active.
Q2: Yes, but it would be crazy to attempt this, since a: it's the wrong call, and b: it won't see or care about the parameter you're passing.
3. Re: EuGTK - CheckAll, UncheckAll
- Posted by Jerry_Story Nov 02, 2010
- 1407 views
I should have used set(MenuG[fg],"active",1) instead of set(MenuG[fg],"activate",1). "active" works better.