Hello Everyone,
In my application i need to select a file using open dialog
box. And then i dont need to open the file. I just need to display the
name of the selected file in a text control. And then open the file in
later part of the program. But i am not able to get the file name and
display it in the text control. Here is the sample code.
import wx
import os
Fname = '' #Global variable to hold the file name.
class ScrolledWindow(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(350, 300))
panel = wx.Panel(self, -1)
txt1 = wx.TextCtrl(panel, -1, pos=(30, 100), size=(150, 20))
button11 = wx.Button(panel, -1, "Open", pos=(200,100))
self.Bind(wx.EVT_BUTTON, self.OnOpen, button11)
txt1.write(Fname)
self.Centre()
self.Show()
def OnOpen(self,event):
self.dirname = ''
dlg = wx.FileDialog(self, "Choose a file", self.dirname,"",
"*.*", wx.OPEN)
if dlg.ShowModal()==wx.ID_OK:
self.filename=dlg.GetFilename()
Fname = self.filename
self.dirname=dlg.GetDirectory()
dlg.Destroy()
app = wx.App()
ScrolledWindow(None, -1, 'Aliens')
app.MainLoop()
Any help is appreciated....
Rani