久久久久久久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.com视频| av激情在线 | 97国产精品视频人人做人人爱 | 久久综合狠狠综合久久 | 一级aaaaaa毛片免费同男同女 | 欧美日韩中文在线 | av在线天堂网 | 日韩成人免费 | 国产视频中文字幕在线观看 | 久草在线青青草 | 一级毛片在线看 | 黄色大片免费网站 | 中文字幕综合在线 | 国产精品视频在线播放 | 一级片网址 | 99re国产视频 | 精品国产一区二区三区久久狼黑人 | 久久久久久色 | 国产精品免费一区二区三区四区 | 欧美日韩国产在线观看 | 国产精品色 | 日本偷偷操 | 久久国产精品一区二区三区 | 99久久婷婷国产综合精品电影 | 97精品超碰一区二区三区 | 日韩视频区 | 久久久精| 国产成人免费视频网站高清观看视频 | 免费看大片bbbb欧美 | 日韩精品一区二区三区老鸭窝 | 91精品www | 日韩电影中文字幕在线观看 | 国产真实乱全部视频 | 国产欧美三区 | 精品免费视频 | 欧美日产国产成人免费图片 | 国产精品1区2区3区 欧美 中文字幕 | 成人免费淫片aa视频免费 | 国产精品美女在线观看 |