I wrote a ID Property Editor. It has a zoomable (Ctrl+Scroll), panable (Middle Mouse) and scrollable GUI (Scroll, Shift+Scroll for horizontal scrolling).
In order to write this editor I wrote yet another little abstraction layer for Blender.Draw (not all widgets are covered). The abstraction layer is included (bpymodules/panzigui.py). This module is far from perfect but it works so far. I tested it with SVN revision 13918.
Hi panzi,
thank you for sharing,
works well, tested on winXP32, full python installed, current 245.15svn.
bugreport:
tar archive something strange - i had little troubles to extract it
idpropertieseditor.py: error in line 44, (? never seen such python construct; is float() something like wrapper class working with string as parameter?):
MIN_FLOAT = float("-infinity")
MAX_FLOAT = float("infinity")
it works after changing to:
MIN_FLOAT = float(300)
MAX_FLOAT = float(700)
my comments/requests for UI design:
change buttons “+”/"-" to “Add”/“Del” to avoid misinterpretation
add scrollbar for better visual feedback and handling
copying multiple properties between objects will be cool
It could be an inspiration for me.
I am working on similar UI project: Data pyBrowser script
The converse to external module as Draw class was my idea too, but it will take me long because i am not experienced in OOP.
Could you look in? Your opinion if the code is transferable to class model will be very appreciated.
On this stage I concentrate more on UI-ergonomic/optimal functionality than perfect code integration. It is still a proof-of-concept and intended as inspiration for other UI coders.
Yeah, the float bounds are problematic. float(“inf”) seems to be platform dependent for some reason. I changed the bounds. I’d like to give no bounds at all to the Number inputs, but that seems to be not possible.
I made some changes to the script. I even implemented scrollbar classes but I do not use them yet because my whole interface is scalable and moveable but such scrollbars should be absolute positioned. I have to adapt my GUI library that such a thing is possible.
Well I wrote at leas 3 other wrappers for Blenders.Draw and still I’m not the least bit satisfied with my wrapper. So such a thing takes a lot of experience. I just now discovered flaws in my design (possibility for absolute positioned widgets and I think it would be better to abstract the x, y, width and height values in a way where you supply some kind of policy object to the widget which calculates the values as needed e.g. from the bounds of the parent widget or the childs or something like that).
So if your design is not good you will end up in rewriting all your code (as I did several times). And if you don’t use OOP but want to switch to it, you will either end up rewriting all your code or you get a mess, inflexible design. Ant that doesn’t even take all the mess about ref-loops and odd behaviours of blender into account. I have to extensively use the weakref module to break parent/child refloops and I had to write some kind of hack to cleanup my data structures after the script ends and/or another file gets loaded (blender seems not to inform a script by an event when the script is quit trough opening another file, but it also does not cleanup pythons whole memory so there will be broken leftover objects that will crash my script the next time I start it…).
Well, you always have to build a good design when you want to deliver a good product.
The problematic thing about GUI development is that there are two designs: The graphical design and the code design. You have not to neglect either of those.
This is very interesting! I made a similar wrapper for my Spyder project. http://blenderartists.org/forum/showthread.php?t=119282
It is unfortunately hopelessly underdocumented, but it automatically places and scales buttons and it can generate events which are dealt with in an overridable way. It is also very ugly. I haven’t had a look at your wrapper yet apart from the screenshot, but I would be interested in combining my wrapper with yours, if that is okay with you.
You can use my code like you want under the conditions that you give attribution to me (it’s enough to write a comment in the source where you use my code that says who is the original author + link to this thread), to publish the source again and to put the same conditions on your derived work (so basically the 3 rules of open source: attribution, make source available, share alike).
But my code is not documented at all, the name “panzigui” is just a working title and I’, still working on scrollbar support (I’m so dumb that I’m not able to implement such an easy feature!!). And I’m planning to refactor the static members out of the Widget class into a separate GUI class (I already have name clashes!). A infrastructure for registering key combinations would also be nice, but I guess I have no time for any of this because the semester already started.
And in the blender developers mailinglist there is rumour about changes in 2.50 that maybe lead to an usable GUI API, so this effort might very well be redundant. Who knows.
Thanks! I will wait till your GUI wrapper is a bit more mature then. Perhaps I will port it to Tkinter so that it can be used in a different window / outside Blender.