Tkinter Scale, Scrollbar, Toplevel & Spinbox


Tkinter Scale

Sintax :

w = Scale(top, options)


Contoh :

from tkinter import *  

def select():  

   sel = "Value = " + str(v.get())  

   label.config(text = sel)  

top = Tk()  

top.geometry("200x100")  

v = DoubleVar()  

scale = Scale( top, variable = v, from_ = 1, to = 50, orient = HORIZONTAL)  

scale.pack(anchor=CENTER)  

btn = Button(top, text="Value", command=select)  

btn.pack(anchor=CENTER)  

label = Label(top)  

label.pack()  

top.mainloop() 


Tkinter Scrollbar

Sintax :

w = Scrollbar(top, options) 


Contoh :

from tkinter import *  

top = Tk()  

sb = Scrollbar(top)  

sb.pack(side = RIGHT, fill = Y)  

mylist = Listbox(top, yscrollcommand = sb.set )  

for line in range(30):  

    mylist.insert(END, "Number " + str(line))  

mylist.pack( side = LEFT )  

sb.config( command = mylist.yview )  

mainloop() 


Tkinter Toplevel

Sintax :

w = Toplevel(options)


Contoh :

from tkinter import *  

root = Tk()  

root.geometry("200x200")  

def open():  

    top = Toplevel(root)  

    top.mainloop()  

btn = Button(root, text = "open", command = open)  

btn.place(x=75,y=50)  

root.mainloop() 


Tkinter Spinbox

Sintax :

w = Spinbox(top, options)


Contoh :

from tkinter import *  

top = Tk()  

top.geometry("200x200")  

spin = Spinbox(top, from_= 0, to = 25)  

spin.pack()  

top.mainloop()