Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# to native line endings on checkout.
*.c text
*.h text
*.py text
*.py text eol=lf

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
Expand Down
2 changes: 2 additions & 0 deletions examples_node_pack/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### __pycache__ folders
__pycache__/
24 changes: 24 additions & 0 deletions examples_node_pack/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <https://unlicense.org>
9 changes: 9 additions & 0 deletions examples_node_pack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# examples_node_pack

A node pack with example nodes, just for demonstrating how to create different kinds of widgets/nodes

They have no other dependency. Just open Nodezator, create a new file and select this folder with the menubar command **Graph > Select node paths**

The nodes have no purpose beyond being used as demonstrations. They do not represent all possibilities regarding widget options, but they are great for beginners.

Also, in case you didn't know it is possible, you can see the source of any user-defined node by selecting it and pressing **<i>**. So if you want to know how any node from this node pack was created all you need to do is create it, select it and press **<i>** to see its source code.
47 changes: 47 additions & 0 deletions examples_node_pack/intfloat/int_float_more/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""Facility for int float entry widget advanced tests."""


### function definition

def int_float_more(

### param 01

int_from_0_to_100 : {
"widget_name" : "int_float_entry",
"widget_kwargs": {
"min_value": 0,
"max_value": 100
},
"type": int
} = 0,

### param 02

int_float_none_def_int : {
"widget_name": "int_float_entry",
"type": (int, float, type(None))
} = 0

):
"""Return the arguments given.

Just a simple node to test advanced options for
usage of the int float entry widget.

Parameters:

- int_from_0_to_100 (int)
this int float entry only accepts ints from 0 to 100.

- int_float_none_def_int (int, float or None)
this int float accepts int, float or None, but the
default value isn't None.
"""
return (
int_from_0_to_100,
int_float_none_def_int
)

### the callable used must also be aliased as 'main'
main_callable = int_float_more
47 changes: 47 additions & 0 deletions examples_node_pack/intfloat/int_float_test/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""Facility for int float entry testing."""


def int_float_test(

### int float entry accepts only integers
int_default_int : int = 0,

### int float entry accepts only integers and None
int_default_none : int = None,

### int float entry accepts only floats
float_default_float : float = 0.0,

### int float entry accepts only floats and None
float_default_None : float = None,

### int float entries accepts ints and floats (only
### the default value is different.

int_float_default_int : (int, float) = 0,
int_float_default_float : (int, float) = 0.0,

### int float entries accepts ints, floats and None
int_float_default_none : (int, float) = None,

### reversing the order of the classes in the tuple
### also works, though it makes no difference (this
### exists so that the user don't bother remembering
### the order)
float_int_default_int : (float, int) = 0

):
"""Return received values."""
return (
int_default_int,
int_default_none,
float_default_float,
float_default_None,
int_float_default_int,
int_float_default_float,
int_float_default_none,
float_int_default_int
)

### callable used must always be aliased to 'main'
main_callable = int_float_test
10 changes: 10 additions & 0 deletions examples_node_pack/more_widgets/checkbutton_test/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""Facility for checkbutton test."""

### function definition

def check_button_test(boolean:bool=False) -> bool:
"""Return received boolean."""
return boolean

### callable used must always be aliased to 'main'
main_callable = check_button_test
19 changes: 19 additions & 0 deletions examples_node_pack/more_widgets/color_button_test/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Facility for demonstrating color button widget."""

def color_button_test(

color: {
"widget_name" : "color_button",
"type": tuple
} = (255, 0, 0)

):
"""Return received color.

The color button attached to the "color" parameter
makes it easy to select any desired color.
"""
return color

### functions used must always be aliased as 'main'
main_callable = color_button_test
27 changes: 27 additions & 0 deletions examples_node_pack/more_widgets/default_holder_test/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Default holder demonstration.

