Adding an HTML link to a user panel in Blender

Previously, add-on and extension developers could only include an HTML link, such as to a contact form or a website with additional information and documentation, in the add-on/extension’s information section. The link was displayed as a button in the information block in the Preference – Add-ons area. Since Blender 5.2, developers have been able to place HTML links anywhere on the UI panels.

The most convenient way, of course, is to place such links on the user panels of the add-ons/extensions themselves.

An HTML link is added to a panel in the same way as buttons and other interface elements. To add a link, use the “layout.link” command.

As an example, let’s create a test user panel in the 3D viewport area.

And register it in the Blender Python API so it can be viewed and used.

Now, inside the draw() function of our panel, add a link, for example, to a website.

In the “url” parameter, we specify the actual link address. In the “text” parameter, we specify the text representation – the link text that will be shown to the user. And in the “icon” parameter, we can specify an icon from Blender’s standard set, which will be placed to the left of the link.

After adding this command call to the draw() function, the created link will be displayed on our panel.

By default, links are centered horizontally in the middle of the panel. However, we can specify left or right alignment. Let’s add another left-aligned link to the panel.

Our panel class now looks like this:

Now our panel will display two links, one below the other, to the website and to the GitHub repositories.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Newest
Oldest Most Voted