Function not available after importing module
Stephen Boulet
stephendotboulet at motorola_._com
Wed Jun 30 17:02:50 EDT 2004
This must be a dumb error on my part.
I'm creating a module called "wxMessageBox.py".
When I do an "import wxMessageBox" I don't see my "askopenfilename"
function in the wxMessageBox namespace.
When I do a "python -i wxMessageBox.py" it's there and seems to work fine.
Here's the (short) code:
def askopenfilename(startdir, filetypes="All files (*.*)|*.*"):
....import wx
....app = wx.PySimpleApp()
....dlg = wx.FileDialog(None,
........message="Choose a file",
........defaultDir=startdir,
........defaultFile="",
........wildcard=filetypes,
........style=wx.OPEN | wx.CHANGE_DIR)
....path = -1
....if dlg.ShowModal() == wx.ID_OK:
........path = dlg.GetPath()
....return path
def showerror(caption, message):
....import wx
....app = wx.PySimpleApp()
....dlg = wx.MessageDialog(None,
........message=message,
........caption=caption,
........style=wx.ICON_ERROR)
....app.MainLoop()
....dlg.ShowModal()
if __name__ == '__main__':
....#showerror('Error!', 'No text on clipboard')
....print askopenfilename(startdir="C:\\")
More information about the Python-list
mailing list