require 'tk' tkroot=TkRoot.new { title 'hellw word' geometry '300x200' } lb = TkLabel.new(tkroot) do text 'hello' font 'arial 20 bold' pack :padx=>2,:pady=>2,:side=>'top'#使用pack把组件组装在界面中 end lb.bind("Enter"){ lb.text='点击了' } Thread.start do while true lb.text=Time.new.strftime("%Y-%m-%d %H:%M:%S") sleep(1) end end TkButton.new(tkroot){ text '关闭' command {exit} pack :side=>'left',:padx=>10,:pady=>10 } tkroot.mainloop
版权声明:除特别声明外,本站所有文章皆是本站原创,转载请以超链接形式注明出处!