Tk库的使用(1)
来源:互联网 发布:淘宝开直通车有效果吗 编辑:程序博客网 时间:2024/06/07 09:36
#
# To change this template, choose Tools | Templates
# and open the template in the editor.
# Sample code from Programing Ruby, page 248
require 'tk'
class Draw
def do_press(x, y)
@start_x = x
@start_y = y
@current_line = TkcLine.new(@canvas, x, y, x, y)
end
def do_motion(x, y)
if @current_line
@current_line.coords @start_x, @start_y, x, y
end
end
def do_release(x, y)
if @current_line
@current_line.coords @start_x, @start_y, x, y
@current_line.fill 'black'
@current_line = nil
end
end
def initialize(parent)
@canvas = TkCanvas.new(parent)
@canvas.pack
@start_x = @start_y = 0
@canvas.bind("1", lambda {|e| do_press(e.x, e.y)})
@canvas.bind("B1-Motion",
lambda {|x, y| do_motion(x, y)}, "%x %y")
@canvas.bind("ButtonRelease-1",
lambda {|x, y| do_release(x, y)},
"%x %y")
end
end
root = TkRoot.new { title 'Canvas' }
Draw.new(root)
Tk.mainloop
# To change this template, choose Tools | Templates
# and open the template in the editor.
# Sample code from Programing Ruby, page 248
require 'tk'
class Draw
def do_press(x, y)
@start_x = x
@start_y = y
@current_line = TkcLine.new(@canvas, x, y, x, y)
end
def do_motion(x, y)
if @current_line
@current_line.coords @start_x, @start_y, x, y
end
end
def do_release(x, y)
if @current_line
@current_line.coords @start_x, @start_y, x, y
@current_line.fill 'black'
@current_line = nil
end
end
def initialize(parent)
@canvas = TkCanvas.new(parent)
@canvas.pack
@start_x = @start_y = 0
@canvas.bind("1", lambda {|e| do_press(e.x, e.y)})
@canvas.bind("B1-Motion",
lambda {|x, y| do_motion(x, y)}, "%x %y")
@canvas.bind("ButtonRelease-1",
lambda {|x, y| do_release(x, y)},
"%x %y")
end
end
root = TkRoot.new { title 'Canvas' }
Draw.new(root)
Tk.mainloop
- Tk库的使用(1)
- tk库的使用
- Tk库的使用(2)
- tk-filters 的使用
- Eclipse3.1使用tk.eclipse.plugin.struts的问题
- 菜鸟文档::Tcl/Tk的使用环境
- TK域名的最新使用教程
- Tk/Tkx滚动条的使用
- 使用python Tk的实现tablepanel+treeview
- 使用tk-filters
- tcl/tk脚本中使用大量重复代码的解决方法
- 申请.TK域名,并使用DNSPOD解析的方法
- windows下ruby使用tk编程的方法
- 使用tk.mapper引起的一次框架代码学习
- Qt 使用glaux.h库,glaux.lib(tk.obj) 错误。
- tcl/tk的安装
- tcl/tk的安装
- TK的unclock
- LoadRunner如何在大负载下测试
- Windows 硬件开发人员中心中文网站
- NotSerializableException
- 如何把数据库里的4000条记录的文章内容批量生成静态页html
- linux安装过程示例
- Tk库的使用(1)
- Cool URIs for the Semantic Web学习笔记
- 【转】项目风险管理
- 各种字符编码(GBK,BIG5,Unicode)
- Profile:Sequential Numbering各個選項的含義
- [转]如何使用CTabCtrl来实现多页面属性对话框?
- 将汉字转华为拼音的类
- [转]在对话框中加入属性页
- Tk库的使用(2)