Ответ:
import tkinter as tk
def change_window():
window.config(bg=color_choice.get(), width=width_choice.get(), height=height_choice.get())
def reset_window():
window.config(bg='white', width=300, height=200)
root = tk.Tk()
root.title("Window Changer")
color_choice = tk.StringVar(value='white')
width_choice = tk.IntVar(value=300)
height_choice = tk.IntVar(value=200)
window = tk.Frame(root, bg='white')
window.pack(fill='both', expand=True)
colors = ['white', 'red', 'green', 'blue']
color_dropdown = tk.OptionMenu(root, color_choice, *colors)
color_dropdown.pack()
width_entry = tk.Entry(root, textvariable=width_choice)
width_entry.pack()
height_entry = tk.Entry(root, textvariable=height_choice)
height_entry.pack()
change_button = tk.Button(root, text="Change Window", command=change_window)
change_button.pack()
reset_button = tk.Button(root, text="Reset Window", command=reset_window)
reset_button.pack()
root.mainloop()
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
import tkinter as tk
def change_window():
window.config(bg=color_choice.get(), width=width_choice.get(), height=height_choice.get())
def reset_window():
window.config(bg='white', width=300, height=200)
root = tk.Tk()
root.title("Window Changer")
color_choice = tk.StringVar(value='white')
width_choice = tk.IntVar(value=300)
height_choice = tk.IntVar(value=200)
window = tk.Frame(root, bg='white')
window.pack(fill='both', expand=True)
colors = ['white', 'red', 'green', 'blue']
color_dropdown = tk.OptionMenu(root, color_choice, *colors)
color_dropdown.pack()
width_entry = tk.Entry(root, textvariable=width_choice)
width_entry.pack()
height_entry = tk.Entry(root, textvariable=height_choice)
height_entry.pack()
change_button = tk.Button(root, text="Change Window", command=change_window)
change_button.pack()
reset_button = tk.Button(root, text="Reset Window", command=reset_window)
reset_button.pack()
root.mainloop()