[PyQt] File Dialog Opens Twice
David Arnold
dwarnold45 at suddenlink.net
Sat Feb 13 02:07:44 GMT 2010
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.
More information about the PyQt
mailing list