glimmer-dsl-tk 0.0.50 → 0.0.51

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 275b189ef447a6e367ee34c453b2e1b0e3764b7a6bfb44d505287b9aa2ae7918
4
- data.tar.gz: f6a737cfc3db92a03bb0004cae4b9c3fe539c8550836a0bcff04d22519f9d3de
3
+ metadata.gz: 8e73712c604d4ac237f122877e2c4a558570b212fcbf0c192b3c3cccf760cd10
4
+ data.tar.gz: 6bf3e67c3cebdd497c2775d2a7f72cc5efefb68c2116bf61e0511a3fa4c54161
5
5
  SHA512:
6
- metadata.gz: de44c79d480b46078c796ca9bbb83a452c8f8a933f1444c8b83eba5b162e0b5bcbf39a44c63403451146172aeab831a39770a98575b0b715ae2e7e1fde2fac30
7
- data.tar.gz: a33417fbf638f89b71db35778e9e7977a5c137af40334d26a0aa4e52cf399cb643babaad25ed2c49c75ab2898a9cbe35747beeaa66a8a454abb902c7fb359048
6
+ metadata.gz: ffe9c7c5fb555f4419828d34cca5a86aca6c98756afa37d7b83d2c46086e6ca964651b5f256e092a7c1622bb30f86b52c9e3168529f6bc45426ff5cbb9fceb37
7
+ data.tar.gz: aca17f0b69b67fa68ef13ac707a96416a3a88d16bf3607190c8cba553763fc9bebf7054a25db310dd5dd0975746f3f5e0717cba899fe8e9f0eaf0f4870fd2870
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.51
4
+
5
+ - Center application root/toplevel within screen by default (if x or y are specified, they are respected instead)
6
+ - Enhance Hello, Contextual Menu! & Hello, Menu Bar! to display a message box upon selecting a Language/Country
7
+ - Explicitly support all menu item attributes: `activebackground`, `activeforeground`, `background`, `bitmap`, `columnbreak`, `compound`, `font`, `foreground`, `hidemargin`, `indicatoron`, `menu`, `offvalue`, `onvalue`, `selectcolor`, `selectimage`, `state`, `underline`, `value`
8
+
3
9
  ## 0.0.50
4
10
 
