Home > database >  Python Tkinter VERTICAL Slider and HOROZONTAL Slider beneath each other
Python Tkinter VERTICAL Slider and HOROZONTAL Slider beneath each other

Time:11-08

I'am relative new to python and just wanted to create a GUI with a VERTICAL Slider on the left and like 4 HORIZOTAL Slider on the right without Space. This is my current Code, and as you can see, the Vertical Slider is above the Horozontal Slider. So how do I get the Vertical Slider to the left and all other beside the Slider?

Thank You in Advance

from tkinter import *

master = Tk()
Slider1 = Scale(master, from_=0, to=42, orient=VERTICAL, length=400)
Slider1.pack()

Slider2 = Scale(master, from_=0, to=200, orient=HORIZONTAL, length=400)
Slider2.pack()

Slider3 = Scale(master, from_=0, to=200, orient=HORIZONTAL,length=400)
Slider3.pack()

Slider4 = Scale(master, from_=0, to=200, orient=HORIZONTAL,length=400)
Slider4.pack()

Slider5 = Scale(master, from_=0, to=200, orient=HORIZONTAL, length=400)
Slider5.pack()

Slider6 = Scale(master, from_=0, to=200, orient=HORIZONTAL, length=400)
Slider6.pack()

mainloop()

Everthing I've tried so far didnt work

CodePudding user response:

In this very specific case, Slider1.pack(side="left") is what you need to do before calling pack on any of the other sliders.

pack works by reserving a side of the available space, and then placing the widget inside that space. By packing something with side='left' you're requesting the widget to be along the left edge. If you don't provide a value for side, it defaults to side='top'.

Once one widget is placed on the left, it uses the entire left side and nothing else can appear above or below it. When the other widgets are packed to the top, they will be along the top side and to the right of the widget on the left.

  • Related