Popup menus without an associated window

R

Rich Churcher

Is there a way using any of the Python UI toolkits to generate popup
menus outside the context of an application? For example,
middle-clicking on the desktop shows a list of shortcuts to choose
from.

Pointers to source examples would be appreciated.
 
M

Miki Tebeka

Hello Rich,
Is there a way using any of the Python UI toolkits to generate popup
menus outside the context of an application? For example,
middle-clicking on the desktop shows a list of shortcuts to choose
from.

Pointers to source examples would be appreciated.

wxPython:

import wx

class Hidden(wx.Dialog):
def __init__(self):
wx.Dialog.__init__(self, None, -1)
self.menu = wx.Menu()
def add(title):
item = self.menu.Append(-1, title)
return item.GetId()

self.ids = {}

for title in ["One", "Two", "Three"]:
self.ids[add(title)] = title

self.Bind(wx.EVT_MENU, self.OnPopup)

def Go(self):
self.PopupMenu(self.menu)

def OnPopup(self, evt):
print "You selected %s" % (self.ids[evt.GetId()])

app = wx.PySimpleApp()
dlg = Hidden()
dlg.Go()
dlg.Destroy()


HTH,
 

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

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top