If you just put a default value in a parameter, a default
holder widget will be used. This widget doesn't have the
ability to edit the value and serves only to display
the default value of the parameter.
"""


# function with three parameters, all with default values
# but they don't define widgets, so the values appear
# in the node as default holder widgets, which is just
# greyed out text in the default app theme

def default_holder_test(
a_string = 'a string',
an_integer = 100,
none_value = None,
):

return (
a_string,
an_integer,
none_value,
)

main_callable = default_holder_test
14 changes: 14 additions & 0 deletions examples_node_pack/more_widgets/literal_display_test/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Demonstration of the literal display widget.

The literal display widget does the same as the literal
entry. It is just that it has more space to see the value.
"""

def literal_display_test(
python_literal: {
'widget_name': 'literal_display'
} = ('this', 'is', 'a', 'tuple', 'of', 'values')
):
return python_literal

main_callable = literal_display_test
18 changes: 18 additions & 0 deletions examples_node_pack/more_widgets/literal_entry_test/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Literal entry demonstration.

Can be used to provide any Python literal.
You want.
"""

def literal_entry_test(
python_literal: {
'widget_name': 'literal_entry',
# note that we don't need to provide the
# 'type' key here, since this widget can
# edit a vast number of types (as long as
# the value is a python literal
} = None
):
return python_literal

main_callable = literal_entry_test
22 changes: 22 additions & 0 deletions examples_node_pack/more_widgets/sorting_button_test/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Demonstrating the sorting button widget.

Item can be used to provide sorted collections of a set
of available items.
"""

def sorting_button_test(
sorted_tuple : {
'widget_name': 'sorting_button',
'widget_kwargs': {
'available_items': {
'red',
'green',
'blue',
},
},
'type': tuple
} = ('blue', 'red')
):
return sorted_tuple

main_callable = sorting_button_test
5 changes: 5 additions & 0 deletions examples_node_pack/more_widgets/string_entry_test/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

def string_entry_test(a_string:str='string'):
return a_string

main_callable = string_entry_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""Demonstrating string entry widget with validation.

That is, the user will only be able to leave a value in
the entry if the validation command allows it.

The validation command option can be any callable that,
given the a string, returns True if it is valid and False
otherwise. It can also be the name of any string method
starting with 'is...'.

Below we use 'isidentifier', which means the
str.isidentifier() method is used to validate the
content of the string entry. Now the user can only leave
a value in the string for which str.isidentifier()
returns True. For instance, identifiers in Python cannot
have spaces or start with a digit character, so if you
type such values in the entry and press <Enter> the
entry will not allow it and will instead revert to the
previous value.
"""


def string_entry_validation(

string_with_validation : {

'widget_name': 'string_entry',
'widget_kwargs': {
'validation_command': 'isidentifier'
},
'type': str

} = 'string'

):
return string_with_validation

main_callable = string_entry_validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""Facility for option menu widget testing."""

from itertools import combinations


def option_menu_test(

costant_name: {
'widget_name' : 'option_menu',
'widget_kwargs': {
'options' : ['e', 'inf', 'nan', 'pi']
},
'type': str
} = 'pi',

chosen_combination: {
'widget_name' : 'option_menu',
'widget_kwargs': {
'options': [''.join(tup) for tup in combinations('abcdefgh', 5)]
},
'type': str
} = 'abcde'

):
"""Return math constant specified by name."""
from math import pi, e, inf, nan

constant_value = {
"e" : e,
"inf" : inf,
"nan" : nan,
"pi" : pi
}[constant_name]

return constant_value, chosen_combination

main_callable = option_menu_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

def option_tray_test(

param1: bool = None,
param2: (None, bool) = True,
param3: (type(None), bool) = None,

param4: {
'widget_name' : 'option_tray',
'widget_kwargs' : {
'options' : [False, None, True]
},
'type': (None, bool)
} = None,

param5: {
'widget_name' : 'option_tray',
'widget_kwargs' : {
'options' : ['Red', 'Green', 'Blue']
},
'type': str
} = 'Red',

param6: {
'widget_name' : 'option_tray',
'widget_kwargs' : {
'options' : [1, 10, 100, 500]
},
'type': int
} = 100

):
"""Return tuple with received arguments."""
return (
param1,
param2,
param3,
param4,
param5,
param6
)

main_callable = option_tray_test
Loading