Danke für Deinen Tipp, nach dieser kleinen Änderung, funktioniert es wie ich es mir vorgestellt habe!

Grüße Nobuddy
Code: Alles auswählen
class MyButton(tk.Button):
"""Steuerung der Hauptbuttons"""
selected_button_obj = None
HIGHLIGHT_COLOR = 'green'
HIGHLIGHT_CONF = dict(bg=HIGHLIGHT_COLOR,
activebackground=HIGHLIGHT_COLOR)
def __init__(self, parent, **options):
try:
self.command_call = options['command']
del options['command']
except KeyError:
self.command_call = None
tk.Button.__init__(self, parent, **options)
self.bind('<Button-1>', self.callback)
self.std_conf = dict(bg=self['bg'],
activebackground=self['activebackground'])
def callback(self, event=None):
button_obj = MyButton.selected_button_obj
if button_obj is not None:
button_obj.config(self.std_conf)
if self.command_call:
self.config(MyButton.HIGHLIGHT_CONF)
MyButton.selected_button_obj = self
self.command_call(event.widget['text'])
class MySubButton(tk.Button):
"""Steuerung der Subbuttons"""
selected_sub_button_obj = None
HIGHLIGHT_COLOR = 'green'
HIGHLIGHT_CONF = dict(bg=HIGHLIGHT_COLOR,
activebackground=HIGHLIGHT_COLOR)
def __init__(self, parent, **options):
try:
self.command_call = options['command']
del options['command']
except KeyError:
self.command_call = None
tk.Button.__init__(self, parent, **options)
self.bind('<Button-1>', self.callback)
self.std_conf = dict(bg=self['bg'],
activebackground=self['activebackground'])
def callback(self, event=None):
sub_button_obj = MySubButton.selected_sub_button_obj
self.mysubbutton = sub_button_obj
if sub_button_obj is not None:
sub_button_obj.config(self.std_conf)
if self.command_call:
self.config(MySubButton.HIGHLIGHT_CONF)
MySubButton.selected_sub_button_obj = self
self.command_call(event.widget['text'])
Code: Alles auswählen
def button_callback(self, button_name):
"""Rückruf der Haupt-Buttons"""
print("Button (rechts): {0}".format(button_name))
self.master_check = button_name
self.sub_check = ''
# Entferne alle bestehende Sub-Buttons aus dem linken Frame
for button in self.button_frame_left.winfo_children():
button.destroy()
# Kontrolle: Hat der aktivierte rechte Button zugehörige Sub-Buttons?
try:
MySubButton.selected_sub_button_obj = None
for button_name in self.my_sub_buttons[button_name]:
MySubButton(self.button_frame_left,
width=self.conf['button_width'],
font=(self.conf['sub_font']), text=button_name,
command=self.sub_button_callback).pack(padx=8, ipady=2,
pady=19, fill='x')
# Ja es gibt Sub-Buttons!
except KeyError:
print("Für {} gibt es keine Liste mit Sub-Buttons!".format(
button_name))
Code: Alles auswählen
def sub_button_callback(self, sub_button_name):
"""Rückruf der Sub-Buttons"""
print("Sub-Button (links): {0}".format(sub_button_name))
Code: Alles auswählen
self.sub_button_callback('Sub-Button-1')