python Tkinter

实现一个个人使用编辑器,记录。

1.实时刷新 -- after

from Tkinter import *

colors = ('red', 'orange', 'yellow', 'green', 'blue', 'purple')

root = Tk()
f = Frame(root, height=200, width=200)
f.color = 0
f['bg'] = colors[f.color]
def foo():
    f.color = (f.color+1)%(len(colors))
    f['bg'] = colors[f.color]
    f.after(500, foo)
f.pack()

#注意是foo 不是foo()
f.after(500, foo)

mainloop()

代码引自:

https://zhidao.baidu.com/question/253342302.html

表格与自动刷新案例:

http://www.cnblogs.com/cllovewxq/p/5776346.html

pyQt样例:

http://www.vnpy.org/basic-tutorial-7.html

Tkintertable

https://pypi.python.org/pypi/tkintertable

2.布局

grid布局

http://blog.shouji-zhushou.com/python-gui-tkinter-grid%E7%BD%91%E6%A0%BC%E5%87%A0%E4%BD%95%E5%B8%83%E5%B1%80%E7%AE%A1%E7%90%86%E5%99%A8%E4%BD%BF%E7%94%A8/

3.Text 文本框

详细教程,解决关于文本高亮,文本替换等众多百思不得解的问题带来启发。

http://botailang.com/blog/302.html

4.Tkinter 事件

http://blog.csdn.net/wjciayf/article/details/50550947

5. Tkinter text正则search并添加tag

#pos1 存储匹配到的字符串起点,countVar为匹配字符串的长度
countVar = StringVar()
pos1 = text.search(r'W(.*?)d', "1.0", END, count=countVar, regexp=True)

print "index: %s + %sc"%(pos1, countVar.get())
text.tag_configure("search", background="green")
text.tag_add("search", pos1, "%s + %sc"%(pos1, countVar.get()))
python Tkinter_第1张图片
image.png

6. 复选菜单

http://www.cnblogs.com/hongten/p/hongten_python_tkinter_checkbutton_menu.html

你可能感兴趣的:(python Tkinter)