Skip to content

Commit fe64646

Browse files
committed
Specify initial dimensions for widgets
1 parent eede390 commit fe64646

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

docs/custom_widgets.rst

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,23 @@ This is a simple compound widget that really just displays the 4 buttons of a
3939
d-pad. To Add this to the studio we would need to define the class with the
4040
metadata. Below are some of the supported metadata.
4141

42-
+------------------+-----------------------+-----------------------------------------------------------+
43-
| Metadata | default | Description |
44-
+------------------+-----------------------+-----------------------------------------------------------+
45-
| *display_name* | name of the meta class| The name used to refer to the widget within the studio |
46-
+------------------+-----------------------+-----------------------------------------------------------+
47-
| *impl* | the meta's super class| The custom widget class |
48-
+------------------+-----------------------+-----------------------------------------------------------+
49-
| *is_container* | False | whether the custom widget allows other widgets to be |
50-
| | | placed within it. |
51-
+------------------+-----------------------+-----------------------------------------------------------+
52-
| *icon* | play | Text identifier to on of the built in icons to be used as |
53-
| | | image identifier for the widget |
54-
+------------------+-----------------------+-----------------------------------------------------------+
42+
+-------------------------+-----------------------+-----------------------------------------------------------+
43+
| Metadata | default | Description |
44+
+-------------------------+-----------------------+-----------------------------------------------------------+
45+
| *display_name* | name of the meta class| The name used to refer to the widget within the studio |
46+
+-------------------------+-----------------------+-----------------------------------------------------------+
47+
| *impl* | the meta's super class| The custom widget class |
48+
+-------------------------+-----------------------+-----------------------------------------------------------+
49+
| *is_container* | False | whether the custom widget allows other widgets to be |
50+
| | | placed within it. |
51+
+-------------------------+-----------------------+-----------------------------------------------------------+
52+
| *icon* | play | Text identifier to on of the built in icons to be used as |
53+
| | | image identifier for the widget |
54+
+-------------------------+-----------------------+-----------------------------------------------------------+
55+
| *initial_dimensions* | Automatic | The initial dimensions of the widget when first placed on |
56+
| | | the design pad provided as a (width, height) tuple |
57+
+-------------------------+-----------------------+-----------------------------------------------------------+
58+
5559

5660
Each of the above metadata is optional and the default will be used if not its
5761
not provided.
@@ -70,6 +74,7 @@ Below is a sample metadata class for a our D-pad widget
7074
impl = DPad
7175
icon = "gaming"
7276
is_container = False
77+
initial_dimensions = 90, 100
7378
7479
Connecting to the studio
7580
=========================
@@ -110,6 +115,7 @@ but that is not necessary. Only the metadata class is required to be in the file
110115
impl = DPad
111116
icon = "gaming"
112117
is_container = False
118+
initial_dimensions = 90, 100
113119
114120
Our new custom widget should now be available in the components pane under
115121
the ``custom`` group.

studio/lib/legacy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ class Scale(PseudoWidget, tk.Scale):
205205
group = Groups.input
206206
icon = "scale"
207207
impl = tk.Scale
208+
initial_dimensions = 45, 100
208209

209210
def __init__(self, master, id_):
210211
super().__init__(master)
@@ -219,6 +220,7 @@ class Scrollbar(PseudoWidget, tk.Scrollbar):
219220
group = Groups.widget
220221
icon = "play"
221222
impl = tk.Scrollbar
223+
initial_dimensions = 20, 100
222224

223225
def __init__(self, master, id_):
224226
super().__init__(master)

studio/lib/native.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class LabeledScale(PseudoWidget, ttk.LabeledScale):
119119
group = Groups.input
120120
icon = "scale"
121121
impl = ttk.LabeledScale
122+
initial_dimensions = 150, 40
122123

123124
def __init__(self, master, id_):
124125
super().__init__(master)
@@ -209,6 +210,7 @@ class Progressbar(PseudoWidget, ttk.Progressbar):
209210
group = Groups.widget
210211
icon = "progressbar"
211212
impl = ttk.Progressbar
213+
initial_dimensions = 200, 20
212214

213215
def __init__(self, master, id_):
214216
super().__init__(master)
@@ -240,6 +242,7 @@ class Scale(PseudoWidget, ttk.Scale):
240242
group = Groups.input
241243
icon = "scale"
242244
impl = ttk.Scale
245+
initial_dimensions = 150, 20
243246

244247
def __init__(self, master, id_):
245248
super().__init__(master)
@@ -254,6 +257,7 @@ class Scrollbar(PseudoWidget, ttk.Scrollbar):
254257
group = Groups.widget
255258
icon = "play"
256259
impl = ttk.Scrollbar
260+
initial_dimensions = 20, 100
257261

258262
def __init__(self, master, id_):
259263
super().__init__(master)
@@ -267,6 +271,7 @@ class Separator(PseudoWidget, ttk.Separator):
267271
group = Groups.widget
268272
icon = "play"
269273
impl = ttk.Separator
274+
initial_dimensions = 150, 1
270275

271276
def __init__(self, master, id_):
272277
super().__init__(master)

0 commit comments

Comments
 (0)