Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-14-2009, 07:24 AM   #1
Registered: Sep 2007
Location: Berlin
Distribution: Slackware
Posts: 509

Rep: Reputation: 41
GtkCheckButton - how to put label on the other side of the button?

Due to a very specific style guide for a project I have to adjust Gtk radio and checkbuttons to show their text label on the _left_ side of the button like this:

apple []
pears []
grape []

Gtks default puts the button on the left side and the textlabel on the right.

Did I miss some incredibly simple flag or do I have to derive a custom button from ToggleButton to archieve that? (If so - some illustrating pseudo code would be appreciated..)

I've tried some hack with not showing the default label of a radio/checkbutton and instead putting my own label on the left side - but as both button-types have a clickable area around them where usally the label is set, this is ugly and not really working.
Old 04-14-2009, 09:08 AM   #2
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I'm no expert on this subject, but I did play around with radio buttons in Glade, and can suggest a work-around. Make the radio button's label an empty string, and pack a separate label adjacent to it, all within a hbox. The relevant code generated by glade:
  hbox3 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox3);
  gtk_table_attach (GTK_TABLE (table1), hbox3, 0, 1, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  label1 = gtk_label_new (_("label1"));
  gtk_widget_show (label1);
  gtk_box_pack_start (GTK_BOX (hbox3), label1, TRUE, TRUE, 0);
  gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_RIGHT);

  radiobutton3 = gtk_radio_button_new_with_mnemonic (NULL, "");
  gtk_widget_show (radiobutton3);
  gtk_box_pack_end (GTK_BOX (hbox3), radiobutton3, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON(radiobutton3),radiobutton3_group);
  radiobutton3_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton3));
Hoping someone comes up with a better solution.
--- rod.
Old 04-14-2009, 09:59 AM   #3
Registered: Sep 2007
Location: Berlin
Distribution: Slackware
Posts: 509

Original Poster
Rep: Reputation: 41
That's what I did...

As mentioned it's not really that nice because of Gtk sets a clickable area around the label. This is very useful, because you don't have to acutally hit the (tiny) button itself but just the label to activate the check/radio button..

Now I have my clickable area still on the right side of my buttons and my label left-sided.

Here's a screenshot of some checkbuttons.

I could add an EventBox or something like this - but at least I'd like to disable the empty click area on the right side.
Old 04-22-2009, 07:34 PM   #4
Registered: Jul 2005
Location: maryland
Distribution: Ubuntu 9.04
Posts: 88

Rep: Reputation: 17
You could change the size of the window, or modify the size of the columns and rows of your widgets. Also, you can set the labels so that they aren't "clickable", lol, i don't know if that's the right word. Anyways, hope that helps.


gtk, programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
mouse side button problems... vik Slackware 3 04-17-2008 10:22 PM
TeamSpeak2 - Logitech MX1000 - Side Button Push to Talk nutnut Linux - Software 1 08-14-2007 12:31 PM
SLED 10, Microsoft Wireless Notebook Optical Mouse 4000 and side button... Aleksej Linux - Hardware 0 03-29-2007 09:42 AM
button-widget's label text is cut in half xideum Linux - Software 0 10-02-2004 02:01 PM
Logitech Mouse: side button won't work hopper02 Linux - Hardware 0 11-21-2003 02:44 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:43 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration