MapInfo Pro Developers User Group

 View Only
  • 1.  Trouble with Ribbon Features

    Posted 12-12-2024 12:36

    Hello all,

      I have been going through the python quick start examples to learn how to use Python and Mapinfo together. I am going through the "ribboncustomization" example and am noticing some inconsistencies with how the ribbon is handling "button*.ToolTip". I copied a section of the code below for reference. When you run the code and go to the ribbon customization tab, you will see in the demo controls group, there is the "zoom-in tool" and the "Info tool". In the code below both buttons are set up the same but when hovering on each of the two buttons; one shows the three different pieces of information, while the other only shows two. As far as I can tell these should both show three different pieces of information, unless I am missing something?

    Similarly, I am having trouble with getting KeyTips to work. They appear to not be working through out all of my Mapinfo, not just the ones from this python example. I went through the HelpCenter documentation on them and there doesn't seem to be any required setting that needs to be switched on for them to work.

    Would appreciate any help on either of the two matters. 

    Thanks in advance!

        def AddNewTabToRibbon(self):
            self._newTab = self._pro.Ribbon.Tabs.Add("RibbonCustomization","Ribbon Customization")
            if self._newTab:
                tabGroup = self._newTab.Groups.Add("DemoControls", "Demo Controls")
                if tabGroup:
                    tabGroup.IsLauncherVisible = False
                    buttonZoomIn = tabGroup.Controls.Add("ZoomInToolButton", "Zoom-In Tool", ControlType.ToolButton)
                    if buttonZoomIn:
                        buttonZoomIn.IsLarge = True
                        buttonZoomIn.KeyTip = "ZI"
                        buttonZoomIn.ToolTip = AddinUtil.create_tooltip("Zoom In", "Zoom In", "Open Mapper to use")
                        buttonZoomIn.LargeIcon = CommonUtil.path_to_uri("pack://application:,,,/MapInfo.StyleResources;component/Images/Mapping/zoomIn_32x32.png")
                        buttonZoomIn.SmallIcon = CommonUtil.path_to_uri("pack://application:,,,/MapInfo.StyleResources;component/Images/Mapping/zoomIn_16x16.png")
                        buttonZoomIn.CommandId = 1705
                        buttonZoomIn.Cursor = "129"
                        buttonZoomIn.DrawMode = 30
                        buttonZoomIn.BModifier = True
                
                    buttonInfoTool = tabGroup.Controls.Add("InfoToolButton", "Info Tool", ControlType.ToolButton)
                    if buttonInfoTool:
                        buttonInfoTool.IsLarge = True
                        buttonInfoTool.KeyTip = "IT"
                        buttonInfoTool.ToolTip = AddinUtil.create_tooltip("Info Tool", "Info Tool", "Click in Mapper")
                        buttonInfoTool.LargeIcon = CommonUtil.path_to_uri("pack://application:,,,/MapInfo.StyleResources;component/Images/Mapping/infoTool_32x32.png")
                        buttonInfoTool.SmallIcon = CommonUtil.path_to_uri("pack://application:,,,/MapInfo.StyleResources;component/Images/Mapping/infoTool_16x16.png")
                        buttonInfoTool.CommandId = 834
                        buttonInfoTool.Cursor = "103 FILE \"gcsres32.dll\""
                        buttonInfoTool.DrawMode = 34
                        buttonInfoTool.BModifier = False


    ------------------------------
    Tanner Mork
    Knowledge Community Shared Account
    Burlington MA
    ------------------------------


  • 2.  RE: Trouble with Ribbon Features

    Employee
    Posted 12-13-2024 03:02

    Hi Tanner

    I can see why you get confused with this behavior.

    The issue is that these built-in tools are disabled under different circumstances.

    The Zoom-in tool is only enabled when a mapper is the active window; the Info tool is not.

    The last parameter for the create_tooltip method is the disabled tooltip which shows when the tool/button is disabled:

     buttonZoomIn.ToolTip = AddinUtil.create_tooltip("Zoom In", "Zoom In", "Open Mapper to use")

    As the Info tool isn't disabled, it doesn't show this text.

    Close all tables to see the disabled text of the Info tool.



    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------