Sha256: 1a91b4124602ada7cbbcdc88aca0493ea579b0e2d7db2ceab48e5535c53dcf67

Contents?: true

Size: 937 Bytes

Versions: 1

Compression:

Stored size: 937 Bytes

Contents

#!/usr/bin/env ruby

require 'rubygems'
require_relative '../../lib/ppcurses.rb'

@app = PPCurses::Application.new

def handle_cancel
  @app.terminate
  @pressed_cancel = true
end

def handle_submit
  @app.terminate
  @pressed_submit = true
end


form = PPCurses::Form.new

first_name = PPCurses::InputElement.new('First Name', 10)
last_name = PPCurses::InputElement.new(' Last Name', 10)
age = PPCurses::InputElement.new_integer_only('       Age', 5)

gender = PPCurses::RadioButtonGroup.new('      Sex', %w(Male Female))
button_pair = PPCurses::ButtonPair.new('Submit', 'Cancel')

button_pair.button1.action = method(:handle_submit)
button_pair.button2.action = method(:handle_cancel)

form.add(first_name)
form.add(last_name)
form.add(age)
form.add(gender)
form.add(button_pair)



@app.content_view = form
@app.launch

if @pressed_cancel
  puts 'The user pressed cancel.'
end

if @pressed_submit
  puts 'The user pressed submit.'
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ppcurses-0.1.2 test/form/simple_form.rb