[Tutor] Self and class functions
Phil
phil_lor at bigpond.com
Sun Jun 30 00:36:31 CEST 2013
Thank you for reading this.
I'm attempting to access the GUI widgets. The buttonClicked slot does
what I want but I'd like to access the widgets outside of the class. My
function setLabel doesn't work because self and ui are not known.
I have a second class named Frame that includes a function named dummy.
Accessing that function is not a problem.
-------------------------------------
from mainwindow import Ui_MainWindow
from PySide import QtCore, QtGui
from frame import Frame
class DrawTest(QtGui.QMainWindow):
def __init__(self, parent=None):
super(DrawTest, self).__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
def buttonClicked(self):
print("clicked")
self.ui.pushButton.setText("test")
self.ui.label.setText("Testing")
def setLabel(self):
self.ui.label.setText("Bingo")
DrawTest.setLabel(self)
DrawTest.ui.label.setText("Bingo")
The two lines above don't work, so my question is how do access the
setText function? And, what do I do about the self parameter in the
setLabel function?
Accessing the Frame class is not a problem.
Frame.dummy()
I have spent the better part of a day searching the Internet for an
answer and I have attempted to find an answer from two other mailing
lists but they don't entertain low level questions.
--
Regards,
Phil
More information about the Tutor
mailing list