5
11
  - Support manual binding of contextual menu by passing `bind: false` option (e.g. `menu(bind: false) {...}` as demonstrated in samples/hello/hello_contextual_menu.rb)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Tk 0.0.50
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Tk 0.0.51
2
2
  ## MRI Ruby Desktop Development GUI Library
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-tk.svg)](http://badge.fury.io/rb/glimmer-dsl-tk)
4
4
  [![Ruby](https://github.com/AndyObtiva/glimmer-dsl-tk/actions/workflows/ruby.yml/badge.svg)](https://github.com/AndyObtiva/glimmer-dsl-tk/actions/workflows/ruby.yml)
@@ -86,6 +86,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems you might be int
86
86
  - [Icon Photo](#icon-photo)
87
87
  - [Root Background](#root-background)
88
88
  - [Toplevel Mac Style](#toplevel-mac-style)
89
+ - [Root/Toplevel Centered Within Screen](#root-toplevel-centered-within-screen)
89
90
  - [Text Defaults](#text-defaults)
90
91
  - [The Grid Geometry Manager](#the-grid-geometry-manager)
91
92
  - [Data-Binding](#data-binding)
@@ -183,7 +184,7 @@ gem install glimmer-dsl-tk
183
184
 
184
185
  Add the following to `Gemfile`:
185
186
  ```
186
- gem 'glimmer-dsl-tk', '0.0.50'
187
+ gem 'glimmer-dsl-tk', '0.0.51'
187
188
  ```
188
189
 
189
190
  And, then run:
@@ -209,6 +210,7 @@ Tk Concepts consist of:
209
210
  - [Widgets](https://tkdocs.com/tutorial/concepts.html#widgets): Widgets are all the things that you see onscreen. In our example, we had a button, an entry, a few labels, and a frame. Others are things like checkboxes, tree views, scrollbars, text areas, and so on. Widgets are what are often referred to as "controls"; you'll also often see them referred to as "windows," particularly in Tk's documentation, a holdover from its X11 roots (so under that terminology, both a toplevel window and things like a button would be called windows).
210
211
  - [Geometry Management](https://tkdocs.com/tutorial/concepts.html#geometry): If you've been playing around creating widgets, you've probably noticed that just by creating them, they didn't end up showing up onscreen. Having things actually put in the onscreen window, and precisely where in the window they show up is a separate step called geometry management.
211
212
  - [Event Handling](https://tkdocs.com/tutorial/concepts.html#events): In Tk, as in most other user interface toolkits, there is an event loop which receives events from the operating system. These are things like button presses, keystrokes, mouse movement, window resizing, and so on.
213
+ - [Themes](https://tkdocs.com/tutorial/styles.html): Tk apps are themable. You can list available themes with `::Tk::Tile::Style.theme_names` (e.g. `["aqua", "clam", "alt", "default", "classic"]` on Mac) and select a theme with `::Tk::Tile::Style.theme_use 'theme_name'` (e.g. `::Tk::Tile::Style.theme_use 'classic'`). Theme defaults to `'clam'` in Linux and `'aqua'` in Mac.
212
214
 
213
215
  Learn more at the official [Tk Concepts Tutorial](https://tkdocs.com/tutorial/concepts.html)
214
216
 
@@ -580,6 +582,10 @@ Tk.tk_call("::tk::unsupported::MacWindowStyle", "style", tk_toplevel_widget, mac
580
582
 
581
583
  More details can be found at the [Hello, Toplevel!](#hello-toplevel) sample.
582
584
 
585
+ #### Root/Toplevel Centered Within Screen
586
+
587
+ `root` and `toplevel` are centered within screen by default unless `x` or `y` attributes are specified, in which case, they are honored instead.
588
+
583
589
  #### Text Defaults
584
590
 
585
591
  `text` widget has these defaults:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.50
1
+ 0.0.51
Binary file
@@ -36,10 +36,13 @@ module Glimmer
36
36
  'Control' => 'Control',
37
37
  }
38
38
 
39
+ ATTRIBUTES = %w[activebackground activeforeground background bitmap columnbreak compound font foreground hidemargin indicatoron menu offvalue onvalue selectcolor selectimage state underline value]
40
+
39
41
  attr_reader :options
40
42
 
41
43
  def initialize(underscored_widget_name, parent_proxy, args, &block)
42
44
  @options = args.last.is_a?(Hash) ? args.last : {}
45
+ @label = @options[:label]
43
46
  super
44
47
  end
45
48
 
@@ -62,17 +65,14 @@ module Glimmer
62
65
  end.join('-')
63
66
  end
64
67
 
65
- def state=(value)
66
- @state = value
67
- configure_menu_item_attribute(state: value)
68
- end
69
-
70
- def state
71
- @state
68
+ def label=(value)
69
+ @last_label = @label
70
+ @label = value
71
+ configure_menu_item_attribute(label: @label)
72
72
  end
73
73
 
74
74
  def label
75
- @options[:label]
75
+ @label
76
76
  end
77
77
 
78
78
  def image=(*args)
@@ -151,9 +151,9 @@ module Glimmer
151
151
 
152
152
  def selection=(value)
153
153
  if value
154
- variable.value = label
154
+ self.value = variable.value = label
155
155
  elsif checkbutton?
156
- variable.value = ''
156
+ self.value = variable.value = ''
157
157
  end
158
158
  end
159
159
 
@@ -170,7 +170,34 @@ module Glimmer
170
170
  elsif quit? && attribute_value_hash[:command]
171
171
  ::Tk.ip_eval("proc ::tk::mac::Quit {} {#{::Tk.install_cmd(attribute_value_hash[:command])}}") if OS.mac?
172
172
  else
173
- @parent_proxy.tk.entryconfigure label, attribute_value_hash
173
+ if attribute_value_hash.keys.first.to_s == 'label'
174
+ @parent_proxy.tk.entryconfigure @last_label, attribute_value_hash
175
+ self.value = variable.value = attribute_value_hash.values.first if variable.value == @last_label
176
+ else
177
+ @parent_proxy.tk.entryconfigure label, attribute_value_hash
178
+ end
179
+ end
180
+ end
181
+
182
+ def has_attributes_attribute?(attribute)
183
+ attribute = attribute.to_s
184
+ attribute = attribute.sub(/\?$/, '').sub(/=$/, '')
185
+ ATTRIBUTES.include?(attribute)
186
+ end
187
+
188
+ def set_attribute(attribute, value)
189
+ if has_attributes_attribute?(attribute)
190
+ configure_menu_item_attribute(attribute => value)
191
+ else
192
+ super
193
+ end
194
+ end
195
+
196
+ def get_attribute(attribute)
197
+ if has_attributes_attribute?(attribute)
198
+ @parent_proxy.tk.entrycget label, attribute
199
+ else
200
+ super
174
201
  end
175
202
  end
176
203
 
@@ -36,6 +36,7 @@ module Glimmer
36
36
  alias escapable? escapable
37
37
 
38
38
  def post_add_content
39
+ center_within_screen unless @x || @y
39
40
  if escapable?
40
41
  on('KeyPress') do |event|
41
42
  if event.keysym == 'Escape'
@@ -93,10 +94,12 @@ module Glimmer
93
94
  end
94
95
 
95
96
  def x=(value)
97
+ @x = value
96
98
  self.geometry = "#{@width || DEFAULT_WIDTH}x#{@height || DEFAULT_HEIGHT}#{value.to_i > 0 ? '+' : '-'}#{value.to_i.abs}#{y_sign}#{abs_y}"
97
99
  end
98
100
 
99
101
  def y=(value)
102
+ @y = value
100
103
  self.geometry = "#{@width || DEFAULT_WIDTH}x#{@height || DEFAULT_HEIGHT}#{x_sign}#{abs_x}#{value.to_i > 0 ? '+' : '-'}#{value.to_i.abs}"
101
104
  end
102
105
 
@@ -110,6 +113,17 @@ module Glimmer
110
113
  end
111
114
  end
112
115
 
116
+ def center_within_screen
117
+ monitor_width, monitor_height = wm_maxsize
118
+ update :idletasks
119
+ current_width = width
120
+ current_height = height
121
+ self.x = (winfo_screenwidth - width) / 2
122
+ self.y = (winfo_screenheight - height) / 2
123
+ self.width = width
124
+ self.height = height
125
+ end
126
+
113
127
  private
114
128
 
115
129
  def sign_number(sign, number)
@@ -92,6 +92,10 @@ root { |r|
92
92
  menu_item(:radiobutton, label: image_name.capitalize) {
93
93
  selection image_name == 'usa'
94
94
  image File.expand_path("images/#{image_name}.png", __dir__)
95
+
96
+ on('command') do
97
+ message_box(parent: r, title: 'Language Selection', message: "You selected the language of #{image_name.capitalize}!")
98
+ end
95
99
  }
96
100
  end
97
101
  }
@@ -102,6 +106,10 @@ root { |r|
102
106
  selection image_name == 'usa'
103
107
  image File.expand_path("images/#{image_name}.png", __dir__)
104
108
  compound 'left'
109
+
110
+ on('command') do
111
+ message_box(parent: r, title: 'Country Selection', message: "You selected the country of #{image_name.capitalize}!")
112
+ end
105
113
  }
106
114
  end
107
115
  }
@@ -157,6 +157,10 @@ root { |r|
157
157
  menu_item(:radiobutton, label: image_name.capitalize) {
158
158
  selection image_name == 'usa'
159
159
  image File.expand_path("images/#{image_name}.png", __dir__)
160
+
161
+ on('command') do
162
+ message_box(parent: r, title: 'Language Selection', message: "You selected the language of #{image_name.capitalize}!")
163
+ end
160
164
  }
161
165
  end
162
166
  }
@@ -167,6 +171,10 @@ root { |r|
167
171
  selection image_name == 'usa'
168
172
  image File.expand_path("images/#{image_name}.png", __dir__)
169
173
  compound 'left'
174
+
175
+ on('command') do
176
+ message_box(parent: r, title: 'Country Selection', message: "You selected the country of #{image_name.capitalize}!")
177
+ end
170
178
  }
171
179
  end
172
180
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-tk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.50
4
+ version: 0.0.51
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-10 00:00:00.000000000 Z
11
+ date: 2021-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer