Note that there are some explanatory texts on larger screens.

plurals
  1. POQWidget: Must construct a QApplication before a QPaintDevice in Python script
    primarykey
    data
    text
    <p>I want to invoke the form below ("First Script") from another script ("the Second Script"), and I want the Second script to populate the label field (presumably using the Qlabel's setText property) with new information. </p> <p>The following 7 lines in the Second Script first produce the original window w/o the label updated; but after I close the non-updated window, a new window appears with the label updated. I don't know why the non-updated window appears first.</p> <pre><code>import Form2use4ques4stackoverflow_2013_02_23_am_09_33_45_ app = QApplication(sys.argv) nuform = Form2use4ques4stackoverflow_2013_02_23_am_09_33_45_.Form() nuform.prefix_label.setText('newtext') nuform.show() #return app.exec_() app.exec_() Marc # -*- coding: latin-1 -*- """ Form2use4ques4stackoverflow_2013_02_23_am_09_33_45_.py """ import sys from PyQt4 import QtCore from PyQt4 import QtGui from PyQt4.QtCore import (Qt, SIGNAL) from PyQt4.QtGui import (QApplication, QDialog, QHBoxLayout, QLabel, QPushButton) class Form(QDialog): def __init__(self, parent=None): super(Form, self).__init__(parent) self.initUI() def initUI(self): okButton01 = QtGui.QPushButton("OK") cancelButton01 = QtGui.QPushButton("Cancel") prefix_label = QtGui.QLabel('Prefix') self. prefix_label = prefix_label hbox_prefix_digit_iterations = QtGui.QHBoxLayout() hbox_prefix_digit_iterations.addWidget(prefix_label) hbox_btnsOK_cancel = QtGui.QHBoxLayout() hbox_btnsOK_cancel.addStretch(1) hbox_btnsOK_cancel.addWidget(okButton01) hbox_btnsOK_cancel.addWidget(cancelButton01) vbox0 = QtGui.QVBoxLayout() vbox0.addLayout(hbox_prefix_digit_iterations) vbox0.addStretch(1) vbox0.addLayout(hbox_btnsOK_cancel) self.setLayout(vbox0) self.setGeometry(300, 300, 600, 300) #class PySide.QtCore.QRectF(left, top, width, height) http://srinikom.github.com/pyside-docs/PySide/QtCore/QRectF.html#PySide.QtCore.QRectF self.setWindowTitle('Duplicate Code Strings W/Increasing Numbers') self.show() def formm(): app = QApplication(sys.argv) form = Form() form.show() app.exec_() if 1 == 1: formm() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload