Skip to content

Instantly share code, notes, and snippets.

@sh4869 sh4869/tweet_gtk2.rb
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.