In this video, we will be looking at how we can display messages to the user. This can be simple info messages to error messages and more.
You can also use it to debug your scripts and print messages and/or numbers to let you know what is happening.
As always you can follow along and download the template script here.
Alternatively, you can download the finished script here.
To do this is pretty simple and only requires one line of code:
This is placed in the Execute of the Operator.
When the button is pressed, the string we entered "This is a Custom Message" along with an Info Icon will be displayed at the bottom right of Blender:
It will also be displayed in the Info Window.
We can change the type of message that is displayed. For example, should we want to display a caution or warning to the user we simply need to remove 'INFO' and replace it with 'WARNING' like so:
This will change how it is displayed:
Notice how the Color and Icon has changed. This will immediately let the user know that something may be wrong and needs attention.
If you want to display an error message:
If you change it to 'ERROR' it will still change the color and icon like so:
But it will also add a pop up message:
We also use 'PROPERTY' and 'OPERATOR' which again will give us more options to display messages to the user.
If you want to display a property you can do so:
Which would be displayed as:
I hope you find this tutorial helpful and as always thanks for reading!.
No comments:
Post a Comment