Il giorno gio, 25/11/2010 alle 23.04 +0200, Vladimir Gordeev ha scritto:
> builder.connect_signals has no effect
> 
> If I connect signals manualy -- it works.
> But using connect_signals does nothing.

First the bad news: to use connect_signals you have to go, in Glade, in
the "Signals" tab of the widget of your like, and set, for each signal
you want to connect to, the name of the handler.

Then the good news: assume for instance that you have assigned to the
signal "destroy" of your dialog the name "close_app"; then you can just
replace your code

    builder.connect_signals({
                # any of these don't work
                'on_dialog1_delete' : self.close_app,
                'on_dialog1_destroy' : self.close_app,
                'on_dialog1_close' : self.close_app,
                 })


with

    builder.connect_signals( self )


have fun!

Pietro       

> 
> ----
> 
> import pygtk
> pygtk.require('2.0')
> import gtk
> 
> class Application(object):
> 
>     def close_app(self, widget, data=None):
>         gtk.main_quit()
> 
>     def __init__(self):
>         builder = gtk.Builder()
>         builder.add_from_file('test.glade')
> 
>         self._test = builder.get_object('dialog1')
>         # uncommenting this line gets expected behaviour
>         # gtk.main_quit() will be called
>         #self._test.connect('delete-event',
>                             self.close_app)
>         builder.connect_signals({
>                 # any of these don't work
>                 'on_dialog1_delete' : self.close_app,
>                 'on_dialog1_destroy' : self.close_app,
>                 'on_dialog1_close' : self.close_app,
>                 })
>         
>         self._test.show()
> 
> if __name__=='__main__':
>     app = Application()
>     gtk.main()
> 
> ------------
> 
> test.glade is:
> ---------------------------
> <?xml version="1.0"?>
> <interface>
>   <requires lib="gtk+" version="2.16"/>
>   <!-- interface-naming-policy project-wide -->
>   <object class="GtkDialog" id="dialog1">
>     <property name="border_width">5</property>
>     <property name="type_hint">normal</property>
>     <property name="has_separator">False</property>
>     <child internal-child="vbox">
>       <object class="GtkVBox" id="dialog-vbox1">
>         <property name="visible">True</property>
>         <property name="spacing">2</property>
>         <child>
>           <object class="GtkCalendar" id="calendar1">
>             <property name="visible">True</property>
>             <property name="can_focus">True</property>
>             <property name="year">2010</property>
>             <property name="month">10</property>
>             <property name="day">25</property>
>           </object>
>           <packing>
>             <property name="position">1</property>
>           </packing>
>         </child>
>         <child internal-child="action_area">
>           <object class="GtkHButtonBox" id="dialog-action_area1">
>             <property name="visible">True</property>
>             <property name="layout_style">end</property>
>             <child>
>               <object class="GtkButton" id="button1">
>                 <property name="label" translatable="yes">button</property>
>                 <property name="visible">True</property>
>                 <property name="can_focus">True</property>
>                 <property name="receives_default">True</property>
>               </object>
>               <packing>
>                 <property name="expand">False</property>
>                 <property name="fill">False</property>
>                 <property name="position">0</property>
>               </packing>
>             </child>
>             <child>
>               <object class="GtkButton" id="button2">
>                 <property name="label" translatable="yes">button</property>
>                 <property name="visible">True</property>
>                 <property name="can_focus">True</property>
>                 <property name="receives_default">True</property>
>               </object>
>               <packing>
>                 <property name="expand">False</property>
>                 <property name="fill">False</property>
>                 <property name="position">1</property>
>               </packing>
>             </child>
>           </object>
>           <packing>
>             <property name="expand">False</property>
>             <property name="pack_type">end</property>
>             <property name="position">0</property>
>           </packing>
>         </child>
>       </object>
>     </child>
>     <action-widgets>
>       <action-widget response="0">button1</action-widget>
>       <action-widget response="0">button2</action-widget>
>     </action-widgets>
>   </object>
> </interface>
> ----------------------------
> 
> Gtk+ version is 2.21.1
> PyGTK version is 2.17.0
> Glade version is 3.6.7
> 
> All simply installed from ubuntu repository.
> _______________________________________________
> pygtk mailing list   [email protected]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/


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

Reply via email to