<code>def populate(frame):
global entries_list
global total_field
global clicked_car
global clicked_player
global car_entry
# Labels
labels_list = [
Label(modding_frame, text=part, padx=40, pady=20, fg=text_color, bg=background, font=heading_font)
for part in mod_part_list]
total_label = Label(modding_frame, text="Total", padx=40, pady=20, fg=label_text, bg=background, font=heading_font)
total_label.grid(row=12, column=3, columnspan=5, sticky=E + W)
total_field = Label(modding_frame, text="", width=10, fg=label_text, bg=label_bg, font=heading_font, anchor=E, relief=SUNKEN)
total_field.grid(row=12, column=6, columnspan=2, sticky=W + E)
# Menus
menu_names = [name.replace("clicked_", "").capitalize() for name in menu_list]
menu_vars = {menu: StringVar(value=f'Select {item}') for menu, item in zip(menu_list, menu_names)}
menus_config = {
'clicked_armor': (armor_list, 0, 1),
'clicked_brakes': (brakes_list, 2, 1),
'clicked_tunes': (engine_tunes_list, 0, 4),
'clicked_headlights': (headlights_list, 9, 7),
'clicked_neon_kits': (neon_kits_list, 0, 10),
'clicked_neon_colors': (neon_colour_list, 1, 10),
'clicked_license_plate': (license_plate_list, 8, 10),
'clicked_suspension': (suspension_list, 2, 16),
'clicked_transmission': (transmission_list, 6, 16),
'clicked_turbo': (turbo_list, 8, 16),
}
menu_entry_map = {}
for menu, (values, row, col) in menus_config.items():
mods_menu = OptionMenu(modding_frame, menu_vars[menu], *values.keys(), command=menu_selection())
mods_menu.config(fg=text_color, bg=background, font=text_font)
mods_menu.grid(row=row, column=col, padx=(0, 10))
entry_index = row * 10 + col // 2
if entry_index < len(entries_list):
entry = entries_list[entry_index]
menu_entry_map[menu_vars[menu]] = entry
menu_vars[menu].trace('w', lambda *args, m=menu_vars[menu], e=entry, d=values: menu_selection(m, e, d))
menu_vars['clicked_player'] = StringVar()
menu_vars['clicked_player'].trace('w', lambda *args: update_cars())
player_menu = OptionMenu(modding_frame, menu_vars['clicked_player'], *players)
player_menu.config(fg=text_color, bg=background, font=text_font)
player_menu.grid(row=11, column=1, pady=15)
menu_vars['clicked_car'] = StringVar()
car_menu = OptionMenu(modding_frame, menu_vars['clicked_car'], 'Select Car')
car_menu.config(fg=text_color, bg=background, font=text_font)
car_menu.grid(row=11, column=2, padx=10)
# Entries
entries_list = [Entry(modding_frame, width=10, font=heading_font, justify=CENTER) for _ in range(67)]
for entry in entries_list:
if not entry.get():
entry.insert(END, '0')
for i, (label, entry) in enumerate(zip(labels_list, entries_list)):
label_col = (i // 10) * 3
row = i % 10
entry_col = label_col + 2
label.grid(row=row, column=label_col)
entry.grid(row=row, column=entry_col, padx=(0, 10))
# Buttons
submit_button = Button(modding_frame, text='Submit', command=submit, fg=text_color, bg=background, font=text_font)
submit_button.grid(row=11, column=3, pady=15)
clear_all_button = Button(modding_frame, text="Clear All Fields", padx=20, pady=10, command=clear_all, fg=text_color, bg=background, font=heading_font)
clear_all_button.grid(row=13, column=5)
clear_button = Button(modding_frame, text="Clear Total", padx=20, pady=10, command=remove_text, fg=text_color, bg=background, font=heading_font)
clear_button.grid(row=13, column=6)
calculate_button = Button(modding_frame, text="Calculate", padx=20, pady=10, command=mod_calculation, fg=text_color, bg=background, font=heading_font)
calculate_button.grid(row=13, column=7)
def on_frame_configure(canvas):
canvas.configure(scrollregion=canvas.bbox("all"))
def _on_mouse_wheel(event):
window_canvas.xview_scroll(-1 * int((event.delta / 120)), "units")
def menu_selection(menu_var, entry, dictionary):
selected_item = menu_var.get()
if selected_item in dictionary:
price = dictionary[selected_item]
entry.delete(0, END)
entry.insert(0, price)
</code>
<code>def populate(frame):
global entries_list
global total_field
global clicked_car
global clicked_player
global car_entry
# Labels
labels_list = [
Label(modding_frame, text=part, padx=40, pady=20, fg=text_color, bg=background, font=heading_font)
for part in mod_part_list]
total_label = Label(modding_frame, text="Total", padx=40, pady=20, fg=label_text, bg=background, font=heading_font)
total_label.grid(row=12, column=3, columnspan=5, sticky=E + W)
total_field = Label(modding_frame, text="", width=10, fg=label_text, bg=label_bg, font=heading_font, anchor=E, relief=SUNKEN)
total_field.grid(row=12, column=6, columnspan=2, sticky=W + E)
# Menus
menu_names = [name.replace("clicked_", "").capitalize() for name in menu_list]
menu_vars = {menu: StringVar(value=f'Select {item}') for menu, item in zip(menu_list, menu_names)}
menus_config = {
'clicked_armor': (armor_list, 0, 1),
'clicked_brakes': (brakes_list, 2, 1),
'clicked_tunes': (engine_tunes_list, 0, 4),
'clicked_headlights': (headlights_list, 9, 7),
'clicked_neon_kits': (neon_kits_list, 0, 10),
'clicked_neon_colors': (neon_colour_list, 1, 10),
'clicked_license_plate': (license_plate_list, 8, 10),
'clicked_suspension': (suspension_list, 2, 16),
'clicked_transmission': (transmission_list, 6, 16),
'clicked_turbo': (turbo_list, 8, 16),
}
menu_entry_map = {}
for menu, (values, row, col) in menus_config.items():
mods_menu = OptionMenu(modding_frame, menu_vars[menu], *values.keys(), command=menu_selection())
mods_menu.config(fg=text_color, bg=background, font=text_font)
mods_menu.grid(row=row, column=col, padx=(0, 10))
entry_index = row * 10 + col // 2
if entry_index < len(entries_list):
entry = entries_list[entry_index]
menu_entry_map[menu_vars[menu]] = entry
menu_vars[menu].trace('w', lambda *args, m=menu_vars[menu], e=entry, d=values: menu_selection(m, e, d))
menu_vars['clicked_player'] = StringVar()
menu_vars['clicked_player'].trace('w', lambda *args: update_cars())
player_menu = OptionMenu(modding_frame, menu_vars['clicked_player'], *players)
player_menu.config(fg=text_color, bg=background, font=text_font)
player_menu.grid(row=11, column=1, pady=15)
menu_vars['clicked_car'] = StringVar()
car_menu = OptionMenu(modding_frame, menu_vars['clicked_car'], 'Select Car')
car_menu.config(fg=text_color, bg=background, font=text_font)
car_menu.grid(row=11, column=2, padx=10)
# Entries
entries_list = [Entry(modding_frame, width=10, font=heading_font, justify=CENTER) for _ in range(67)]
for entry in entries_list:
if not entry.get():
entry.insert(END, '0')
for i, (label, entry) in enumerate(zip(labels_list, entries_list)):
label_col = (i // 10) * 3
row = i % 10
entry_col = label_col + 2
label.grid(row=row, column=label_col)
entry.grid(row=row, column=entry_col, padx=(0, 10))
# Buttons
submit_button = Button(modding_frame, text='Submit', command=submit, fg=text_color, bg=background, font=text_font)
submit_button.grid(row=11, column=3, pady=15)
clear_all_button = Button(modding_frame, text="Clear All Fields", padx=20, pady=10, command=clear_all, fg=text_color, bg=background, font=heading_font)
clear_all_button.grid(row=13, column=5)
clear_button = Button(modding_frame, text="Clear Total", padx=20, pady=10, command=remove_text, fg=text_color, bg=background, font=heading_font)
clear_button.grid(row=13, column=6)
calculate_button = Button(modding_frame, text="Calculate", padx=20, pady=10, command=mod_calculation, fg=text_color, bg=background, font=heading_font)
calculate_button.grid(row=13, column=7)
def on_frame_configure(canvas):
canvas.configure(scrollregion=canvas.bbox("all"))
def _on_mouse_wheel(event):
window_canvas.xview_scroll(-1 * int((event.delta / 120)), "units")
def menu_selection(menu_var, entry, dictionary):
selected_item = menu_var.get()
if selected_item in dictionary:
price = dictionary[selected_item]
entry.delete(0, END)
entry.insert(0, price)
</code>
def populate(frame):
global entries_list
global total_field
global clicked_car
global clicked_player
global car_entry
# Labels
labels_list = [
Label(modding_frame, text=part, padx=40, pady=20, fg=text_color, bg=background, font=heading_font)
for part in mod_part_list]
total_label = Label(modding_frame, text="Total", padx=40, pady=20, fg=label_text, bg=background, font=heading_font)
total_label.grid(row=12, column=3, columnspan=5, sticky=E + W)
total_field = Label(modding_frame, text="", width=10, fg=label_text, bg=label_bg, font=heading_font, anchor=E, relief=SUNKEN)
total_field.grid(row=12, column=6, columnspan=2, sticky=W + E)
# Menus
menu_names = [name.replace("clicked_", "").capitalize() for name in menu_list]
menu_vars = {menu: StringVar(value=f'Select {item}') for menu, item in zip(menu_list, menu_names)}
menus_config = {
'clicked_armor': (armor_list, 0, 1),
'clicked_brakes': (brakes_list, 2, 1),
'clicked_tunes': (engine_tunes_list, 0, 4),
'clicked_headlights': (headlights_list, 9, 7),
'clicked_neon_kits': (neon_kits_list, 0, 10),
'clicked_neon_colors': (neon_colour_list, 1, 10),
'clicked_license_plate': (license_plate_list, 8, 10),
'clicked_suspension': (suspension_list, 2, 16),
'clicked_transmission': (transmission_list, 6, 16),
'clicked_turbo': (turbo_list, 8, 16),
}
menu_entry_map = {}
for menu, (values, row, col) in menus_config.items():
mods_menu = OptionMenu(modding_frame, menu_vars[menu], *values.keys(), command=menu_selection())
mods_menu.config(fg=text_color, bg=background, font=text_font)
mods_menu.grid(row=row, column=col, padx=(0, 10))
entry_index = row * 10 + col // 2
if entry_index < len(entries_list):
entry = entries_list[entry_index]
menu_entry_map[menu_vars[menu]] = entry
menu_vars[menu].trace('w', lambda *args, m=menu_vars[menu], e=entry, d=values: menu_selection(m, e, d))
menu_vars['clicked_player'] = StringVar()
menu_vars['clicked_player'].trace('w', lambda *args: update_cars())
player_menu = OptionMenu(modding_frame, menu_vars['clicked_player'], *players)
player_menu.config(fg=text_color, bg=background, font=text_font)
player_menu.grid(row=11, column=1, pady=15)
menu_vars['clicked_car'] = StringVar()
car_menu = OptionMenu(modding_frame, menu_vars['clicked_car'], 'Select Car')
car_menu.config(fg=text_color, bg=background, font=text_font)
car_menu.grid(row=11, column=2, padx=10)
# Entries
entries_list = [Entry(modding_frame, width=10, font=heading_font, justify=CENTER) for _ in range(67)]
for entry in entries_list:
if not entry.get():
entry.insert(END, '0')
for i, (label, entry) in enumerate(zip(labels_list, entries_list)):
label_col = (i // 10) * 3
row = i % 10
entry_col = label_col + 2
label.grid(row=row, column=label_col)
entry.grid(row=row, column=entry_col, padx=(0, 10))
# Buttons
submit_button = Button(modding_frame, text='Submit', command=submit, fg=text_color, bg=background, font=text_font)
submit_button.grid(row=11, column=3, pady=15)
clear_all_button = Button(modding_frame, text="Clear All Fields", padx=20, pady=10, command=clear_all, fg=text_color, bg=background, font=heading_font)
clear_all_button.grid(row=13, column=5)
clear_button = Button(modding_frame, text="Clear Total", padx=20, pady=10, command=remove_text, fg=text_color, bg=background, font=heading_font)
clear_button.grid(row=13, column=6)
calculate_button = Button(modding_frame, text="Calculate", padx=20, pady=10, command=mod_calculation, fg=text_color, bg=background, font=heading_font)
calculate_button.grid(row=13, column=7)
def on_frame_configure(canvas):
canvas.configure(scrollregion=canvas.bbox("all"))
def _on_mouse_wheel(event):
window_canvas.xview_scroll(-1 * int((event.delta / 120)), "units")
def menu_selection(menu_var, entry, dictionary):
selected_item = menu_var.get()
if selected_item in dictionary:
price = dictionary[selected_item]
entry.delete(0, END)
entry.insert(0, price)
The lamda event isn’t doing anything, when I select anything from the dropdown menu, nothing happens and when I debug with print() nothing prints to screen when menu selection is made. I have even tried: *** mods_menu.bind(‘<>’, lambda event, menu_var=menu_vars[menu], entry=entries_list[entry_index], values=values: menu_selection(menu_var, entry, values)) *** without success. Please assist. Thanx.