Re: [Tutor] [wxPython-users] How to save file name of file opened from wx.FileDialog ?

2007-11-17 Thread Varsha Purohit
HI Alan,
Thanks for suggestion its working now

import wx
import os

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)
self.txt1 = wx.TextCtrl(panel, -1, pos=(30, 100), size=(150, 20))
self.button11 = wx.Button(panel, -1, "Open", pos=(200,100))
self.button11.Bind(wx.EVT_BUTTON, self.OnOpen)

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()
   self.dirname=dlg.GetDirectory()

self.txt1.write(self.filename)
dlg.Destroy()


app = wx.App()
ScrolledWindow(None, -1, 'Aliens')
app.MainLoop()

On Nov 17, 2007 12:44 PM, Varsha Purohit <[EMAIL PROTECTED]> wrote:
> 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
>
> thanks,
> --
> Varsha Purohit,
> Graduate Student
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [wxPython-users] How to save file name of file opened from wx.FileDialog ?

2007-11-17 Thread Varsha Purohit
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

thanks,
-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor