GeDialog layout
-
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 PythonGROUP_ID1=1000
GROUP_ID2=1001
TEXTBOX=1002
BUTTON1=1003
BUTTON2=1004
HNCHECK=1005
CONNECTCHECK=1006
RAILCHECK=1007
GROUPCHECK=1008class 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 Truedef 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 Truedef Command(self, id, msg) :
#handle user input
if id==BUTTON1:
self.Close()
return False
elif id==BUTTON2:
self.Close()
return Truedlg = SettingsDlg()
dlg.Open(c4d.DLG_TYPE_ASYNC, defaultw=500, defaulth=500) -
On 07/03/2013 at 13:40, xxxxxxxx wrote:
This is a script. Not a plugin.
Give it a try and see if it answers your question:import c4d from c4d import gui class YourDialog(gui.GeDialog) : BUTTON_ID = 1001 TEXTBOX_ID = 1002 def CreateLayout(self) : self.AddButton(self.BUTTON_ID, c4d.BFH_SCALE|c4d.BFV_SCALE, 100, 25, "Close Dialog") self.AddMultiLineEditText(self.TEXTBOX_ID, flags=c4d.BFH_CENTER|c4d.BFV_TOP, inith=80, initw=300, style=c4d.DR_MULTILINE_READONLY|c4d.DR_MULTILINE_WORDWRAP) return True def InitValues(self) : #This method initializes things when the plugin starts self.SetString(self.TEXTBOX_ID, "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) : if id==self.BUTTON_ID: self.Close() return True if __name__=='__main__': dlg = YourDialog() dlg.Open(dlgtype=c4d.DLG_TYPE_MODAL, defaultw=400, defaulth=400)
-ScottA
-
On 07/03/2013 at 14:16, xxxxxxxx wrote:
Many thanks; that works much better...
Does anyone else thank that the SDK docs could use some more sample code?
-
On 28/05/2014 at 10:27, xxxxxxxx wrote:
Does it have any example code to begin with??? Lol, I would second that.
-
On 08/07/2014 at 11:40, xxxxxxxx wrote:
Did you have a look in the "examples" folder of the Python Documentation?