Skip to content

Commit

Permalink
Specify initial dimensions for widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
ObaraEmmanuel committed Jan 20, 2022
1 parent eede390 commit fe64646
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
32 changes: 19 additions & 13 deletions docs/custom_widgets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,23 @@ This is a simple compound widget that really just displays the 4 buttons of a
d-pad. To Add this to the studio we would need to define the class with the
metadata. Below are some of the supported metadata.

+------------------+-----------------------+-----------------------------------------------------------+
| Metadata | default | Description |
+------------------+-----------------------+-----------------------------------------------------------+
| *display_name* | name of the meta class| The name used to refer to the widget within the studio |
+------------------+-----------------------+-----------------------------------------------------------+
| *impl* | the meta's super class| The custom widget class |
+------------------+-----------------------+-----------------------------------------------------------+
| *is_container* | False | whether the custom widget allows other widgets to be |
| | | placed within it. |
+------------------+-----------------------+-----------------------------------------------------------+
| *icon* | play | Text identifier to on of the built in icons to be used as |
| | | image identifier for the widget |
+------------------+-----------------------+-----------------------------------------------------------+
+-------------------------+-----------------------+-----------------------------------------------------------+
| Metadata | default | Description |
+-------------------------+-----------------------+-----------------------------------------------------------+
| *display_name* | name of the meta class| The name used to refer to the widget within the studio |
+-------------------------+-----------------------+-----------------------------------------------------------+
| *impl* | the meta's super class| The custom widget class |
+-------------------------+-----------------------+-----------------------------------------------------------+
| *is_container* | False | whether the custom widget allows other widgets to be |
| | | placed within it. |
+-------------------------+-----------------------+-----------------------------------------------------------+
| *icon* | play | Text identifier to on of the built in icons to be used as |
| | | image identifier for the widget |
+-------------------------+-----------------------+-----------------------------------------------------------+
| *initial_dimensions* | Automatic | The initial dimensions of the widget when first placed on |
| | | the design pad provided as a (width, height) tuple |
+-------------------------+-----------------------+-----------------------------------------------------------+


Each of the above metadata is optional and the default will be used if not its
not provided.
Expand All @@ -70,6 +74,7 @@ Below is a sample metadata class for a our D-pad widget
impl = DPad
icon = "gaming"
is_container = False
initial_dimensions = 90, 100
Connecting to the studio
=========================
Expand Down Expand Up @@ -110,6 +115,7 @@ but that is not necessary. Only the metadata class is required to be in the file
impl = DPad
icon = "gaming"
is_container = False
initial_dimensions = 90, 100
Our new custom widget should now be available in the components pane under
the ``custom`` group.
Expand Down
2 changes: 2 additions & 0 deletions studio/lib/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ class Scale(PseudoWidget, tk.Scale):
group = Groups.input
icon = "scale"
impl = tk.Scale
initial_dimensions = 45, 100

def __init__(self, master, id_):
super().__init__(master)
Expand All @@ -219,6 +220,7 @@ class Scrollbar(PseudoWidget, tk.Scrollbar):
group = Groups.widget
icon = "play"
impl = tk.Scrollbar
initial_dimensions = 20, 100

def __init__(self, master, id_):
super().__init__(master)
Expand Down
5 changes: 5 additions & 0 deletions studio/lib/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class LabeledScale(PseudoWidget, ttk.LabeledScale):
group = Groups.input
icon = "scale"
impl = ttk.LabeledScale
initial_dimensions = 150, 40

def __init__(self, master, id_):
super().__init__(master)
Expand Down Expand Up @@ -209,6 +210,7 @@ class Progressbar(PseudoWidget, ttk.Progressbar):
group = Groups.widget
icon = "progressbar"
impl = ttk.Progressbar
initial_dimensions = 200, 20

def __init__(self, master, id_):
super().__init__(master)
Expand Down Expand Up @@ -240,6 +242,7 @@ class Scale(PseudoWidget, ttk.Scale):
group = Groups.input
icon = "scale"
impl = ttk.Scale
initial_dimensions = 150, 20

def __init__(self, master, id_):
super().__init__(master)
Expand All @@ -254,6 +257,7 @@ class Scrollbar(PseudoWidget, ttk.Scrollbar):
group = Groups.widget
icon = "play"
impl = ttk.Scrollbar
initial_dimensions = 20, 100

def __init__(self, master, id_):
super().__init__(master)
Expand All @@ -267,6 +271,7 @@ class Separator(PseudoWidget, ttk.Separator):
group = Groups.widget
icon = "play"
impl = ttk.Separator
initial_dimensions = 150, 1

def __init__(self, master, id_):
super().__init__(master)
Expand Down

0 comments on commit fe64646

Please sign in to comment.