Author: bugman Date: Fri Jan 15 11:24:40 2010 New Revision: 10235 URL: http://svn.gna.org/viewcvs/relax?rev=10235&view=rev Log: Simplifications to the file dialog code. This corresponds to one component of the patch_II file attached to https://gna.org/task/?6847 by Michael Bieri (https://gna.org/users/michaelbieri). Modified: branches/bieri_gui/gui_bieri/res/filedialog.py Modified: branches/bieri_gui/gui_bieri/res/filedialog.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/res/filedialog.py?rev=10235&r1=10234&r2=10235&view=diff ============================================================================== --- branches/bieri_gui/gui_bieri/res/filedialog.py (original) +++ branches/bieri_gui/gui_bieri/res/filedialog.py Fri Jan 15 11:24:40 2010 @@ -36,12 +36,10 @@ #openfile('select file to open','/usr', 'save.relaxGUI', 'relaxGUI files (*.relaxGUI)|*.relaxGUI|all files (*.*)|*.*') #suggests to open /usr/save.relaxGUI, supported files to open are: *.relaxGUI, *.* - application = wx.PySimpleApp() - newfile = None - dialog = wx.FileDialog ( None, message = msg, style = wx.OPEN, defaultDir= directory, defaultFile = filetype, wildcard = default) - if dialog.ShowModal() == wx.ID_OK: - newfile = dialog.GetPath() - dialog.Destroy() + newfile = None + dialog = wx.FileDialog ( None, message = msg, style = wx.OPEN, defaultDir= directory, defaultFile = filetype, wildcard = default) + if dialog.ShowModal() == wx.ID_OK: + newfile = dialog.GetPath() return newfile def multi_openfile(msg, directory, filetype, default): # open multiple file @@ -56,12 +54,10 @@ #openfile('select file to open','/usr', 'save.relaxGUI', 'relaxGUI files (*.relaxGUI)|*.relaxGUI|all files (*.*)|*.*') #suggests to open /usr/save.relaxGUI, supported files to open are: *.relaxGUI, *.* - application = wx.PySimpleApp() - newfile = [] - dialog = wx.FileDialog ( None, message = msg, style = wx.OPEN | wx.FD_MULTIPLE, defaultDir= directory, defaultFile = filetype, wildcard = default) - if dialog.ShowModal() == wx.ID_OK: - newfile = dialog.GetPaths() - dialog.Destroy() + newfile = [] + dialog = wx.FileDialog ( None, message = msg, style = wx.OPEN | wx.FD_MULTIPLE, defaultDir= directory, defaultFile = filetype, wildcard = default) + + if dialog.ShowModal() == wx.ID_OK: return newfile def savefile(msg, directory, filetype, default): # save a file @@ -76,20 +72,16 @@ #savefile('select file to save', '/usr', 'save.relaxGUI', 'relaxGUI files (*.relaxGUI)|*.relaxGUI|all files (*.*)|*.*') #suggests to save /usr/save.relaxGUI, supported files to save are: *.relaxGUI, *.* - application = wx.PySimpleApp() - newfile = None - dialog = wx.FileDialog ( None, message = msg, style = wx.SAVE, defaultDir= directory, defaultFile = filetype, wildcard = default) - if dialog.ShowModal() == wx.ID_OK: - newfile = dialog.GetPath() - dialog.Destroy() + newfile = None + dialog = wx.FileDialog ( None, message = msg, style = wx.SAVE, defaultDir= directory, defaultFile = filetype, wildcard = default) + if dialog.ShowModal() == wx.ID_OK: + newfile = dialog.GetPath() return newfile def opendir(msg, default): # select directory, msg is message to display, default is starting directory - application = wx.PySimpleApp() newdir = None dlg = wx.DirDialog(None, message = msg, style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON, defaultPath = default) if dlg.ShowModal() == wx.ID_OK: newdir= dlg.GetPath() - dlg.Destroy() - return newdir + return newdir