본문 바로가기

Coding/cinema4D python

[c4dpython] GUI

GUI

 yes no dialog

 

rvalue = c4d.gui.QuestionDialog("Hello")

 

name = c4d.gui.InputDialog("input:")

 

File Explorer

import c4d

fn = c4d.storage.LoadDialog()
doc = c4d.documemnts.LoadDocument(fn.decode("utf8"))

 

GeDialog example

import c4d
from c4d import gui
#Welcome to the world of Python

GROUP_ID1=1000
TEXTBOX=1001
BUTTON1=1002
BUTTON2=1003

class ExampleDlg(gui.GeDialog):
    
    def CreateLayout(self):
        #creat the layout of the dialog
        self.GroupBegin(GROUP_ID1, c4d.BFH_SCALEFIT, 3, 1)
        self.AddEditText(TEXTBOX, c4d.BFH_SCALEFIT)
        self.AddButton(BUTTON1, c4d.BFH_SCALE, name="MessadeDialog")
        self.AddButton(BUTTON2, c4d.BFH_SCALE, name="Close")
        self.GroupEnd()
        return True

    def InitValues(self):
        #initiate the gadgets with values
        self.SetString(TEXTBOX, "Hello World!")
        return True

    def Command(self, id, msg):
        #handle user input
        if id==BUTTON1:
            gui.MessageDialog(self.GetString(TEXTBOX))
        elif id==BUTTON2:
            self.Close()
        return True


dlg = ExampleDlg()
dlg.Open(c4d.DLG_TYPE_MODAL, defaultw=300, defaulth=50)

참고 자료

maxon gui:

developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d.gui/index.html

 

file explorer: 

developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d.storage/index.html#c4d.storage