久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      1. <i id='nU7tW'><tr id='nU7tW'><dt id='nU7tW'><q id='nU7tW'><span id='nU7tW'><b id='nU7tW'><form id='nU7tW'><ins id='nU7tW'></ins><ul id='nU7tW'></ul><sub id='nU7tW'></sub></form><legend id='nU7tW'></legend><bdo id='nU7tW'><pre id='nU7tW'><center id='nU7tW'></center></pre></bdo></b><th id='nU7tW'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='nU7tW'><tfoot id='nU7tW'></tfoot><dl id='nU7tW'><fieldset id='nU7tW'></fieldset></dl></div>

          <bdo id='nU7tW'></bdo><ul id='nU7tW'></ul>
        <legend id='nU7tW'><style id='nU7tW'><dir id='nU7tW'><q id='nU7tW'></q></dir></style></legend>
      2. <tfoot id='nU7tW'></tfoot>

        <small id='nU7tW'></small><noframes id='nU7tW'>

        從不同文件中的其他類更改標簽

        change label from other class in a different file(從不同文件中的其他類更改標簽)
        • <small id='FKVL5'></small><noframes id='FKVL5'>

          <legend id='FKVL5'><style id='FKVL5'><dir id='FKVL5'><q id='FKVL5'></q></dir></style></legend>
            <tbody id='FKVL5'></tbody>
            1. <tfoot id='FKVL5'></tfoot>
              • <bdo id='FKVL5'></bdo><ul id='FKVL5'></ul>
                <i id='FKVL5'><tr id='FKVL5'><dt id='FKVL5'><q id='FKVL5'><span id='FKVL5'><b id='FKVL5'><form id='FKVL5'><ins id='FKVL5'></ins><ul id='FKVL5'></ul><sub id='FKVL5'></sub></form><legend id='FKVL5'></legend><bdo id='FKVL5'><pre id='FKVL5'><center id='FKVL5'></center></pre></bdo></b><th id='FKVL5'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='FKVL5'><tfoot id='FKVL5'></tfoot><dl id='FKVL5'><fieldset id='FKVL5'></fieldset></dl></div>

                  本文介紹了從不同文件中的其他類更改標簽的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在創建一個應用程序,其中有一個帶有標簽的主窗口,然后是另一個文件中的停靠小部件.我想從停靠小部件上的按鈕更改主窗口標簽.我嘗試導入主窗口文件,但無法訪問標簽.而且我還嘗試在主窗口中調用一個函數來更改標簽,但標簽不會改變.代碼如下:

                  I am creating an application where I have a main window whit a label and then a docked widget that is in another file. I want to change the main windows label from a button at the docked widget. I try to import the main window file but then I can not access to the label. And I also tried to call a function in the main windows that changes the label but then the label does not change. Here is the code:

                  main_window.py:

                  main_window.py:

                  import results_window
                  
                  class MainWindow(QMainWindow):
                  
                      def __init__(self):
                          super(MainWindow, self).__init__()
                  
                          self.define_main_windows()
                  
                          self.create_dock_widgets()
                  
                      def define_main_windows(self):
                          # Define de Main window properties
                          self.setMinimumSize(QSize(300, 100))    
                          self.setWindowTitle("Python SkyLibris") 
                          self.setWindowIcon(QtGui.QIcon("skylibris_icon.png"))
                          self.setStyleSheet("QMainWindow {background: 'white';}")
                  
                          self.top = 50
                          self.left = 0
                          self.width = 1300
                          self.height = 400
                          self.setGeometry(self.left, self.top, self.width, self.height)
                  
                          self.result = QLabel("result:")
                          self.setCentralWidget(self.result)
                  
                  
                      def create_dock_widgets(self):
                          # Create dock widgets
                          self.results_window = results_window.results_window()
                          self.resultsWindowDock = QDockWidget("Results Viewer", self)
                          self.resultsWindowDock.setWidget(self.results_window )
                          self.resultsWindowDock.setFloating(False)
                          self.resultsWindowDock.setVisible(True)
                          self.addDockWidget(Qt.LeftDockWidgetArea, self.resultsWindowDock)
                  
                  if __name__ == "__main__":
                      app = QtWidgets.QApplication(sys.argv)
                      app.setStyle('Fusion')
                      mainWin = MainWindow()
                      mainWin.show()
                      sys.exit(app.exec_())
                  

                  results_window.py:

                  results_window.py:

                  import main_window
                  
                  class results_window(QWidget):
                  
                      def __init__(self):
                          super(results_window, self).__init__()
                          print("init")
                  
                          self.label = QLabel()
                          self.value = QLineEdit()
                  
                          self.bt = QPushButton("Click")
                          self.bt.clicked.connect(self.clickMethod)
                  
                  
                          self.main_layout = QVBoxLayout()
                          self.main_layout.addWidget(self.label)
                          self.main_layout.addWidget(self.value)
                          self.main_layout.addWidget(self.bt)
                  
                          self.setLayout(self.main_layout)
                  
                      def clickMethod(self):
                          print(self.value.text())
                          text = self.value.text()
                          main_window.result.setText(text)
                  

                  推薦答案

                  你使用了錯誤的工具,例如你的代碼有一個循環導入導致你的應用程序關閉,因為它相當于一個 while True.

                  You are using the wrong tools, for example your code has a circular import that causes your application to close since it is equivalent to a while True.

                  在 Qt 中,信號和槽用于異步共享數據,并有助于實現類之間不存在耦合的事實.在您的情況下,Results_Window 必須具有將該信息傳輸到 MainWindow 的信號,該信號必須在 clickMethod 內發出.

                  In Qt, signals and slots are used to share data asynchronously, as well as contributing to the fact that there is no coupling between classes. In your case, Results_Window must have a signal that transmits that information to the MainWindow, this signal must be emit within clickMethod.

                  results_window.py

                  from PyQt5 import QtCore, QtWidgets
                  
                  class Results_Window(QtWidgets.QWidget):
                      resultChanged = QtCore.pyqtSignal(str)
                  
                      def __init__(self):
                          super(Results_Window, self).__init__()
                          print("init")
                  
                          self.label = QtWidgets.QLabel()
                          self.value = QtWidgets.QLineEdit()
                  
                          self.bt = QtWidgets.QPushButton("Click")
                          self.bt.clicked.connect(self.clickMethod)
                  
                          main_layout = QtWidgets.QVBoxLayout(self)
                          main_layout.addWidget(self.label)
                          main_layout.addWidget(self.value)
                          main_layout.addWidget(self.bt)
                  
                      @QtCore.pyqtSlot()
                      def clickMethod(self):
                          text = self.value.text()
                          self.resultChanged.emit(text)
                  
                  if __name__ == "__main__":
                      import sys
                      app = QtWidgets.QApplication(sys.argv)
                      app.setStyle('Fusion')
                      w = Results_Window()
                      w.show()
                      sys.exit(app.exec_())
                  

                  ma??in_window.py

                  from PyQt5 import QtCore, QtGui, QtWidgets
                  import results_window
                  
                  class MainWindow(QtWidgets.QMainWindow):
                      def __init__(self):
                          super(MainWindow, self).__init__()
                          self.define_main_windows()
                          self.create_dock_widgets()
                  
                      def define_main_windows(self):
                          self.setMinimumSize(QtCore.QSize(300, 100))    
                          self.setWindowTitle("Python SkyLibris") 
                          self.setWindowIcon(QtGui.QIcon("skylibris_icon.png"))
                          self.setStyleSheet("QMainWindow {background: 'white';}")
                          top, left, width, height = 50, 0, 1300, 400
                          self.setGeometry(left, top, width, height)
                          self.result = QtWidgets.QLabel("result:")
                          self.setCentralWidget(self.result)
                  
                      def create_dock_widgets(self):
                          self.results_window = results_window.Results_Window()
                          self.results_window.resultChanged.connect(self.result.setText)
                          self.resultsWindowDock = QtWidgets.QDockWidget("Results Viewer", self)
                          self.resultsWindowDock.setWidget(self.results_window )
                          self.resultsWindowDock.setFloating(False)
                          self.resultsWindowDock.setVisible(True)
                          self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.resultsWindowDock)
                  
                  if __name__ == "__main__":
                      import sys
                      app = QtWidgets.QApplication(sys.argv)
                      app.setStyle('Fusion')
                      mainWin = MainWindow()
                      mainWin.show()
                      sys.exit(app.exec_())
                  

                  這篇關于從不同文件中的其他類更改標簽的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動后進度躍升至 100%)
                  How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標簽設置在固定位置,以便當我向左或向右滾動時,yaxis 刻度標簽應該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構造函數有未知關鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)
                1. <small id='txv6U'></small><noframes id='txv6U'>

                        <tfoot id='txv6U'></tfoot>

                          <legend id='txv6U'><style id='txv6U'><dir id='txv6U'><q id='txv6U'></q></dir></style></legend>
                            <tbody id='txv6U'></tbody>

                            <bdo id='txv6U'></bdo><ul id='txv6U'></ul>
                            <i id='txv6U'><tr id='txv6U'><dt id='txv6U'><q id='txv6U'><span id='txv6U'><b id='txv6U'><form id='txv6U'><ins id='txv6U'></ins><ul id='txv6U'></ul><sub id='txv6U'></sub></form><legend id='txv6U'></legend><bdo id='txv6U'><pre id='txv6U'><center id='txv6U'></center></pre></bdo></b><th id='txv6U'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='txv6U'><tfoot id='txv6U'></tfoot><dl id='txv6U'><fieldset id='txv6U'></fieldset></dl></div>
                            主站蜘蛛池模板: 成人午夜视频在线观看 | 日韩国产一区二区三区 | 综合五月 | 国产成人精品亚洲男人的天堂 | 国产视频黄色 | 免费一级大片 | 91视频播放 | 国产一区二区三区免费视频 | 免费的毛片 | 亚洲精品成人 | 午夜理伦三级理论 | 一区二区三区国产 | 大乳女喂男人吃奶 | 国产精品婷婷 | 国产精品二区一区二区aⅴ污介绍 | 久久久国产视频 | 黄色午夜| 美女国产精品 | 日韩精品免费看 | 日韩欧美在线视频观看 | 成人av影视 | 一级特黄aaaaaa大片 | h片免费观看 | 欧美日韩在线一区二区 | 日韩免费高清 | 超碰在线人人 | 午夜免费视频 | 一级理论片| 亚洲精品久久久久久久久久久 | 亚洲精品一区二区三区精华液 | 成人在线视频免费观看 | 免费av播放 | 精品免费视频 | 国产日韩一区 | 亚洲午夜在线观看 | 天天色影院 | 精品视频在线播放 | 国产视频一区在线 | 国产一区二区三区精品视频 | 日韩在线不卡 | 日韩网站免费观看 |