On 07/03/2013 at 12:26, xxxxxxxx wrote:
Hi all,
I've adapted some sample code from Per Anders' wiki to experiment with the implementation of a settings dialog for a script I'm writing. Getting a decent dialog layout has been a really try-and-fail process so far, but I think I'm finally starting to grok GeDialog...
A couple of things are puzzling to me still:
- Is there a way to get the multiline edit text box to actually be read-only? I thought I had the flags set correctly, but its still editable
- Failing that, is the solution really to add a series of static text boxes?
Here's the script as it stands (Note: it is just a dummy dialog at this point, with none of the hooks back to the functional part of the script).
==========
import c4d
from c4d import gui
#Welcome to the world of Python
GROUP_ID1=1000
GROUP_ID2=1001
TEXTBOX=1002
BUTTON1=1003
BUTTON2=1004
HNCHECK=1005
CONNECTCHECK=1006
RAILCHECK=1007
GROUPCHECK=1008
class SettingsDlg(gui.GeDialog) :
def CreateLayout(self) :
#creat the layout of the dialog
self.GroupBegin(GROUP_ID1, flags=c4d.BFH_SCALEFIT|c4d.BFV_SCALEFIT, cols=1, rows=7, title="AutoNeuron", groupflags=5)
self.GroupBorderSpace(10, 10, 10, 10)
#add multiline edit box for script description
self.AddMultiLineEditText(TEXTBOX, flags=c4d.BFH_CENTER|c4d.BFV_TOP, inith=80, initw=300, style=0000400)
#add check boxes for various construction options
self.AddCheckbox(HNCHECK, flags=c4d.BFH_LEFT, initw=300, inith=0, name="Add HyperNURBs")
self.SetBool(HNCHECK, True)
self.AddCheckbox(CONNECTCHECK, flags=c4d.BFH_LEFT, initw=300, inith=0, name="Add connect object")
self.SetBool(CONNECTCHECK, True)
self.AddCheckbox(RAILCHECK, flags=c4d.BFH_LEFT, initw=300, inith=0, name="Add rail splines (controls thickness)")
self.SetBool(RAILCHECK, True)
self.AddCheckbox(GROUPCHECK, flags=c4d.BFH_LEFT, initw=300, inith=0, name="Group splines")
self.SetBool(GROUPCHECK, True)
self.GroupEnd()
self.GroupBegin(GROUP_ID2, flags=c4d.BFH_RIGHT|c4d.BFV_BOTTOM, cols=2, rows=1, title="", groupflags=5)
self.GroupBorderSpace(10, 10, 10, 10)
self.AddButton(BUTTON1, flags=c4d.BFH_RIGHT, name="Cancel")
self.AddButton(BUTTON2, flags=c4d.BFH_RIGHT, name="Import File")
self.GroupEnd()
return True
def InitValues(self) :
#initiate the gadgets with values
self.SetString(TEXTBOX, "The AutoNeuron script imports neuromorpho SWC files "
"and creates spline-based geometry. Choose modeling options below; "
"if all boxes are unchecked, only the base splines will be added to the scene:")
return True
def Command(self, id, msg) :
#handle user input
if id==BUTTON1:
self.Close()
return False
elif id==BUTTON2:
self.Close()
return True
dlg = SettingsDlg()
dlg.Open(c4d.DLG_TYPE_ASYNC, defaultw=500, defaulth=500)