Stuart Hughes wrote:
Hi,
I've been pulling my hair out trying to get tooltips to work within a toolbutton.
I'm using glade-2 (2.6.5), libglade-2.3.6, pygtk-2.4.0, and python 2.3.4
I've attached a simple test case that shows a normal button's tooltip works, but a toolbutton's doesn't.
Has anyone got an idea what's wrong.
My experience is that tooltips can't be attached to a ToolButton (or ToolItem) until after it is added to a Toolbar. I don't know how libglade builds up these things but I suspect that this may be the problem. Try adding the tooltip after the Toolbar is built as a workaround.
John
TIA, Stuart
------------------------------------------------------------------------
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkWindow" id="window1"> <property name="visible">True</property> <property name="title" translatable="yes">window1</property> <property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="window_position">GTK_WIN_POS_NONE</property> <property name="modal">False</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</property> <property name="decorated">True</property> <property name="skip_taskbar_hint">False</property> <property name="skip_pager_hint">False</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<child> <widget class="GtkToolbar" id="toolbar1"> <property name="visible">True</property> <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property> <property name="toolbar_style">GTK_TOOLBAR_BOTH</property> <property name="tooltips">True</property> <property name="show_arrow">True</property>
<child> <widget class="GtkToolButton" id="toolbutton3"> <property name="visible">True</property> <property name="tooltip" translatable="yes">quit now</property> <property name="can_focus">True</property> <property name="stock_id">gtk-quit</property> <property name="visible_horizontal">True</property> <property name="visible_vertical">True</property> <property name="is_important">False</property> <signal name="clicked" handler="on_quit_clicked" last_modification_time="Tue, 09 Nov 2004 09:31:39 GMT"/> </widget> <packing> <property name="expand">False</property> <property name="homogeneous">True</property> </packing> </child>
<child> <widget class="GtkToolItem" id="toolitem2"> <property name="visible">True</property> <property name="visible_horizontal">True</property> <property name="visible_vertical">True</property> <property name="is_important">False</property>
<child> <widget class="GtkButton" id="button1"> <property name="visible">True</property> <property name="tooltip" translatable="yes">cancel me</property> <property name="can_focus">True</property> <property name="label">gtk-cancel</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> <signal name="clicked" handler="on_cancel_clicked" last_modification_time="Tue, 09 Nov 2004 09:50:21 GMT"/> </widget> </child> </widget> <packing> <property name="expand">False</property> <property name="homogeneous">False</property> </packing> </child> </widget> </child> </widget>
</glade-interface>
------------------------------------------------------------------------
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> <!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
<glade-project>
<name>Project4</name>
<program_name>project4</program_name>
<gnome_support>FALSE</gnome_support>
</glade-project>
------------------------------------------------------------------------
#!/bin/sh """"exec ${PYTHON:-python} -t $0 "$@";" """
import gtk import gtk.glade
def main_quit(obj): gtk.main_quit()
# mapping from glade to functions
dic = { "on_window1_destroy" : main_quit,
"on_quit_clicked" : main_quit,
"on_cancel_clicked" : main_quit, }
# create a widget tree from a glade file, # also does the work of showing the window
tree = gtk.glade.XML("project4.glade")
# connects signal handlers defined in the glade file to actual code
tree.signal_autoconnect(dic)
# mainloop
gtk.main()
------------------------------------------------------------------------
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
_______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
