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

It seems that the signature of Insert is Insert(self, item, pos, client_data=None), See here .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.