Skip to content

Panel

Source code in core/treeclass.py
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
class Panel:
    def __init__(self, name: str, tip: str = "", default_closed: bool = False, create_layout: bool = False):
        """ Socket panel

        All group input and output sockets an panels will be created within the current panel

        Parameters
        ----------
        name : str
            Panel title

        tip
            panel description

        default_closed: bool, default=False
            closed by default

        """

        self.tree   = Tree.current_tree()
        self.name   = name
        self.path   = self.tree.get_panel(name)
        self.bpanel = None
        self.create_layout = create_layout

        if self.tree._interface is not None:
            self.bpanel = self.tree._interface.get_panel(self.path, default_closed=default_closed, create=True)
            self.bpanel.description = tip

    def __str__(self):
        return self.path.path

    def push(self):
        self.tree.push_panel(self.path)
        if self.create_layout:
            self.layout = Layout(self.name)
            self.layout.push()

    def pop(self):
        if self.create_layout:
            self.layout.pop()
        self.tree.pop_panel()

    def __enter__(self):
        self.push()
        return self

    def __exit__(self, type, exc_value, traceback):
        self.pop()

    # ====================================================================================================
    # Panel test
    # ====================================================================================================

    @staticmethod
    def _class_test():

        from geonodes import GeoNodes, Panel, Float, Mesh

        with GeoNodes("Panel Class Test"):

            # Create a top level socket
            a = Float(1, name="A")

            # Create in a panel using panel argument
            a += Float(2, name="B Panel", min=0, max=100, panel="Panel")

            # Create in a panel using Panel context
            with Panel("Panel"):
                a += Float(3, "C Panel")
                a += Float(4, "D Sub Panel", panel="Sub Panel")

            # Chaining panel names
            with Panel("Panel > Sub Panel"):
                a += Float(5, name="E Sub Panel")

            with Panel("Panel"):
                with Panel("Other"):
                    a += Float(6, name="F Other")
                    a += Float(7, name="G Last", panel="Last")

            a += Float(8, name="H Last", panel="Panel>Other>Last")

            # Creating homonyms
            with Panel("Panel_1"):
                a += Float(9, name="I 2nd Panel")

            with Panel("Panel_1"):
                with Panel("Sub Panel"):
                    a += Float(10, name="J 2nd Sub Panel")

            # Use the inputs
            Mesh.IcoSphere(radius=a/8).out()

__init__(name, tip='', default_closed=False, create_layout=False)

Socket panel

All group input and output sockets an panels will be created within the current panel

Parameters:

Name Type Description Default
name str

Panel title

required
tip str

panel description

''
default_closed bool

closed by default

False
Source code in core/treeclass.py
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
def __init__(self, name: str, tip: str = "", default_closed: bool = False, create_layout: bool = False):
    """ Socket panel

    All group input and output sockets an panels will be created within the current panel

    Parameters
    ----------
    name : str
        Panel title

    tip
        panel description

    default_closed: bool, default=False
        closed by default

    """

    self.tree   = Tree.current_tree()
    self.name   = name
    self.path   = self.tree.get_panel(name)
    self.bpanel = None
    self.create_layout = create_layout

    if self.tree._interface is not None:
        self.bpanel = self.tree._interface.get_panel(self.path, default_closed=default_closed, create=True)
        self.bpanel.description = tip