python 2.7 - Capture the current value in ComboBox. wxpython -


in code below trying capture current value of combobox when save button clicked.

ive defined function triggerd evt_button captures values in textctrl fields not work combobox.

i've tried few different approaches such trying assign audit_engineer = self.engineer_name.

can me?

regards paul.

class createaudit(wx.panel):      def __init__(self, parent):         wx.panel.__init__(self, parent)         self.lblname = wx.statictext(self, label = "site name :", pos=(20,60))         self.site_name = wx.textctrl(self, value = "enter site name here.", pos=(150, 60), size=(140,-1))         self.lblname = wx.statictext(self, label = "job number", pos=(20,120))         self.job_number = wx.textctrl(self, value = "4 digit number only.", pos=(150, 120), size=(140,-1))          con = sqlite3.connect("hs_audit.sqlite")         con.row_factory = lambda cursor, row: row[0]         mylist = con.execute('select engineer t1').fetchall()         self.lblname = wx.statictext(self, label="select engineer :", pos=(20,180))         self.engineer_name = wx.combobox(self, pos=(150, 180), size=(140,-1)).setitems(mylist)          self.save_button =wx.button(self, label="save", pos=(150, 400))         self.save_button.bind(wx.evt_button, self.save_details)         self.show()      def save_details(self, event):         audit_site = self.site_name.getvalue()         audit_engineer = self.engineer_name.getvalue() #<-- not work none value error         audit_jobnumber = self.job_number.getvalue()         print audit_site         print audit_engineer         print audit_jobnumber 

changing

self.engineer_name = wx.combobox(self, pos=(150, 180), size=(140,-1)).setitems(mylist) 

to

self.engineer_name = wx.combobox(self, pos=(170, 180), size=(170,-1), choices = mylist) 

did trick. on complicated syntax in first effort think. fixing these little things takes age, i'm enjoying learning curve.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -