内容五
from tkinter import *
master = Tk()
theLb = Listbox(master)
theLb.pack()
mainloop()
from tkinter import *
master = Tk()
theLb = Listbox(master)
theLb.pack()
for item in ["zhu", "猪", "huzhuzhu", "胡猪猪"]:
theLb.insert(END, item)
theButton = Button(master, text="删除它",
command=lambda x=theLb:x.delete(ACTIVE))
theButton.pack()
mainloop()
from tkinter import *
master = Tk()
theLb = Listbox(master, selectmode=SINGLE, height=11)
theLb.pack()
for item in range(11):
theLb.insert(END, item)
theButton = Button(master, text="删除它",
command=lambda x=theLb:x.delete(ACTIVE))
theButton.pack()
mainloop()
from tkinter import *
root = Tk()
sb = Scrollbar(root)
sb.pack()
sb.pack(side=RIGHT, fill=Y)
mainloop()
from tkinter import *
root = Tk()
sb = Scrollbar(root)
sb.pack()
sb.pack(side=RIGHT, fill=Y)
lb = Listbox(root, yscrollcommand=sb.set)
for i in range(1000):
lb.insert(END, i)
lb.pack(side=LEFT, fill=BOTH)
sb.config(command=lb.yview)
mainloop()
from tkinter import *
root = Tk()
Scale(root, from_=0, to=42).pack()
Scale(root, from_=0, to=200, orient=HORIZONTAL).pack()
mainloop()
from tkinter import *
root = Tk()
s1 = Scale(root, from_=0, to=42)
s1.pack()
s2 = Scale(root, from_=0, to=200, orient=HORIZONTAL)
s2.pack()
def show():
print(s1.get(), s2.get())
Button(root, text="获取位置",command=show).pack()
mainloop()
from tkinter import *
root = Tk()
Scale(root, from_=0, to=42,
tickinterval=5, resolution=5, length=200).pack()
Scale(root, from_=0, to=200,
tickinterval=10, orient=HORIZONTAL, length=600).pack()
mainloop()
内容六
from tkinter import *
root = Tk()
text = Text(root, width=30, height=2)
text.pack()
text.insert(INSERT, "I love \n")
text.insert(END, "FishC.com!")
mainloop()
from tkinter import *
root = Tk()
text = Text(root, width=30, height=5)
text.pack()
text.insert(INSERT, "I love \n")
text.insert(END, "FishC.com!")
def show():
print("我被点了")
b1 = Button(text, text="点我", command=show)
text.window_create(INSERT, window=b1)
mainloop()
hotoImage(file="18.gif")
def show():
text.image_create(END, image=photo)
b1 = Button(text, text="点我", command=show)
text.window_create(INSERT, window=b1)
mainloop()