iT邦幫忙

0

PYQT5的開啟另一視窗問題

  • 分享至 

  • xImage

這是介面的語法
mission.py

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(514, 525)
       
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit.setGeometry(QtCore.QRect(30, 50, 161, 20))
        self.lineEdit.setObjectName("lineEdit")
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(310, 50, 75, 23))
        self.pushButton.setObjectName("pushButton")
        ....

這是功能語法

from mission import Ui_MainWindow
class MainWindow_controller(QtWidgets.QMainWindow):  
    # global positionx,positiony,status

    # global counttrip
    def __init__(self):
        super().__init__() # in python3, super(Class, self).xxx = super().xxx
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.setup_control()
        
       
        

    def setup_control(self):
        # TODO
        # qpushbutton doc: https://doc.qt.io/qt-5/qpushbutton.html

        self.ui.pushButton.clicked.connect(self.buttonClicked) #push button to start  buttonCliked function             
        self.ui.pushButton.clicked.connect(self.startThread)   #push button to start startThread  function        
        self.ui.pushButton_2.clicked.connect(self.buttonClicked_2) 
        ....

這是我想插入的視窗跟語法

lass Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(262, 335)
        self.tableWidget = QtWidgets.QTableWidget(Form)
        self.tableWidget.setGeometry(QtCore.QRect(20, 30, 221, 241))
        self.tableWidget.setObjectName("tableWidget")
        self.tableWidget.setColumnCount(2)
        self.tableWidget.setRowCount(7)
        item = QtWidgets.QTableWidgetItem()
        self.tableWidget.setVerticalHeaderItem(0, item)
        item = QtWidgets.QTableWidgetItem()
        self.tableWidget.setVerticalHeaderItem(1, item)
        item = QtWidgets.QTableWidgetItem()
        self.tableWidget.setVerticalHeaderItem(2, item)
        item = QtWidgets.QTableWidgetItem()
        self.tableWidget.setVerticalHeaderItem(3, item)
        item = QtWidgets.QTableWidgetItem()
        self.tableWidget.setVerticalHeaderItem(4, item)
        item = QtWidgets.QTableWidgetItem()
        self.tableWidget.setVerticalHeaderItem(5, item)
        item = QtWidgets.QTableWidgetItem()
        self.tableWidget.setVerticalHeaderItem(6, item)
        item = QtWidgets.QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(0, item)
        item = QtWidgets.QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(1, item)
        item = QtWidgets.QTableWidgetItem()
        self.tableWidget.setItem(0, 0, item)
        item = QtWidgets.QTableWidgetItem()
        self.tableWidget.setItem(0, 1, item)
        item = QtWidgets.QTableWidgetItem()
        ....

想請問大大一些解答或是提供網站資訊 我再看看學習!!

第一個是我的介面語法
第二個是我介面的功能語法

第三個是我想在原本介面內按下按鈕開啟的視窗
我有點搞混...我應該把連結設在哪兩者才比較正確呢!?

謝謝!!

froce iT邦大師 1 級 ‧ 2022-11-24 08:35:05 檢舉
不是ui加個按鈕,然後功能那邊做connect,讓form去做show()就行了?
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答