Sha256: 88d8614b5a573bfca0813088d7cc12fe6e3df943b2b43599e425919e9bcb9f24

Contents?: true

Size: 936 Bytes

Versions: 2

Compression:

Stored size: 936 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

2 entries across 2 versions & 1 rubygems

Version Path
ppcurses-0.1.1 test/form/simple_form.rb
ppcurses-0.1.0 test/form/simple_form.rb