[PyQt] File Dialog Opens Twice

detlev detlev at die-offenbachs.de
Sat Feb 13 08:58:06 GMT 2010


The simple answer is, that your dialog is connected twice. The first time is 
done automatically within self.setupUi() and a second time explicitly by the 
connect call in the __init__ method. Remove the later and it should be fine.

Regards,
Detlev

On Samstag, 13. Februar 2010, David Arnold wrote:
> All,
> 
> I am attempting to go through the tutorial offered at:
> 
> http://www.rkblog.rk.edu.pl/w/p/simple-text-editor-pyqt4/
> 
> However, I am trying to use the eric4 ide to develop the application,
>  following the outline provided by the Minibrowser tutorial on the eric ide
>  website. My project is zipped at:
> 
> http://msemac.redwoods.edu/~darnold/junk/SimpleTextEditor.zip
> 
> I've adapted the file edytor.py created by the Generate Dialog Code ...
>  option in eric4:
> 
> from PyQt4.QtGui import QMainWindow,  QFileDialog
> from PyQt4.QtCore import pyqtSignature,  SIGNAL
> from Ui_edytor import Ui_Notepad
> 
> class Notepad(QMainWindow, Ui_Notepad):
>   def __init__(self, parent = None):
>       QMainWindow.__init__(self, parent)
>       self.setupUi(self)
> 
>       self.connect(self.button_open,
>                              SIGNAL("clicked()"),
>  self.on_button_open_clicked)
> 
>   @pyqtSignature("")
>   def on_button_open_clicked(self):
>       fd=QFileDialog(self)
>       plik=open(fd.getOpenFileName()).read()
>       self.editor_window.setText(plik)
> 
> 
> However, when I run the project and click on the Open button, the file
>  dialog opens, I select start.py in the SimpleTextEditor folder, press OK
>  and it opens fine in the QTextEdit window. However, then the QFileDialog
>  opens a second time. Weird.
> 
> Can anyone explain what I am doing wrong?
> 
> David.
> _______________________________________________
> 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