Class: Gtk::HelloWorld

Inherits:
Box
  • Object
show all
Defined in:
lib/gtk_paradise/examples/gtk2/022_hello_world_in_gtk2_and_bold_font.rb,
lib/gtk_paradise/examples/gtk3/042_hello_world_in_gtk3_and_bold_font.rb

Constant Summary collapse

USE_THIS_FONT =
#

USE_THIS_FONT

#
'Sans Bold 25'

Instance Method Summary collapse

Methods inherited from Box

#add_space, #left_aligned_text, #text

Constructor Details

#initialize(run_already = true) ⇒ HelloWorld

#

initialize

#


21
22
23
24
25
26
27
28
29
# File 'lib/gtk_paradise/examples/gtk2/022_hello_world_in_gtk2_and_bold_font.rb', line 21

def initialize(
    run_already = true
  )
  super('First example')
  set_size_request(400, 400)
  set_border_width(10)
  # set_icon_from_file('/Depot/j/foo.png') # <- You could specify a fav-icon too.
  run if run_already
end

Instance Method Details

#runObject

#

run

#


34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/gtk_paradise/examples/gtk2/022_hello_world_in_gtk2_and_bold_font.rb', line 34

def run
  button = ::Gtk::Button.new('Say hello')
  button.signal_connect(:clicked) { |_widget|
    e 'Hello World!! \\o/'
  }
  button.modify_font(
    Pango::FontDescription.new(USE_THIS_FONT)
  )
  add(button)
  signal_connect(:delete_event) { |_widget| ::Gtk.main_quit }
  show_all
  move(0, 0)
  ::Gtk.main
end