On 11/02/2017 at 13:53, xxxxxxxx wrote:
Hello there,
How to update a variable in a dialog "CreateLayout(self)".
in the script below I want to passing the value from the path field or the self.DIRECTORY to the variable "dirs".
import c4d, re, os
from c4d import gui
class Dialog(c4d.gui.GeDialog) :
SELECT_DIR = 40
def CreateLayout(self) :
self.GroupBegin(0,c4d.BFH_SCALEFIT,3,0,"");
self.AddStaticText(0, c4d.BFH_RIGHT, 0, 0, "Path :", c4d.BORDER_NONE)
**self.AddEditText(1, c4d.BFH_SCALEFIT, 250, 15)** **#Path to pass**
self.AddButton(self.SELECT_DIR, flags=c4d.BFH_RIGHT,inith=15, name="...")
self.GroupEnd()
self.AddComboBox(1000, c4d.BFH_SCALEFIT, 0, 15)
self.AddChild(1000,0,"Folders :&i" + str(c4d.RESOURCEIMAGE_OPENED) + "&" )
self.AddChild(1000,0,"")
**dirs = os.listdir(os.path.join( self.GetString(1))) # Passing the path value or the self.DIRECTORY here**
** # or** **:
# dirs = os.listdir(os.path.join(** ** ** ** **self.DIRECTORY****** )) **
id = 2000
for plugin_name in dirs:
self.AddChild(1000,id,plugin_name)
id += 1
return True
def UpdateDlg(self, id) :
self.SetString(1,self.DIRECTORY)
return True
def Command(self, id, msg) :
if id == self.SELECT_DIR:
**self.DIRECTORY** = c4d.storage.LoadDialog(flags=c4d.FILESELECT_DIRECTORY)
self.UpdateDlg(self.GetLong(1000))
return True
def CoreMessage(self, id, msg) :
if id==c4d.EVMSG_CHANGE:
self.UpdateDlg(self.GetBool(self.DIRECTORY))
return True
def main() :
global Dialog
Dialog = Dialog()
Dialog.Open(c4d.DLG_TYPE_MODAL, xpos=700, ypos= 200, defaultw=516, defaulth=10)
return True
if __name__=='__main__':
main()
I want to obtain this result:
Thanks