Hi folks,

I dont need any code snippet, but at least i need somebody to lead me to a solution.

I got an app form that will have personal info from employees, and i need to let them pick a photo from filesystem to attach to this form.

what i will do with the photo i already have the theory, but dont know how to open a filesystem window, let the person pick a photo, and than.. do something with this photo.

any tips? thanks in advance.

Do you have to display the photo for the person to pick it?

nope... just a regular file system window

.. that will show blablabla.jpg, blebleble.jpg, bliblibli.jpg ... the person picking the photo before doing it , has already took the photo, transfered it to the PC, and after that he will pick the file in my form.

when he submits the form, i will get that file ( always an image) save it to a server, save the URI to my DB and make use of it whenever its needed...

You can use either a tk or wxPython file dialog. Both should provide a native file chooser window for the user. Plenty of examples on this site or through searching google.

thanks man, as soon as possible i'll be looking for it !! thx in advance!

i just didnt know what to look for, now i'll google it ! thx

hey man, im getting very confused tryin to understand how wxPython works...


all examples they only talk about the wxPython code itself... like wx.filedialog and bla bla...

but none says how do you execute them from a app...

im using turbogears as framework, i got a form and a button that when clicked i want to execute this wx.filedialog... how i do that?

anyone with code snippet from a form, button, action .. how to send to controller(turbogears) ?!!?!?

im not a python advanced programmer, just got this job without knowing shit about python.. and maybe thats why im confused.

im very newbie to it.. and i hope somebody can explain me that... the Getting Started guide from wxpython.org dont say nothing about how to run the code.

You can give Tkinter (part of the Python install) a try. This code will pop up a file dialog and the selected file can be transferred to your program ...

# use Tkinter's file dialog window to get a full path file name
# that you can use in a console or other program
# askopenfilename() gives one selected filename

# with Python2 use ...
from tkFileDialog import askopenfilename

# with Python3 use ...
#from tkinter.filedialog import askopenfilename

# optional list/mask of graphic formats to open
myformats = [
('JPEG or JFIF', '*.jpg'),
('Windows Bitmap', '*.bmp'),
('Portable Network Graphics', '*.png'),
('CompuServer GIF', '*.gif'),
('All Files','*.*')
]

file_name = askopenfilename(filetypes=myformats, title="Image Files")
# testing ...
print( file_name )

I don't know enough about turbogear to tell you the details how to transfer the file_name to that program from the popup dialog.

This article has been dead for over six months. Start a new discussion instead.