wxPython FileDialog, select folder

S

SMALLp

How can i select folder either with wx.FileDialog or with any other. I
managed to fine only how to open files but I need to select folder to
get files from all sub folders.....

Thanks in advance!
 
C

Chris Mellon

How can i select folder either with wx.FileDialog or with any other. I
managed to fine only how to open files but I need to select folder to
get files from all sub folders.....


There's a separate dialog, wx.DirDialog.
 
F

farsheed

import wx
def dirchoose():
'Gives the user selected path. Use: dirchoose()'
global _selectedDir , _userCancel #you should define
them before
userPath = 'c:/'
app = wx.App()
dialog = wx.DirDialog(None, "Please choose your project directory:",\
style=1 ,defaultPath=userPath, pos = (10,10))
if dialog.ShowModal() == wx.ID_OK:
_selectedDir = dialog.GetPath()
return _selectedDir
else:
#app.Close()
dialog.Destroy()
return _userCancel

Cheers, Farsheed.
 
S

SMALLp

farsheed said:
import wx
def dirchoose():
'Gives the user selected path. Use: dirchoose()'
global _selectedDir , _userCancel #you should define
them before
userPath = 'c:/'
app = wx.App()
dialog = wx.DirDialog(None, "Please choose your project directory:",\
style=1 ,defaultPath=userPath, pos = (10,10))
if dialog.ShowModal() == wx.ID_OK:
_selectedDir = dialog.GetPath()
return _selectedDir
else:
#app.Close()
dialog.Destroy()
return _userCancel

Cheers, Farsheed.
Thanks! I've already figured it out from first reply. Now i get selected
directory and i want to get all directories from thin directory. I found
os.listdir but it oly gets names of files and i nedd output with
permisions e.g. -rw-r--r-- 1 pofuk pofuk 105 2007-12-19 21:59 login.py
 
T

Tim Roberts

SMALLp said:
Thanks! I've already figured it out from first reply. Now i get selected
directory and i want to get all directories from thin directory. I found
os.listdir but it oly gets names of files and i nedd output with
permisions e.g. -rw-r--r-- 1 pofuk pofuk 105 2007-12-19 21:59 login.py

Do you want to KNOW the permissions, or do you really want to get the
output of "ls -l"?

What you probably want is os.walk. You can call stat or os.path.isdir to
get information about the files you discover.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top