Skip to main content Search the docs ... Ctrl + K Site Navigation Getting Started User Guides API Reference Manuals Application Development Site Navigation Getting Started User Guides API Reference Manuals Application Development Search the docs ... Module guitk # class guitk. constants # BCAlignAuto : int = None # BCAlignLeft : int = None # BCAlignRight : int = None # BCAlignHCenter : int = None # BCAlignJustify : int = None # BCAlignHorizontal_Mask : int = None # BCAlignTop : int = None # BCAlignBottom : int = None # BCAlignVCenter : int = None # BCAlignVJustify : int = None # BCAlignVertical_Mask : int = None # BCAlignCenter : int = None # BCTty : int = None # BCGuiClient : int = None # BCGuiServer : int = None # BCBorder : int = None # BCNoBorder : int = None # BCTopBorder : int = None # BCNoBorderNoMargin : int = None # BCNoButton : int = None # BCLeftButton : int = None # BCRightButton : int = None # BCMiddleButton : int = None # BCMouseButtonMask : int = None # BCShiftButton : int = None # BCControlButton : int = None # BCAltButton : int = None # BCMetaButton : int = None # BCKeypad : int = None # BCKeyButtonMask : int = None # BCNoColumn : int = None # BCAllColumns : int = None # BCLastColumn : int = None # BCCommitDataOtherReason : int = None # BCCommitDataKeyEnterReason : int = None # BCCommitDataKeyTabReason : int = None # BCCommitDataKeyBackTabReason : int = None # BCCaseSensitive : int = None # BCBeginsWith : int = None # BCEndsWith : int = None # BCContains : int = None # BCExactMatch : int = None # BCCursorInvalid : int = None # BCCursorCross : int = None # BCCursorBlank : int = None # BCCursorWhatsThis : int = None # BCCursorWait : int = None # BCCursorMouse : int = None # BCCursorExclamation : int = None # BCCursorArrow : int = None # BCCursorSizeVer : int = None # BCCursorSizeHor : int = None # BCCursorSizeBDiag : int = None # BCCursorSizeFDiag : int = None # BCCursorSizeAll : int = None # BCCursorSplitV : int = None # BCCursorSplitH : int = None # BCCursorPointingHand : int = None # BCCursorForbidden : int = None # BCCursorOpenHand : int = None # BCCursorClosedHand : int = None # BCCursorBusy : int = None # BCCursorZoomIn : int = None # BCCursorZoomOut : int = None # BCCursorIBeam : int = None # BCCursorUpArrow : int = None # BCCursorRotate : int = None # BCCursorZoomRect : int = None # BCCursorZoom : int = None # BCCursorPanRotateZoom : int = None # BCInt : int = None # BCFloat : int = None # BCDouble : int = None # BCString : int = None # BCStringList : int = None # BCBool : int = None # BCInvalid : int = None # BCDate : int = None # BCLeftToRight : int = None # BCRightToLeft : int = None # BCTopToBottom : int = None # BCBottomToTop : int = None # BCDown : int = None # BCUp : int = None # BCDockAuto : int = None # BCDockHorizontal : int = None # BCDockVertical : int = None # BCDockNone : int = None # BCDockLeft : int = None # BCDockRight : int = None # BCDockTop : int = None # BCDockBottom : int = None # BCNoDrag : int = None # BCCopy : int = None # BCMove : int = None # BCAuto : int = None # BCInvalidPosition : int = None # BCAboveTarget : int = None # BCBelowTarget : int = None # BCOnTarget : int = None # BCBoth : int = None # BCNone : int = None # BCNormalEchoMode : int = None # BCNoEchoMode : int = None # BCPasswordMode : int = None # BCEventNone : int = None # BCEventTimer : int = None # BCEventMouseButtonPress : int = None # BCEventMouseButtonRelease : int = None # BCEventMouseButtonDblClick : int = None # BCEventMouseMove : int = None # BCEventKeyPress : int = None # BCEventKeyRelease : int = None # BCEventFocusIn : int = None # BCEventFocusOut : int = None # BCEventEnter : int = None # BCEventLeave : int = None # BCEventPaint : int = None # BCEventMove : int = None # BCEventResize : int = None # BCEventCreate : int = None # BCEventDestroy : int = None # BCEventShow : int = None # BCEventHide : int = None # BCEventClose : int = None # BCEventQuit : int = None # BCEventReparent : int = None # BCEventShowMinimized : int = None # BCEventShowNormal : int = None # BCEventWindowActivate : int = None # BCEventWindowDeactivate : int = None # BCEventShowToParent : int = None # BCEventHideToParent : int = None # BCEventShowMaximized : int = None # BCEventShowFullScreen : int = None # BCEventWheel : int = None # BCEventAccelerator : int = None # BCEventShortcut : int = None # BCEventShortcutOverride : int = None # BCEventWindowEnabled : int = None # BCEventWindowDisabled : int = None # BCEventQuitAll : int = None # BCOnExitHide : int = None # BCOnExitDestroy : int = None # BCEquals : int = None # BCNotEquals : int = None # BCContain : int = None # BCNotContain : int = None # BCLess : int = None # BCLessOrEqual : int = None # BCGreater : int = None # BCGreaterOrEqual : int = None # BCBetween : int = None # BCOpen : int = None # BCSave : int = None # BCSelect : int = None # BCDefaultOptions : int = None # BCNoOverwriteWarning : int = None # BCShowModal : int = None # BCSelectFilesAndDirs : int = None # BCSelectExistingFiles : int = None # BCCheckForPermissions : int = None # BCCheckForReadAccess : int = None # BCCheckForWriteAccess : int = None # BCMultiSelection : int = None # BCSingleSelection : int = None # BCAnyFile : int = None # BCFilesOnly : int = None # BCDirectory : int = None # BCFilesAndDirs : int = None # BCDirsOnly : int = None # BCNoFocus : int = None # BCTabFocus : int = None # BCClickFocus : int = None # BCStrongFocus : int = None # BCWheelFocus : int = None # BCLeftSide : int = None # BCRightSide : int = None # BCHorizontalCenter : int = None # BCIconsFixed : int = None # BCAdjust : int = None # BCAutomatic : int = None # BCSmall : int = None # BCLarge : int = None # BCOffState : int = None # BCOnState : int = None # BCShowIndicator : int = None # BCDontShowIndicator : int = None # BCDontShowIndicatorWhenChildless : int = None # BCIterateAll : int = None # BCIterateSelected : int = None # BCIterateUnselected : int = None # BCIterateVisible : int = None # BCIterateHidden : int = None # BCIterateFirstLevel : int = None # BCBesideIcon : int = None # BCBelowIcon : int = None # BCHistoryOpen : int = None # BCHistorySaveAs : int = None # BCHistorySelect : int = None # BCHistoryFolders : int = None # BCHistoryFiles : int = None # BCHistoryAnything : int = None # BCDelayedOnSelectedClicked : int = None # BCDirectOnClicked : int = None # BCManagedEnable : int = None # BCManagedDisable : int = None # BCManagedShow : int = None # BCManagedHide : int = None # BCMsgWinIgnore : int = None # BCMsgWinAccept : int = None # BCMsgWinReject : int = None # BCMsgWinCustom : int = None # BCQuitAll : int = None # BCEscKey : int = None # BCRetKey : int = None # BCNormalMode : int = None # BCDisabledMode : int = None # BCActiveMode : int = None # BCSelectedMode : int = None # BCClick : int = None # BCPress : int = None # BCNotOpen : int = None # BCReadOnly : int = None # BCWriteOnly : int = None # BCReadWrite : int = None # BCAppend : int = None # BCTruncate : int = None # BCText : int = None # BCUnbuffered : int = None # BCVertical : int = None # BCHorizontal : int = None # BCInDock : int = None # BCOutsideDock : int = None # BCPlot3DX : int = None # BCPlot3DY : int = None # BCPlot3DZ : int = None # BCIdlePriority : int = None # BCLowestPriority : int = None # BCLowPriority : int = None # BCNormalPriority : int = None # BCHighPriority : int = None # BCHighestPriority : int = None # BCTimeCriticalPriority : int = None # BCInheritPriority : int = None # BCRecordingManagerFilterIncoming : int = None # BCRecordingManagerFilterOutgoing : int = None # BCRecursive : int = None # BCNonRecursive : int = None # BCRenameType_None : int = None # BCRenameType_Double : int = None # BCRenameType_Int : int = None # BCRenameType_String : int = None # BCResizeAuto : int = None # BCResizeStretch : int = None # BCResizeKeepSize : int = None # BCResizeFollowSizeHint : int = None # BCMoveModeNoRestriction : int = None # BCMoveModeSameDepth : int = None # BCMulti : int = None # BCSingle : int = None # BCNoSelection : int = None # BCPlain : int = None # BCSunken : int = None # BCRaised : int = None # BCNoFrame : int = None # BCBox : int = None # BCPanel : int = None # BCStyledPanel : int = None # BCHLine : int = None # BCVLine : int = None # BCGroupBoxPanel : int = None # BCWinPanel : int = None # BCToolBarPanel : int = None # BCMenuBarPanel : int = None # BCPopupPanel : int = None # BCLineEditPanel : int = None # BCTabWidgetPanel : int = None # BCSizeAuto : int = None # BCSizeSmall : int = None # BCSizeMedium : int = None # BCSizeLarge : int = None # BCSizeExtraLarge : int = None # BCFixed : int = None # BCMinimum : int = None # BCMaximum : int = None # BCPreferred : int = None # BCExpanding : int = None # BCMinimumExpanding : int = None # BCIgnored : int = None # BCMessageBoxWarning : int = None # BCMessageBoxCritical : int = None # BCMessageBoxInformation : int = None # BCMessageBoxQuestion : int = None # BCNoMenu : int = None # BCInsertRow : int = None # BCInsertColumn : int = None # BCDeleteRow : int = None # BCDeleteColumn : int = None # BCClipboardFunctions : int = None # BCAll : int = None # BCTableNoSelection : int = None # BCTableMulti : int = None # BCTableSingle : int = None # BCTableContiguous : int = None # BCTableSingleRow : int = None # BCTableMultiRow : int = None # BCPlainText : int = None # BCRichText : int = None # BCAutoText : int = None # BCLogText : int = None # BCTicksNoMarks : int = None # BCTicksAbove : int = None # BCTicksLeft : int = None # BCTicksBelow : int = None # BCTicksRight : int = None # BCTicksBoth : int = None # BCNothing : int = None # BCCloseButton : int = None # BCMaximizeButton : int = None # BCMinimizeButton : int = None # BCValidatorNone : int = None # BCValidatorInt : int = None # BCValidatorDouble : int = None # BCWidgetStateNone : int = None # BCWidgetStateInformation : int = None # BCWidgetStateWarning : int = None # BCWidgetStateError : int = None # BCWidgetStateReadOnly : int = None # BCManualMode : int = None # BCMaximumMode : int = None # BCNoWrap : int = None # BCWidgetWidth : int = None # BCFixedPixelWidth : int = None # BCFixedColumnWidth : int = None # BCManualWrap : int = None # BCWordWrap : int = None # BCWrapAnywhere : int = None # BCWrapAtWordBoundaryOrAnywhere : int = None # blank : int = None # guitk. UserWarning ( prompt : str ) → int # Deprecated since version 18.0.0: Use ansa.guitk.BCMessageWindowCreate() instead. This function opens a dialog box to show a warning message to the user. Parameters : prompt str The warning message. Returns : int Always returns 1. Examples import ansa from ansa import guitk def main (): guitk UserWarning ( "Things might go wrong" ) guitk. UserError ( prompt : str ) → int # Deprecated since version Use: ansa.guitk.BCMessageWindowCreate() instead. This function opens a dialog box to show an error message to the user. Parameters : prompt str The error message. Returns : int Always returns 1. Notes Should not be used to display very large messages, since there is an upper limit to the number of characters of the displayed string. Examples import ansa from ansa import guitk def main (): guitk UserError ( "Things went really wrong" ) guitk. UserInput ( title : str , message : str ) → str # This function opens a dialog box to allow the user input a string. Parameters : title str The title. message str, optional The message to the user. Returns : str Returns a string with the value entered by the user. Examples import ansa from ansa import guitk def main (): my_name = guitk UserInput ( "What is your name?" , "Type your name" ) print ( my_name ) if __name__ == "__main__" : main () guitk. UserQuestion ( prompt : str ) → int # Deprecated since version 18.0.0: Use ansa.guitk.BCMessageWindowCreate() instead. This function opens a dialog box prompting the user and waits for a response. Parameters : prompt str The question text. Returns : int Returns 1 on OK, 0 on Cancel. Examples import ansa from ansa import guitk def main (): response = guitk UserQuestion ( "Do you like Rock'n'Roll?" ) guitk. BCVBoxCreate ( p : BCGuiObject ) → BCGuiObject # Creates a Box in parent p having vertical orientation. NOTE: BCVBox is actually a widget not a layout, so for example, it cannot be inserted directly into a BCFrame. This function is not supported under VR mode. Parameters : p BCGuiObject the parent widget or layout. Returns : BCGuiObject the created Box with vertical orientation. See also guitk.BCBoxLayoutCreate , guitk.BCHBoxCreate Examples from ansa import guitk def main (): window = guitk BCWindowCreate ( "H/VBoxCreate Example" , guitk constants BCOnExitDestroy ) checkBoxReverse = guitk BCCheckBoxCreate ( window , "Reverse Main Layout" ) guitk BCCheckBoxSetToggledFunction ( checkBoxReverse , reverseToggled , window ) vBox = guitk BCVBoxCreate ( window ) guitk BCLabelCreate ( vBox , "Vertical Label 1" ) guitk BCLabelCreate ( vBox , "Vertical Label 2" ) guitk BCLabelCreate ( vBox , "Vertical Label 3" ) hBox = guitk BCHBoxCreate ( window ) guitk BCLabelCreate ( hBox , "Horizontal Label 1" ) guitk BCLabelCreate ( hBox , "Horizontal Label 2" ) vBox2 = guitk BCVBoxCreate ( hBox ) guitk BCLabelCreate ( vBox2 , "H-V label 1" ) guitk BCLabelCreate ( vBox2 , "H-V label 2" ) btnFlash = guitk BCPushButtonCreate ( vBox2 , "Flash Box" , btnFlashClicked , vBox2 ) guitk BCShow ( window ) def reverseToggled ( checkBOx , state , window ): layMain = guitk BCLayout ( window ) guitk BCBoxLayoutSetDirection ( layMain , guitk constants BCBottomToTop if state else guitk constants BCTopToBottom , ) return 0 def btnFlashClicked ( btn , box ): guitk BCFlash ( box ) return 0 if __name__ == "__main__" : main () guitk. BCHBoxCreate ( p : BCGuiObject ) → BCGuiObject # Creates a Box in parent p having horizontal orientation. NOTE: BCHBox is actually a widget not a layout, so for example, it cannot be inserted directly into a BCFrame. This function is not supported under VR mode. Parameters : p BCGuiObject the parent widget or layout. Returns : BCGuiObject the created Box with horizontal orientation. See also guitk.BCBoxLayoutCreate , guitk.BCVBoxCreate Examples from ansa import guitk def main (): window = guitk BCWindowCreate ( "H/VBoxCreate Example" , guitk constants BCOnExitDestroy ) checkBoxReverse = guitk BCCheckBoxCreate ( window , "Reverse Main Layout" ) guitk BCCheckBoxSetToggledFunction ( checkBoxReverse , reverseToggled , window ) vBox = guitk BCVBoxCreate ( window ) guitk BCLabelCreate ( vBox , "Vertical Label 1" ) guitk BCLabelCreate ( vBox , "Vertical Label 2" ) guitk BCLabelCreate ( vBox , "Vertical Label 3" ) hBox = guitk BCHBoxCreate ( window ) guitk BCLabelCreate ( hBox , "Horizontal Label 1" ) guitk BCLabelCreate ( hBox , "Horizontal Label 2" ) vBox2 = guitk BCVBoxCreate ( hBox ) guitk BCLabelCreate ( vBox2 , "H-V label 1" ) guitk BCLabelCreate ( vBox2 , "H-V label 2" ) btnFlash = guitk BCPushButtonCreate ( vBox2 , "Flash Box" , btnFlashClicked , vBox2 ) guitk BCShow ( window ) def reverseToggled ( checkBOx , state , window ): layMain = guitk BCLayout ( window ) guitk BCBoxLayoutSetDirection ( layMain , guitk constants BCBottomToTop if state else guitk constants BCTopToBottom , ) return 0 def btnFlashClicked ( btn , box ): guitk BCFlash ( box ) return 0 if __name__ == "__main__" : main () guitk. BCPushButtonCreate ( p : BCGuiObject , text : str , funct : Callable , data : Any = None ) → BCGuiObject # Creates a new BCPushButton in parent p. Parameters : p BCGuiObject the parent widget or layout. text str the text shown on the button. funct Callable the function that will be called when BCPushButton b is activated. See BC_BUTTON_CLICKED_FUNCTION for details. integer BC_BUTTON_CLICKED_FUNCTION(b, data) The function to be called when the BCButton is clicked. Note the difference between click and press. Click means first pressed down and then released when the mouse cursor is inside the button. Press operates when button is pressed down. WARNING: If you need to delete a GUI object (button, list view item etc) inside your call back function, do NOT delete it directly but with the use of a timer (BCTimerSingleShot). Arguments * b : BCGuiObject the BCPushButton, or BCToolButton. * data : Any anything that may be required by the function. Return: Reserved for future use. We recommend you always return 0. data Any, optional anything that may be required in funct. Returns : BCGuiObject the created BCPushButton. See also guitk.BCButtonSetClickedFunction , guitk.BCButtonSetToggleButton Examples import os import ansa from ansa import guitk def main (): w = guitk BCWindowCreate ( "Buttons" , guitk constants BCOnExitDestroy ) # ToolButtons occupy only the space they need tbut = guitk BCToolButtonCreate ( w , "file_open.svg" , "Open" , clickFunction , None ) # whereas PushButtons tend to occupy all available width pbut = guitk BCPushButtonCreate ( w , "Open" , clickFunction , None ) guitk BCButtonSetIconFileName ( pbut , "file_open.svg" ) guitk BCShow ( w ) def clickFunction ( b , data ): print ( "Button clicked" ) return 0 main () guitk. BCToolButtonCreate ( p : BCGuiObject , iconName : str , label : str , funct : Callable , data : Any = None ) → BCGuiObject # Creates a new BCToolButton with parent p. BCToolButtons are usually created inside toolbars. BCToolButtons have not been designed to replace BCPushButtons. With a BCToolButton you can have a button operating with a popupMenu without losing its click function. All properties and functions of BCPushButtons are valid in BCToolButtons as well. NOTE: Embedded icons can be found in Script Editor Help menu. Parameters : p BCGuiObject the parent widget or layout. iconName str the filename of the icon. label str the label of the BCToolButton. funct Callable the function that will be called when BCToolButton b is activated. See BC_BUTTON_CLICKED_FUNCTION for details. integer BC_BUTTON_CLICKED_FUNCTION(b, data) The function to be called when the BCButton is clicked. Note the difference between click and press. Click means first pressed down and then released when the mouse cursor is inside the button. Press operates when button is pressed down. WARNING: If you need to delete a GUI object (button, list view item etc) inside your call back function, do NOT delete it directly but with the use of a timer (BCTimerSingleShot). Arguments * b : BCGuiObject the BCPushButton, or BCToolButton. * data : Any anything that may be required by the function. Return: Reserved for future use. We recommend you always return 0. data Any, optional another pointer to anything that may be required in funct. Returns : BCGuiObject the created BCToolButton. See also guitk.BCButtonSetClickedFunction , guitk.BCButtonSetToggleButton , guitk.BCButtonSetPopup , guitk.BCIconIsValid Examples import os import ansa from ansa import guitk def main (): w = guitk BCWindowCreate ( "Buttons" , guitk constants BCOnExitDestroy ) # ToolButtons occupy only the space they need tbut = guitk BCToolButtonCreate ( w , "file_open.svg" , "Open" , clickFunction , None ) # whereas PushButtons tend to occupy all available width pbut = guitk BCPushButtonCreate ( w , "Open" , clickFunction , None ) guitk BCButtonSetIconFileName ( pbut , "file_open.svg" ) guitk BCShow ( w ) def clickFunction ( b , data ): print ( "Button clicked" ) return 0 main () guitk. BCToolButtonSetDownArrowEnabled ( b : BCGuiObject , enabled : bool ) → None # Function is obsolete. Use BCListViewGetSelectedItem() instead. This function is not supported under VR mode. Parameters : b BCGuiObject the BCToolButton. enabled bool set True to show or False to hide the down arrow. Returns : None guitk. BCToolButtonDownArrowEnabled ( b : BCGuiObject ) → bool # Function is obsolete. Use BCToolButtonIsSideArrowEnabled() instead. This function is not supported under VR mode. Parameters : b BCGuiObject the BCToolButton. Returns : bool guitk. BCToolButtonSetPopupIndicator ( b : BCGuiObject , draw : bool ) → None # Sets the appearance of BCToolButton b when a popup is used and the down-arrow has not been enabled. When popup is used, the appearance of tool button can be seen with a small triangle at the bottom right corner of the BCToolButton. This function is not supported under VR mode. Parameters : b BCGuiObject the BCToolButton. draw bool set True to show (the default) or False to hide the popup indicator. Returns : None See also guitk.BCButtonSetPopup , guitk.BCToolButtonSetSideArrowEnabled Examples from ansa import guitk def main (): window = guitk BCWindowCreate ( "SideArrow and PopupIndicator Example" , guitk constants BCOnExitDestroy ) popupMenu = guitk BCPopupMenuCreate ( window ) guitk BCPopupMenuInsertItem ( popupMenu , "Item 1" , None , None ) guitk BCPopupMenuInsertItem ( popupMenu , "Item 2" , None , None ) hBox0 = guitk BCHBoxCreate ( window ) guitk BCLabelCreate ( hBox0 , "Default" ) toolButtonDefault = guitk BCToolButtonCreate ( hBox0 , "filter.svg" , "ToolButton" , None , None ) print ( "ToolButtonSideArrow Default = " + str ( guitk BCToolButtonIsSideArrowEnabled ( toolButtonDefault )) ) guitk BCButtonSetPopup ( toolButtonDefault , popupMenu ) hBox1 = guitk BCHBoxCreate ( window ) guitk BCLabelCreate ( hBox1 , "No Side Arrow" ) toolButtonNoSideArrow = guitk BCToolButtonCreate ( hBox1 , "filter.svg" , "ToolButton" , None , None ) guitk BCToolButtonSetSideArrowEnabled ( toolButtonNoSideArrow , False ) guitk BCButtonSetPopup ( toolButtonNoSideArrow , popupMenu ) hBox2 = guitk BCHBoxCreate ( window ) guitk BCLabelCreate ( hBox2 , "No Popup Indicator" ) toolButtonNoPopupIndicator = guitk BCToolButtonCreate ( hBox2 , "filter.svg" , "ToolButton" , None , None ) # False Popup Indicator has no Effect with Side Arrow Enabled guitk BCToolButtonSetSideArrowEnabled ( toolButtonNoPopupIndicator , False ) guitk BCToolButtonSetPopupIndicator ( toolButtonNoPopupIndicator , False ) guitk BCButtonSetPopup ( toolButtonNoPopupIndicator , popupMenu ) guitk BCShow ( window ) if __name__ == "__main__" : main () guitk. BCButtonSetClickedFunction ( b : BCGuiObject , funct : Callable , data : Any = None ) → None # Sets the function called when an existing button is pressed. Parameters : b BCGuiObject the BCPushButton. funct Callable the function that will be called when BCPushButton b is activated. See BC_BUTTON_CLICKED_FUNCTION for details. integer BC_BUTTON_CLICKED_FUNCTION(b, data) The function to be called when the BCButton is clicked. Note the difference between click and press. Click means first pressed down and then released when the mouse cursor is inside the button. Press operates when button is pressed down. WARNING: If you need to delete a GUI object (button, list view item etc) inside your call back function, do NOT delete it directly but with the use of a timer (BCTimerSingleShot). Arguments * b : BCGuiObject the BCPushButton, or BCToolButton. * data : Any anything that may be required by the function. Return: Reserved for future use. We recommend you always return 0. data Any, optional another pointer to anything that may be required in funct. Returns : None See also guitk.BCButtonAddManagedWidget , guitk.BCButtonSetToggledFunction , guitk.BCButtonRunClickFunction , guitk.BCBlockCallBackFunctions Examples from ansa import guitk def main (): window = guitk BCWindowCreate ( "Button" , guitk constants BCOnExitDestroy ) pushBtn = guitk BCPushButtonCreate ( window , "Button" , None , None ) # Change BCPushbutton's function to call on click. guitk BCButtonSetClickedFunction ( pushBtn , clickFunction , None ) label = guitk BCLabelCreate ( window , "Appeared after click" ) guitk BCPushButtonSetFlat ( pushBtn , True ) # BCPushbutton manages BCLabel automatically when clicked guitk BCButtonAddManagedWidget ( pushBtn , label , guitk constants BCManagedShow , guitk constants BCManagedHide ) funct_found = guitk BCButtonRunClickFunction ( pushBtn ) if funct_found == - 1 : print ( "Button's callback function not found." ) else : print ( "Callback function called." ) guitk BCShow ( window ) def clickFunction ( button , data ): print ( "Button clicked." ) return 0 if __name__ == "__main__" : main () guitk. BCButtonSetToggleButton ( b : BCGuiObject , toggle : bool ) → None # Makes BCPushButton b a toggle button. Toggle buttons are BCPushButtons or BCToolButtons that once pressed, remain pressed until the user depresses them. It can be seen as On/Off states. Parameters : b BCGuiObject the button as returned by BCPushButtonCreate() or BCToolButtonCreate() toggle bool if True, the BCPushButton becomes a toggle button, otherwise it becomes a normal button. NOTE: Any BCButtonSetClickedFunction() set will be disabled by this function. You should also use BCButtonSetToggledFunction(). Returns : None See also guitk.BCButtonToggle , guitk.BCButtonSetToggledFunction , guitk.BCButtonIsToggleButton Examples import os import ansa from ansa import guitk def main (): w = guitk BCWindowCreate ( "Buttons" , guitk constants BCOnExitDestroy ) # Although all Buttons can display a PopupMenu... lay_menu = guitk BCPopupMenuCreate ( w ) guitk BCPopupMenuInsertItemWithIcon ( lay_menu , "Layout 1x1" , "mdi_windows_layout_1x1.svg" , itemFunction ) guitk BCPopupMenuInsertItemWithIcon ( lay_menu , "Layout 2x1" , "mdi_windows_layout_2x1.svg" , itemFunction ) menu_pbut = guitk BCPushButtonCreate ( w , "Layouts" , None ) guitk BCButtonSetIconFileName ( menu_pbut , "mdi_windows_layout_2x2.svg" ) guitk BCButtonSetPopup ( menu_pbut , lay_menu ) menu = guitk BCPopupMenuCreate ( w ) guitk BCPopupMenuInsertItem ( menu , "Item 1" , itemFunction ) guitk BCPopupMenuInsertItem ( menu , "Item 2" , itemFunction ) menu_tbut = guitk BCToolButtonCreate ( w , "filter.svg" , "" , None ) guitk BCToolButtonSetSideArrowEnabled ( menu_tbut , False ) guitk BCButtonSetPopup ( menu_tbut , menu ) # Only BCToolButtons can display a PopupMenu through a separate sub-button, # thus keeping their clicking / toggling functionality toggling_but = guitk BCToolButtonCreate ( w , "filter.svg" , "" , None ) guitk BCButtonSetToggleButton ( toggling_but , True ) guitk BCButtonSetToggledFunction ( toggling_but , toggledFunction ) guitk BCButtonSetPopup ( toggling_but , menu ) guitk BCShow ( w ) def itemFunction ( pm , id , data ): print ( "Item " + str ( id ) + " clicked" ) return 0 def toggledFunction ( b , state , data ): s = "off" if state : s = "on" print ( "The button is now " + s ) return 0 main () guitk. BCButtonToggle ( b : BCGuiObject ) → None # Toggles a toggle BCPushButton b. This means that the button’s state will change (if button b was pressed it depresses it, otherwise it presses it). Parameters : b BCGuiObject the toggle button to be toggled. NOTE: This function should only be called after a call to BCButtonSetToggleButton(). Returns : None See also guitk.BCButtonSetToggleButton Examples from ansa import guitk def main (): window = guitk BCWindowCreate ( "Toggle Button" , guitk constants BCOnExitDestroy ) btn = guitk BCPushButtonCreate ( window , "Button" , None , None ) cbox = guitk BCCheckBoxCreate ( window , "Make Button Toggle" ) cboxToggle = guitk BCCheckBoxCreate ( window , "Check me to toggle the Button" ) guitk BCSetEnabled ( cboxToggle , False ) guitk BCCheckBoxSetToggledFunction ( cbox , setButtonFunct , [ btn , cboxToggle ]) guitk BCCheckBoxSetToggledFunction ( cboxToggle , toggleButtonFunct , btn ) guitk BCShow ( window ) def setButtonFunct ( cb , state , data ): if state : guitk BCButtonSetToggleButton ( data [ 0 ], True ) guitk BCButtonSetToggledFunction ( data [ 0 ], toggledFunct ) guitk BCButtonToggle ( data [ 0 ]) guitk BCSetEnabled ( data [ 1 ], True ) else : guitk BCButtonSetToggleButton ( data [ 0 ], False ) guitk BCSetEnabled ( data [ 1 ], False ) if guitk BCButtonIsToggleButton ( data [ 0 ]): guitk BCButtonSetText ( data [ 0 ], "Toggle Button" ) else : guitk BCButtonSetText ( data [ 0 ], "No Toggle Button" ) return 0 def toggleButtonFunct ( cb , state , btn ): if guitk BCButtonIsOn ( btn ): guitk BCButtonSetOn ( btn , False ) else : guitk BCButtonSetOn ( btn , True ) return 0 def toggledFunct ( btn , state , data ): if state : guitk BCButtonSetText ( btn , "Toggled state" ) else : guitk BCButtonSetText ( btn , "Non Toggled state" ) return 0 if __name__ == "__main__" : main () guitk. BCButtonIsOn ( b : BCGuiObject ) → bool # Returns True if the BCPushButton b is toggled, otherwise returns False. Parameters : b BCGuiObject the BCPushButton or BCToolButton. Returns : bool True if the button b is toggled, otherwise returns False. See also guitk.BCButtonSetOn Examples from ansa import guitk def main (): window = guitk BCWindowCreate ( "Toggle Button" , guitk constants BCOnExitDestroy ) btn = guitk BCPushButtonCreate ( window , "Button" , None , None ) cbox = guitk BCCheckBoxCreate ( window , "Make Button Toggle" ) cboxToggle = guitk BCCheckBoxCreate ( window , "Check me to toggle the Button" ) guitk BCSetEnabled ( cboxToggle , False ) guitk BCCheckBoxSetToggledFunction ( cbox , setButtonFunct , [ btn , cboxToggle ]) guitk BCCheckBoxSetToggledFunction ( cboxToggle , toggleButtonFunct , btn ) guitk BCShow ( window ) def setButtonFunct ( cb , state , data ): if state : guitk BCButtonSetToggleButton ( data [ 0 ], True ) guitk BCButtonSetToggledFunction ( data [ 0 ], toggledFunct ) guitk BCButtonToggle ( data [ 0 ]) guitk BCSetEnabled ( data [ 1 ], True ) else : guitk BCButtonSetToggleButton ( data [ 0 ], False ) guitk BCSetEnabled ( data [ 1 ], False ) if guitk BCButtonIsToggleButton ( data [ 0 ]): guitk BCButtonSetText ( data [ 0 ], "Toggle Button" ) else : guitk BCButtonSetText ( data [ 0 ], "No Toggle Button" ) return 0 def toggleButtonFunct ( cb , state , btn ): if guitk BCButtonIsOn ( btn ): guitk BCButtonSetOn ( btn , False ) else : guitk BCButtonSetOn ( btn , True ) return 0 def toggledFunct ( btn , state , data ): if state : guitk BCButtonSetText ( btn , "Toggled state" ) else : guitk BCButtonSetText ( btn , "Non Toggled state" ) return 0 if __name__ == "__main__" : main () guitk. BCButtonIsToggleButton ( b : BCGuiObject ) → bool # Returns True if the BCPushButton b is a toggle button, otherwise(normal button) returns False. Parameters : b BCGuiObject the BCPushButton. Returns : bool True if the BCPushButton b is a toggle button, otherwise(normal button) returns False. See also guitk.BCButtonSetToggleButton Examples from ansa import guitk def main (): window = guitk BCWindowCreate ( "Toggle Button" , guitk constants BCOnExitDestroy ) btn = guitk BCPushButtonCreate ( window , "Button" , None , None ) cbox = guitk BCCheckBoxCreate ( window , "Make Button Toggle" ) cboxToggle = guitk BCCheckBoxCreate ( window , "Check me to toggle the Button" ) guitk BCSetEnabled ( cboxToggle , False ) guitk BCCheckBoxSetToggledFunction ( cbox , setButtonFunct , [ btn , cboxToggle ]) guitk BCCheckBoxSetToggledFunction ( cboxToggle , toggleButtonFunct , btn ) guitk BCShow ( window ) def setButtonFunct ( cb , state , data ): if state : guitk BCButtonSetToggleButton ( data [ 0 ], True ) guitk BCButtonSetToggledFunction ( data [ 0 ], toggledFunct ) guitk BCButtonToggle ( data [ 0 ]) guitk BCSetEnabled ( data [ 1 ], True ) else : guitk BCButtonSetToggleButton ( data [ 0 ], False ) guitk BCSetEnabled ( data [ 1 ], False ) if guitk BCButtonIsToggleButton ( data [ 0 ]): guitk BCButtonSetText ( data [ 0 ], "Toggle Button" ) else : guitk BCButtonSetText ( data [ 0 ], "No Toggle Button" ) return 0 def toggleButtonFunct ( cb , state , btn ): if guitk BCButtonIsOn ( btn ): guitk BCButtonSetOn ( btn , False ) else : guitk BCButtonSetOn ( btn , True ) return 0 def toggledFunct ( btn , state , data ): if state : guitk BCButtonSetText ( btn , "Toggled state" ) else : guitk BCButtonSetText ( btn , "Non Toggled state" ) return 0 if __name__ == "__main__" : main () guitk. BCButtonSetOn ( b : BCGuiObject , on : bool ) → None # Sets whether toggle button b is on (toggled) or not. It is meaningful only for toggling buttons. This function is not supported under VR mode. Parameters : b BCGuiObject the button. on bool set this parameter to True for the button to be toggled, or False otherwise. Returns : None See also guitk.BCButtonIsOn , guitk.BCButtonSetToggleButton Examples from ansa import guitk def main (): window = guitk BCWindowCreate ( "Toggle Button" , guitk constants BCOnExitDestroy ) btn = guitk BCPushButtonCreate ( window , "Button" , None , None ) cbox = guitk BCCheckBoxCreate ( window , "Make Button Toggle" ) cboxToggle = guitk BCCheckBoxCreate ( window , "Check me to toggle the Button" ) guitk BCSetEnabled ( cboxToggle , False ) guitk BCCheckBoxSetToggledFunction ( cbox , setButtonFunct , [ btn , cboxToggle ]) guitk BCCheckBoxSetToggledFunction ( cboxToggle , toggleButtonFunct , btn ) guitk BCShow ( window ) def setButtonFunct ( cb , state , data ): if state : guitk BCButtonSetToggleButton ( data [ 0 ], True ) guitk BCButtonSetToggledFunction ( data [ 0 ], toggledFunct ) guitk BCButtonToggle ( data [ 0 ]) guitk BCSetEnabled ( data [ 1 ], True ) else : guitk BCButtonSetToggleButton ( data [ 0 ], False ) guitk BCSetEnabled ( data [ 1 ], False ) if guitk BCButtonIsToggleButton ( data [ 0 ]): guitk BCButtonSetText ( data [ 0 ], "Toggle Button" ) else : guitk BCButtonSetText ( data [ 0 ], "No Toggle Button" ) return 0 def toggleButtonFunct ( cb , state , btn ): if guitk BCButtonIsOn ( btn ): guitk BCButtonSetOn ( btn , False ) else : guitk BCButtonSetOn ( btn , True ) return 0 def toggledFunct ( btn , state , data ): if state : guitk BCButtonSetText ( btn , "Toggled state" ) else : guitk BCButtonSetText ( btn , "Non Toggled state" ) return 0 if __name__ == "__main__" : main () guitk. BCButtonSetToggledFunction ( b : BCGuiObject , funct : Callable , data : Any = None ) → None # Sets the function that will be called when toggle button b is toggled. NOTE: this function should only be called after a call to BCButtonSetToggleButton(). Parameters : b BCGuiObject the toggle button. funct Callable the function that will be called when toggle button b is toggled. See BC_BUTTON_TOGGLED_FUNCTION for details. integer BC_BUTTON_TOGGLED_FUNCTION(b, state, data) The function to be called when the BCButton is toggled. WARNING: If you need to delete a GUI object (button, list view item etc) inside your call back function, do NOT delete it directly but with the use of a timer (BCTimerSingleShot). Arguments * b : BCGuiObject the BCPushButton, or BCToolButton. * state : int the toggle state information: 1 when the button is on (i.e. toggled); 0 otherwise. * data : Any anything that may be required in function. Return: Reserved for future use. We recommend you always return 0. data Any, optional any user data required by function funct. Returns : None See also guitk.BCButtonToggle , guitk.BCButtonSetClickedFunction , guitk.BCBlockCallBackFunctions Examples import os import ansa from ansa import guitk def main (): w = guitk BCWindowCreate ( "Buttons" , guitk constants BCOnExitDestroy ) # Although all Buttons can display a PopupMenu... lay_menu = guitk BCPopupMenuCreate ( w ) guitk BCPopupMenuInsertItemWithIcon ( lay_menu , "Layout 1x1" , "mdi_windows_layout_1x1.svg" , itemFunction ) guitk BCPopupMenuInsertItemWithIcon ( lay_menu , "Layout 2x1" , "mdi_windows_layout_2x1.svg" , itemFunction ) menu_pbut = guitk BCPushButtonCreate ( w , "Layouts" , None ) guitk BCButtonSetIconFileName ( menu_pbut , "mdi_windows_layout_2x2.svg" ) guitk BCButtonSetPopup ( menu_pbut , lay_menu ) menu = guitk BCPopupMenuCreate ( w ) guitk BCPopupMenuInsertItem ( menu , "Item 1" , itemFunction ) guitk BCPopupMenuInsertItem ( menu , "Item 2" , itemFunction ) menu_tbut = guitk BCToolButtonCreate ( w , "filter.svg" , "" , None ) guitk BCToolButtonSetSideArrowEnabled ( menu_tbut , False ) guitk BCButtonSetPopup ( menu_tbut , menu ) # Only BCToolButtons can display a PopupMenu through a separate sub-button, # thus keeping their clicking / toggling functionality toggling_but = guitk BCToolButtonCreate ( w , "filter.svg" , "" , None ) guitk BCButtonSetToggleButton ( toggling_but , True ) guitk BCButtonSetToggledFunction ( toggling_but , toggledFunction ) guitk BCButtonSetPopup ( toggling_but , menu ) guitk BCShow ( w ) def itemFunction ( pm , id , data ): print ( "Item " + str ( id ) + " clicked" ) return 0 def toggledFunction ( b , state , data ): s = "off" if state : s = "on" print ( "The button is now " + s ) return 0 main () guitk. BCButtonSetAllowColorChange ( b : BCGuiObject , allow : bool ) → None # Function is not supported. For more info, please contact Customer Service department. This function is not supported under VR mode. Parameters : b BCGuiObject the BCToolButton. allow bool set this variable to True if you want the toggled button to become red when pressed or to False (the default) if you do not want a color change to take place. Returns : None guitk. BCButtonSetText ( b : BCGuiObject , text : str ) → None # Sets the text displayed on BCPushButton or BCToolButton b. If you have set an icon with BCButtonSetIconFileName(), it will be removed. Parameters : b BCGuiObject the button of which the text will be set. text str the new text. Returns : None See also guitk.BCButtonSetIconFileName Examples from ansa import guitk def main (): window = guitk BCWindowCreate ( "Toggle Button" , guitk constants BCOnExitDestroy ) btn = guitk BCPushButtonCreate ( window , "Button" , None , None ) cbox = guitk BCCheckBoxCreate ( window , "Make Button Toggle" ) cboxToggle = guitk BCCheckBoxCreate ( window , "Check me to toggle the Button" ) guitk BCSetEnabled ( cboxToggle , False ) guitk BCCheckBoxSetToggledFunction ( cbox , setButtonFunct , [ btn , cboxToggle ]) guitk BCCheckBoxSetToggledFunction ( cboxToggle , toggleButtonFunct , btn ) guitk BCShow ( window ) def setButtonFunct ( cb , state , data ): if state : guitk BCButtonSetToggleButton ( data [ 0 ], True ) guitk BCButtonSetToggledFunction ( data [ 0 ], toggledFunct ) guitk BCButtonToggle ( data [ 0 ]) guitk BCSetEnabled ( data [ 1 ], True ) else : guitk BCButtonSetToggleButton ( data [ 0 ], False ) guitk BCSetEnabled ( data [ 1 ], False ) if guitk BCButtonIsToggleButton ( data [ 0 ]): guitk BCButtonSetText ( data [ 0 ], "Toggle Button" ) else : guitk BCButtonSetText ( data [ 0 ], "No Toggle Button" ) return 0 def toggleButtonFunct ( cb , state , btn ): if guitk BCButtonIsOn ( btn ): guitk BCButtonSetOn ( btn , False ) else : guitk BCButtonSetOn ( btn , True ) return 0 def toggledFunct ( btn , state , data ): if state : guitk BCButtonSetText ( btn , "Toggled state" ) else : guitk BCButtonSetText ( btn , "Non Toggled state" ) return 0 if __name__ == "__main__" : main () guitk. BCButtonSetIconFileName ( b : BCGuiObject , fileName : str ) → None # Sets the icon that is displayed on the button to be the one specified by fileName. This allows an icon to be displayed next to the button’s label, as well as to change the button’s size. NOTE: Embedded icons can be found in Script Editor Help menu. Parameters : b BCGuiObject the button. fileName str the filename of the icon. Returns : None See also guitk.BCButtonSetText , guitk.BCIconIsValid Examples import os import ansa from ansa import guitk def main (): w = guitk BCWindowCreate ( "Buttons" , guitk constants BCOnExitDestroy ) # ToolButtons occupy only the space they need tbut = guitk BCToolButtonCreate ( w , "file_open.svg" , "Open" , clickFunction , None ) # whereas PushButtons tend to occupy all available width pbut = guitk BCPushButtonCreate ( w , "Open" , clickFunction , None ) guitk BCButtonSetIconFileName ( pbut , "file_open.svg" ) guitk BCShow ( w ) def clickFunction ( b , data ): print ( "Button clicked" ) return 0 main () guitk. BCButtonAddIconFileName ( b : BCGuiObject , fileName : str , mode : int , state : int ) → None # Adds an icon to the button’s iconSet that will be displayed when the button is in mode mode and state state. This function will operate ONLY on buttons for which an icon file has already been set via BCButtonSetIconFileName() or BCToolButtonCreate(). NOTE: Embedded i