Popup Menu

Hey List people,

I'm having some trouble with my popup menu. i don't know what I am
supposed to do. I'm trying to do the same as whats on the demo but it
doesn't work.

Here is the code.

Cheers
Naeill

···

_____________________
class MyEvtHandler(ogl.ShapeEvtHandler):
    def __init__(self):
        ogl.ShapeEvtHandler.__init__(self)

    def OnLeftClick(self, x, y, keys=0, attachment=0):
        shape = self.GetShape()
        canvas = shape.GetCanvas()
        dc = wx.ClientDC(canvas)
        canvas.PrepareDC(dc)
        if (shape.Selected() == True):
           shape.Select(False, dc)
           canvas.Redraw(dc)
        else:
           shape.Select(True, dc)
           canvas.Redraw(dc)

    def OnLeftDoubleClick(self, x, y, keys=0, attachment=0):
        shape = self.GetShape()
        canvas = shape.GetCanvas()
        dc = wx.ClientDC(canvas)
        canvas.PrepareDC(dc)
        self.Properties()

    def Properties(self):
        dia = MainWindow(None, -1, "Please Edit Attributes")
        dia.Destroy()

    def OnRightClick(self, *dontcare):
        shape = self.GetShape()
        canvas = shape.GetCanvas()
        frame = self.statbarFrame
        if (shape.Selected() == True):
           self.popupID1 = wx.NewId()
           self.popupID2 = wx.NewId()

           # self.Bind(wx.EVT_MENU, self.OnPopupOne, id=self.popupID1)
           # self.Bind(wx.EVT_MENU, self.OnPopupTwo, id=self.popupID2)

           menu = wx.Menu()
           item = wx.MenuItem(menu, self.popupID1,"Properties")
           menu.AppendItem(item)
           menu.Append(self.popupID2, "Delete")

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

        else:
           pass
           canvas.Refresh()

________________________________

Cheers for the app. When Robin also helped me.

Cheers Naeill
P.S. This was is a bit clearer, also include little icon pictures with
pop menu thou

···

On Thu, 10 Feb 2005 16:09:07 -0800, Chris Barker <Chris.Barker@noaa.gov> wrote:

I found the way popups are done in the menu to be kind of ugly. Here is
a message I sent a while back:

Hi all,

I've "classified" Alberto's code, and now have a nice menu class that
can be popped up in any number of windows. I'm thinking that this is
much cleaner than the way the demo is written. Should I re-write the
demo this way?

Below is the class, enclosed is a complete sample app.

-Chris

--
Christopher Barker, Ph.D.
Oceanographer

NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Sorry about last message I was in two worlds.

Thanks for the app. Robin sent me an email and told me what the
problem was. Your app was coll but you should include little icon
pictures like in the demo.

Thanks again
naeill

···

On Fri, 11 Feb 2005 11:23:32 +1100, Naeill Leigh <naeill@gmail.com> wrote:

Cheers for the app. When Robin also helped me.

Cheers Naeill
P.S. This was is a bit clearer, also include little icon pictures with
pop menu thou

On Thu, 10 Feb 2005 16:09:07 -0800, Chris Barker <Chris.Barker@noaa.gov> wrote:
> I found the way popups are done in the menu to be kind of ugly. Here is
> a message I sent a while back:
>
> Hi all,
>
> I've "classified" Alberto's code, and now have a nice menu class that
> can be popped up in any number of windows. I'm thinking that this is
> much cleaner than the way the demo is written. Should I re-write the
> demo this way?
>
> Below is the class, enclosed is a complete sample app.
>
> -Chris
>
> --
> Christopher Barker, Ph.D.
> Oceanographer
>
> NOAA/OR&R/HAZMAT (206) 526-6959 voice
> 7600 Sand Point Way NE (206) 526-6329 fax
> Seattle, WA 98115 (206) 526-6317 main reception
>
> Chris.Barker@noaa.gov
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
>
>
>

Another problem has come up. It won't compile when I have the
self.bind statements in. When they are commented out it compiles.

Thanks again
Naeill

···

____________________________

    def Properties(self,event):
        dia = MainWindow(None, -1, "Please Edit Attributes")
        dia.Destroy()

    def Delete(self,event):
        shape = self.GetShape()
        canvas = shape.GetCanvas()
        shape.RemoveFromCanvas(canvas)
        canvas.RemoveShape(shape)
        canvas.diagram.RemoveShape(shape)
        canvas.Refresh()

    def OnRightClick(self, *dontcare):
        shape = self.GetShape()
        canvas = shape.GetCanvas()
       
        if (shape.Selected() == True):
           self.popupID1 = wx.NewId()
           self.popupID2 = wx.NewId()

           menu = wx.Menu()
           item = wx.MenuItem(menu, self.popupID1,"Properties")
           menu.AppendItem(item)
           menu.Append(self.popupID2, "Delete")

           self.Bind(wx.EVT_MENU, self.Properties, self.popupID1)
           self.Bind(wx.EVT_MENU, self.Delete, self.popupID2)

        # Popup the menu. If an item is selected then its handler
        # will be called before PopupMenu returns.
           canvas.PopupMenu(menu)
           menu.Destroy()

        else:
           pass
           canvas.Refresh()

______________________________