how to popup flatmenu?

i got some errors with this code i cant make the popup

import wx
import wx.lib.agw.flatmenu as fmenu

class Form(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title)

        self.menubar = wx.MenuBar()
        self.menu_a = wx.Menu()
        self.menu_a.Append(-1, "&Cerrar\tCtrl+Q", "yo")

        self.menubar.Append(self.menu_a, "&Archivo")
        self.SetMenuBar(self.menubar)

        self.CreateStatusBar()

        self.panel = wx.Panel(self, -1)
        self.Bind(wx.EVT_CONTEXT_MENU, self.onPopUp)

        #popupmenu
        self.pmenu = fmenu.FlatMenu()
        self.pmenu.Append(-1, "menu1\tCtrl + A", "", None)
        self.pmenu.Append(-1, "menu1", "", None)
        self.pmenu.Append(-1, "menu1", "", None)
        self.pmenu.Append(-1, "menu1", "", None)
        self.pmenu.Append(-1, "menu1", "", None)

    def onPopUp(self, event):
        pos = event.GetPosition()
        pos = self.panel.ScreenToClient(pos)
        self.pmenu.Popup( pos, None, self.panel)

app = wx.App()
Form(None, -1, "menu").Show()
app.MainLoop()

The Error messages would help. I get two sets of error messages. Once
the menu pops up and I move the mouse I get:

Traceback (most recent call last):
  File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\agw\flatmenu.py",
line 3818, in OnMouseMove
    self.ProcessMouseMove(pos)
  File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\agw\flatmenu.py",
line 4019, in ProcessMouseMove
    win.ProcessMouseMove(p)
AttributeError: 'Panel' object has no attribute 'ProcessMouseMove'

After selecting a menu item from the popup menu I get;

Traceback (most recent call last):
  File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\agw\flatmenu.py",
line 3865, in OnMouseLeftUp
    self.ProcessMouseLClickEnd(pos)
  File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\agw\flatmenu.py",
line 3986, in ProcessMouseLClickEnd
    self.DoAction(itemIdx)
  File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\agw\flatmenu.py",
line 4211, in DoAction
    self.Dismiss(True, False)
  File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\agw\flatmenu.py",
line 3421, in Dismiss
    FlatMenuBase.Dismiss(self, dismissParent, resetOwner)
  File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\agw\flatmenu.py",
line 2258, in Dismiss
    self._parentMenu.OnChildDismiss()
AttributeError: 'Panel' object has no attribute 'OnChildDismiss'

It looks like the flatmenu is sending a command to the parent menu,
which is the panel because this is a popup menu.

I haven't played with FlatMenu so I don't know how it works. From the
looks of the error messages, I'd say FlatMenu wasn't designed to be a
popup menu.

Josh English

Try this,

    def onPopUp(self, event):
        pos = wx.GetMousePosition()
        self.pmenu.Popup( pos, self.panel)

Prashant