Sha256: ed0e129dd797046469e8ed0dfd2dde508ac1874e0246fa711c104ff7bfa3061e

Contents?: true

Size: 703 Bytes

Versions: 9

Compression:

Stored size: 703 Bytes

Contents

require 'ffi-tk'

Tk.init

def change_palette(background)
  Tk.set_palette(background)
  @exception.configure(text: '')
rescue Exception => ex
  @exception.configure(text: ex.message)
end

desc = <<DESC
This example shows how Tk can calculate whole palettes from a given background color.
Simply fill the entry field with a color you would like.

For example: "black", "yellow", "#fafafa", or "#f00"

Hit Return to change the color.
DESC

Tk::Label.new(Tk.root, text: desc).pack

@exception = Tk::Label.new(Tk.root).pack
@entry = Tk::Entry.new(Tk.root).pack
@entry.bind('<Return>'){
  change_palette(@entry.get)
  @entry.delete(0, :end)
}

Tk::Button.new(Tk.root, text: 'Exit'){ exit }.pack

Tk.mainloop

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ffi-tk-2010.08.23 example/set_palette.rb
ffi-tk-2010.08 example/set_palette.rb
ffi-tk-2010.06 example/set_palette.rb
ffi-tk-2010.03 example/set_palette.rb
ffi-tk-2010.02 example/set_palette.rb
ffi-tk-2010.01 example/set_palette.rb
ffi-tk-2010.01.02 example/set_palette.rb
ffi-tk-2009.12.14 example/set_palette.rb
ffi-tk-2009.11.29 example/set_palette.rb