Skip to content

How to send data between different classes (frames)? #2620

Answered by dipeshSam
yapiyapo28 asked this question in Q&A
Discussion options

You must be logged in to vote

It is recommended that you should learn some Python OOP and Tkinter basics. Your modified code is as follows:

import customtkinter as ctk

class Main(ctk.CTk): # Define Main class
    def __init__(self):
        super().__init__()
        self.frame1 = Frame1(self)
        self.frame1.grid(row=0, column=0, padx=20, pady=20)
        self.frame2 = Frame2(self, frame1_ref=self.frame1)
        self.frame2.grid(row=0, column=1, padx=20, pady=20)

class Frame1(ctk.CTkFrame): # Define frame class for containing the label
    def __init__(self, master):
        super().__init__(master)
        self.label = ctk.CTkLabel(master=self, text='', fg_color='grey25')
        self.label.grid(row=0, column=0

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@yapiyapo28
Comment options

Answer selected by yapiyapo28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants