c4d.gui
¶
Follow me to the Inheritance diagramm .
Note
Read Introduction into the GUI of Cinema 4D
Note
File dialogs are defined in
c4d.storage
.
GetShortcutCount()
Shortcut2String()
AddShortcut()
GetShortcut()
RemoveShortcut()
LoadShortcutSet()
SaveShortcutSet()
GetMenuResource()
SearchMenuResource()
SearchPluginMenuResource()
SearchPluginSubMenuResource()
UpdateMenus()
c4d.gui.
GetInputState
(
askdevice
,
askchannel
,
res
)
¶
Polls a certain channel of a device for the current input state. If the return value is True , the container stored in res is just like an input event message, otherwise no state was available.
See also
Parameters: |
|
||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
bool |
||||||||||||||||||
Returns: |
True if a state could be retrieved, otherwise False . |
c4d.gui.
GetInputEvent
(
askdevice
,
res
)
¶
Gets the next input event for a certain device from the event queue. If the return value is True , the container stored in res is just like an input event message, otherwise no event was available.
See also
Parameters: |
|
||||
---|---|---|---|---|---|
Return type: |
bool |
||||
Returns: |
True if the event could be retrieved, otherwise False . |
c4d.gui.
MessageDialog
(
text
[
,
type=GEMB_OK
]
)
¶
Display a message dialog with the string as the message:
from c4d import gui gui.MessageDialog("Why do you take baths in milk?'\n'I can't find a cow tall enough for a shower.")
Parameters: |
|
||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
int |
||||||||||||||
Returns: |
Result from the message box. The value for this are:
|
c4d.gui.
QuestionDialog
(
text
)
¶
Opens a standard question dialog with a question mark icon and Yes/No buttons. The text is specified as a string:
from c4d import gui rvalue = gui.QuestionDialog("Do you think I am a dialog?")
Parameters: | text ( str ) – The string to show. |
---|---|
Return type: | bool |
Returns: | True if the user answered Yes, otherwise False . |
c4d.gui.
RenameDialog
(
text
)
¶
Opens a standard rename dialog:
from c4d import gui name = op.GetName() # Get the name of the active object rvalue = gui.RenameDialog(name) # Pass it for rename print rvalue # Returns None if the user aborts the dialog
Parameters: | text ( str ) – The string with the name to change. |
---|---|
Return type: | str |
Returns: | The changed string on success, otherwise None if the user canceled the dialog. |
c4d.gui.
InputDialog
(
text
[
,
preset
]
)
¶
Opens an input dialog which returns the input string.
Return text: | The label string. |
---|---|
Return preset: | The default value which will be written on popup. |
Return type: | str |
Returns: | The input as string. |
c4d.gui.
ColorDialog
(
flags
[
,
col = c4d.Vector()
]
)
¶
Opens a color chooser dialog for the user to select a color. The look of this dialog depends on the operating system.
Parameters: |
|
---|---|
Return type: | |
Returns: |
A
|
c4d.gui.
FontDialog
(
)
¶
Opens a font chooser dialog for the user to select a font. The look of this dialog depends on the operating system.
Return type: | c4d.BaseContainer |
---|---|
Returns: |
A
BaseContainer
with the font settings, otherwise
None
|
c4d.gui.
SelectionListDialog
(
arr, doc[, x][, y]
)
¶
Shows a popup menu with of the given object tuple and lets the user choose an object at the position of the mouse.
Parameters: |
|
---|---|
Return type: |
int |
Returns: |
The user choice, or NOTOK if nothing was selected. |
c4d.gui.
ShowPopupDialog
(
cd
,
bc
,
x
,
y
,
flags=POPUP_RIGHT|POPUP_EXECUTECOMMANDS
)
¶
Displays a popup menu dialog. The menu is defined by adding string items sequentially to a
BaseContainer
. (i.e. the order the items are set in the container determines their order in the menu.) The ID of the string item determines its function.
Here is a complete example of the features:
import c4d from c4d import gui # Declare menu items ID IDM_MENU1 = c4d.FIRST_POPUP_ID IDM_MENU2 = c4d.FIRST_POPUP_ID+1 IDM_MENU3 = c4d.FIRST_POPUP_ID+2 IDM_MENU4 = c4d.FIRST_POPUP_ID+3 IDM_SUBMENU1 = c4d.FIRST_POPUP_ID+10 IDM_SUBMENU2 = c4d.FIRST_POPUP_ID+11 # Main menu menu = c4d.BaseContainer() menu.InsData(IDM_MENU1, 'Item 1') menu.InsData(IDM_MENU2, 'Item 2') menu.InsData(0, '') # Append separator # Sub menu submenu = c4d.BaseContainer() submenu.InsData(1, 'Item 3') # Set submenu title submenu.InsData(IDM_SUBMENU1, 'SubItem 1') submenu.InsData(IDM_SUBMENU2, 'SubItem 2&c&') # Check this subitem menu.SetContainer(IDM_MENU3, submenu) # Set submenu as subcontainer menu.InsData(0, '') # Append separator # Add another item to the menu menu.InsData(IDM_MENU4, 'Item 4&d&') # Disable this item # Finally show popup dialog result = gui.ShowPopupDialog(cd=None, bc=menu, x=300, y=300) print result
A string with ID=0 gives a separator:
menu.InsData(0, ”)
A string with ID=1 sets the name of the menu (used for submenus):
submenu.SetString(1, ‘Text’)
IDs in the range 1000 to 899999 inserts a Cinema 4D command:
menu.SetString(c4d.IDM_COPY, ‘Copy’) menu.SetString(c4d.IDM_PASTE, ‘Paste’)
For a list of IDs, see the c4d_symbols.h file. A special case is the c4d.IDM_CM_CLOSEWINDOW ID that will close the current dialog.
The same applies to plugin IDs of plugins that have a menu entry (everything above 1000000):
menu.SetString(pluginid, ‘Text’)
The IDs that are left, between 900000 ( c4d.FIRST_POPUP_ID ) and 999999, can be used for your own menu items:
ID_MENU1 = c4d.FIRST_POPUP_ID ID_MENU2 = c4d.FIRST_POPUP_ID+1 ID_MENU3 = c4d.FIRST_POPUP_ID+2
Parameters: |
|
||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
int |
||||||||||||||||||
Returns: |
The ID of the selected item, or 0 if nothing was selected. |
c4d.gui.
GeUpdateUI
(
)
¶
Private.
c4d.gui.
SetMousePointer
(
l
)
¶
Sets the type of mouse pointer.
Parameters: |
l
(
int
) –
Values for the mouse pointer image:
|
---|
c4d.gui.
GetShortcutCount
(
)
¶
Gets the global shortcut count.
Return type: | int |
---|---|
Returns: | Number of shortcuts. |
c4d.gui.
Shortcut2String
(
shortqual
,
shortkey
)
¶
Converts a shortcut to a readable string.
Parameters: |
|
---|---|
Return type: |
str |
Returns: |
Shortcut string. |
c4d.gui.
AddShortcut
(
bc
)
¶
Adds the shortcut in bc to the shortcut list.
Parameters: |
bc
(
c4d.BaseContainer
) –
Shortcut to add. These are the IDs:
|
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: | bool | ||||||||||||
Returns: | True if successful, otherwise False . |
c4d.gui.
RemoveShortcut
(
index
)
¶
Removes the shortcut at index .
Parameters: |
index
(
int
) – Shortcut index,
0<=index<
GetShortcutCount()
|
---|---|
Return type: | bool |
Returns: | True if successful, otherwise False . |
c4d.gui.
LoadShortcutSet
(
fn
,
add
)
¶
Loads shortcuts from fn .
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
True if successful, otherwise False . |
c4d.gui.
SaveShortcutSet
(
fn
)
¶
Saves shortcuts to fn .
Parameters: |
fn
(str or
MemoryFileStruct
) – File to save the shortcuts to.
|
---|---|
Return type: | bool |
Returns: | True if successful, otherwise False . |
c4d.gui.
GetMenuResource
(
menuname
)
¶
Gets the menu container of a main menu.
Parameters: | menuname ( str ) – Main menu name, e.g. “M_EDITOR” (the same name as on disk or that you can see in the menu editor). | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: | c4d.BaseContainer | |||||||||||||||||||||||||||
Returns: |
The menu container:
|
c4d.gui.
SearchMenuResource
(
bc
,
searchstr
)
¶
Searches a menu container for a certain plugin command (which is a string identifier, for example “PLUGIN_CMD_1000472” ).
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
True if the command was found, otherwise False . |
c4d.gui.
SearchPluginMenuResource
(
[
identifier=”IDS_EDITOR_PLUGINS”
]
)
¶
Searches for the ‘Plugins’ main category in ‘M_EDITOR’.
Parameters: | identifier ( str ) – The resource identifier. |
---|---|
Return type: | ptr |
Returns: |
The found menu container, or
None
.
Note
To get the actual menu container use
res = gui.SearchPluginMenuResource() bc = c4d.Cast(None, res) |
c4d.gui.
SearchPluginSubMenuResource
(
[identifier=”IDS_EDITOR_PLUGINS”][, bc=None]
)
¶
Searches for the “Plugins” main category in “M_EDITOR” or optionally a submenu specified by bc .
Parameters: |
|
---|---|
Return type: |
ptr |
Returns: |
The found menu container, or None . Note
To get the actual menu container use
res = gui.SearchPluginMenuResource() bc = c4d.Cast(None, res) |
c4d.gui.
UpdateMenus
(
)
¶
Forces a menu update.
c4d.gui.
GetInterfaceIcon
(
type
,
id_x
,
id_y
,
id_w
,
id_h
)
¶
New in version R14.014.
Returns the icon for an interface element.
Parameters: |
|
||||||
---|---|---|---|---|---|---|---|
Return type: |
dict{
bmp
:
|
||||||
Returns: |
The icon ressource data, or None if an error occured. |
c4d.gui.
RegisterIcon
(
lIconID, pBmp[, x=0][, y=0][, w=-1][, h=-1]
)
¶
Registers an icon from a bitmap. Optionally a sub-icon can be specified within an larger image by giving a rectangle from ( x , y ) to ( x+w , y+h ). If no rectangle is specified the whole bitmap is used. The bitmap is internally copied.
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
True if the icon was registered, otherwise False . |
c4d.gui.
GetIcon
(
lIconID
)
¶
Gets an icon registered with
RegisterIcon()
. Similar to
InitResourceBitmap()
:
import c4d from c4d import gui icon = gui.GetIcon(c4d.RESOURCEIMAGE_MOVE) bmp = icon["bmp"] x, y = icon["x"], icon["y"]
Parameters: |
lIconID
(
int
) – The ID of the icon. For a list of possible IDs check out
InitResourceBitmap()
|
---|---|
Return type: |
dict{
bmp
:
BaseBitmap
,
x
: int,
y
: int,
w
: int,
h
: int}
|
Returns: | The information about the icon data. |
c4d.gui.
UnregisterIcon
(
lIconID
)
¶
Unregisters the icon with ID lIconID . Only unregister your own registered icons.
Parameters: | lIconID ( int ) – The ID of the icon. |
---|---|
Return type: | bool |
Returns: | True if the icon was unregistered, otherwise False . |
c4d.gui.
GetShortcut
(
index
)
¶
Gets the shortcut at index .
Parameters: |
index
(
int
) – Shortcut index,
0<=index<
GetShortcutCount
|
---|---|
Return type: | c4d.BaseContainer |
Returns: | The retrieved shortcut. |
c4d.gui.
SizePixChr
(
pixels
,
chars
)
¶
Combines the
SizePix()
and
SizeChr()
functions. The returned value is interpreted as a number of characters/lines plus a number of pixels.
Parameters: |
|
---|---|
Return type: |
int |
Param: |
The size value. |
c4d.gui.
SizePix
(
pixels
)
¶
Bakes a pixel size so that it can be used to specify dialog control dimension.
Parameters: | pixels ( int ) – The pixel dimension. |
---|---|
Return type: | int |
Param: | The size value. |
c4d.gui.
SizeChr
(
chars
)
¶
Bakes a character count so that it can be used to specify dialog control dimension. (How many characters that will fit in a control for widths, and how many standard lines that will fit for heights.)
Parameters: | chars ( int ) – The number of characters. |
---|---|
Return type: | int |
Returns: | The size value. |
c4d.gui.
GeGetScreenDimensions
(
x
,
y
,
whole_screen
)
¶
Returns the screen dimensions in pixels.
Parameters: |
|
||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
dict{ sx1 : int, sy1 : int, sx2 : int, sy2 : int} |
||||||||||||||||
Returns: |
A dictionary with the screen dimensions:
|
c4d.gui.
ActiveObjectManager_SetObject
(
id
,
op
,
flags
[
,
activepage=DescID()
]
)
¶
Sets the currently shown object op in the specified mode.
Note
You only need to use this if you have registered your own mode without a hook. Otherwise the managers will ask for new objects themselves, and listen for events when new objects are selected.
Parameters: |
|
---|