[PyQt] Dock widgets and window's lost of focus.
IloChab
ilochab at gmail.com
Wed Mar 26 19:53:59 GMT 2008
I designed a main window that contains 1 tableView and 3 dockWidgets.
If I use it on top of other windows, it works fine.
If I let it under other windows, when recall it on top, I find the 3
dockWidget gone (they automatically closed), and if I reopen them manually
(through a menu action) they come up correctly and I find all the text that
my application output meanwhile into them.
Why does this happen?
What did I do wrong?
I found out that this behaviour doesn't depend on my application.
If I just run the window alone (only the ui file, I mean) I get a similar
behaviour.
1) I run the script and I get 1 tableView and 3 dockWidgets
2) I minimize the window
3) I reopen the window and the 3 dockWidgets are gone.
Please help.
This is my pyui file:
from PyQt4 import QtCore, QtGui
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(QtCore.QSize(QtCore.QRect
(0,0,800,600).size()).expandedTo(MainWindow.minimumSizeHint()))
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridlayout = QtGui.QGridLayout(self.centralwidget)
self.gridlayout.setObjectName("gridlayout")
self.splitter = QtGui.QSplitter(self.centralwidget)
self.splitter.setOrientation(QtCore.Qt.Vertical)
self.splitter.setObjectName("splitter")
self.tvLog = QtGui.QTableView(self.splitter)
self.tvLog.setSortingEnabled(True)
self.tvLog.setObjectName("tvLog")
self.dockWidget_log = QtGui.QDockWidget(self.splitter)
self.dockWidget_log.setObjectName("dockWidget_log")
self.dockWidgetContents_log = QtGui.QWidget(self.dockWidget_log)
self.dockWidgetContents_log.setObjectName("dockWidgetContents_log")
self.gridlayout1 = QtGui.QGridLayout(self.dockWidgetContents_log)
self.gridlayout1.setObjectName("gridlayout1")
self.textBrowser_log = QtGui.QTextBrowser(
self.dockWidgetContents_log)
font = QtGui.QFont()
font.setFamily("Monospace")
self.textBrowser_log.setFont(font)
self.textBrowser_log.setLineWrapMode(QtGui.QTextEdit.NoWrap)
self.textBrowser_log.setTabStopWidth(255)
self.textBrowser_log.setAcceptRichText(False)
self.textBrowser_log.setOpenLinks(False)
self.textBrowser_log.setObjectName("textBrowser_log")
self.gridlayout1.addWidget(self.textBrowser_log,0,0,1,1)
self.dockWidget_log.setWidget(self.dockWidgetContents_log)
self.dockWidget_out = QtGui.QDockWidget(self.splitter)
self.dockWidget_out.setObjectName("dockWidget_out")
self.dockWidgetContents_err_2 = QtGui.QWidget(self.dockWidget_out)
self.dockWidgetContents_err_2.setObjectName
("dockWidgetContents_err_2")
self.gridlayout2 = QtGui.QGridLayout(self.dockWidgetContents_err_2)
self.gridlayout2.setObjectName("gridlayout2")
self.textEdit_out = QtGui.QTextEdit(self.dockWidgetContents_err_2)
self.textEdit_out.setLineWrapMode(QtGui.QTextEdit.NoWrap)
self.textEdit_out.setReadOnly(True)
self.textEdit_out.setObjectName("textEdit_out")
self.gridlayout2.addWidget(self.textEdit_out,0,0,1,1)
self.dockWidget_out.setWidget(self.dockWidgetContents_err_2)
self.dockWidget_err = QtGui.QDockWidget(self.splitter)
self.dockWidget_err.setObjectName("dockWidget_err")
self.dockWidgetContents_err = QtGui.QWidget(self.dockWidget_err)
self.dockWidgetContents_err.setObjectName("dockWidgetContents_err")
self.gridlayout3 = QtGui.QGridLayout(self.dockWidgetContents_err)
self.gridlayout3.setObjectName("gridlayout3")
self.textEdit_err = QtGui.QTextEdit(self.dockWidgetContents_err)
self.textEdit_err.setLineWrapMode(QtGui.QTextEdit.NoWrap)
self.textEdit_err.setReadOnly(True)
self.textEdit_err.setObjectName("textEdit_err")
self.gridlayout3.addWidget(self.textEdit_err,0,0,1,1)
self.dockWidget_err.setWidget(self.dockWidgetContents_err)
self.gridlayout.addWidget(self.splitter,0,0,1,1)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0,0,800,29))
self.menubar.setObjectName("menubar")
self.menuTask = QtGui.QMenu(self.menubar)
self.menuTask.setObjectName("menuTask")
self.menuLogging = QtGui.QMenu(self.menubar)
self.menuLogging.setObjectName("menuLogging")
self.menuAdd_handler = QtGui.QMenu(self.menuLogging)
self.menuAdd_handler.setObjectName("menuAdd_handler")
self.menuStart_log_msg = QtGui.QMenu(self.menuLogging)
self.menuStart_log_msg.setObjectName("menuStart_log_msg")
self.menuHelp = QtGui.QMenu(self.menubar)
self.menuHelp.setObjectName("menuHelp")
self.menuView = QtGui.QMenu(self.menubar)
self.menuView.setObjectName("menuView")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.actionExit = QtGui.QAction(MainWindow)
self.actionExit.setObjectName("actionExit")
self.actionStop = QtGui.QAction(MainWindow)
self.actionStop.setObjectName("actionStop")
self.actionRemove_handler = QtGui.QAction(MainWindow)
self.actionRemove_handler.setObjectName("actionRemove_handler")
self.actionAbout = QtGui.QAction(MainWindow)
self.actionAbout.setObjectName("actionAbout")
self.actionStd_output = QtGui.QAction(MainWindow)
self.actionStd_output.setCheckable(True)
self.actionStd_output.setObjectName("actionStd_output")
self.actionStd_error = QtGui.QAction(MainWindow)
self.actionStd_error.setCheckable(True)
self.actionStd_error.setObjectName("actionStd_error")
self.actionFile = QtGui.QAction(MainWindow)
self.actionFile.setCheckable(True)
self.actionFile.setObjectName("actionFile")
self.actionCircular_file = QtGui.QAction(MainWindow)
self.actionCircular_file.setCheckable(True)
self.actionCircular_file.setObjectName("actionCircular_file")
self.actionCyclic_file = QtGui.QAction(MainWindow)
self.actionCyclic_file.setCheckable(True)
self.actionCyclic_file.setObjectName("actionCyclic_file")
self.actionLog_server = QtGui.QAction(MainWindow)
self.actionLog_server.setCheckable(True)
self.actionLog_server.setObjectName("actionLog_server")
self.actionLog_widget = QtGui.QAction(MainWindow)
self.actionLog_widget.setChecked(False)
self.actionLog_widget.setObjectName("actionLog_widget")
self.actionError_widget = QtGui.QAction(MainWindow)
self.actionError_widget.setChecked(False)
self.actionError_widget.setObjectName("actionError_widget")
self.actionOutput_widget = QtGui.QAction(MainWindow)
self.actionOutput_widget.setObjectName("actionOutput_widget")
self.actionStd_output_v = QtGui.QAction(MainWindow)
self.actionStd_output_v.setCheckable(True)
self.actionStd_output_v.setChecked(True)
self.actionStd_output_v.setObjectName("actionStd_output_v")
self.actionStd_error_v = QtGui.QAction(MainWindow)
self.actionStd_error_v.setCheckable(True)
self.actionStd_error_v.setChecked(True)
self.actionStd_error_v.setObjectName("actionStd_error_v")
self.actionLogging_v = QtGui.QAction(MainWindow)
self.actionLogging_v.setCheckable(True)
self.actionLogging_v.setChecked(True)
self.actionLogging_v.setObjectName("actionLogging_v")
self.actionStdOutput = QtGui.QAction(MainWindow)
self.actionStdOutput.setCheckable(True)
self.actionStdOutput.setObjectName("actionStdOutput")
self.actionStdError = QtGui.QAction(MainWindow)
self.actionStdError.setCheckable(True)
self.actionStdError.setObjectName("actionStdError")
self.actionDebug = QtGui.QAction(MainWindow)
self.actionDebug.setObjectName("actionDebug")
self.actionInfo = QtGui.QAction(MainWindow)
self.actionInfo.setObjectName("actionInfo")
self.actionWarning = QtGui.QAction(MainWindow)
self.actionWarning.setObjectName("actionWarning")
self.actionError = QtGui.QAction(MainWindow)
self.actionError.setObjectName("actionError")
self.actionFault = QtGui.QAction(MainWindow)
self.actionFault.setObjectName("actionFault")
self.actionCustom = QtGui.QAction(MainWindow)
self.actionCustom.setObjectName("actionCustom")
self.actionLog_log = QtGui.QAction(MainWindow)
self.actionLog_log.setCheckable(True)
self.actionLog_log.setObjectName("actionLog_log")
self.actionTrace = QtGui.QAction(MainWindow)
self.actionTrace.setObjectName("actionTrace")
self.actionFile_v = QtGui.QAction(MainWindow)
self.actionFile_v.setCheckable(True)
self.actionFile_v.setObjectName("actionFile_v")
self.actionStart_server = QtGui.QAction(MainWindow)
self.actionStart_server.setCheckable(True)
self.actionStart_server.setObjectName("actionStart_server")
self.menuTask.addAction(self.actionStart_server)
self.menuTask.addSeparator()
self.menuTask.addAction(self.actionExit)
self.menuTask.addSeparator()
self.menuAdd_handler.addAction(self.actionLog_log)
self.menuAdd_handler.addAction(self.actionStdOutput)
self.menuAdd_handler.addAction(self.actionStdError)
self.menuAdd_handler.addSeparator()
self.menuAdd_handler.addAction(self.actionFile)
self.menuAdd_handler.addAction(self.actionCircular_file)
self.menuAdd_handler.addAction(self.actionCyclic_file)
self.menuAdd_handler.addSeparator()
self.menuAdd_handler.addAction(self.actionLog_server)
self.menuStart_log_msg.addAction(self.actionTrace)
self.menuStart_log_msg.addAction(self.actionDebug)
self.menuStart_log_msg.addAction(self.actionInfo)
self.menuStart_log_msg.addAction(self.actionWarning)
self.menuStart_log_msg.addAction(self.actionError)
self.menuStart_log_msg.addAction(self.actionFault)
self.menuStart_log_msg.addAction(self.actionCustom)
self.menuLogging.addAction(self.menuAdd_handler.menuAction())
self.menuLogging.addSeparator()
self.menuLogging.addAction(self.menuStart_log_msg.menuAction())
self.menuLogging.addAction(self.actionStop)
self.menuHelp.addAction(self.actionAbout)
self.menuView.addAction(self.actionStd_output_v)
self.menuView.addAction(self.actionStd_error_v)
self.menuView.addAction(self.actionLogging_v)
self.menuView.addAction(self.actionFile_v)
self.menubar.addAction(self.menuTask.menuAction())
self.menubar.addAction(self.menuLogging.menuAction())
self.menubar.addAction(self.menuView.menuAction())
self.menubar.addAction(self.menuHelp.menuAction())
self.retranslateUi(MainWindow)
QtCore.QObject.connect(self.actionExit,QtCore.SIGNAL("triggered()"),
MainWindow.close)
QtCore.QObject.connect(self.actionStd_error_v,QtCore.SIGNAL
("toggled(bool)"),self.dockWidget_err.setVisible)
QtCore.QObject.connect(self.actionStd_output_v,QtCore.SIGNAL
("toggled(bool)"),self.dockWidget_out.setVisible)
QtCore.QObject.connect(self.actionLogging_v,QtCore.SIGNAL
("toggled(bool)"),self.dockWidget_log.setVisible)
QtCore.QObject.connect(self.dockWidget_err,QtCore.SIGNAL
("visibilityChanged(bool)"),self.actionStd_error_v.setChecked)
QtCore.QObject.connect(self.dockWidget_log,QtCore.SIGNAL
("visibilityChanged(bool)"),self.actionLogging_v.setChecked)
QtCore.QObject.connect(self.dockWidget_out,QtCore.SIGNAL
("visibilityChanged(bool)"),self.actionStd_output_v.setChecked)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow",
"TW-logging system", None, QtGui.QApplication.UnicodeUTF8))
self.dockWidget_log.setWindowTitle(QtGui.QApplication.translate("MainWindow",
"Log", None, QtGui.QApplication.UnicodeUTF8))
self.dockWidget_out.setWindowTitle(QtGui.QApplication.translate("MainWindow",
"Output", None, QtGui.QApplication.UnicodeUTF8))
self.dockWidget_err.setWindowTitle(QtGui.QApplication.translate("MainWindow",
"Error", None, QtGui.QApplication.UnicodeUTF8))
self.menuTask.setTitle(QtGui.QApplication.translate("MainWindow",
"Task", None, QtGui.QApplication.UnicodeUTF8))
self.menuLogging.setTitle(QtGui.QApplication.translate("MainWindow",
"Logging", None, QtGui.QApplication.UnicodeUTF8))
self.menuAdd_handler.setTitle(QtGui.QApplication.translate("MainWindow",
"Add/remove handler", None, QtGui.QApplication.UnicodeUTF8))
self.menuStart_log_msg.setTitle(QtGui.QApplication.translate("MainWindow",
"Start periodic log msg", None, QtGui.QApplication.UnicodeUTF8))
self.menuHelp.setTitle(QtGui.QApplication.translate("MainWindow",
"Help", None, QtGui.QApplication.UnicodeUTF8))
self.menuView.setTitle(QtGui.QApplication.translate("MainWindow",
"View", None, QtGui.QApplication.UnicodeUTF8))
self.actionExit.setText(QtGui.QApplication.translate("MainWindow",
"Exit", None, QtGui.QApplication.UnicodeUTF8))
self.actionStop.setText(QtGui.QApplication.translate("MainWindow",
"Stop all periodic log msg", None, QtGui.QApplication.UnicodeUTF8))
self.actionRemove_handler.setText(QtGui.QApplication.translate("MainWindow",
"Remove handler", None, QtGui.QApplication.UnicodeUTF8))
self.actionAbout.setText(QtGui.QApplication.translate("MainWindow",
"About", None, QtGui.QApplication.UnicodeUTF8))
self.actionStd_output.setText(QtGui.QApplication.translate("MainWindow",
"std output", None, QtGui.QApplication.UnicodeUTF8))
self.actionStd_error.setText(QtGui.QApplication.translate("MainWindow",
"std error", None, QtGui.QApplication.UnicodeUTF8))
self.actionFile.setText(QtGui.QApplication.translate("MainWindow",
"file", None, QtGui.QApplication.UnicodeUTF8))
self.actionCircular_file.setText(QtGui.QApplication.translate("MainWindow",
"circular file", None, QtGui.QApplication.UnicodeUTF8))
self.actionCyclic_file.setText(QtGui.QApplication.translate("MainWindow",
"cyclic file", None, QtGui.QApplication.UnicodeUTF8))
self.actionLog_server.setText(QtGui.QApplication.translate("MainWindow",
"log server", None, QtGui.QApplication.UnicodeUTF8))
self.actionLog_widget.setText(QtGui.QApplication.translate("MainWindow",
"log widget", None, QtGui.QApplication.UnicodeUTF8))
self.actionError_widget.setText(QtGui.QApplication.translate("MainWindow",
"error widget", None, QtGui.QApplication.UnicodeUTF8))
self.actionOutput_widget.setText(QtGui.QApplication.translate("MainWindow",
"output widget", None, QtGui.QApplication.UnicodeUTF8))
self.actionStd_output_v.setText(QtGui.QApplication.translate("MainWindow",
"std output", None, QtGui.QApplication.UnicodeUTF8))
self.actionStd_error_v.setText(QtGui.QApplication.translate("MainWindow",
"std error", None, QtGui.QApplication.UnicodeUTF8))
self.actionLogging_v.setText(QtGui.QApplication.translate("MainWindow",
"logging", None, QtGui.QApplication.UnicodeUTF8))
self.actionStdOutput.setText(QtGui.QApplication.translate("MainWindow",
"stdOutput", None, QtGui.QApplication.UnicodeUTF8))
self.actionStdError.setText(QtGui.QApplication.translate("MainWindow",
"stdError", None, QtGui.QApplication.UnicodeUTF8))
self.actionDebug.setText(QtGui.QApplication.translate("MainWindow",
"debug", None, QtGui.QApplication.UnicodeUTF8))
self.actionInfo.setText(QtGui.QApplication.translate("MainWindow",
"info", None, QtGui.QApplication.UnicodeUTF8))
self.actionWarning.setText(QtGui.QApplication.translate("MainWindow",
"warning", None, QtGui.QApplication.UnicodeUTF8))
self.actionError.setText(QtGui.QApplication.translate("MainWindow",
"error", None, QtGui.QApplication.UnicodeUTF8))
self.actionFault.setText(QtGui.QApplication.translate("MainWindow",
"critical", None, QtGui.QApplication.UnicodeUTF8))
self.actionCustom.setText(QtGui.QApplication.translate("MainWindow",
"custom", None, QtGui.QApplication.UnicodeUTF8))
self.actionLog_log.setText(QtGui.QApplication.translate("MainWindow",
"log window", None, QtGui.QApplication.UnicodeUTF8))
self.actionTrace.setText(QtGui.QApplication.translate("MainWindow",
"trace", None, QtGui.QApplication.UnicodeUTF8))
self.actionFile_v.setText(QtGui.QApplication.translate("MainWindow",
"file", None, QtGui.QApplication.UnicodeUTF8))
self.actionStart_server.setText(QtGui.QApplication.translate("MainWindow",
"Start server", None, QtGui.QApplication.UnicodeUTF8))
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080326/e7be1ad1/attachment-0001.html
More information about the PyQt
mailing list