# Form implementation generated from reading ui file 'text.ui'
#
# Created: Wed Dec 24 02:58:37 2008
# by: PyQt4 UI code generator 4.4.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.btn_save = QtGui.QPushButton(self.centralwidget)
self.btn_save.setGeometry(QtCore.QRect(250, 80, 75, 23))
self.btn_save.setObjectName("btn_save")
self.txt_info = QtGui.QTextEdit(self.centralwidget)
self.txt_info.setGeometry(QtCore.QRect(70, 60, 101, 41))
self.txt_info.setObjectName("txt_info")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 20))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
self.btn_save.setText(QtGui.QApplication.translate("MainWindow", "确定", None, QtGui.QApplication.UnicodeUTF8))
#End
7 个解决方案
#1
补充一下,就是怎么才能看见我的Windows窗体?
#2
在#End后面贴上
def main(args):
app = QApplication(args)
win = Ui_MainWindow()
win.show()
app.exec_loop()
if __name__ == "__main__":
main(sys.argv)
#3
谢谢了,但是我还是弄不出来啊。。我是才学的。看看错误再给我改改行吗??
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'text.ui'
#
# Created: Wed Dec 24 02:58:37 2008
# by: PyQt4 UI code generator 4.4.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.btn_save = QtGui.QPushButton(self.centralwidget)
self.btn_save.setGeometry(QtCore.QRect(250, 80, 75, 23))
self.btn_save.setObjectName("btn_save")
self.txt_info = QtGui.QTextEdit(self.centralwidget)
self.txt_info.setGeometry(QtCore.QRect(70, 60, 101, 41))
self.txt_info.setObjectName("txt_info")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 20))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
self.btn_save.setText(QtGui.QApplication.translate("MainWindow", "确定", None, QtGui.QApplication.UnicodeUTF8))
#End
def main(args):
app = QtGui.QApplication(args)
win = Ui_MainWindow()
win.show()
app.exec_loop()
if __name__ == "__main__":
main(sys.argv)
运行后————>
IDLE 1.2 ==== No Subprocess ====
>>>
Traceback (most recent call last):
File "D:\Program\Python25\Lib\site-packages\PyQt4\te.py", line 12, in <module>
class Ui_MainWindow(object):
File "D:\Program\Python25\Lib\site-packages\PyQt4\te.py", line 46, in Ui_MainWindow
main(sys.argv)
File "D:\Program\Python25\Lib\site-packages\PyQt4\te.py", line 43, in main
win.show()
AttributeError: 'Ui_MainWindow' object has no attribute 'show'
>>>
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'text.ui'
#
# Created: Wed Dec 24 02:58:37 2008
# by: PyQt4 UI code generator 4.4.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.btn_save = QtGui.QPushButton(self.centralwidget)
self.btn_save.setGeometry(QtCore.QRect(250, 80, 75, 23))
self.btn_save.setObjectName("btn_save")
self.txt_info = QtGui.QTextEdit(self.centralwidget)
self.txt_info.setGeometry(QtCore.QRect(70, 60, 101, 41))
self.txt_info.setObjectName("txt_info")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 20))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
self.btn_save.setText(QtGui.QApplication.translate("MainWindow", "确定", None, QtGui.QApplication.UnicodeUTF8))
#End
def main(args):
app = QtGui.QApplication(args)
win = Ui_MainWindow()
win.show()
app.exec_loop()
if __name__ == "__main__":
main(sys.argv)
运行后————>
IDLE 1.2 ==== No Subprocess ====
>>>
Traceback (most recent call last):
File "D:\Program\Python25\Lib\site-packages\PyQt4\te.py", line 12, in <module>
class Ui_MainWindow(object):
File "D:\Program\Python25\Lib\site-packages\PyQt4\te.py", line 46, in Ui_MainWindow
main(sys.argv)
File "D:\Program\Python25\Lib\site-packages\PyQt4\te.py", line 43, in main
win.show()
AttributeError: 'Ui_MainWindow' object has no attribute 'show'
>>>
#4
不会qt,不过按lz的设计应该先得到一个窗口当参数后呼叫setupUi,而2楼给的方式嘛,你的类要改写得要继承某个qt类,并定义__init__函数,不然是跑不起来的。觉得初学直接用rad工具算了,然后学习自动生成的代码...
#5
对啊,我当时就想问的,最后忘了,你的代码不全吧?连构造函数都没有?你是PyQT的新手还是Python的新手?
#6
我是python新手。不过我想整点好看的界面的应用程序。没办法了。。只有发帖子求救了。。
#7
顺便说一下 class Ui_MainWindow(object): 中(object)是什么啊???
#1
补充一下,就是怎么才能看见我的Windows窗体?
#2
在#End后面贴上
def main(args):
app = QApplication(args)
win = Ui_MainWindow()
win.show()
app.exec_loop()
if __name__ == "__main__":
main(sys.argv)
#3
谢谢了,但是我还是弄不出来啊。。我是才学的。看看错误再给我改改行吗??
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'text.ui'
#
# Created: Wed Dec 24 02:58:37 2008
# by: PyQt4 UI code generator 4.4.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.btn_save = QtGui.QPushButton(self.centralwidget)
self.btn_save.setGeometry(QtCore.QRect(250, 80, 75, 23))
self.btn_save.setObjectName("btn_save")
self.txt_info = QtGui.QTextEdit(self.centralwidget)
self.txt_info.setGeometry(QtCore.QRect(70, 60, 101, 41))
self.txt_info.setObjectName("txt_info")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 20))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
self.btn_save.setText(QtGui.QApplication.translate("MainWindow", "确定", None, QtGui.QApplication.UnicodeUTF8))
#End
def main(args):
app = QtGui.QApplication(args)
win = Ui_MainWindow()
win.show()
app.exec_loop()
if __name__ == "__main__":
main(sys.argv)
运行后————>
IDLE 1.2 ==== No Subprocess ====
>>>
Traceback (most recent call last):
File "D:\Program\Python25\Lib\site-packages\PyQt4\te.py", line 12, in <module>
class Ui_MainWindow(object):
File "D:\Program\Python25\Lib\site-packages\PyQt4\te.py", line 46, in Ui_MainWindow
main(sys.argv)
File "D:\Program\Python25\Lib\site-packages\PyQt4\te.py", line 43, in main
win.show()
AttributeError: 'Ui_MainWindow' object has no attribute 'show'
>>>
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'text.ui'
#
# Created: Wed Dec 24 02:58:37 2008
# by: PyQt4 UI code generator 4.4.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.btn_save = QtGui.QPushButton(self.centralwidget)
self.btn_save.setGeometry(QtCore.QRect(250, 80, 75, 23))
self.btn_save.setObjectName("btn_save")
self.txt_info = QtGui.QTextEdit(self.centralwidget)
self.txt_info.setGeometry(QtCore.QRect(70, 60, 101, 41))
self.txt_info.setObjectName("txt_info")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 20))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
self.btn_save.setText(QtGui.QApplication.translate("MainWindow", "确定", None, QtGui.QApplication.UnicodeUTF8))
#End
def main(args):
app = QtGui.QApplication(args)
win = Ui_MainWindow()
win.show()
app.exec_loop()
if __name__ == "__main__":
main(sys.argv)
运行后————>
IDLE 1.2 ==== No Subprocess ====
>>>
Traceback (most recent call last):
File "D:\Program\Python25\Lib\site-packages\PyQt4\te.py", line 12, in <module>
class Ui_MainWindow(object):
File "D:\Program\Python25\Lib\site-packages\PyQt4\te.py", line 46, in Ui_MainWindow
main(sys.argv)
File "D:\Program\Python25\Lib\site-packages\PyQt4\te.py", line 43, in main
win.show()
AttributeError: 'Ui_MainWindow' object has no attribute 'show'
>>>
#4
不会qt,不过按lz的设计应该先得到一个窗口当参数后呼叫setupUi,而2楼给的方式嘛,你的类要改写得要继承某个qt类,并定义__init__函数,不然是跑不起来的。觉得初学直接用rad工具算了,然后学习自动生成的代码...
#5
对啊,我当时就想问的,最后忘了,你的代码不全吧?连构造函数都没有?你是PyQT的新手还是Python的新手?
#6
我是python新手。不过我想整点好看的界面的应用程序。没办法了。。只有发帖子求救了。。
#7
顺便说一下 class Ui_MainWindow(object): 中(object)是什么啊???