我为我的插件创建了一个带有3个按钮的启动GUI.这非常有效,如果我单击其中一个按钮,则会启动特定操作.到目前为止这个工作.如果我点击其中一个按钮,新的GUI有两个按钮"ok"和"cancel",并出现一条lineedit.如果我按下取消,GUI将被关闭,如果我按下ok,我希望程序从editline读取文本并将其存储在变量中.到目前为止,这还没有奏效.
这是包含对话框的类:
from PyQt4.QtCore import pyqtSlot
from PyQt4.QtGui import QDialog, QLineEdit
from ui_grz import Ui_Dialog
class grzDialog(QDialog):
def __init__(self):
QDialog.__init__(self)
# Set up the user interface from Designer.
self.ui = Ui_Dialog()
self.ui.setupUi(self)
Run Code Online (Sandbox Code Playgroud)
在使用QT Designer和命令pyuic4创建GUI之后,这是一个包含GUI结构的类:
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName(_fromUtf8("Dialog"))
Dialog.resize(387, 153)
self.buttonBox = QtGui.QDialogButtonBox(Dialog)
self.buttonBox.setGeometry(QtCore.QRect(30, 110, 341, 32))
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
self.label = QtGui.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(10, 10, 361, 51))
self.label.setObjectName(_fromUtf8("label"))
self.lineEdit = QtGui.QLineEdit(Dialog)
self.lineEdit.setGeometry(QtCore.QRect(10, …Run Code Online (Sandbox Code Playgroud)