t gillespie
t gillespie

Reputation: 123

changing data in list on button press

in wxpython how do you update the information in the list when the user presses the button... the code i have is this :

ButtonImage8 = "Images/GUI/MP3Player/button_reload.bmp"
ButtonImageBMP8 = wx.Image(ButtonImage8, wx.BITMAP_TYPE_ANY).ConvertToBitmap()

button8 = wx.BitmapButton(BUTTONpanel8, id=wx.ID_ANY,bitmap=ButtonImageBMP8, size=(40, 40), pos=(0, 0),style=wx.NO_BORDER)
button8.Bind(wx.EVT_BUTTON, self.Music_Reload)


BUTTONpanel8 = wx.Panel(self, -1, pos=(280, 160), size=(40, 40), style=wx.NO_BORDER)

MP3FileListPanel = wx.Panel(self, -1,style=wx.NO_BORDER, pos=(0, 0), size=(320, 160))

MP3FileList = wx.ListBox(choices=[], parent=MP3FileListPanel, pos=wx.Point(0, 0),size=(320, 160))

def Music_Reload(self, event): for root, dirs, files in os.walk("/home/tjohnson/python"): for file in files: if file.endswith(".py"): self.MP3FileList.Append(file) print(os.path.join(root, file))

when i press the button the code says "Attribute not found" referring to the list box keep in mind i have extracted this code from the full script. when it tries to self.list.append() it throws an error

Upvotes: 0

Views: 46

Answers (1)

Mike Driscoll
Mike Driscoll

Reputation: 33071

You can use SetItems to set the entire list of choices in a wx.ListBox widget. I don't see self.list defined in your code snippet, so I'm not sure what that refers to.

Upvotes: 0

Related Questions