【发布时间】:2022-12-27 22:34:03
【问题描述】:
How can I access the variables x and y defined inside funA in class A from class B?
class A(QWidget):
def __init__(self):
QWidget.__init__(self)
self.y = 1
def funA(self):
self.x = 1
self.y = 2
return self.x, self.y
class B(QMainWindow):
def __init__(self, name, low, high, step=10, a):
QMainWindow.__init__(self)
a = A.funA()
print(a)
a = A()
B(a)
Can someone help me with this?
【问题讨论】:
-
I see you have posted some code for us to see. Does it work? Do you get anything printed out? Are there any errors?
-
Are you looking for
a.xanda.y? -
Yes, I would like to access x and y from class B @mkrieger1
-
No, this code does not work correctly @quamrana
标签: python python-3.x python-2.7 class pyqt5