Rich Shepard wrote:
This is the definition of a wx.RadioBox() on a notebook page (using
2.6.3.2):self.valphaType = wx.RadioBox(self, wx.ID_ANY, choices=['Strong', 'Weak'],
label=' Alpha-cut ', majorDimension=2,
style=wx.RA_SPECIFY_COLS|wx.RAISED_BORDER)
# self.valphaType.SetSelection(0)
self.varAlphaType = self.valphaType.GetStringSelection()Regardless of whether that second line is evaluated or commented out, I
cannot get the second string, 'Weak,' to be assigned to self.varAlphaType.
It's always 'Strong.' I don't see what I've written incorrectly, and would
appreciate a clue.
The SetSelection, and the default selection are selecting the first radio item, which is of course 'Strong'. If you want the 'Weak' item selected then use SetSelection(1). For example, in a PyShell:
PyShell 0.9.5 - The Flakiest Python Shell
Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02)
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Startup script executed: /home/robind/bin/pythonstartup.py
>>> import wx
>>> rb = wx.RadioBox(shell, choices=['Strong', 'Weak'], label = 'Alpha-cut',
... majorDimension=2, style=wx.RA_SPECIFY_COLS|wx.RAISED_BORDER)
>>> rb.SetSelection(1)
>>> rb.GetStringSelection()
u'Weak'
>>> rb.SetSelection(0)
>>> rb.GetStringSelection()
u'Strong'
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!