Young-Jin Lee wrote:
But the problem is I don't want more them one
tool button selected at once. Is there any convenient way to do this?
In other language, for instance Java, there is a group mechanism which
allows only one component can be selected.
Last I checked, there was not a way to do this automataically, but it
was being worked on, so this info may be old.
If it is not in wxPython, how can I implemented it? Any comment would be
greatly appreciated.
I have done it like this: (code cut and pasted from a larger app, get
ideas form it, it won't run as is.)
## Set up Tool Bar
tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER)
self.ToolBar = tb
## three toggle buttons, where one can only be active at once:
## they all call the SetMode method below.
tb.AddTool(ID_ZOOM_IN_BUTTON, wxBitmap('Mag_plus3.bmp',
wxBITMAP_TYPE_BMP),isToggle=true)
EVT_TOOL(self, ID_ZOOM_IN_BUTTON, self.SetMode)
tb.AddTool(ID_ZOOM_OUT_BUTTON, wxBitmap('Mag_minus3.bmp',
wxBITMAP_TYPE_BMP),isToggle=true)
EVT_TOOL(self, ID_ZOOM_OUT_BUTTON, self.SetMode)
tb.AddTool(ID_MOVE_MODE_BUTTON, wxBitmap('hand3.bmp',
wxBITMAP_TYPE_BMP),isToggle=true)
EVT_TOOL(self, ID_MOVE_MODE_BUTTON, self.SetMode)
<snip>
#and here is the set mode method:
def SetMode(self,event):
# set all the buttons toggle off
for id in [ID_ZOOM_IN_BUTTON,ID_ZOOM_OUT_BUTTON,ID_MOVE_MODE_BUTTON]:
self.ToolBar.ToggleTool(id,0)
# set the one that was clicked on
self.ToolBar.ToggleTool(event.GetId(),1)
if event.GetId() == ID_ZOOM_IN_BUTTON:
self.Canvas.SetGUIMode("ZoomIn")
elif event.GetId() == ID_ZOOM_OUT_BUTTON:
self.Canvas.SetGUIMode("ZoomOut")
elif event.GetId() == ID_MOVE_MODE_BUTTON:
self.Canvas.SetGUIMode("Move")
By the way, this would make a nice wiki entry> I doubt I will get a
chance to write it up, but once you get it figured outl, it would be
great if you did...
-Chris
···
--
Christopher Barker,
Ph.D.
ChrisHBarker@home.net --- --- ---
http://members.home.net/barkerlohmann ---@@ -----@@ -----@@
------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------