python-pyqt4的主窗口界面程序显示问题,谢谢各位了
系统运行没有报错,我仿照的程序我看各个环节都有,但是运行之后就是不显示窗口,主函数也有。程序如下,请各位指点迷津谢谢了
from PyQt4.Qt import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import time
import OpenOPC
import sys
from PyQt4 import QtGui
from PyQt4 import QtCore
class Test(QtGui.QMainWindow):
def __init__(self):
super(Test, self).__init__()
self.UI()
self.opc = OpenOPC.client()
self.opc.connect('matrikon.opc.simulation.1')
def UI(self):
self.but1= QPushButton('start')
self.but2=QPushButton('settings')
self.but3=QPushButton('close')
self.but1.clicked.connect(self.set)
self.but2.clicked.connect(self.read)
self.but3.clicked(exit())
self.setGeometry(500,500,250,250)
self.but1.move(100,100)
self.but2.move(200,100)
self.but3.move(300,100)
self.setWindowTitle('opc mainwindow')
self.show()
def set(self):
self.setGeometry(500,500,250,250)
self.setWindowTitle('settings')
self.but4=QPushButton('frequency')
self.but5=QPushButton('addition')
self.frequency.clicked.connect(self.showdialog)
self.line1 = QtGui.QLineEdit(self)
self.addition.clicked(self.add)
self.but6=QPushButton('read')
self.but6.clicked(self.read)
def showdialog(self):
text, ok = QtGui.QInputDialog.getText(self, 'Input Dialog', 'Enter the frenquency:')
if ok:
self.line1.setText(str(text))
def add(self):#show the opc list
self.line2 = QtGui.QLineEdit(self)
self.line2.move(100,100)
self.line2=self.opc.list()
self.line3=QtGui.QLineEdit(self)
self.line3.move(200,100)
self.but5=QPushButton('add')
self.but5.clicked(self.show)
def show(self):
text, ok = QtGui.QInputDialog.getText(self, 'Input Dialog', 'Enter the type you want')
if ok:
self.line3.setText(str(text))
def read(self):
while True:
self.opc.time.sleep(self.line1)
self.opc.read('self.line3')
def main():
app = QtGui.QApplication(sys.argv)
ex = Test()
sys.exit(app.exec_())
if __name__ == '__main__':
main()