Skip to content

Instantly share code, notes, and snippets.

@sh4869
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sh4869/9464926 to your computer and use it in GitHub Desktop.
Save sh4869/9464926 to your computer and use it in GitHub Desktop.
gtk2を使って簡単にツイートするスクリプト
require 'gtk2'
require 'twitter'
CONSUMER_KEY = YOUR_CONSUMER_KEY
CONSUMER_SECRET = YOUR_CONSUMER_SECRET
ACCESS_TOKEN = YOUR_ACCESS_TOKEN
ACCESS_SECRET = YOUR_ACCESS_SECRET
@rest_client = Twitter::REST::Client.new do |config|
config.consumer_key = CONSUMER_KEY
config.consumer_secret = CONSUMER_SECRET
config.access_token = ACCESS_TOKEN
config.access_token_secret = ACCESS_SECRET
end
window = Gtk::Window.new
window.title = "Table"
window.signal_connect("delete_event") do
Gtk.main_quit
false
end
window.border_width = 20
#4x4 のテーブルを作成
table = Gtk::Table.new(4, 4, true)
window.add(table)
#テキストエントリを作成する
entry = Gtk::Entry.new
entry.max_length = 140
table.attach_defaults(entry, 0, 4, 0, 2)
button = Gtk::Button.new("Tweet")
button.signal_connect("clicked") do
text = "#{entry.text}"
@rest_client.update("#{text}")
entry.text = ""
end
table.attach_defaults(button,0,4,2,4)
window.show_all
Gtk.main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment