Menu's problem

carlosperezs at carlosperezs at
Mon May 22 12:02:59 CEST 2006

Hello together :

I have programmed that: a listCtrl with binding functions.

self.ListCtrlMarks = wx.ListCtrl(self.panel, -1, style = wx.LC_REPORT)
self.ListCtrlMarks.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
self.ListCtrlMarks.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnRightClick)
self.ListCtrlMarks.Bind(wx.EVT_RIGHT_UP, self.OnRightClick)

The respectives handler are:

    def OnRightDown(self, event):
        self.x = event.GetX()
        self.y = event.GetY()
        item, flags = self.ListCtrlMarks.HitTest((self.x, self.y))
        fDep.write("Item :"+str(item)+"  "+str(self.x)+"  "+str(self.y)+"\n")

        if flags & wx.LIST_HITTEST_ONITEM:


    def OnRightClick(self, event):
        """ The mouse right button has been pressed into a mark"""

        fDep.write("Despois \n")
        # only do this part the first time so the events are only bound once
        if not hasattr(self, "popupID1"):
            self.popupID1 = wx.NewId()
            self.popupID2 = wx.NewId()
            self.popupID3 = wx.NewId()
            self.popupID4 = wx.NewId()

            self.Bind(wx.EVT_MENU, self.OnPopupOne, id=self.popupID1)
            self.Bind(wx.EVT_MENU, self.OnPopupTwo, id=self.popupID2)
            self.Bind(wx.EVT_MENU, self.OnPopupThree, id=self.popupID3)
            self.Bind(wx.EVT_MENU, self.OnPopupFour, id=self.popupID4)

        # make a menu
        menu = wx.Menu()
        # add some items
        menu.Append(self.popupID1, "Edit (Name and Note)")
        menu.Append(self.popupID2, "Init")
        menu.Append(self.popupID3, "End")
        menu.Append(self.popupID4, "Delete")

        # Popup the menu.  If an item is selected then its handler
        # will be called before PopupMenu returns.
        self.PopupMenu(menu, (self.x, self.y))

the problem i have is thaht menu do not popup at the mouse cursor position.
I do not know what goes wrong?

Thank you


Servicio de acceso ó correo electrónico vía web da Universidade de Vigo
Servicio de acceso al correo electrónico vía web de la Universidad de Vigo

Servicios Informáticos [ ]
Universidade de Vigo [ ]


More information about the Python-list mailing list