python - GtkToolButton are disabled by default in glade3 + pygtk -
i've created simple app skeleton in python 2.7 using pygtk , glade (3.16.1) on ubiuntu 14.04 lts. i've added toolbar , buttons, gtktoolbutton disabled. how can enable them glade?
i've tried in python using "set_sensitive" nothing works.
can me? thank much!
this snippet glade file:
<child> <object class="gtktoolbar" id="toolbar1"> <property name="visible">true</property> <property name="can_focus">false</property> <property name="toolbar_style">both-horiz</property> <property name="show_arrow">false</property> <style> <class name="primary-toolbar"/> </style> <child> <object class="gtktoolbutton" id="toolbutton1"> <property name="name">bt1</property> <property name="visible">true</property> <property name="can_focus">false</property> <property name="is_important">true</property> <property name="action_name">bt1</property> <property name="label" translatable="yes">toolbutton1</property> <property name="use_underline">true</property> <property name="stock_id">gtk-connect</property> <signal name="clicked" handler="on_toolbutton1_clicked" swapped="no"/> </object>
gtktoolbars not straightforward use. have create corresponding action. simple example of how use them:
the glade file:
<interface> <requires lib="gtk+" version="3.16"/> <object class="gtkwindow" id="window"> <property name="can_focus">false</property> <child> <object class="gtktoolbar"> <property name="visible">true</property> <property name="can_focus">false</property> <child> <object class="gtktoolbutton"> <property name="visible">true</property> <property name="can_focus">false</property> <property name="action_name">app.zoom</property> <property name="label" translatable="yes">zoom</property> <property name="use_underline">true</property> <property name="stock_id">gtk-zoom-in</property> </object> <packing> <property name="expand">false</property> <property name="homogeneous">true</property> </packing> </child> </object> </child> </object> </interface> the python file:
from gi.repository import gtk, gio class application(gtk.application): def do_activate(self): action = gio.simpleaction.new('zoom', none) action.connect('activate', self.on_zoom) self.add_action(action) builder = gtk.builder.new_from_file('window.glade') window = builder.get_object('window') window.show_all() self.add_window(window) def on_zoom(self, action, param): print('clicked') if __name__ == '__main__': application().run() you can have @ example application menu similar

Comments
Post a Comment