Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How to show all UI from another python file in current file when button is clicked for pyqt5
QtWS25 Last Chance

How to show all UI from another python file in current file when button is clicked for pyqt5

Scheduled Pinned Locked Moved Unsolved Qt for Python
5 Posts 2 Posters 2.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sdf1444
    wrote on last edited by
    #1

    Hi

    I want to know how to show all UI from another python file in current file when button is clicked.

    Thanks
    Spencer

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sdf1444
      wrote on last edited by
      #2

      Basically I have this code and I want to display all the UI elements from another pyqt5 python file in this file when the button is clicked. How do I do this?

      import sys
      from PyQt5 import *
      from PyQt5.QtWidgets import *
      from PyQt5.QtWidgets import *
      from PyQt5.QtCore import *

      class MainWindow(QMainWindow):
      def init(self):
      QMainWindow.init(self)

          self.setMinimumSize(QSize(300, 200))    
          self.setWindowTitle("PyQt button example - pythonprogramminglanguage.com") 
      
          pybutton = QPushButton('Click me', self)
          pybutton.clicked.connect(self.clickMethod)
          pybutton.resize(100,32)
          pybutton.move(50, 50)        
      
      def clickMethod(self):
          print('Clicked Pyqt button.')
      

      if name == "main":
      app = QtWidgets.QApplication(sys.argv)
      mainWin = MainWindow()
      mainWin.show()
      sys.exit( app.exec_() )

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sdf1444
        wrote on last edited by
        #3

        @denni-0

        Basically I have this code and I want to display all the UI elements from another pyqt5 python file in this file when the button is clicked in the same window. How do I do this?

        import sys
        from PyQt5 import *
        from PyQt5.QtWidgets import *
        from PyQt5.QtWidgets import *
        from PyQt5.QtCore import *
        class MainWindow(QMainWindow):
        def init(self):
        QMainWindow.init(self)
        self.setMinimumSize(QSize(300, 200))
        self.setWindowTitle("PyQt button example - pythonprogramminglanguage.com")

        pybutton = QPushButton('Click me', self)
        pybutton.clicked.connect(self.clickMethod)
        pybutton.resize(100,32)
        pybutton.move(50, 50)        
        

        def clickMethod(self):
        print('Clicked Pyqt button.')
        if name == "main":
        app = QtWidgets.QApplication(sys.argv)
        mainWin = MainWindow()
        mainWin.show()
        sys.exit( app.exec_() )

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sdf1444
          wrote on last edited by
          #4

          @denni-0

          Ok thank you very much but I dont want a new window. I just want to display all UI elements from another file in the current window.

          Thanks

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sdf1444
            wrote on last edited by
            #5

            @denni-0

            They are stored in classes and functions not designer window.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved