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()))
image.png

6. 复选菜单

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • ¥开启¥ 【雷霆战机】 〖http://pan.baidu.com/s/1kVstszX〗 《解压源码后直接用AI...
    小菜c阅读 3,594评论 1 10
  • ¥关闭¥ 【雷霆战机】 〖http://pan.baidu.com/s/1kVstszX〗 《解压源码后直接用AI...
    小菜c阅读 9,613评论 0 19
  • @synthesize和@dynamic分别有什么作用?@property有两个对应的词,一个是 @synthes...
    笔笔请求阅读 533评论 0 1
  • 《情绪管理》 文/六悦王 2080法则告诉我们,一个人遇到的几乎所有的问题都与情绪管理不当有关。情绪像个导...
    六悦茗阅读 267评论 0 0
  • 新乡学院 一杯浮生茶,尝遍世间情 一生一世一双人,半醉半醒半浮生 人们常说:世间有百态。世间百态,每一个都...
    葬月仙阅读 1,392评论 0 1