change label from other class in a different file










1















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:



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:



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)









share|improve this question




























    1















    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:



    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:



    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)









    share|improve this question


























      1












      1








      1








      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:



      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:



      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)









      share|improve this question
















      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:



      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:



      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)






      python python-3.x pyqt pyqt5






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 '18 at 17:36









      eyllanesc

      80.9k103259




      80.9k103259










      asked Nov 12 '18 at 17:21









      filipefraqueirofilipefraqueiro

      82




      82






















          1 Answer
          1






          active

          oldest

          votes


















          0














          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.



          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_())


          main_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_())





          share|improve this answer























          • I understand that I was creating a circular import and that I had problems with that. I tried several things but none of them resulted. I never used QSignal and I didn't know that it was the answer to this problem. It worked, thank you very much @eyllanesc

            – filipefraqueiro
            Nov 12 '18 at 18:16












          • @filipefraqueiro One of the best things about Qt are the signals.

            – eyllanesc
            Nov 12 '18 at 18:17










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267112%2fchange-label-from-other-class-in-a-different-file%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          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.



          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_())


          main_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_())





          share|improve this answer























          • I understand that I was creating a circular import and that I had problems with that. I tried several things but none of them resulted. I never used QSignal and I didn't know that it was the answer to this problem. It worked, thank you very much @eyllanesc

            – filipefraqueiro
            Nov 12 '18 at 18:16












          • @filipefraqueiro One of the best things about Qt are the signals.

            – eyllanesc
            Nov 12 '18 at 18:17















          0














          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.



          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_())


          main_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_())





          share|improve this answer























          • I understand that I was creating a circular import and that I had problems with that. I tried several things but none of them resulted. I never used QSignal and I didn't know that it was the answer to this problem. It worked, thank you very much @eyllanesc

            – filipefraqueiro
            Nov 12 '18 at 18:16












          • @filipefraqueiro One of the best things about Qt are the signals.

            – eyllanesc
            Nov 12 '18 at 18:17













          0












          0








          0







          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.



          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_())


          main_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_())





          share|improve this answer













          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.



          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_())


          main_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_())






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 '18 at 17:35









          eyllanesceyllanesc

          80.9k103259




          80.9k103259












          • I understand that I was creating a circular import and that I had problems with that. I tried several things but none of them resulted. I never used QSignal and I didn't know that it was the answer to this problem. It worked, thank you very much @eyllanesc

            – filipefraqueiro
            Nov 12 '18 at 18:16












          • @filipefraqueiro One of the best things about Qt are the signals.

            – eyllanesc
            Nov 12 '18 at 18:17

















          • I understand that I was creating a circular import and that I had problems with that. I tried several things but none of them resulted. I never used QSignal and I didn't know that it was the answer to this problem. It worked, thank you very much @eyllanesc

            – filipefraqueiro
            Nov 12 '18 at 18:16












          • @filipefraqueiro One of the best things about Qt are the signals.

            – eyllanesc
            Nov 12 '18 at 18:17
















          I understand that I was creating a circular import and that I had problems with that. I tried several things but none of them resulted. I never used QSignal and I didn't know that it was the answer to this problem. It worked, thank you very much @eyllanesc

          – filipefraqueiro
          Nov 12 '18 at 18:16






          I understand that I was creating a circular import and that I had problems with that. I tried several things but none of them resulted. I never used QSignal and I didn't know that it was the answer to this problem. It worked, thank you very much @eyllanesc

          – filipefraqueiro
          Nov 12 '18 at 18:16














          @filipefraqueiro One of the best things about Qt are the signals.

          – eyllanesc
          Nov 12 '18 at 18:17





          @filipefraqueiro One of the best things about Qt are the signals.

          – eyllanesc
          Nov 12 '18 at 18:17



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267112%2fchange-label-from-other-class-in-a-different-file%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

          Edmonton

          Crossroads (UK TV series)