python-tkinter 发表于 2018-05-11 123456789101112131415161718192021222324252627282930313233import tkinter as tk #引入包win = tk.Tk()win.geometry('200x200') #大小var = tk.StringVar() #tk字符串text = tk.Text() #文本框text.insert('insert',var)lb = tk.Listbx(win,lisvariable=var)tk.Scale() #横条tk.CheckButton()canvas = tk.Canvas(win,bg='blue',height=100,width=200)bt = tk.Button(win,text='move',command=move) #command指向的是一个函数bt.pack() #布置到窗口上去image_file = tk.PhotoImage(file='abc.gif')image = canvas.create_image(0,0,anchor='nw',image=image_file) #將锚点定在左上角0,0处line = canvas.create_line(x0,y0,x1,y1)canvas.move(rect,0,2) #rect 为移动的对象menubar = tk.MenuBar(win)filemenu = tk.Menu(menubar,tearoff=0)menubar.add_cascade(label='File',menu=filemenu)filemenu.add_commond(label='new',commond=do_job)filemenu.add_separator() #分隔线win.congfig(menu=menubar).pack().place(x=10,y=100,anchor='nw').grid(row=i,col=j,padx,pad,y)tk.MessageBox.showInfo(title='hi',message='HaHa')