Creating a simple panel
We will start with a simple panel that contains some text and icons, and we will see how to expand this initial idea into a tool that can help manage the objects in the scene.
Our panel is a new class that derives from bpy.types.Panel
. Like operators, panels require some static members to be set; otherwise, they will not work. Similar to operators, panels can have a poll()
class method that states under which conditions the panel can be displayed.
Instead of using the execute
function, panels set up and draw their content via the draw(self,
context)
function.
Since we are adding a new piece to the Blender interface, we will do that inside a new add-on. It’s not mandatory, but it makes it easier to enable and disable our panel.
To keep our code orderly and clean, we will create a new folder for the scripts written for this chapter.
Setting the environment
Let’s create a folder for Chapter 5 in our Visual Studio Code project. Then...