Ruby/Tk/TkButton
Материал из Wiki.crossplatform.ru
Add button and label
#!/usr/bin/env ruby require "tk" require "tkextlib/tkimg/jpeg" require "open-uri" photo = open("http://www.crossplatform.ru/style/logo.png", "rb") {|io| io.read} TkRoot.new {title "Sunrise" } TkLabel.new { image TkPhotoImage.new( :data => Tk::BinaryString( photo ) ) width 300 pack } TkLabel.new { font TkFont.new( "verdana 24 bold" ) text "Sunrise at sunset!" pack } TkButton.new { text "Quit" command "exit" pack } Tk.mainloop
Create the main or "root" window
require "tk" root = TkRoot.new button = TkButton.new(root) { text "Hello, World!" command proc { puts "I said, Hello!" } } button.pack Tk.mainloop