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. PySide - Append to textwidget
Qt 6.11 is out! See what's new in the release blog

PySide - Append to textwidget

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.2k 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.
  • B Offline
    B Offline
    Blackbear
    wrote on last edited by
    #1

    Warning; this is my first venture into python & pySide.

    Have the following in a python file, quota.py.

    @import sys
    import subprocess

    def get_quota():
    process = subprocess.Popen(['/home/me/scripts/pySide/dummy.sh'], stdout=subprocess.PIPE)
    quotaoutput = process.communicate()[0]
    #print quotaoutput
    txtQuota.append(quotaoutput)@

    I am trying to use this function to write the output of the bash script into a textwidget (txtQuota) but python tells me that txtQuota is not defined. The txtQuota widget is defined in another file, statchk.py, that was generated by designer-qt4 and pyside-uic. The function is called with a pushbutton.

    @self.btnQuota.clicked.connect(get_quota)@

    The function will work with a print statement and nicely output quotaoutput to the terminal. I'm just at a loss as to how to tell the get_quota function how to find the textwidget.

    Any comments, advice, or suggestions are welcome.

    Thanks in advance.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Blackbear
      wrote on last edited by
      #2

      Got it working. Moved the function definition into the class created by pyside-uic. It has to take an argument, self, so I changed the call to;

      @self.btnQuota.clicked.connect(self.get_quota)@

      and modified the def;

      @ def get_quota(self):
      process = subprocess.Popen(['df', '-kh'], stdout=subprocess.PIPE)
      quotaoutput = process.communicate()[0]
      self.txtQuota.clear()
      self.txtQuota.append(quotaoutput)@

      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