[PyQt] stand alone QFileDialog
Detlev Offenbach
detlev at die-offenbachs.de
Mon May 30 15:38:50 BST 2011
Hello Janwillem,
there is nothing wrong with your setup. It is caused by a bug which was
undiscovered for years. Congratulations :-))
It has been fixed for all eric4 variants and eric5 5.1 and pushed to the
sourcecode repo. It will be included in the next releases.
Detlev
On Montag, 30. Mai 2011, Janwillem van Dijk wrote:
> Thanks, can it than be that there is something wrong with my debug
> settings? I also still have that problem (see 6 April 2011) that when
> debuging with Python3 a run time error generates the familiar error with
> the correct line number but opens a new tab called <string> and creates a
> file called <string> in my home directory (both including the <>).
> Debugging with 2.7 does not raise that problem. An example:
> number = 5
> print('divide by 1: %d' % (number // 1))
> print('divide by 0: %d' % (number // 0))
> print('finished')
> Although a bit large I attached my ini file for using Python3.
>
> On 05/30/2011 10:23 AM, Detlev Offenbach wrote:
> > On Sonntag, 29. Mai 2011, Janwillem van Dijk wrote:
> >> Thanks for paying attention to my question. It was about as far as I
> >> could get. The example below I made (unfortunaly more based on intuition
> >> than understanding) works when called from the command line. However,
> >> when called from inside the Eric5 IDE the dialog returns the results but
> >> hangs. This made me think my solution is incorrect.
> >
> > I just tested your script in eric5 and it works ok. I could not observe
> > your issue.
> >
> >> Any comments very welcome, cheers!
> >>
> >> def open_files(default_dir=None):
> >> """Returns list of filenames optionally given a default dir"""
> >> from sys import argv
> >> from os import environ
> >> from PyQt4.QtGui import QApplication, QFileDialog
> >>
> >> if default_dir == None:
> >> default_dir = environ['HOME']
> >>
> >> app = QApplication(argv)
> >> filenames = QFileDialog.getOpenFileNames(directory=default_dir)
> >> app.exit()
> >> return list(filenames)
> >>
> >> if __name__ == '__main__':
> >> print('open dialog')
> >> lst = open_files()
> >> print('dialog finished')
> >>
> >> for fname in lst:
> >> print(fname)
> >>
> >> for completeness the TkInter version that does work both from the
> >> commandline and from Eric5:
> >>
> >> def open_files(default_dir=None):
> >> """Returns list of filenames+paths given default dir"""
> >> from os import environ
> >> from Tkinter import Tk
> >> import tkFileDialog
> >>
> >> if default_dir == None:
> >> default_dir = environ['HOME']
> >>
> >> root = Tk()
> >> root.withdraw() # Hide root window
> >> filenames = tkFileDialog.askopenfilenames(initialdir=default_dir,
> >>
> >> multiple=True)
> >>
> >> return list(filenames)
> >>
> >> if __name__ == '__main__':
> >> print('open dialog')
> >> lst = open_files()
> >> print('dialog finished')
> >>
> >> for fname in lst:
> >> print(fname)
> >>
> >> On 05/27/2011 10:53 AM, Wilbert Berendsen wrote:
> >>> Op woensdag 11 mei 2011 schreef Janwillem:
> >>>> Is there for opening a file in a non-qui script a PqQt4 equivalent for
> >>>> the TkInter based function below?
> >>>
> >>> look for QFileDialog.
> >>> http://doc.trolltech.com/4.7/qfiledialog.html and
> >>> http://www.riverbankcomputing.com/static/Docs/PyQt4/html/python_v3.html
> >>> #q filedialog
> >>>
> >>> w best regards,
> >>> Wilbert Berendsen
> >>
> >> _______________________________________________
> >> PyQt mailing list PyQt at riverbankcomputing.com
> >> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
--
Detlev Offenbach
detlev at die-offenbachs.de
More information about the PyQt
mailing list