免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2495 | 回复: 0
打印 上一主题 下一主题

Ruby Tk 使用 Frame 组件 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-01-19 01:09 |只看该作者 |倒序浏览
  1. require 'tk'
  2. top=TkRoot.new{title "Shopping Details"}
  3. fname_label=TkLabel.new(top){
  4.     text "First Name"
  5.     place('relx'=>0.0,'rely'=>0.1)
  6. }
  7. fname_entry=TkEntry.new(top){
  8.     place('relx'=>0.1,'rely'=>0.1)
  9. }
  10. lname_label=TkLabel.new(top){
  11.     text "Last Name"
  12.     place('relx'=>0.0,'rely'=>0.2)
  13. }
  14. lname_entry=TkEntry.new(top){
  15.     place('relx'=>0.1,'rely'=>0.2)
  16. }
  17. age_label=TkLabel.new(top){
  18.     text "Age"
  19.     place('relx'=>0.0,'rely'=>0.3)
  20. }
  21. age_entry=TkEntry.new(top){
  22.     place('relx'=>0.1,'rely'=>0.3)
  23. }
  24. gender_label=TkLabel.new(top){
  25.     text "Gender : "
  26.     place('relx'=>0.0,'rely'=>0.4)
  27. }
  28. radioVar=TkVariable.new
  29.     r1 = TkRadioButton.new(top){
  30.     text "Male"
  31.     variable radioVar
  32.    
  33.     value 1
  34.     place('relx'=>0.1,'rely'=>0.4)
  35. }
  36. r2 = TkRadioButton.new(top){
  37.     text "Female"
  38.     variable radioVar
  39.     value 2
  40.     place('relx'=>0.2,'rely'=>0.4)
  41. }
  42. list = TkListbox.new(top){
  43. place('relx'=>0.8,'rely'=>0.1)
  44. }
  45. list.insert(1," Python")
  46. list.insert(2," Perl")
  47. list.insert(3," C")
  48. list.insert(4," PHP")
  49. list.insert(5," JSP")
  50. list.insert(6," Ruby")
  51. submit=TkButton.new(top){
  52. text "SUBMIT"
  53. command proc {
  54. val=list.curselection()
  55. sel = list.get(val)
  56. Tk.messageBox('message'=>" The book name chosen is #{sel} ")
  57. }
  58. place('relx'=>0.3,'rely'=>0.8)
  59. }
  60. Tk.mainloop
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP