GrpC_Identikit/ImageProcessing/menu_deroulant.py

32 lines
805 B
Python

import tkinter as tk
from tkinter import ttk
# Function to toggle the button state
def toggle_button():
if toggle_var.get():
toggle_button.config(text="Activated")
else:
toggle_button.config(text="Deactivated")
# Main window
root = tk.Tk()
root.title("Toggle Button with Dropdown Menu")
# Dropdown menu for options
options = ["Option 1", "Option 2", "Option 3"]
selected_option = tk.StringVar(root)
selected_option.set(options[0]) # default value
dropdown_menu = ttk.Combobox(root, textvariable=selected_option, values=options)
dropdown_menu.pack(pady=10)
# Variable to store the toggle state
toggle_var = tk.BooleanVar()
# Toggle button
toggle_button = tk.Button(root, text="Deactivated", command=toggle_button)
toggle_button.pack(pady=20)
# Start the GUI
root.mainloop()