Python Global Scope Changes - 2023

MapInfo Pro Help

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapInfo Pro
Version
2023
ft:locale
en-US
Product name
MapInfo Pro
ft:title
MapInfo Pro Help
First publish date
1985
ft:lastEdition
2023-09-12
ft:lastPublication
2023-09-12T16:39:16.995000
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()))