A new python global scope method is now available to
attach a command URI to a button created in python
script.
attach_command_uri(button, uri) ' Attaches a MapInfo Pro command uri to a button. ' Parameters: ' button: Button control to which MapInfo Pro command uri will be attached. ' uri: Uri to process
Example:
from MapInfo.Types import IMapInfoPro, ControlType, PaperUnits, DimensionedValue, NotificationObject, NotificationType from System import Uri, UriKindtab = pro.Ribbon.Tabs.Add("Python") group = tab.Groups.Add('pytab', 'Custom') button = group.Controls.Add("ButtonEdit", "Edit Script", ControlType.Button) button.IsLarge = Truebutton.LargeIcon = Uri("pack://application:,,,/MapInfo.StyleResources;component/Images/Mapping/infoTool_32x32.png", UriKind.RelativeOrAbsolute) # attach command uri to the button.attach_command_uri(button, "MapInfoPro://application:PythonConsole.mbx;edit/{}".format(get_current_module_path()))