UI ?

3dslider

New member
Hello,

How to keep UI as Persistent without closing it before for some operation in 3D mesh writing in Python ? Can you help me to make some code on how to keep a simple UI ?

Thanks in advance.
 
Using callbacks on buttons is the easiest method, and only having an "OK" button to end the script.

I'll see if I can't find an example I can post....
 
Thank you Kryslin, I am looking forward your example ! Or maybe better without having an "Ok" button but just a button for some operation in 3D. Like to link with LW 11 making a chess game so keeping UI more persistent.
 
I've got one python script that is persistent, with the OK and Cancel buttons, and it was something of a pain to troubleshoot and get working right. So there's one caveat for you. I'll see if I can't hunt that example down today and get it posted...

*edit* : Ok, the trick to getting a panel with no buttons at all is...
Python:
ui = lwsdk.LWPanels()
panel = ui.create("Your Panel Name")
panel.set_close_callback(ThePanelIsClosing)
"""Other UI Stuff Here"""
panel.open(lwsdk.PANF_NOBUTT)
Line 3 is IMPORTANT! It handles all the tasks you need to handle when closing the panel. Since there's no OK/Cancel buttons, specified by the panel.open flag lwsdk.PANF_NOBUTT.

The other thing to keep in mind is that once you open the panel, it actually reaches the end of the script, and the only way you can do anything is through the button callbacks. I found that you had to have your needed import calls inside every callback function, because process only runs once.

The script is attached as a file, since there is a 10K character limit on postings. You should be able to use any text editor to read it. Unpack the zip, read into a text editor, and be confused. :) I'll try to answer any questions you have.
 

Attachments

  • swa2.zip
    3.8 KB · Views: 183
Last edited:
EDIT : Nice for your script, it works once I have understood. It is great ! thank you !
 
Last edited:
One thing I would recommend is go through the C SDK files regarding the panels and controls.. Then, once armed with class names, go and use the python help() function on those class names. There are also examples under support/plugins/scripts/python in the directory where lightwave is installed. You'll need to set the python console to handle all the output.

A lot of useful features of the Python SDK are not documented (many of these are classes which are returned, an includes the entirety of the UI) in the python docs, and has to be dug out of the example scripts and C SDK, and then helped() out of the lwsdk library. I wish you luck and persistence, you'll need it. :)
 
Back
Top