Grouping Toggle Buttons

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Grouping Toggle Buttons

Jens Luedicke
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hiya..

I want to group toggle buttons so that only one is active at a time and
clicking another one in the group de-toggles all others. Like Radiobuttons.

Any ideas?

TIA,
Jens

- --
Jens Luedicke
web: http://perldude.de

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCysvIiCvkc4H0gTERAtVkAJ4kctI25aJs5YSWj1Kyg4EN18WL5gCfZZwb
FjtELPc7SrXC4SC0V1Klv50=
=ftEp
-----END PGP SIGNATURE-----
_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Grouping Toggle Buttons

muppet-6

On Jul 5, 2005, at 2:04 PM, Jens Luedicke wrote:

> I want to group toggle buttons so that only one is active at a time  
> and
> clicking another one in the group de-toggles all others. Like  
> Radiobuttons.
>
> Any ideas?

Use RadioButtons.

/me ducks

No, seriously.  ToggleButton, from which RadioButton inherits, has an  
object property named "draw_indicator".  In modern times this would  
be a style property, but it's apparently a holdover, and you can  
still use it in your code to make your RadioButton look like a  
ToggleButton, for whatever odd reason you may have (insert standard  
disclaimer about how only themes are supposed to be in charge of this  
sort of thing).


   #!/usr/bin/perl -w
   use strict;
   use Glib qw(FALSE);
   use Gtk2 -init;

   my $window = Gtk2::Window->new;
   $window->signal_connect (destroy => sub { Gtk2->main_quit });
   my $vbox = Gtk2::VBox->new;
   $window->add ($vbox);
   my $rb = undef;
   foreach (qw(one two three four)) {
       $rb = Gtk2::RadioButton->new ($rb, $_);
       $rb->set (draw_indicator => FALSE); # i'm evil
       $vbox->add ($rb);
       $rb->signal_connect (toggled => sub {
           print $_[0]->get_label." ".($_[0]->get_active ? "on" :  
"off")."\n";
       });
   }
   $window->show_all;
   Gtk2->main ;


--
"it's hard to be eventful when you have this much style."
    - me, rationalizing yet another night of sitting at home.

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Grouping Toggle Buttons

Jens Luedicke
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

muppet wrote:

>
> Use RadioButtons.
>
> /me ducks
>
> No, seriously.  ToggleButton, from which RadioButton inherits, has an
> object property named "draw_indicator".  In modern times this would  be
> a style property, but it's apparently a holdover, and you can  still use
> it in your code to make your RadioButton look like a  ToggleButton, for
> whatever odd reason you may have (insert standard  disclaimer about how
> only themes are supposed to be in charge of this  sort of thing).

Thanks. Works fine! I don't mind abusing this style property :)

jens

- --
Jens Luedicke
web: http://perldude.de

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCyxyDiCvkc4H0gTERAlMPAKCJJeKgT+AGfSwx9sSkHOPaUAezCwCdEg+4
H0e9jn6EGNOJsPl+rtjgl3g=
=2J8e
-----END PGP SIGNATURE-----
_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list