Python bpy.types.Panel() Examples

The following are 13 code examples of bpy.types.Panel(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module bpy.types , or try the search function .
Example #1
Source File: space_view3d.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
def draw(self, context):
        layout = self.layout

        layout.operator("transform.translate")
        layout.operator("transform.rotate")
        layout.operator("transform.resize", text="Scale")

        layout.separator()

        layout.operator("transform.bend", text="Bend")
        layout.operator("transform.shear", text="Shear")
        layout.operator("transform.tosphere", text="To Sphere")
        layout.operator("transform.transform", text="Shrink Fatten").mode = 'GPENCIL_SHRINKFATTEN'


# ********** Panel ********** 
Example #2
Source File: pdt_menus.py    From Precision-Drawing-Tools with GNU General Public License v3.0 6 votes vote down vote up
def ui_width():
    """Return the Width of the UI Panel.

    Args:
        None.

    Returns:
        UI Width.
    """

    area = bpy.context.area
    resolution = bpy.context.preferences.system.ui_scale

    for reg in area.regions:
        if reg.type == "UI":
            region_width = reg.width
    return region_width

# PDT Panel menus
# 
Example #3
Source File: gui.py    From FontSelector_blender_addon with GNU General Public License v3.0 5 votes vote down vote up
def draw(self, context):
        layout = self.layout
        activedata = context.active_object.data
        draw_general_gui(layout, activedata)


# Sequencer Panel GUI 
Example #4
Source File: space_view3d.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def draw(self, context):
        layout = self.layout

        layout.operator("gpencil.interpolate", text="Interpolate")
        layout.operator("gpencil.interpolate_sequence", text="Sequence")


# ********** Panel ********** 
Example #5
Source File: archipack_window.py    From archipack with GNU General Public License v3.0 5 votes vote down vote up
def create(self, context):
        m = bpy.data.meshes.new("Window Panel")
        o = bpy.data.objects.new("Window Panel", m)
        d = m.archipack_window_panel.add()
        d.center = self.center
        d.origin = self.origin
        d.size = self.size
        d.radius = self.radius
        d.frame_y = self.frame_y
        d.frame_x = self.frame_x
        d.curve_steps = self.curve_steps
        d.shape = self.shape
        d.fixed = self.fixed
        d.pivot = self.pivot
        d.angle_y = self.angle_y
        d.side_material = self.side_material
        d.handle = self.handle
        d.handle_model = self.handle_model
        d.handle_altitude = self.handle_altitude
        d.enable_glass = self.enable_glass
        context.scene.objects.link(o)
        o.select = True
        context.scene.objects.active = o
        m = o.archipack_material.add()
        m.category = "window"
        m.material = self.material
        o.show_transparent = True
        o.lock_location = (False, True, True)
        o.lock_rotation = (False, True, False)
        o.lock_scale = (True, True, True)
        d.update(context)
        return o 
Example #6
Source File: archipack_door.py    From archipack with GNU General Public License v3.0 5 votes vote down vote up
def create(self, context):
        """
            expose only basic params in operator
            use object property for other params
        """
        m = bpy.data.meshes.new("Panel")
        o = bpy.data.objects.new("Panel", m)
        d = m.archipack_door_panel.add()
        d.x = self.x
        d.y = self.y
        d.z = self.z
        d.model = self.model
        d.direction = self.direction
        d.chanfer = self.chanfer
        d.panel_border = self.panel_border
        d.panel_bottom = self.panel_bottom
        d.panel_spacing = self.panel_spacing
        d.panels_distrib = self.panels_distrib
        d.panels_x = self.panels_x
        d.panels_y = self.panels_y
        d.handle = self.handle
        context.scene.objects.link(o)
        o.lock_location[0] = True
        o.lock_location[1] = True
        o.lock_location[2] = True
        o.lock_rotation[0] = True
        o.lock_rotation[1] = True
        o.lock_scale[0] = True
        o.lock_scale[1] = True
        o.lock_scale[2] = True
        o.select = True
        context.scene.objects.active = o
        m = o.archipack_material.add()
        m.category = "door"
        m.material = self.material
        d.update(context)
        # MaterialUtils.add_door_materials(o)
        o.lock_rotation[0] = True
        o.lock_rotation[1] = True
        return o 
Example #7
Source File: mol_sim.py    From cellblender with GNU General Public License v2.0 5 votes vote down vote up
def draw(self, context):

        row = self.layout.row()
        row.label ( "Scene Panel Version", icon='COLOR_BLUE' )

        box = self.layout.box() ### Used only as a separator

        app = context.scene.molecule_simulation
        app.draw_layout ( context, self.layout ) 
Example #8
Source File: material.py    From BlendLuxCore with GNU General Public License v3.0 5 votes vote down vote up
def draw(self, context):
        layout = self.layout
        layout.prop(context.material, "pass_index")


# Since we can't disable the original MATERIAL_PT_viewport panel, it makes no sense to add our own
# (see register function below)

#class LUXCORE_PT_settings(MaterialButtonsPanel, Panel):
#    bl_label = "Settings"
#    bl_context = "material"
#    bl_options = {'DEFAULT_CLOSED'}
#
#    @classmethod
#    def poll(cls, context):
#        engine = context.scene.render.engine
#        return context.material and engine == "LUXCORE"
#
#    def draw(self, context):
#        layout = self.layout
#        mat = context.material
#
#        if mat.luxcore.auto_vp_color:
#            split = layout.split(factor=0.8)
#            split.prop(mat.luxcore, "auto_vp_color")
#            row = split.row()
#            row.enabled = not mat.luxcore.auto_vp_color
#            row.prop(mat, "diffuse_color", text="")
#        else:
#            layout.prop(mat.luxcore, "auto_vp_color")
#            layout.prop(mat, "diffuse_color", text="Viewport Color") 
Example #9
Source File: nodes_terrain_analysis_reclassify.py    From BlenderGIS with GNU General Public License v3.0 5 votes vote down vote up
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
		'''
		called for each item of the collection visible in the list
		must handle the three layout types 'DEFAULT', 'COMPACT' and 'GRID'
		data is the object containing the collection (in our case, the scene)
		item is the current drawn item of the collection (in our case a propertyGroup "customItem")
		index is index of the current item in the collection (optional)
		'''
		scn = bpy.context.scene
		mode = scn.analysisMode
		self.use_filter_show = False
		if self.layout_type in {'DEFAULT', 'COMPACT'}:
			if mode == 'ASPECT':
				aspectLabels = self.getAspectLabels()
				split = layout.split(factor=0.2)
				if aspectLabels:
					split.label(text=aspectLabels[item.idx])
				else:
					split.label(text=str(item.idx+1))
				split = split.split(factor=0.4)
				split.prop(item, "color", text="")
				split.prop(item, "val", text="")
			else:
				split = layout.split(factor=0.2)
				#split.label(text=str(index))
				split.label(text=str(item.idx+1))
				split = split.split(factor=0.4)
				split.prop(item, "color", text="")
				split.prop(item, "val", text="")
		elif self.layout_type in {'GRID'}:
			layout.alignment = 'CENTER'


#Make a Panel
######################################### 
Example #10
Source File: space_view3d_quickPrefs.py    From Fluid-Designer with GNU General Public License v3.0 4 votes vote down vote up
def execute(self, context):
        scn=bpy.context.scene
        button=self.button


        if   button=="add":
            gllightpreset_add()
        elif button=="delete":
            if len(scn.quickprefs.gllightpreset)>1:
                gllightpreset_delete()
            else:
                self.report({'INFO'}, "Must have at least 1 Preset")

        elif button=="save":
            gllightpreset_save()
            self.report({'INFO'}, "Saved Preset to Blend File.")
        elif button=="sort":     gllightpreset_sort()
        elif button=="select":   gllightpreset_select()
        elif button=="export":
            gllightpreset_exportsingle(scn.quickprefs.gllightpreset_index, False)
            self.report({'INFO'}, "Exported Preset to: "+scn.quickprefs.gllightpreset_exportfile)
        elif button=="exportall":
            gllightpreset_exportall(1)
            self.report({'INFO'}, "Exported Presets to: "+scn.quickprefs.gllightpreset_exportdirectory)
        elif button=="import":
            if not os.path.isdir(scn.quickprefs.gllightpreset_importfile):
                if not scn.quickprefs.gllightpreset_importdirectory=="":
                    gllightpreset_importsingle(scn.quickprefs.gllightpreset_importfile)
                else:
                    self.report({'INFO'}, "Please choose a valid preset file")
            else:
                self.report({'INFO'}, "Please choose a valid preset file")
        elif button=="importall":
            gllightpreset_importall()
            self.report({'INFO'}, "Imported Presets from: "+scn.quickprefs.gllightpreset_importdirectory)
        elif button=="defaults":
                gllightpreset_addDefault()

        if scn.quickprefs.gllightpreset_index > len(scn.quickprefs.gllightpreset)-1:
            scn.quickprefs.gllightpreset_index = len(scn.quickprefs.gllightpreset)-1

        return {"FINISHED"}

#Panel for tools 
Example #11
Source File: archipack_window.py    From archipack with GNU General Public License v3.0 4 votes vote down vote up
def _synch_childs(self, context, o, linked, childs):
        """
            sub synch childs nodes of linked object
        """

        # remove childs not found on source
        l_childs = self.get_childs_panels(context, linked)
        c_names = [c.data.name for c in childs]
        for c in l_childs:
            try:
                id = c_names.index(c.data.name)
            except:
                self.delete_object(context, c)

        # children ordering may not be the same, so get the right l_childs order
        l_childs = self.get_childs_panels(context, linked)
        l_names = [c.data.name for c in l_childs]
        order = []
        for c in childs:
            try:
                id = l_names.index(c.data.name)
            except:
                id = -1
            order.append(id)

        # add missing childs and update other ones
        for i, child in enumerate(childs):
            if order[i] < 0:
                p = bpy.data.objects.new("Window Panel", child.data)
                context.scene.objects.link(p)
                p.show_transparent = True
                p.lock_location[1] = True
                p.lock_location[2] = True
                p.lock_rotation[1] = True
                p.lock_scale[0] = True
                p.lock_scale[1] = True
                p.lock_scale[2] = True
                p.parent = linked
                p.matrix_world = linked.matrix_world.copy()
                m = p.archipack_material.add()
                m.category = 'window'
                m.material = o.archipack_material[0].material
            else:
                p = l_childs[order[i]]

            self.synch_locks(p)

            # update handle
            handle = self.find_handle(child)
            h = self.find_handle(p)
            if handle is not None:
                if h is None:
                    h = create_handle(context, p, handle.data)
                h.location = handle.location.copy()
            elif h is not None:
                self.delete_object(context, h)

            p.location = child.location.copy()

        # restore context
        context.scene.objects.active = o 
Example #12
Source File: archipack_fence.py    From archipack with GNU General Public License v3.0 4 votes vote down vote up
def get_panel(self, subs, altitude, panel_x, panel_z, sub_offset_x, idmat, verts, faces, matids, uvs):
        n_subs = len(subs)
        if n_subs < 1:
            return
        f = len(verts)
        x0 = sub_offset_x - 0.5 * panel_x
        x1 = sub_offset_x + 0.5 * panel_x
        z0 = 0
        z1 = panel_z
        profile = [Vector((x0, z0)), Vector((x1, z0)), Vector((x1, z1)), Vector((x0, z1))]
        user_path_uv_v = []
        n_sections = n_subs - 1
        n, dz, zl = subs[0]
        p0 = n.p
        v0 = n.v.normalized()
        for s, section in enumerate(subs):
            n, dz, zl = section
            p1 = n.p
            if s < n_sections:
                v1 = subs[s + 1][0].v.normalized()
            dir = (v0 + v1).normalized()
            scale = 1 / cos(0.5 * acos(min(1, max(-1, v0 * v1))))
            for p in profile:
                x, y = n.p + scale * p.x * dir
                z = zl + p.y + altitude
                verts.append((x, y, z))
            if s > 0:
                user_path_uv_v.append((p1 - p0).length)
            p0 = p1
            v0 = v1

        # build faces using Panel
        lofter = Lofter(
            # closed_shape, index, x, y, idmat
            True,
            [i for i in range(len(profile))],
            [p.x for p in profile],
            [p.y for p in profile],
            [idmat for i in range(len(profile))],
            closed_path=False,
            user_path_uv_v=user_path_uv_v,
            user_path_verts=n_subs
            )
        faces += lofter.faces(16, offset=f, path_type='USER_DEFINED')
        matids += lofter.mat(16, idmat, idmat, path_type='USER_DEFINED')
        v = Vector((0, 0))
        uvs += lofter.uv(16, v, v, v, v, 0, v, 0, 0, path_type='USER_DEFINED') 
Example #13
Source File: archipack_stair.py    From archipack with GNU General Public License v3.0 4 votes vote down vote up
def get_panel(self, subs, altitude, panel_x, panel_z, sub_offset_x, idmat, verts, faces, matids, uvs):
        n_subs = len(subs)
        if n_subs < 1:
            return
        f = len(verts)
        x0 = sub_offset_x - 0.5 * panel_x
        x1 = sub_offset_x + 0.5 * panel_x
        z0 = 0
        z1 = panel_z
        profile = [Vector((x0, z0)), Vector((x1, z0)), Vector((x1, z1)), Vector((x0, z1))]
        user_path_uv_v = []
        n_sections = n_subs - 1
        n, dz, zs, zl = subs[0]
        p0 = n.p
        v0 = n.v.normalized()
        for s, section in enumerate(subs):
            n, dz, zs, zl = section
            p1 = n.p
            if s < n_sections:
                v1 = subs[s + 1][0].v.normalized()
            dir = (v0 + v1).normalized()
            scale = 1 / cos(0.5 * acos(min(1, max(-1, v0 * v1))))
            for p in profile:
                x, y = n.p + scale * p.x * dir
                z = zl + p.y + altitude
                verts.append((x, y, z))
            if s > 0:
                user_path_uv_v.append((p1 - p0).length)
            p0 = p1
            v0 = v1

        # build faces using Panel
        lofter = Lofter(
            # closed_shape, index, x, y, idmat
            True,
            [i for i in range(len(profile))],
            [p.x for p in profile],
            [p.y for p in profile],
            [idmat for i in range(len(profile))],
            closed_path=False,
            user_path_uv_v=user_path_uv_v,
            user_path_verts=n_subs
            )
        faces += lofter.faces(16, offset=f, path_type='USER_DEFINED')
        matids += lofter.mat(16, idmat, idmat, path_type='USER_DEFINED')
        v = Vector((0, 0))
        uvs += lofter.uv(16, v, v, v, v, 0, v, 0, 0, path_type='USER_DEFINED')