#! /usr/bin/python import Tkinter as T import tkFont as Tf import tkMessageBox as M import time import threading as Th import Queue """ the bug : when clicking on the label as indicated in the label... if I let the button pushed and go out of the menu the menu doesn't pop down if I iconnify the window the menu doesn't behave in a transient way it stay raised. """ class PopUpMenu(T.Menu): def __init__(self,frameOwner,bindTo=None): T.Menu.__init__(self,frameOwner,tearoff=0) #self.winfo_toplevel().wm_transient(self) if bindTo: self.bind_to(bindTo) self.populate() def populate(self): pass def do_popup(self,event): # display the popup menu try: self.tk_popup(event.x_root, event.y_root, 0) finally: # make sure to release the grab (Tk 8.0a1 only) self.grab_release() def bind_to (self,w): w.bind("", self.do_popup) class MyPopUp(PopUpMenu): def populate(self): self.add_command(label="Next") # , command=next) etc... self.add_command(label="Previous") self.add_separator() self.add_command(label="Home") class Window(object): def __init__(self): self.frame=T.Tk() self.frame.geometry("250x150+300+300") self.create_widgets() self.frame.mainloop() def create_widgets(self): b = T.Button(self.frame, text="Quit", command=self.frame.destroy) b.pack() l = T.Label(self.frame, text="Right-click to display menu", width=40, height=20) l.pack() p=MyPopUp(self.frame,l) if __name__ == "__main__": cw=Window()