Glimmer DSL for Tk (Ruby Tk Desktop Development GUI Library) v0.0.54 and v0.0.55 just got released with two new samples:
- Hello, Labelframe!: demonstrates the `labelframe` widget, also known as the named group widget, which wraps around a group of other widgets and adds a title to them at the top-left by default
- Hello, Scale!: demonstrates the `scale` widget, which is a scale slider that can be data-bound to a float or integer value
Hello, Labelframe! Screenshot
Hello, Labelframe! Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From: https://github.com/AndyObtiva/glimmer-dsl-tk#hello-labelframe | |
require 'glimmer-dsl-tk' | |
include Glimmer | |
root { | |
title 'Hello, Labelframe!' | |
labelframe { | |
grid column: 0, row: 0, padx: 10, pady: 10 | |
text 'Name:' | |
# labelanchor 'nw' # Default. Other options: 'n', 'ne', 'en', 'e', 'es', 'se', 's', 'sw', 'ws', 'w', 'wn' | |
label { | |
grid column: 0, row: 0, sticky: 'w' | |
text 'First Name:' | |
} | |
entry { | |
grid column: 1, row: 0 | |
width 15 | |
} | |
label { | |
grid column: 0, row: 1, sticky: 'w' | |
text 'Last Name:' | |
} | |
entry { | |
grid column: 1, row: 1 | |
width 15 | |
} | |
} | |
labelframe { | |
grid column: 0, row: 1, padx: 10, pady: 10 | |
text 'Address:' | |
label { | |
grid column: 0, row: 0, sticky: 'w' | |
text 'Street:' | |
} | |
entry { | |
grid column: 1, row: 0 | |
width 15 | |
} | |
label { | |
grid column: 0, row: 1, sticky: 'w' | |
text 'City:' | |
} | |
entry { | |
grid column: 1, row: 1 | |
width 15 | |
} | |
label { | |
grid column: 0, row: 2, sticky: 'w' | |
text 'State:' | |
} | |
entry { | |
grid column: 1, row: 2 | |
width 15 | |
} | |
label { | |
grid column: 0, row: 3, sticky: 'w' | |
text 'Zip:' | |
} | |
entry { | |
grid column: 1, row: 3 | |
width 15 | |
} | |
} | |
labelframe { | |
grid column: 1, row: 0, rowspan: 2, padx: 10, pady: 10 | |
text 'Medical Info:' | |
label { | |
grid column: 0, row: 0, sticky: 'w' | |
text 'Family Doctor:' | |
} | |
entry { | |
grid column: 1, row: 0 | |
width 15 | |
} | |
label { | |
grid column: 0, row: 1, sticky: 'w' | |
text 'Chronic Conditions:' | |
} | |
entry { | |
grid column: 1, row: 1 | |
width 15 | |
} | |
label { | |
grid column: 0, row: 2, sticky: 'w' | |
text 'Past Surgeries:' | |
} | |
entry { | |
grid column: 1, row: 2 | |
width 15 | |
} | |
label { | |
grid column: 0, row: 3, sticky: 'w' | |
text 'Health Insurance Info:' | |
} | |
entry { | |
grid column: 1, row: 3 | |
width 15 | |
} | |
label { | |
grid column: 0, row: 4, sticky: 'w' | |
text 'Dental Insurance Info:' | |
} | |
entry { | |
grid column: 1, row: 4 | |
width 15 | |
} | |
label { | |
grid column: 0, row: 5, sticky: 'w' | |
text 'Diet:' | |
} | |
entry { | |
grid column: 1, row: 5 | |
width 15 | |
} | |
label { | |
grid column: 0, row: 6, sticky: 'w' | |
text 'Exercise:' | |
} | |
entry { | |
grid column: 1, row: 6 | |
width 15 | |
} | |
} | |
}.open |
Hello, Scale! Screenshot
Hello, Scale! Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From: https://github.com/AndyObtiva/glimmer-dsl-tk#hello-scale | |
require 'glimmer-dsl-tk' | |
class HelloScale | |
include Glimmer | |
attr_accessor :scale_value | |
def initialize | |
self.scale_value = 50 | |
end | |
def launch | |
root { | |
text 'Hello, Scale!' | |
label { | |
anchor 'center' | |
text <= [self, :scale_value] | |
} | |
scale { | |
orient 'horizontal' | |
length 200 | |
from 0.0 | |
to 100.0 | |
variable <=> [self, :scale_value, on_write: ->(val) {val.to_i}] | |
} | |
}.open | |
end | |
end | |
HelloScale.new.launch |
Happy Glimmering!
No comments:
Post a Comment