Sha256: 12487f5a4e31568bf0c8c6bbdb55ed94e119f4fa36db0bb5b5a17b7ddb3ef8ac
Contents?: true
Size: 797 Bytes
Versions: 9
Compression:
Stored size: 797 Bytes
Contents
require 'ffi-tk' Tk.init label = Tk::Label.new(Tk.root, text: 'Press any key to open the dialog') label.pack Tk.root.bind('<Key>'){ question = 'Do you love ruby?' answers = ['Yes', 'No', "I'm not sure"] reply = Tk.dialog('.foo', 'Love is all around', question, 'questhead', 0, *answers) label.configure text: 'Press any key to close the window' text = case reply when 0 "Of course you do!" when 1 "Your loss" when 2 Tk::Button.new(Tk.root, text: 'Show source'){ text = Tk::Text.new(Tk.root) text.insert :end, File.read(__FILE__) text.pack }.pack "If you haven't fallen in love yet, take a look at my source." end Tk::Label.new(Tk.root, text: text).pack Tk.root.bind('<Key>'){ exit } } Tk.mainloop
Version data entries
9 entries across 9 versions & 1 rubygems