[PyQt] PyQt4.Gui.QFileDialog

Janwillem van Dijk jwevandijk at xs4all.nl
Tue Nov 1 11:27:45 GMT 2011


I am sorry to say that this does not help either. On linux the dialog 
shows until the sleep finishes on windows it exits as soon as the button 
is clicked as expected.
For the time being I changed to traits. Bit heavy weight perhaps but 
give the opportunity to have a few other parameters conveniently 
adjusted too.
Thanks again, Janwillem


On 10/31/2011 10:19 AM, Vincent Vande Vyvre wrote:
> Le 31/10/11 10:07, Vincent Vande Vyvre a écrit :
>> Le 31/10/11 09:32, Matteo Boscolo a écrit :
>>> Try this after instantiate the application:
>>> app.setQuitOnLastWindowClosed(False)
>>>
>>> and this after closing the dialog:
>>> app.closeAllWindows()
>>>
>>> I use this in some case in my com application .. hope it helps
>>>
>>> Regards,
>>> Matteo
>>>
>>>
>>>
>>> Il 31/10/2011 09:08, Janwillem ha scritto:
>>>> Thanks, yes I see, that is under windows (XP on VirtualBox, python 
>>>> 2.7.1 and
>>>> pyqt4 4.7.2 in my case) but under linux (ubuntu 11.10, python 
>>>> 2.7.2+ and
>>>> pyqt 4.7.3) it only closes after the sleep has finished (or in case 
>>>> of my
>>>> practical application, until the data processing finished)
>>>> So any tips from a ubuntu user???
>>>> cheers, Janwillem
>>>>
>>>>
>>>> Matteo Boscolo wrote:
>>>>> with this configuration
>>>>> Python 2.6.6
>>>>> PyQt4 4.7.3
>>>>> open dialog
>>>>> dialog finished
>>>>> C:\Users\mboscolo\Documents\.bzr.log
>>>>> finished
>>>>>
>>>>> it works perfectly .. after press the opendialog the form is 
>>>>> closed and
>>>>> start to print the rest of the debug
>>>>>
>>>>> regards,
>>>>> Matteo
>>>>>
>>>>> Il 31/10/2011 08:07, Janwillem ha scritto:
>>>>>> I want a small script with just a few filedialogs not a full 
>>>>>> blown gui
>>>>>> application . However when I try the code below the dialog does not
>>>>>> disappear after clicking the Open button on the dialog  but stays 
>>>>>> on top
>>>>>> until the script exits. What am I doing wrong??
>>>>>> Thanks, Janwillem
>>>>>>
>>>>>> 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,QWidget
>>>>>>       if default_dir == None:
>>>>>>           default_dir = environ['HOME']
>>>>>>       app = QApplication(argv)
>>>>>>       fdialog = QFileDialog
>>>>>>       filenames = fdialog.getOpenFileNames(directory=default_dir)
>>>>>>       app.exit()
>>>>>>       return list(filenames)
>>>>>>
>>>>>> if __name__ == '__main__':
>>>>>>       from PyQt4.QtCore import QT_VERSION_STR
>>>>>>       from platform import python_version
>>>>>>       print('Python %s' % (python_version()))
>>>>>>       print('PyQt4 %s' %QT_VERSION_STR)
>>>>>>       print('open dialog')
>>>>>>       lst = open_files()
>>>>>>       print('dialog finished')
>>>>>>       for fname in lst:
>>>>>>           print(fname)
>>>>>>       import time
>>>>>>       time.sleep(2)
>>>>>>       print 'finished'
>>>>>>
>>>>> _______________________________________________
>>>>> PyQt mailing list PyQt at riverbankcomputing.com
>>>>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>>>>
>>>>>
>>>
>>> _______________________________________________
>>> PyQt mailing list PyQt at riverbankcomputing.com
>>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>>
>> No problem for me on Ubuntu 10.04
>>
>> vincent at tiemoko:~/Bureau$ python test.py
>> Python 2.6.5
>> PyQt4 4.6.2
>> open dialog
>> dialog finished
>> /home/vincent/Documents/gabarit_cd.svg
>> finished
>> vincent at tiemoko:~/Bureau$
>>
>> -- 
>> Vincent V.V.
>> Oqapy <https://launchpad.net/oqapy> . Qarte+7 
>> <https://launchpad.net/qarte+7> . PaQager <https://launchpad.net/paqager>
>>
>>
>> _______________________________________________
>> PyQt mailing listPyQt at riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> Works as expected too on 11.10
>
> vincent at bacoudian:~/Bureau$ python test.py
> Python 2.7.2+
> PyQt4 4.7.3
> open dialog
> dialog finished
> /home/vincent/examples.desktop
> finished
> vincent at bacoudian:~/Bureau$
>
> -- 
> Vincent V.V.
> Oqapy <https://launchpad.net/oqapy> . Qarte+7 
> <https://launchpad.net/qarte+7> . PaQager <https://launchpad.net/paqager>
>
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20111101/c246d2bb/attachment.html>


More information about the PyQt mailing list