-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_form.cr
More file actions
43 lines (33 loc) · 1008 Bytes
/
basic_form.cr
File metadata and controls
43 lines (33 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require "../../src/uing"
UIng.init
window = UIng::Window.new("Form Example", 300, 200, margined: true)
window.on_closing do
UIng.quit
true
end
form = UIng::Form.new(padded: true)
username_entry = UIng::Entry.new
username_entry.text = "user123"
form.append("Username:", username_entry)
password_entry = UIng::Entry.new(:password)
password_entry.text = "password123" # For demonstration
form.append("Password:", password_entry)
age_spinbox = UIng::Spinbox.new(0, 120)
age_spinbox.value = 25
form.append("Age:", age_spinbox)
volume_slider = UIng::Slider.new(0, 100)
volume_slider.value = 50
form.append("Volume:", volume_slider)
submit_button = UIng::Button.new("Submit")
submit_button.on_clicked do
username = username_entry.text || ""
age = age_spinbox.value
volume = volume_slider.value
message = "Username: #{username}\nAge: #{age}\nVolume: #{volume}"
window.msg_box("Form Submitted", message)
end
form.append("", submit_button)
window.child = form
window.show
UIng.main
UIng.uninit