From: Morton Goldberg Date: 2008-02-23T09:57:04+09:00 Subject: Re: Ruby/Tk On Feb 22, 2008, at 1:29 PM, Isaac Toothyxdip wrote: > so how would you do this? require 'tk' class Example def initialize @number = 1 root = Tk.root root.title('Ruby/Tk Example') @lbl = TkLabel.new(root) { borderwidth 1 relief :solid width 10 pack(:pady => 10) } @lbl.text = @number.to_s @btn = TkButton.new(root) { text "Add One" pack(:pady => 10) } @btn.command = lambda { action } # Set initial window geometry; i.e., size and placement. win_w, win_h, win_y = 200, 85, 50 win_x = (root.winfo_screenwidth - win_w) / 2 root.geometry("#{win_w}x#{win_h}+#{win_x}+#{win_y}") # Set resize permissions. root.resizable(false, false) # Make Cmnd+Q work as expected on OS X. if RUBY_PLATFORM =~ /darwin/ root.bind('Command-q') { root.destroy } end Tk.mainloop end def action @number += 1 @lbl.text = @number.to_s end end Example.new > Ive tried to google a good guide but they are > only like a couple examples and maybe a page. Other then help with > this > problem (which im going to continue to work on while this is posted) i > want to know if anyone has a good guide that has examples but also > explains them. Or maybe a website like > http://www.ruby-doc.org/docs/ProgrammingRuby/ for tk so i can see > all of > the commands like label and button. There are a lot of examples at http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ext/ tk/sample/ Regards, Morton