[PyQt] File Dialog Opens Twice
david at boddie.org.uk
Sat Feb 13 04:13:22 GMT 2010
On Sat Feb 13 02:07:44 GMT 2010, David Arnold wrote:
> class Notepad(QMainWindow, Ui_Notepad):
> def __init__(self, parent = None):
> QMainWindow.__init__(self, parent)
^^^ Connection 1 (behind the scenes)
^^^ Connection 2
> def on_button_open_clicked(self):
> 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?
You called setupUi(self) which connects all the signals to specially-named
slots like the one you defined (on_button_open_clicked) and decorated with
@pyqtSignature. Then you explicitly connected the push button's signal to
the slot again.
So, when the button is pressed, the slot will be invoked twice and the
dialog will be opened twice.
More information about the PyQt