0
def on3_click(self):
    subprocess.call('ip a',shell=True)

Hello so this clicked.connect pointer allows me to print out my desktop ip address using ip acommand but it will only print out in the terminal. How can I display the output of the subprocess in a QMessageBox or other GUI window ?

1 Answers1

0

You could collect the output of the subprocess call as a string and then just open a QMessageBox.

class Template(QWidget):

    def __init__(self):
        super().__init__()
        btn = QPushButton('Button', self)
        btn.clicked.connect(self.on3_click)

    def on3_click(self):
        ip = str(subprocess.call('ip a', shell=True))
        QMessageBox.information(self, 'Info', ip)
alec
  • 5,799
  • 1
  • 7
  • 20
  • wow thank you that work it turnes out that my syntax is somehow upside down . Anyways is there a way to resize a QMessageBox ? – potato guy 123123123 Mar 01 '20 at 08:27
  • Check out this post, it has a good answer. https://stackoverflow.com/questions/37668820/how-can-i-resize-qmessagebox – alec Mar 01 '20 at 08:34