Panneau de configuration du redimensionneur de fenêtre – Tkinter

from tkinter import *

from tkinter import ttk

root = Tk()

root.title("Controls")

root.geometry("400x500")

def launch():

    global second

    second = Toplevel()

    second.geometry("100x100")

def width_slide(x):

    second.geometry(f"{int(width_slider.get())}x{int(height_slider.get())}")

def height_slide(x):

    second.geometry(f"{int(width_slider.get())}x{int(height_slider.get())}")

def both_slide(x):

    second.geometry(f"{int(both_slider.get())}x{int(both_slider.get())}")

launch_button = Button(root,

                       text = "launch Window",

                       command = launch)

launch_button.pack(pady = 10)

width_frame = LabelFrame(root,

                         text = "Change width")

width_frame.pack(pady = 10)

height_frame = LabelFrame(root,

                          text = "change height")

height_frame.pack(pady = 10)

both_frame = LabelFrame(root,

                        text = "change both")

both_frame.pack(pady = 10)

width_slider = ttk.Scale(width_frame,from_ = 100, to = 500,

                         orient = HORIZONTAL, length = 200,

                         command = width_slide,

                         value = 100)

width_slider.pack(pady = 10, padx = 20)

height_slider = ttk.Scale(height_frame, from_ = 100, to = 500,

                          orient = VERTICAL, length = 200,

                          command = height_slide,

                          value = 100)

height_slider.pack(pady = 10, padx = 20)

both_slider = ttk.Scale(both_frame, from_ = 100,to = 500,

                        orient = HORIZONTAL, length = 200,

                        command = both_slide, value = 100)

both_slider.pack(pady = 10, padx = 20)

root.mainloop()

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Aller en haut