Hi
I am trying to run a simple gui app using wxPython as follow to list pdf files in a listbox but I am getting this error"
return controls.ListBox_Insert(*args, **kwargs)
TypeError: String or Unicode type required
import os
import wx
class ButtonFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, 'Button Example',size=(500, 500))
panel = wx.Panel(self, -1)
self.button = wx.Button(panel, -1, "List", pos=(50, 20))
self.Bind(wx.EVT_BUTTON, self.OnClick, self.button)
self.button.SetDefault()
sampleList = []
self.listbox = wx.ListBox(panel, -1, (140, 20), (180, 190), sampleList, wx.LB_SINGLE)
def OnClick(self, event):
dirAd = "D:\data\Map\m2012"
for files in os.listdir(dirAd):
if files.endswith(".pdf"):
self.listbox.Insert(0,files)
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = ButtonFrame()
frame.Show()
app.MainLoop()
can you please let me know what I am doing wrong?
Thanks