Python Forum
Calling a class inside other class
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calling a class inside other class
#1
class Class1:

    def __init__(self):
        self.atr1 = value1
        self.atr2 = value2

    def method_1(self):
        ???

class Class2:

    def __init__(self):
        self.atr_new = ???

    def method_2(self):
        ...
Hi, I want these 2 classes to work together. The Class1 has a lot of methods and is doing an important part of my program. The Class2 is just as an addition to Class1. What I want to use this Class2 for is:
After several code lines in Class1 are realised, it has to call Class2 with some of its atributes. Let´s give an example - Class1 creates a tkinter canvas and doing something there, method_1 should call Class2 with self.atr1 and self.atr2 atributes and that method Class2 should according to these 2 atributes do something in that tkinter canvas.

Can you help me with that? How to connect these 2 classes to work so?

Thank you in advance.
Reply


Messages In This Thread
Calling a class inside other class - by dan789 - Jan-05-2019, 12:50 PM
RE: Calling a class inside other class - by Larz60+ - Jan-05-2019, 03:05 PM
RE: Calling a class inside other class - by stullis - Jan-05-2019, 03:06 PM
RE: Calling a class inside other class - by dan789 - Jan-05-2019, 07:44 PM
RE: Calling a class inside other class - by stullis - Jan-05-2019, 07:53 PM
RE: Calling a class inside other class - by dan789 - Jan-05-2019, 09:00 PM
RE: Calling a class inside other class - by stullis - Jan-05-2019, 09:45 PM
RE: Calling a class inside other class - by dan789 - Jan-06-2019, 02:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python inner classes inheritance from parent class Abedin 0 23 43 minutes ago
Last Post: Abedin
  Accessing method attributes of python class Abedin 6 791 Apr-14-2025, 07:02 AM
Last Post: buran
  Python class members based on a type value voidtrance 7 1,199 Apr-11-2025, 10:10 PM
Last Post: deanhystad
  Create a new subclass in a Python extension based on an existing class voidtrance 6 1,357 Mar-25-2025, 06:37 PM
Last Post: voidtrance
  printing/out put issue with class arabuamir 3 973 Aug-25-2024, 09:29 AM
Last Post: arabuamir
  Class test : good way to split methods into several files paul18fr 5 3,691 Jul-17-2024, 11:12 AM
Last Post: felixandrea
  [split] Class and methods ebn852_pan 15 3,315 May-23-2024, 11:57 PM
Last Post: ebn852_pan
  [SOLVED] [listbox] Feed it with dict passed to class? Winfried 3 1,302 May-13-2024, 05:57 AM
Last Post: Larz60+
  Class and methods Saida2024 2 1,101 May-13-2024, 04:04 AM
Last Post: deanhystad
  How does this code create a class? Pedroski55 6 2,027 Apr-21-2024, 06:15 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020