[Tutor] How to access a method defined in one class from another class (which is a thread) in Python3?

SM sunithanc at gmail.com
Thu Aug 8 22:57:54 CEST 2013


Is it necessary that the call should be in __init__? The widget is very
much getting created and I have the line (copied again here) under a method
setupUi() under Ui_MainWindow:

class Ui_MainWindow(object):
    [snip]
    def setupUi(self, MainWindow):
        [snip]
        self.textEdit_fwcmdlineoutput = QtGui.QTextEdit(self.tab_fw)

self.textEdit_fwcmdlineoutput.setObjectName(_fromUtf8("textEdit_fwcmdlineoutput"))
        self.gridLayout.addWidget(self.textEdit_fwcmdlineoutput, 6, 0, 1, 3)


Thanks,
-SM



On Thu, Aug 8, 2013 at 4:41 PM, Prasad, Ramit <ramit.prasad at jpmorgan.com>wrote:

> Please post responses in-line or at the bottom for this
> mailing list.
>
> SM wrote:
> >
> > Ramit:
> > Thanks for the quick response. You are right about the error. When I did
> the following:
> > x = Ui_MainWindow()
> > x.setStdoutToTextEditWindowFw()
> > I got the following error:
> > AttributeError: 'Ui_MainWindow' object has no attribute
> 'textEdit_fwcmdlineoutput'
> > But I do have code that creates an attribute in Ui_MainWindow() class:
> >
> > self.textEdit_fwcmdlineoutput = QtGui.QTextEdit(self.tab_fw)
> > This is what is making me get confused as to why it complains that there
> is no attribute.
> > Thanks,
> > -SM
>
> You need to call that line of code to create the widget. Obviously
> it is not being created from the class's __init__.
>
>
> ~Ramit
>
>
>
> This email is confidential and subject to important disclaimers and
> conditions including on offers for the purchase or sale of securities,
> accuracy and completeness of information, viruses, confidentiality, legal
> privilege, and legal entity disclaimers, available at
> http://www.jpmorgan.com/pages/disclosures/email.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130808/30094019/attachment.html>


More information about the Tutor mailing list