#!/usr/bin/python

import wx
import time


class Frame(wx.Frame):
    def __init__(self, title):
        wx.Frame.__init__(self, None, title=title, pos=(250,150), size=(350,200))

        self.panel = wx.Panel(self)
        box = wx.BoxSizer(wx.VERTICAL)
        
        self.ListCtrl1 = wx.ListCtrl(self.panel, id=-1, style=wx.LC_REPORT)
        self.ListCtrl1.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK,
                    self.OnlistCtrl1ItemRightClick, id=-1)

        self.ListCtrl1.InsertColumn(0, 'ID')
        self.ListCtrl1.InsertColumn(1, 'Description')

        data = ([1, u'first row'], [2, u'second row'])
        for row in data:
            self.ListCtrl1.Append(row)
        
        self.panel.SetSizer(box)
        self.panel.Layout()


    def OnlistCtrl1ItemRightClick(self, event):
        # show Right-Click-Menu
        popupmenu = wx.Menu()
        details = popupmenu.Append(-1, "Show details")
        self.Bind(wx.EVT_MENU, self.OnDetails, details)
        self.panel.PopupMenu(popupmenu)
        event.Skip()
        

    def OnDetails(self, event):
        wx.BeginBusyCursor()
        print('started')
        time.sleep(1)
        print('finished')
        wx.EndBusyCursor()
        event.Skip()
    

app = wx.App(None)
Frame1 = Frame("Busy Popupmenu")
Frame1.Show()
app.MainLoop()

