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()
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()
...全文
相关推荐
完美解决PyQt5登录界面跳转主界面方法
在PyQt5编程中,构建一个应用程序通常涉及创建多个窗口或界面,比如登录界面和主界面。本问题中,我们探讨的是如何在用户成功登录后从登录界面平滑地过渡到主界面。
Python-Pyqt6主窗口调用子窗口并互相传递参数
Pyqt6设计,在主窗口点击按钮,调出子窗口,并向子窗口传递参数;在子窗口输入数据后再向主窗口传递参数,并在主窗口显示输入的数据。
PyQt5主窗口动态加载Widget实例代码
PyQt是一个创建GUI应用程序的工具包。它是Python编程语言和Qt库的成功融合。Qt库是目前最强大的库之一。PyQt是由Phil Thompson 开发。 我们通过Qt Designer设计两个窗口,命名为主窗口(MainForm)和子窗口(ChildrenForm)。我们在主窗口的空白中央添加一个栅格布局并命名为MaingridLayout,等会需要将ChildrenForm放进去。 编写...
Python 中PyQt5 点击主窗口弹出另一个窗口的实现方法
### Python 中PyQt5点击主窗口弹出另一个窗口的实现方法#### 一、概述在使用Python结合PyQt5进行GUI开发时,经常会遇到需要从一个窗口跳转到另一个窗口的需求,例如从主界面点击按钮后弹出一个新的对话框或窗口
PyQt5实现从主窗口打开子窗口的方法
首先,我们需要理解PyQt5的基本架构。PyQt5是Python的一个模块,它为Qt应用程序提供了一个接口。Qt是一个跨平台的应用程序开发框架,广泛用于创建图形用户界面(GUI)。


