Follow me to the Inheritance diagramm.
Note
Note
File dialogs are stored in c4d.storage.
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. For a list of valid devices and channels, Input Events.
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
True if a state could be retrieved, otherwise False. |
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. For a list of valid devices and channels, please see Input Events.
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
True if the event could be retrieved, otherwise False. |
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:
|
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. |
Opens a dialog to rename a string:
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 False symbols if the user abort the dialog
Parameters: | text (str) – The string |
---|---|
Return type: | str or False |
Returns: | The changed string or False on abort. |
Open 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 |
Open a color chooser dialog for the user to select a color. The look of this dialog depends on the operating system.
Parameters: | flags (int) – Flags. |
---|---|
Return type: | Vector or None |
Returns: | A Vector on success, otherwise None if the user canceled the dialog. |
Open a font chooser dialog for the user to select a font. The look of this dialog depends on the operating system.
Return type: | BaseContainer or None |
---|---|
Returns: | A BaseContainer with the font settings, otherwise None |
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. |
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
ID_MENU1 = c4d.FIRST_POPUP_ID
ID_MENU2 = c4d.FIRST_POPUP_ID+1
ID_MENU3 = c4d.FIRST_POPUP_ID+2
ID_MENU4 = c4d.FIRST_POPUP_ID+3
ID_SUBMENU1 = c4d.FIRST_POPUP_ID+10
ID_SUBMENU2 = c4d.FIRST_POPUP_ID+11
# Main menu
menu = c4d.BaseContainer()
menu.SetString(1, 'Title&d&') # Append &d& to grey title entry out
menu.SetString(ID_MENU1, 'Item 1')
menu.SetString(ID_MENU2, 'Item 2')
menu.SetString(0, "") # Append separator
menu.SetString(ID_MENU3, 'Item 3')
menu.SetString(ID_MENU4, 'Item 4')
# Sub menu
submenu = c4d.BaseContainer()
submenu.SetString(1, 'Item 3'); # Set submenu title
submenu.SetString(ID_SUBMENU1, 'SubItem 1')
submenu.SetString(ID_SUBMENU2, 'SubItem 2&c&') # Check this subitem
menu.SetContainer(ID_MENU3, submenu) # Set submenu as subcontainer
# Finally show popup dialog
result = gui.ShowPopupDialog(cd=None, bc=menu, x=70, y=90)
print result
A string with ID=0 gives a separator:
menu.SetString(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 C4D 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. |
Private.
Set the type of mouse pointer.
Parameters: |
l (int) –
Values for the mouse pointer image:
|
---|
Get the global shortcut count.
Return type: | int |
---|---|
Returns: | Number of shortcuts. |
Converts a shortcut to a readable string.
Parameters: |
|
---|---|
Return type: |
str |
Returns: |
Shortcut string. |
Adds the shortcut in bc to the shortcut list.
Parameters: |
bc (BaseContainer) –
Shortcut to add. These are the IDs:
|
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: | bool | ||||||||||||
Returns: | True if successful, otherwise False. |
Removes the shortcut at index.
Parameters: | index (int) – Shortcut index, 0<=index< GetShortcutCount() |
---|---|
Return type: | bool |
Returns: | True if successful, otherwise False. |
Load shortcuts from fn.
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
True if successful, otherwise False. |
Save shortcuts to fn.
Parameters: |
fn (str or MemoryFileStruct) –
File to save the shortcuts to. Changed in version R13.029: It is now possible to pass a memory file. |
---|---|
Return type: | bool |
Returns: | True if successful, otherwise False. |
New in version R13.016.
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: | BaseContainer | |||||||||||||||||||||||||||
Returns: |
The menu container:
|
New in version R13.016.
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. |
New in version R13.016.
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. |
New in version R13.016.
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. |
New in version R13.016.
Forces a menu update.
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. |
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: | A dictionary with the information about the icon data. |
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. |
Gets the shortcut at index.
Parameters: | index (int) – Shortcut index, 0<=index< GetShortcutCount |
---|---|
Return type: | BaseContainer |
Returns: | The retrieved shortcut. |
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. |
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. |
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. |
New in version R13.016.
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:
|
New in version R13.029.
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: |
|
---|