def openFile():
    """Open a file and set it as the current file"""
    cur = GD.cfg.get('curfile',GD.cfg.get('workdir','.'))
    fn = qt.QFileDialog.getSaveFileName(
        cur,"pyformex scripts (*.frm *.py)",None,"save file dialog",
        "Choose a file to open (New or Exisiting)" )
    if fn:
        fn = str(fn)
        GD.cfg['workdir'] = os.path.dirname(fn)
        gui.setcurfile(fn)
def openFile(exist=True):
    """Open a file selection dialog and set the selection as the current file.

    The default only accepts existing files. Use newFile() to accept new files.
    """
    cur = GD.cfg.get('curfile',GD.cfg.get('workdir','.'))
    fs = widgets.FileSelection(cur,"pyformex scripts (*.frm *.py)",exist=exist)
    fn = fs.getFilename()
    if fn:
        GD.cfg['workdir'] = os.path.dirname(fn)
        gui.setcurfile(fn)
def runExample(i):
    """Run example i from the list of found examples."""
    global example
    gui.setcurfile(os.path.join(GD.cfg.exampledir,example[i]))
    play()