Blender GUI Easy Provider - Now v2

Go to…
(The latest v2 can be seen in the post #3)
(Here is the first v1)

I made a simple test code in blender python and I wanted to add a GUI to it so that other people can also try it, but I faced kind of a difficulty to write the code for the GUI.I thought that it would be nice if there is a way to add a GUI taking less time and work, and I created a class and a sample code that explains how to use the class, in order to use it as a template for the next time and after.

First, here is the .blend file that includes all the codes needed:

What is the code like?
What you have to do to make your GUI is only to paste the class code on your source code and change the codes marked with the green rectangles as the image above to whatever you like.
It is necessary to write the code in the event handler OnDrawFirst, where you specify the initial values, and the code in OnRedraw, where you specify how the GUI components are. You can add more events, if needed.
This page helped me with creating the codes in OnRedraw.

How does it look?
When you run the code, you will see Toggle and Button, and click the button to exit.

There will be another well-considered template code in the world, I guess. Please give me your idea :):):slight_smile:
I’m wondering whether it woud be interesting to create another classes that allow you to write codes similar to those for UI in Java or .Net.:spin:

I’m wondering whether it woud be interesting to create another classes that allow you to write codes similar to those for UI in Java or .Net.

I searched a little and soon I found kroni has already created his great library to make a Blender GUI in Java AWT way.

It’s nice and it takes less time to start to use it looking at a sample code.

Even though there is already a good solusion with his Java.AWT/Swing-like library to create your GUI of Blender in an easy way, I created my own class library so as to learn python.

My library is based on the previous class BlenderGUIProvider v1, and it allows you to write your GUI code like Java or .Net.

It has two types of classes, one of which represents the UI objects such as Draw.Button, Draw.Slider, and so on. Another provides the feature of flow layout to arrange the UI objects in line horizontally or vertically. You can nest the classes of flow layout and it’s easy to create a list or a table of the UI objects, or more complex structures, without any your coordinate calculations to decide where the objects should be. Using the class decides the positions of the objects automatically and would make your coding easier. Also you can get their background regions colored by only specifying the property Backcolor in the class.

Using the library, I created a sample GUI as seen below.
In this sample GUI, the classes were nested twice. The root class is BControlVFlowLayout and it has BControlHFlowLayout in each rows. Each BControlHFlowLayout has some UI objects, such as Label, String, Number, Button in this case. BControlVFlowLayout and BControlHFlowLayout get colored to see the nest structure.

Here is the .blend file:

If you open the .blend file, you will see the entire source code in the left side and the GUI in the right side.

interesting concept. i will look at it soon.
Are you going to add scrollbars to the auto generated layouts?

thank for sharing

How about putting it somewhere that people do not have to “sign up” to download it. I am already signed up for so many “free” download sites I cannot remember them all.

SHABA1, Strange, I could download it without sign up.

Oh, I didn’t know that. I thought esnips could provide a free hosting services. Mmm… ok, I’m going to look into FAQ pages of esnips. Anyone else who can’t download that file? Whether it can be downloaded or not might depend on what time you download or how much I used the bandwidth…

Anyway, I’m sorry for that. Here is it on another site:
It would be downloadable for free, but many many ads are displayed and it is a bit difficult to find out where to click to download. Do you have any idea with better one?

Thanks for your reply. That’s good idea. I’m going to try to implement that feature the next.

I’ve searched for things that provides the same idea on the internet, and I found four or five good libraries or codes in some threads or homepages. And also I found out many your comments there where those were posted. So I guess you have seen many kinds of things that make building GUI easier and you know more libraries that are good to use. Which do you think is the best?