Skip to content

Instantly share code, notes, and snippets.

@rubyon
Last active May 19, 2021 06:35
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 rubyon/142f4bfb9d8965c4aab01e5c1f2ef9d6 to your computer and use it in GitHub Desktop.
Save rubyon/142f4bfb9d8965c4aab01e5c1f2ef9d6 to your computer and use it in GitHub Desktop.
require "gtk3"
builder_file = "#{File.expand_path(File.dirname(__FILE__))}/builder-thread.ui"
builder = Gtk::Builder.new(:file => builder_file)
window = builder.get_object("window")
window.signal_connect("destroy") do
Gtk.main_quit
end
button = builder.get_object("button")
button.signal_connect("clicked") do
Gtk.main_quit
end
def thread(button)
Thread.new do
count = 0
while(true)
button.label="Click to Quit (#{count})"
count = count + 1
sleep(0.1)
end
end
end
thread(button)
Gtk.main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment