Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. self.text_console.append(line) not work
Qt 6.11 is out! See what's new in the release blog

self.text_console.append(line) not work

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 368 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.
  • K Offline
    K Offline
    KOHAK
    wrote on last edited by
    #1
    class ServerConsolePage(QMainWindow):
        def __init__(self, parent):
            super(ServerConsolePage, self).__init__(parent)
    
            uic.loadUi(".\ServerConsolePage.ui", self)
    
            #보여주기
            self.show()
    
            #이름
            self.setWindowTitle('통합 서버 구동기 - 서버 콘솔')
            #크기
            self.setGeometry(300, 300, 300, 200)
            self.setFixedSize(1100, 700)
    
            # The display effect is the same as executing in the command window, if there is color output, it can be kept, but the result cannot be returned
    
    
            def run(command):
                subprocess.call(command, shell=True)
    
    
            run("ipconfig")
    
    
            # Real-time output but not color display, you can return the result
            def sh(command, print_msg=True):
                p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
                lines = []
                for line in iter(p.stdout.readline, b''):
                    line = line.rstrip().decode('utf8')
                    if print_msg:
                        global Save_text_console
                        Save_text_console = line
                        self.text_console.append(line)
                    lines.append(line)
                return lines
    
    

    There's a self.text_console.append(line) in the function.
    is not working
    Or is there a way to make that work?

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

      Hi,

      What do you mean by not working ?
      Did you check that you actually get something ?
      What's the content of the lines variable that you return from that method ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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