1.create window
import tkinter as tk#import the package tkinter
mainwindow = tk.Tk()#create a window
mainwindow.title('mainWindow')#set title
mainwindow.geometry('500x400')#set size
mainwindow.mainloop()#loop to make the window exists
#normally: I create a function previously. And I only use it when i wanna
def createWindow(title,geometry):
mainwindow = tk.Tk()#create a window
mainwindow.title(title)#set title
mainwindow.geometry(geometry)#set size
return mainwindow
2.pack a Label and Button
#######u should create a window first and pack on things
label1 = tk.Label(window,text = 'this is a Label',bg = 'yellow',height = 2,width = 20)
# the window to tatch on/text /background color /szie
label1.pack()# dont foret to pack it on the window
button = tk.Button(window,text = 'sign in',command = createSignInWindow)
#the command function should not follow ()
button.pack()
3.tk list
var = tk.StringVar()#tk variable
var.set((1,2,3,4,5,6))#init the var
listbox = tk.Listbox(window,listvariable = var)#create listbox
listbox.pack()#pack it
4.label.config can correct the text on label
lable.config(text = var.get())
5.the tk scale
scale = tk.Scale(mainWindow,label = 'Useing rate',from_ = 0.00,to = 1,orient = tk.VERTICAL,
length = 200,showvalue = 1,resolution = 0.01)
scale.pack()
#lebel ; from which num to which number;otient{HORIZONTAL,VERTICAL};length;
#showvalue(show th evalue on the block or not);resolution = 'the presicion';
#command;