Menu's problem

C

carlosperezs

Hello together :

I have programmed that: a listCtrl with binding functions.

self.ListCtrlMarks = wx.ListCtrl(self.panel, -1, style = wx.LC_REPORT)

self.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnSelectedItem,self.ListCtrlMarks)

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")
fDep.flush()

if flags & wx.LIST_HITTEST_ONITEM:
self.ListCtrlMarks.Select(item)

event.Skip()

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

fDep.write("Despois \n")
fDep.flush()
# 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))
menu.Destroy()

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

Thank you

--oOo-----------------------------------------------------------------oOo--

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 [ http://si.uvigo.es ]
Universidade de Vigo [ http://www.uvigo.es ]

URL: https://correoweb.uvigo.es
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top