By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,272 Members | 1,733 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,272 IT Pros & Developers. It's quick & easy.

help with getting selection from wxChoice with out after it has changed

P: n/a
'
I want to get the selection of several wxChoice boxes.
But i do not want to have to catch the events for all the boxes
I should be able to access the current selection outside of an
event,but i am not seeing how to do this.
This is a hack of the wxpython choice demo to demonstrate my question

#--------- comment marks are for indention
#import wx
#class TestChoice(wx.Dialog):
# def __init__(self, parent):
# #self.log = log
# wx.Dialog.__init__(self, parent, -1)
#
# sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
# 'six', 'seven', 'eight']
#
# wx.StaticText(self, -1, "This example uses the wxChoice
control.", (15, 10))
# wx.StaticText(self, -1, "Select one:", (15, 50), (75, -1))
# self.ch = wx.Choice(self, -1, (100, 50), choices = sampleList)
# self.Bind(wx.EVT_CHOICE, self.EvtChoice, self.ch)
#
#
# def EvtChoice(self, event):
# print('EvtChoice: %s\n' % event.GetString())
# self.ch.Append("A new item")
#
##-----changed here --------- from event.GetSelection()
# if self.ch.GetSelection() == 'one':
# print('Well done!\n')
#
#
#if __name__ == "__main__":
# app = wx.PySimpleApp(0)
# wx.InitAllImageHandlers()
# Dialog_Main = TestChoice(None)
# app.SetTopWindow(Dialog_Main)
# Dialog_Main.Show()
# app.MainLoop()

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
'@'.join([..join(['fred', 'dixon']), ..join(['gmail', 'com'])]) wrote:
From: "'@'.join([..join(['fred', 'dixon']), ..join(['gmail', 'com'])])" <fr********@gmail.com>


This is a SyntaxError.
You want to enclose the dots with '' marks as well, like this:

'@'.join(['.'.join(['fred', 'dixon']), '.'.join(['gmail', 'com'])])

regards,
Gerrit Holl.

--
Weather in Twenthe, Netherlands 29/03 10:55:
10.0°C mist overcast wind 0.9 m/s None (57 m above NAP)
--
In the councils of government, we must guard against the acquisition of
unwarranted influence, whether sought or unsought, by the
military-industrial complex. The potential for the disastrous rise of
misplaced power exists and will persist.
-Dwight David Eisenhower, January 17, 1961
Jul 18 '05 #2

P: n/a
[..join(['fred','dixon'] wrote:
I want to get the selection of several wxChoice boxes.
But i do not want to have to catch the events for all the boxes
I should be able to access the current selection outside of an
event,but i am not seeing how to do this. # def EvtChoice(self, event):
# print('EvtChoice: %s\n' % event.GetString())
# self.ch.Append("A new item")
#
##-----changed here --------- from event.GetSelection()
# if self.ch.GetSelection() == 'one':
# print('Well done!\n')


Perhaps you are confused by the fact that GetSelection() returns an integer?
Changing the above to either

if self.ch.GetStringSelection() == 'one':
print 'Well done!'

or

if self.ch.GetSelection() == 1:
print 'Well done, too!'

should work as you expect then.

Peter
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.