4
votes

I'm using python3.4 and gtk3 and I've been trying to find out if the label texts of the Switch widget ('On'/'Off') can be changed to something else like labels on most widgets?

It's crazy to me if this is not possible as most other widgets or buttons can have their text changed in most languages.

1
You can request for it through a comment on this bug on the GNOME Bugzilla I suppose.andlabs

1 Answers

1
votes

you can get access to it through the buttons children(the 'text' is normal Label)

>>> btn = Gtk.Button('SomeText')
>>> btn.get_children()
[<Gtk.Label object at 0x7f70dd0c86c0 (GtkLabel at 0x2527340)>]

you can then change the label to e.g.: markup with

>>> btn.get_children()[0].set_use_markup(True)
>>> btn.get_children()[0].set_label("<span color='green'>TEST</span>")

from documentation:

The GtkButton widget can hold any valid child widget. That is, it can hold almost any other standard GtkWidget. The most commonly used child is the GtkLabel.