11
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RubyでGUIアプリケーション

Last updated at Posted at 2017-09-05

Rubyで色々GUI環境試してみてruby-gnome2使うのが一番しっくりきたので

環境

  • Mac OS 10.12.6
  • Ruby 2.4.1
  • ruby-gnome2 3.1.8
bash
mkdir gtk3sample
cd gtk3sample
bundle init
vim Gemfile
Gemfile
# frozen_string_literal: true
source 'https://rubygems.org'
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem 'rake'
gem 'gtk3'
bash
bundle install --path vendor/bundle
vim sample.rb
sample.rb
require 'gtk3'

app = Gtk::Application.new('org.gtk.example', :flags_none)

app.signal_connect 'activate' do |application|
  window = Gtk::ApplicationWindow.new(application)
  window.set_title('Window')
  window.set_default_size(200, 200)

  label = Gtk::Label.new('Hello, Gtk3')
  window.add(label)

  window.show_all
end

puts app.run
bash
bundle exec ruby sample.rb

スクリーンショット 2017-09-05 19.33.19.png

参考

11
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?