gtk3
Gtk3 with Ruby
수색…
시작 및 실행
# Like any other ruby code, require gtk3 after installing from "gem install gtk3"
require 'gtk3'
# Like in Rails, you import working functions from a higher class, in this case the GTK Window
class RubyApp < Gtk::Window
# Calling the original method from GTK Window and redefining the defaults
def initialize
super
# Printing window title
set_title "Center"
# Invoking built-in GTK connection and calling destroy to replicate the quit action
signal_connect "destroy" do
Gtk.main_quit
end
# Sets the window size 500px wide by 400px tall
set_default_size 500, 400
# Where the window should be displayed on the screen
set_window_position Gtk::Window::Position::CENTER
# After initialization, show everything
show
end
end
# Call the class, just like any other ruby program
window = RubyApp.new
# GTK method. Runs until destroy is called
Gtk.main
이 파일을 new.rb
로 저장하고 터미널 ruby new.rb
에서 실행 ruby new.rb
Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow