Problem open/save file

27 views
Skip to first unread message

ziargon ziros

unread,
May 2, 2015, 8:26:45 AM5/2/15
to vpytho...@googlegroups.com
Hello everybody!

When using templates when open / save file the file path is sometimes not refundable. Without template are always opens / saves files. How can I solve this problem?
I use import visual.filedialog

Bruce Sherwood

unread,
May 2, 2015, 9:28:32 AM5/2/15
to vpytho...@googlegroups.com
There are two problems.

1) The VPython documentation is incorrect. According to the wx.FileDialog documentation at 


the filter ("wildcard") should look like this (for example):

"Python source (*.py)|*.py|Text files (*.txt)|*.txt"

2) However, there seems to be a bug in wx.FileDialog, because either

"Python source (*.py)|*.py"

or

"Text files (*.txt)|*.txt"

works as expected, but not both simultaneously. I don't see a workaround for this.

ziargon ziros

unread,
May 2, 2015, 12:06:29 PM5/2/15
to vpytho...@googlegroups.com
Thank you

Bruce Sherwood

unread,
May 2, 2015, 10:54:49 PM5/2/15
to vpytho...@googlegroups.com
Good news. I asked about this in the wxPython forum and they gave me more information than I found in the wxPython help. I've updated the documentation at vpython.org on file dialog, like this:

The examples shown above are sufficient for many tasks, but you can customize the file dialog display by specifying what kinds of files will be displayed in the file dialogs like this:

filter = "Python source|*.py"
get_file(filter)

With this filter specification, the only files displayed are .py files. The asterisk (*) is a "wild card" standing for "any text". (The filter option does not work on some versions of Linux.)

Here are other examples of filter expressions:

"Text files|*.txt"                     # show only text files
"All files|*.*"                          # show all types of files
"Python and text|*.py;*.txt"    # show both kinds of files
"Python|*.py|Text|*.txt"           # choose which kind to list

With the following filter specification, the menu lets you choose one or the other sets of files:

"Python|*.py|Text|*.txt" # choose which kind to list

In all of these filter expressions, what you place before the "|" character will be displayed to the user (and if there is more than one, the user can choose). What goes after the "|" character is a list separated by semicolons of the file types to be displayed.


ziargon ziros

unread,
May 3, 2015, 5:25:40 AM5/3/15
to vpytho...@googlegroups.com
Good news. Very good. Thank you
Reply all
Reply to author
Forward
0 new messages