Here is a small patch to apply to the 19990219 snapshot to fix the
GtkMenu.popup handling. Also attached is a simple test program.
Looks like James already mostly fixed the problem. Remaining was a
small bug that prevented "None" from being handled properly for "func"
Hrvoje Niksic wrote:
>
> Silence here is worrysome. Is it possible that noone has needed popup
> menus in PyGtk before? Or, is there an FAQ or a FM that I should
> read?
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
>
>
--
Richard Fish Enhanced Software Technologies, Inc.
Software Developer 4014 E Broadway Rd Suite 405
[EMAIL PROTECTED] Phoenix, AZ 85040
(602) 470-1115 http://www.estinc.com
--- pygtk-SNAP-19990219/gtkmodule.c Thu Feb 18 20:59:43 1999
+++ pygtk-new/gtkmodule.c Fri Feb 19 19:14:03 1999
@@ -4121,17 +4121,18 @@
"third argument must be a GtkWidget or None");
return NULL;
}
- if (!PyCallable_Check(func) && func != Py_None) {
- PyErr_SetString(PyExc_TypeError, "forth argument not callable");
- return NULL;
- }
- if (func) {
+ if (PyCallable_Check(func)) {
Py_INCREF(func);
gtk_menu_popup(GTK_MENU(PyGtk_Get(m)), pms, pmi,
(GtkMenuPositionFunc)PyGtk_MenuPosition,
func, button, time);
- } else
+ } else if (func == Py_None) {
gtk_menu_popup(GTK_MENU(PyGtk_Get(m)), pms, pmi, NULL,NULL, button,time);
+ } else {
+ PyErr_SetString(PyExc_TypeError,
+ "forth argument must be callable or None");
+ return NULL;
+ }
Py_INCREF(Py_None);
return Py_None;
}
from gtk import *
from GDK import *
class MenuTest(GtkWindow):
def __init__(self):
GtkWindow.__init__(self)
b=GtkEventBox()
self.add(b)
l=GtkLabel("Click Here!")
b.add(l)
b.connect("button_press_event",self.MenuPopupCB)
self.menu=GtkMenu()
self.menu.append(GtkMenuItem(label="One"))
self.menu.append(GtkMenuItem(label="Two"))
self.menu.append(GtkMenuItem(label="Three"))
self.menu.show_all()
self.set_usize(200,200)
self.show_all()
def MenuPopupCB(self,widget,event):
self.menu.popup(None,None,None,event.button,event.time)
m=MenuTest()
mainloop()