Support
Quality
Security
License
Reuse
kandi has reviewed glimmer-dsl-swt and discovered the below as its top functions. This is intended to give you an instant insight into glimmer-dsl-swt implemented functionality, and help decide if they suit your requirements.
These features have been suggested. You might see them in a future version of Glimmer. You are welcome to contribute more feature suggestions.
Hello, World! Sample
include Glimmer
shell {
text "Glimmer"
label {
text "Hello, World!"
}
}.open
Hello, Table! Sample
# ... model code precedes
shell {
grid_layout
text 'Hello, Table!'
background_image File.expand_path('hello_table/baseball_park.png', __dir__)
label {
layout_data :center, :center, true, false
text 'BASEBALL PLAYOFF SCHEDULE'
background :transparent
foreground rgb(94, 107, 103)
font name: 'Optima', height: 38, style: :bold
}
combo(:read_only) {
layout_data :center, :center, true, false
selection bind(BaseballGame, :playoff_type)
font height: 14
}
table(:editable) { |table_proxy|
layout_data :fill, :fill, true, true
table_column {
text 'Game Date'
width 150
sort_property :date # ensure sorting by real date value (not `game_date` string specified in items below)
editor :date_drop_down, property: :date_time
}
table_column {
text 'Game Time'
width 150
sort_property :time # ensure sorting by real time value (not `game_time` string specified in items below)
editor :time, property: :date_time
}
table_column {
text 'Ballpark'
width 180
editor :none
}
table_column {
text 'Home Team'
width 150
editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
}
table_column {
text 'Away Team'
width 150
editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
}
table_column {
text 'Promotion'
width 150
# default text editor is used here
}
# Data-bind table items (rows) to a model collection property, specifying column properties ordering per nested model
items bind(BaseballGame, :schedule), column_properties(:game_date, :game_time, :ballpark, :home_team, :away_team, :promotion)
# Data-bind table selection
selection bind(BaseballGame, :selected_game)
# Default initial sort property
sort_property :date
# Sort by these additional properties after handling sort by the column the user clicked
additional_sort_properties :date, :time, :home_team, :away_team, :ballpark, :promotion
menu {
menu_item {
text 'Book'
on_widget_selected {
book_selected_game
}
}
}
}
button {
text 'Book Selected Game'
layout_data :center, :center, true, false
font height: 14
enabled bind(BaseballGame, :selected_game)
on_widget_selected {
book_selected_game
}
}
}.open
# ...
Tetris
# ... more code resides in other files (navigate sample files to learn more)
shell(:no_resize) {
grid_layout {
num_columns 2
make_columns_equal_width false
margin_width 0
margin_height 0
horizontal_spacing 0
}
text 'Glimmer Tetris'
minimum_size 475, 500
image tetris_icon
tetris_menu_bar(game: game)
playfield(game_playfield: game.playfield, playfield_width: playfield_width, playfield_height: playfield_height, block_size: BLOCK_SIZE)
score_lane(game: game, block_size: BLOCK_SIZE) {
layout_data(:fill, :fill, true, true)
}
}
# ...
Pre-requisites
rvm install jruby-9.2.17.0
Option 1: Direct Install
jgem install glimmer-dsl-swt
Option 2: Bundler
gem 'glimmer-dsl-swt', '~> 4.19.0.1'
Glimmer Command
glimmer
Girb (Glimmer irb) Command
girb
Glimmer GUI DSL Syntax
table
Samples
glimmer samples
Packaging & Distribution
glimmer package
QUESTION
Use for loop or multiple prints?
Asked 2022-Mar-01 at 21:31What programming style should I use?
...
print(1)
print(2)
or
...
for i in range(1, 3):
print(i)
The output is the same 1
and on the next line 2
, but which version should I use as a Python programmer?
I mean the first version is redundant or not?
ANSWER
Answered 2022-Mar-01 at 21:31It depends.
There is an old rule "three or more, use for
". (source)
On the other hand, sometimes unrolling a loop can offer a speed-up. (But that's generally more true in C or assembly.)
You should do what makes your program more clear.
For example, in the code below, I wrote out the calculations for the ABD matrix of a fiber reinforced composite laminate, because making nested loops would make it more complex in this case;
for la, z2, z3 in zip(layers, lz2, lz3):
# first row
ABD[0][0] += la.Q̅11 * la.thickness # Hyer:1998, p. 290
ABD[0][1] += la.Q̅12 * la.thickness
ABD[0][2] += la.Q̅16 * la.thickness
ABD[0][3] += la.Q̅11 * z2
ABD[0][4] += la.Q̅12 * z2
ABD[0][5] += la.Q̅16 * z2
# second row
ABD[1][0] += la.Q̅12 * la.thickness
ABD[1][1] += la.Q̅22 * la.thickness
ABD[1][2] += la.Q̅26 * la.thickness
ABD[1][3] += la.Q̅12 * z2
ABD[1][4] += la.Q̅22 * z2
ABD[1][5] += la.Q̅26 * z2
# third row
ABD[2][0] += la.Q̅16 * la.thickness
ABD[2][1] += la.Q̅26 * la.thickness
ABD[2][2] += la.Q̅66 * la.thickness
ABD[2][3] += la.Q̅16 * z2
ABD[2][4] += la.Q̅26 * z2
ABD[2][5] += la.Q̅66 * z2
# fourth row
ABD[3][0] += la.Q̅11 * z2
ABD[3][1] += la.Q̅12 * z2
ABD[3][2] += la.Q̅16 * z2
ABD[3][3] += la.Q̅11 * z3
ABD[3][4] += la.Q̅12 * z3
ABD[3][5] += la.Q̅16 * z3
# fifth row
ABD[4][0] += la.Q̅12 * z2
ABD[4][1] += la.Q̅22 * z2
ABD[4][2] += la.Q̅26 * z2
ABD[4][3] += la.Q̅12 * z3
ABD[4][4] += la.Q̅22 * z3
ABD[4][5] += la.Q̅26 * z3
# sixth row
ABD[5][0] += la.Q̅16 * z2
ABD[5][1] += la.Q̅26 * z2
ABD[5][2] += la.Q̅66 * z2
ABD[5][3] += la.Q̅16 * z3
ABD[5][4] += la.Q̅26 * z3
ABD[5][5] += la.Q̅66 * z3
# Calculate unit thermal stress resultants.
# Hyer:1998, p. 445
Ntx += (la.Q̅11 * la.αx + la.Q̅12 * la.αy + la.Q̅16 * la.αxy) * la.thickness
Nty += (la.Q̅12 * la.αx + la.Q̅22 * la.αy + la.Q̅26 * la.αxy) * la.thickness
Ntxy += (la.Q̅16 * la.αx + la.Q̅26 * la.αy + la.Q̅66 * la.αxy) * la.thickness
# Calculate H matrix (derived from Barbero:2018, p. 181)
sb = 5 / 4 * (la.thickness - 4 * z3 / thickness ** 2)
H[0][0] += la.Q̅s44 * sb
H[0][1] += la.Q̅s45 * sb
H[1][0] += la.Q̅s45 * sb
H[1][1] += la.Q̅s55 * sb
# Calculate E3
c3 += la.thickness / la.E3
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Explore Related Topics
Save this library and start creating your kit