Ok. I got it working.... I used notebook & added the frames to a tab of the notebook:
class MainWindow(tk.Frame):
def __init__(self, parent, *args, **kwargs):
# create different tabs within the main window:
nb = ttk.Notebook(root)
tab1 = ttk.Frame(nb)
TopLeft = WinchFrame(tab1, padx=10, pady=20, relief='ridge')
TopLeft.pack()
TopRight = WinchFrame(tab1, padx=10, pady=20)
TopRight.pack()
BotLeft = WinchFrame(tab1, padx=10, pady=20, relief='ridge')
BotLeft.pack()
BotRight = WinchFrame(tab1, padx=10, pady=20)
BotRight.pack()
class WinchFrame(tk.Frame):
def __init__(self, parent=None, **kw):
Frame.__init__(self, parent, kw)
# CREATE WIDGETS:
self.winch_lbl = Label(self, width=15)
self.lbl_btn_up = Label(self, text="UP")
self.btn_up = Button(self, text="OFF", width=12, fg='green', command=self.toggle_up)
self.txt = Text(self, height=1, width=50, bg="light blue")
self.lbl_btn_down = Label(self, text="DOWN")
self.btn_down = Button(self, text="OFF", width=12, fg='green', command=self.toggle_down)
# LAYOUT:
self.winch_lbl.grid(row=1, column=0, padx=5, pady=5)
self.lbl_btn_up.grid(row=1, column=1, padx=5, pady=5)
self.btn_up.grid(row=1, column=2, padx=5, pady=5)
self.lbl_btn_down.grid(row=3, column=1, padx=5, pady=5)
self.btn_down.grid(row=3, column=2, padx=5, pady=5)
self.txt.grid(row=5, column=1, columnspan=2, padx=5, pady=5)
def toggle_up(self):
'''
use
t_btn.config('text')[-1]
to get the present state of the toggle button
'''
if self.btn_up.config('text')[-1] == 'ON':
self.btn_up.config(text='OFF', highlightbackground='gray')
print('button turned off')
self.btn_down['state'] = tk.NORMAL
else:
self.btn_up.config(text='ON', highlightbackground='red')
print('button turned on')
self.btn_down['state'] = tk.DISABLED
def toggle_down(self):
'''
use
t_btn.config('text')[-1]
to get the present state of the toggle button
'''
if self.btn_down.config('text')[-1] == 'ON':
self.btn_down.config(text='OFF', highlightbackground='gray')
print('button turned off')
self.btn_up['state'] = tk.NORMAL
else:
self.btn_down.config(text='ON', highlightbackground='red')
print('button turned on')
self.btn_up['state'] = tk.DISABLED