上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 47 下一页
摘要: 1 #选项菜单 2 from tkinter import * 3 root = Tk() 4 variable=StringVar() 5 variable.set('one') 6 w = OptionMenu(root,variable,'one','two','three') 7 w.pack() 8 9 mainloop() 阅读全文
posted @ 2017-04-28 11:16 道高一尺 阅读(465) 评论(0) 推荐(0)
摘要: 1 #按钮弹出菜单 2 from tkinter import * 3 root =Tk() 4 5 def callback(): 6 print('我被调用了') 7 8 9 m = Menubutton(root,text = '点我',width=3,height=3) 10 m.pack() 11 12 filemenu = Menu(m) 13 fi... 阅读全文
posted @ 2017-04-28 11:10 道高一尺 阅读(369) 评论(0) 推荐(0)
摘要: 1 #右键弹出菜单 2 from tkinter import * 3 4 root=Tk() 5 6 def callback(): 7 print('我被调用了') 8 9 menubar =Menu(root) 10 menubar.add_command(label='编辑',command=callback) 11 menubar.add_com... 阅读全文
posted @ 2017-04-28 10:43 道高一尺 阅读(262) 评论(0) 推荐(0)
摘要: 1 #menu多级菜单 2 from tkinter import * 3 master = Tk() 4 5 def callback(): 6 print('我被调用了……') 7 menubar=Menu(master)#一级菜单menbar为顶层框架下的菜单总和 8 9 file =Menu(menubar,tearoff=False)#二级菜单file,属... 阅读全文
posted @ 2017-04-28 00:06 道高一尺 阅读(1369) 评论(0) 推荐(0)
摘要: 1 #menu菜单组件 2 3 from tkinter import * 4 5 master=Tk() 6 7 def callback(): 8 print('你好咯!!') 9 10 m = Menu(master) 11 m.add_command(label='hello',command=callback) 12 m.add_command(lab... 阅读全文
posted @ 2017-04-27 23:24 道高一尺 阅读(496) 评论(0) 推荐(0)
摘要: 1 #自由绘制 2 from tkinter import * 3 4 master=Tk() 5 c=Canvas(master,width=400,height=200) 6 c.pack() 7 8 def paint(event): 9 print(event)#由此可见这里的点击事件其实返回的是一个坐标 10 #通过event获取具体坐标 11 ... 阅读全文
posted @ 2017-04-27 22:16 道高一尺 阅读(417) 评论(0) 推荐(0)
摘要: 1 from tkinter import * 2 import math as m 3 4 root = Tk() 5 6 w = Canvas(root, width=200, height=100, background="red") 7 w.pack() 8 9 center_x = 100 阅读全文
posted @ 2017-04-27 20:41 道高一尺 阅读(475) 评论(0) 推荐(0)
摘要: 1 #Canvas画布绘制矩形和线以及修改删除操作 2 from tkinter import * 3 4 master = Tk() 5 6 c = Canvas(master,width=400,height=200) 7 c.pack() 8 line1=c.create_line(0,100,400,100,fill='black') 9 line2=c.creat... 阅读全文
posted @ 2017-04-27 20:15 道高一尺 阅读(226) 评论(0) 推荐(0)
摘要: 1 #撤销操作 2 from tkinter import * 3 master = Tk() 4 #打开undo按钮 5 text=Text(master,width=30,height=5,undo=True) 6 text.pack() 7 text.insert(INSERT,'I love coding') 8 9 def show(): 10 text.e... 阅读全文
posted @ 2017-04-27 19:39 道高一尺 阅读(626) 评论(0) 推荐(0)
摘要: 1 from tkinter import * 2 3 master=Tk() 4 text=Text(master,width=30,height=5) 5 text.pack() 6 text.insert(INSERT,'I love coding!') 7 start='1.0' 8 9 def getIndex(text,inde): 10 return ... 阅读全文
posted @ 2017-04-27 16:28 道高一尺 阅读(234) 评论(0) 推荐(0)
上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 47 下一页