Tk 8.5 and Python nf.py 中的应用
2015-07-02 10:52
627 查看
import Tkinterroot = Tkinter.Tk()
print Tkinter.TkVersion
def test():
return (1, 2, 3)
root.tk.createcommand("test", test)
x = root.tk.call("test")
print x, type(x)
#python 和 tk 的交互
root.tk.createcommand("test", test): tk.createcommand 把python test 函数注册为tk命令test,
#在python 中执行tk 命令
x = root.tk.call("test")
#nf.py 中的makecommad1
def makecommand1(master, name, func, subst=None, needcleanup=0):
f = Tkinter.CallWrapper(func, subst, master).__call__
master.tk.createcommand(name, f)
return name
#将 func ,subst,master 包装在一起
f=Tkinter.CallWrapper(func, subst, master).__call__
#再将 python 中的f 函数注册tk 的name 命令
master.tk.createcommand(name, f)
#当然这段代码可以不使用包装函数
def makecommand1(master, name, func, subst=None, needcleanup=0):
master.tk.createcommand(name, func)
return name
#也可以运行成功.......
print Tkinter.TkVersion
def test():
return (1, 2, 3)
root.tk.createcommand("test", test)
x = root.tk.call("test")
print x, type(x)
#python 和 tk 的交互
root.tk.createcommand("test", test): tk.createcommand 把python test 函数注册为tk命令test,
#在python 中执行tk 命令
x = root.tk.call("test")
#nf.py 中的makecommad1
def makecommand1(master, name, func, subst=None, needcleanup=0):
f = Tkinter.CallWrapper(func, subst, master).__call__
master.tk.createcommand(name, f)
return name
#将 func ,subst,master 包装在一起
f=Tkinter.CallWrapper(func, subst, master).__call__
#再将 python 中的f 函数注册tk 的name 命令
master.tk.createcommand(name, f)
#当然这段代码可以不使用包装函数
def makecommand1(master, name, func, subst=None, needcleanup=0):
master.tk.createcommand(name, func)
return name
#也可以运行成功.......
相关文章推荐
- python多线程
- Python笔记:virtualenv virtualenvwarpper
- python __str__, __repr__的区别
- Python笔记:datetime模块
- Windows条件下配置Python
- python获得路径
- Python中双引号、单引号和多引号的区别
- python 自定义异常
- Python Windows error code
- python Queue在两个地方
- python删除list元素
- python的读写文件和find函数
- Python 使用 xlrd/xlwt 操作 Excel
- 流动python - 字符串KMP匹配
- Python基础知识回顾
- python实现二叉树和它的七种遍历
- python实现二叉树和它的七种遍历
- python3.4学习笔记(十二) python正则表达式的使用,使用pyspider匹配输出带.html结尾的URL
- python中的BaseManager通信(二)文件二分
- python中的BaseManager通信(一)文件三分