hi,

Am Mittwoch, den 04.05.2005, 20:04 -0400 schrieb Paulo Richards: 
> Hello, i need a widget for selecting a date. Just an Entry to manually
> edit a date and a Button to pop up a calendar widget. 
> 
> I have found that the libgnomeui has a widget like that, the
> Gnome-DateEdit widget, but the application must run on Windows as well
> and i can't find any port to Windows for libgnomeui (unfortunately i
> don't have access to a Windows machine to try to build the code myself,
> i've notice on the changelog that a port to win32 is going on). 
> 
> I started looking at the C source code of the Gnome-DateEdit widget, and
> didn't find anything but pure gtk functions, so i'm trying to write it
> myself purely on python.
> 
> The problem i'm having is on the calendar popup, it is a popup window,
> with the calendar widget on it, when the button is pressed, it display
> the window just below the button position and grab the calendar window.
> The button_press_event signal is connected to the calendar window, so i
> can hide it if a button is pressed anywhere on the screen but the
> calendar window.
> 
> To do that on C, they use the gtk_get_event_widget function for getting
> the widget that recibe the button_press_event an compare it with the
> calendar window.
> 
> This is the code in C:
> 
> static gint
> button_press_popup (GtkWidget *widget, GdkEventButton *event, gpointer
> data)
> {
>       GnomeDateEdit *gde;
>       GtkWidget *child;
> 
>       gde = data;
> 
>       child = gtk_get_event_widget ((GdkEvent *) event);
> 
>       if (child != widget) {
>               while (child) {
>                       if (child == widget)
>                       return FALSE;
>               child = child->parent;
>               }
>       }
> 
>       hide_popup (gde);
> 
>       return TRUE;
> }
> 
> 
> The problem is i can't find this function on pygtk. It is posible to do
> it this this way? or is anything easier for that?.

I think it is not there. First, in gdk.override in the ignore section
there is the function gtk_get_event_widget, and second in gdk.override
around row 1247 there seems to be no __members__ including
'widget' (within _wrap_gdk_event_tp_getattr, that is).

You could add it to the all event types there (setting to None if
unavailable) and making _wrap_gdk_event_tp_getattr with "widget" call
gtk_get_event_widget. That should be all that is required to extend
pygtk in a way to support it cleanly.

the actual code is something like,
if (!strcmp(attr, "widget")) {
   widget = gtk_get_event_widget (event);
   if (widget) {
      return pygobject_new((GObject *)widget);
   } else {
      Py_INCREF(Py_None);
      return Py_None;
   }
}


If you are looking for a quick-and-dirty method, maybe taking
gtk_get_event_widget out of the "ignore" list suffices. I dont think so
though.

> 
> The rest of it works fine so far, the calendar window appears where it's
> supposed to, when i double click some day, the window hides, if i press
> Esc also hides (as expected), but otherwise, the whole system gets
> blocks (because of the grab).
> 
> Thanks in advance
> 
> Paulo Richards

cheers,
   Danny

> _______________________________________________
> pygtk mailing list   [email protected]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
> 
-- 
www.keyserver.net key id A334AEA6

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to