PySide - Append to textwidget
-
Warning; this is my first venture into python & pySide.
Have the following in a python file, quota.py.
@import sys
import subprocessdef 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.
-
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)@