Sujeet Kumar wrote:
> Original error: NoMethodError: undefined method `bpressed' for
> Button:Class
>     Error in bgerror: invoked "break" outside of a loop
> when TkButton is pressed.The code is
> require 'tk'
> class Button
>       def bpressed
>      puts "bpressed"
>       end
>
>       root = TkRoot.new(){ title "Buttton"}
>       button =TkButton.new(root){
>            text "Button1"
>            command  {Button::bpressed}
>
>       }.pack
> end
> Tk.mainloop

You are defining bpressed as an instance method, not a class method, of
Button. What you want is this:

class Button
  def self.bpressed
    puts "bpressed"
  end
end