Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- from tkinter import ttk
- class Channel(tk.Frame):
- def __init__(self, parent, *args, **kwargs):
- tk.Frame.__init__(self, parent, *args, **kwargs)
- self.parent = parent
- self.btn = tk.Button(self.parent, text = 'click me', command = self.change_green)
- self.btn.pack()
- def change_green(self):
- main_window.channel_1.btn.config(bg = 'green') # line 11
- class MainApplication(tk.Frame):
- def __init__(self, parent, *args, **kwargs):
- tk.Frame.__init__(self, parent, *args, **kwargs)
- self.parent = parent
- self.tab_control = ttk.Notebook(self.parent)
- self.tab_1 = ttk.Frame(self.tab_control)
- self.tab_2 = ttk.Frame(self.tab_control)
- self.tab_control.add(self.tab_1, text = 'tab 1')
- self.tab_control.add(self.tab_2, text = 'tab 2')
- self.tab_control.pack(fill = 'both', expand = 1)
- self.channel_1 = Channel(self.tab_channel_1)
- self.channel_2 = Channel(self.tab_channel_2)
- if __name__ == "__main__":
- root = tk.Tk()
- main_window = MainApplication(root) # <<<< here defined main_window
- main_window.pack(side="top", fill="both", expand=True)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement