I have wxPython application were user gives a file as an input, and then my program should generate 2 dropdown lists for each line from the file. Problem is that no buttons are generated after user gives a file as an input, this is done in menu and self.content gets it's items. I have tried to call myButtons method after user gives the file, but it didn't work either.
Here is my simplified code for buttons:
class size:
def __init__(self, id, name):
self.id = id
self.name = name
class type:
def __init__(self, id, name):
self.id = id
self.name = name
class GUI(wx.Frame):
def __init__(self, parent, id, title):
self.dirname = ''
self.content = ''
wx.Frame.__init__(self, parent, id, title, size=(700, 400))
#UI stuff
panelControl = wx.Panel(self, 1, style=wx.MAXIMIZE)
sizerControl = wx.GridBagSizer(hgap=4,vgap = 4)
self.menu()
#buttons
if not self.content == '':
self.myButtons()
def myButtons(self):
listOfObjects = self.content #list if lists
#content of the dropdown lists
sizes = [size(0, 'very small'), size(1, 'small'), size(2, 'medium'), size(3, 'large'), size(4,'very large')]
types = [type(0, 'UI'), type(1, 'text'), type(2, 'I/O'), type(3, 'calculation'),
type(4, 'set-up'), type(5, 'logic'), type(6, 'data')]
for i in listOfObjects:
lista = [] #save the dropdown list selections
panel = wx.Panel(self, wx.ID_ANY)
self.labelthing = wx.StaticText(panel, label="Object name: %s LOC: %s Method amount: %s Mean: %s"%(i[0], i[1], i[2], i[3]))
self.sizeDrop = wx.ComboBox(panel,
size=wx.DefaultSize,
choices=lista)
self.typeDrop = wx.ComboBox(panel,
size=wx.DefaultSize,
choices=lista)
self.widgetMaker(self.sizeDrop, self.typeDrop)
self.Show()
def widgetMaker(self, widget1, widget2):
widget1.Bind(wx.EVT_COMBOBOX, self.onSelect)
widget2.Bind(wx.EVT_COMBOBOX, self.onSelect)
def onSelect(self, event):
#wait for the both dropdown list values, then do stuff
pass
def menu(self):
#do other stuff too
self.content = [['foo1', 1 , 'bar1', 1],['foo2', 1 , 'bar2', 1]]
if __name__ == "__main__":
app = wx.PySimpleApp()
frame = GUI(None, -1, "")
frame.Show(1)
app.MainLoop()