How to properly pass an object from one class to another?
📁 method, example, AI
There are two classes: MainWindow and SetOfButtons,
the first class is the main one, building the window skeleton,
and the second class should build buttons on the window skeleton.
So, how can I properly pass the window object to the button class so that the button class can fully control this object?
I already tried creating an object of the SetOfButtons class during initialization of the MainWindow class and passing the window object to it. I managed to build buttons, but when it came to checking for clicks and performing any action, everything broke.
Please help. Below is an example code of the two classes:
# file ProjectPaint.Main from ProjectPaint.Buttons import * import sys class
I tried using recursion. The first argument is the depth of the array. The second argument is the number of elements in the array.
def quant_array(n, x): try: assert isinstance(n, int) except AssertionError: retu ""Input an integer!"" if n <= 1: retu [n]*x retu [(n, quant_array(n-1, x))]*xprint(quant_array(3, 2)) Log in to leave an answer
Blogs
Asynchronous Programming in C++: Complete Guide