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. Execute command and display it problem
Forum Updated to NodeBB v4.3 + New Features

Execute command and display it problem

Scheduled Pinned Locked Moved Solved Qt for Python
7 Posts 3 Posters 963 Views 1 Watching
  • 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.
  • monamourM Offline
    monamourM Offline
    monamour
    wrote on last edited by
    #1

    Dear all,

    I made simple "MainWindow" by QT with "push-button" and "Text Browser".
    

    Once I click on "push-button", execute a function which name is "Comm".

    Everything is working fine except the output is not displaying in "Text Browser"

    The Code

    from PyQt5.QtWidgets import *
    
    from PyQt5.uic import  *
    
    from os import path
    
    
    import sys
    
    import wmi
    
    
    
    
    
    
    FORM_CLASS,_ = loadUiType(path.join(path.dirname(__file__),"main2.ui"))
    
    class Ui_MainWindow(QMainWindow , FORM_CLASS):
        def __init__(self, parent=None):
            #super(Ui_MainWindow,self).__init_(parent)
            QMainWindow.__init__(self)
            self.setupUi(self)
            self.Size_UI()
            self.Buttons()
    
    
        def Size_UI(self):
            self.setWindowTitle('NetworkTools')
            self.setFixedSize(450,450)
    
        def Buttons(self):
            self.press.clicked.connect(self.Comm)
    
    
        def Comm(self):
            c = wmi.WMI ()
            for s in c.Win32_NetworkAdapter():
                if s.Manufacturer == "Intel" and s.Speed == "1000000000":
                    print ("The PC is " +s.SystemName +" and the Speed is 1GB ")
    
    
    
    
    
    def main():
        app = QApplication(sys.argv)
        window = Ui_MainWindow()
        window.show()
        app.exec_()
    if __name__ == '__main__':
        main()
    
    
    
    
    

    The output

    The PC is PCNAME and the Speed is 1GB

    I need this "output" to display on "text browser"

    Thanks in advance,

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Something like
      ui->textBrowser->setText("The PC is " +s.SystemName +" and the Speed is 1GB ");

      D 1 Reply Last reply
      3
      • mrjjM mrjj

        Hi
        Something like
        ui->textBrowser->setText("The PC is " +s.SystemName +" and the Speed is 1GB ");

        D Offline
        D Offline
        Domenico
        wrote on last edited by
        #3

        @mrjj

        but it is not:

        ui->textBrowser->setPlainText("The PC is " +s.SystemName +" and the Speed is 1GB ");

        for QTextBrowser instead of:

        ui->textBrowser->setText("The PC is " +s.SystemName +" and the Speed is 1GB ");

        mrjjM monamourM 2 Replies Last reply
        3
        • D Domenico

          @mrjj

          but it is not:

          ui->textBrowser->setPlainText("The PC is " +s.SystemName +" and the Speed is 1GB ");

          for QTextBrowser instead of:

          ui->textBrowser->setText("The PC is " +s.SystemName +" and the Speed is 1GB ");

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Domenico
          Hi
          setPlainText is also fine.
          setText also work for non html text but will test to see if HTML format.
          Just use setPlainText if you have no plans for HTML.

          1 Reply Last reply
          3
          • monamourM Offline
            monamourM Offline
            monamour
            wrote on last edited by
            #5

            Thanks for the ideas.

            1 Reply Last reply
            0
            • D Domenico

              @mrjj

              but it is not:

              ui->textBrowser->setPlainText("The PC is " +s.SystemName +" and the Speed is 1GB ");

              for QTextBrowser instead of:

              ui->textBrowser->setText("The PC is " +s.SystemName +" and the Speed is 1GB ");

              monamourM Offline
              monamourM Offline
              monamour
              wrote on last edited by
              #6

              @Domenico Many thanks,

              1 Reply Last reply
              0
              • monamourM Offline
                monamourM Offline
                monamour
                wrote on last edited by
                #7

                Solved!

                 self.textBrowser.append("The PC is " +s.SystemName +" and the Speed is 1GB ")
                

                Thanks,

                1 Reply Last reply
                2

                • Login

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