Sha256: e230f6e41d7c7058935e486c5f9f5d4973f4ae436bb01b448d09243f2e5f8808

Contents?: true

Size: 460 Bytes

Versions: 9

Compression:

Stored size: 460 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>'){
  dir = Tk.choose_directory(initialdir: '~', title: 'Choose a directory')

  label.configure text: 'Press any key to close the window'

  if dir
    Tk::Label.new(Tk.root, text: "Selected #{dir}").pack
  else
    Tk::Label.new(Tk.root, text: 'No directory selected').pack
  end

  Tk.root.bind('<Key>'){ exit }
}

Tk.mainloop

Version data entries

9 entries across 9 versions & 1 rubygems

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