Wrapping gtk2:buttons

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

Wrapping gtk2:buttons

Chris Debenham
I need to display 40 buttons in an area which may be resized and the
text in the buttons is dynamic.
As such I can't really determine ahead of time how many buttons will
fit on a row.
Is there any way to display a bunch of Gtk2::Button widgets and have
it wrap around to fit the available space?

--

Dave Barry  - "Camping is nature's way of promoting the motel
business." - http://www.brainyquote.com/quotes/authors/d/dave_barry.html
_______________________________________________
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: Wrapping gtk2:buttons

Grant McLean
On Wed, 2009-06-10 at 15:07 +1000, Chris Debenham wrote:
> I need to display 40 buttons in an area which may be resized and the
> text in the buttons is dynamic.
> As such I can't really determine ahead of time how many buttons will
> fit on a row.
> Is there any way to display a bunch of Gtk2::Button widgets and have
> it wrap around to fit the available space?

I do mean this in a caring way, but that sounds like a *horrible* user
interface :-)

Someone else may have alternate suggestions, but I can think of a couple
of ways to achieve what you're asking for.

* the Gtk::TextView widget is normally used to display word-wrapped
  text but you can add widgets (like buttons) into the textview using
  the add_child_at_anchor() method

* the Gtk::Layout can be used to position widgets at absolute
  coordinates, so by hooking into signals when the window is resized,
  you could adjust the position of the button widgets to reflow them
  as required

I think the Gtk::IconView widget does the kind of layout flowing you're
talking about, but I'm not sure it can be coerced into displaying
buttons.

I do wonder though whether that many options would be better implemented
as menus rather than buttons.

Good luck
Grant

_______________________________________________
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: Wrapping gtk2:buttons

Chris Debenham
2009/6/10 Grant McLean <[hidden email]>:

> On Wed, 2009-06-10 at 15:07 +1000, Chris Debenham wrote:
>> I need to display 40 buttons in an area which may be resized and the
>> text in the buttons is dynamic.
>> As such I can't really determine ahead of time how many buttons will
>> fit on a row.
>> Is there any way to display a bunch of Gtk2::Button widgets and have
>> it wrap around to fit the available space?
>
> I do mean this in a caring way, but that sounds like a *horrible* user
> interface :-)

No worries, Normally I'd agree but it does make sense for this
particular use case.
It is to display a list of bible books as buttons - these buttons are
then replaced with buttons for the chapters, then verses.
It is used for quickly looking up verses (without having to type) See
http://www.adebenham.com/lyricue/screenshot.html for a screenshot
showing part of it

>
> Someone else may have alternate suggestions, but I can think of a couple
> of ways to achieve what you're asking for.
>
> * the Gtk::TextView widget is normally used to display word-wrapped
>  text but you can add widgets (like buttons) into the textview using
>  the add_child_at_anchor() method

Ugly - but may work

>
> * the Gtk::Layout can be used to position widgets at absolute
>  coordinates, so by hooking into signals when the window is resized,
>  you could adjust the position of the button widgets to reflow them
>  as required

This would get complicated/slow as it has to be done for up to 150
buttons (for chapters with lots of verses)

>
> I think the Gtk::IconView widget does the kind of layout flowing you're
> talking about, but I'm not sure it can be coerced into displaying
> buttons.


I found a reference to how iconview implements CellLayout so a custom
CellRenderer should be possible - If I can control the sizing this is
probably the best way

>
> I do wonder though whether that many options would be better implemented
> as menus rather than buttons.

Normally yes - but not in this context

>
> Good luck
> Grant

Thanks for the pointers - now I just have to go and try them out :-)

>
> _______________________________________________
> gtk-perl-list mailing list
> [hidden email]
> http://mail.gnome.org/mailman/listinfo/gtk-perl-list
>



--

Dave Barry  - "Camping is nature's way of promoting the motel
business." - http://www.brainyquote.com/quotes/authors/d/dave_barry.html
_______________________________________________
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: Wrapping gtk2:buttons

Kevin Ryde
Chris Debenham <[hidden email]> writes:
>
> 2009/6/10 Grant McLean <[hidden email]>:
>>
>> * the Gtk::TextView ...
>
> Ugly - but may work

You might check if it will flow them automatically, I suspect they might
end up in one wide line.

>> * the Gtk::Layout ...
>
> This would get complicated/slow as it has to be done for up to 150
> buttons (for chapters with lots of verses)

A custom container widget might be the way to go.  It could be much
easier than wrestling with cell layout/view/renderer/editable/whatnot.

A "flowed-hbox" seems like a reasonable concept.  In one of my dialogs
I've got a set of parameter entry boxes or check buttons and if there's
a lot I could see them flowed instead of scrolled.
_______________________________________________
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: Wrapping gtk2:buttons

Chris Debenham
2009/6/11 Kevin Ryde <[hidden email]>:

> Chris Debenham <[hidden email]> writes:
>>
>> 2009/6/10 Grant McLean <[hidden email]>:
>>>
>>> * the Gtk::TextView ...
>>
>> Ugly - but may work
>
> You might check if it will flow them automatically, I suspect they might
> end up in one wide line.

Perhaps if I put a space character between each?

>
>>> * the Gtk::Layout ...
>>
>> This would get complicated/slow as it has to be done for up to 150
>> buttons (for chapters with lots of verses)
>
> A custom container widget might be the way to go.  It could be much
> easier than wrestling with cell layout/view/renderer/editable/whatnot.
>
> A "flowed-hbox" seems like a reasonable concept.  In one of my dialogs
> I've got a set of parameter entry boxes or check buttons and if there's
> a lot I could see them flowed instead of scrolled.

How would I go about this?



--

Dan Quayle  - "This President is going to lead us out of this
recovery." - http://www.brainyquote.com/quotes/authors/d/dan_quayle.html
_______________________________________________
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: Wrapping gtk2:buttons

Kevin Ryde
Chris Debenham <[hidden email]> writes:
>
> Perhaps if I put a space character between each?

Oh, no, I see it's about right (I forgot the wrap mode).  Looks like it
may want horiz scrollbar in 'automatic' mode or it does silly things
with its size request though (affecting how much the window manager will
offer to shrink it).

> How would I go about this?

As they say, if you have to ask the price then you can't afford it :-).
A custom container isn't outrageously difficult, but a fair few details.


--
"Every turkey dies, but not every turkey truly lives."
_______________________________________________
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: Wrapping gtk2:buttons

Chris Debenham
I just tried the TextView method and it worked!
To only thing I'd like to change is to be able to set the widgets to
'fill' the space horizontally rather then taking the bare minimum of
space.


2009/6/12 Kevin Ryde <[hidden email]>:

> Chris Debenham <[hidden email]> writes:
>>
>> Perhaps if I put a space character between each?
>
> Oh, no, I see it's about right (I forgot the wrap mode).  Looks like it
> may want horiz scrollbar in 'automatic' mode or it does silly things
> with its size request though (affecting how much the window manager will
> offer to shrink it).
>
>> How would I go about this?
>
> As they say, if you have to ask the price then you can't afford it :-).
> A custom container isn't outrageously difficult, but a fair few details.
>
>
> --
> "Every turkey dies, but not every turkey truly lives."
>



--

Josh Billings  - "Every man has his follies - and often they are the
most interesting thing he has got." -
http://www.brainyquote.com/quotes/authors/j/josh_billings.html
_______________________________________________
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: Wrapping gtk2:buttons

Kevin Ryde
Chris Debenham <[hidden email]> writes:
>
> 'fill' the space horizontally rather then taking the bare minimum of
> space.

I suppose that's the sort of expand/fill option the containers have.
Doesn't look like textview does that.

One possibility could be Gtk2::SizeGroup to make the buttons all the
same width, like a flowable grid.
_______________________________________________
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: Wrapping gtk2:buttons

Chris Debenham
2009/6/12 Kevin Ryde <[hidden email]>:

> Chris Debenham <[hidden email]> writes:
>>
>> 'fill' the space horizontally rather then taking the bare minimum of
>> space.
>
> I suppose that's the sort of expand/fill option the containers have.
> Doesn't look like textview does that.
>
> One possibility could be Gtk2::SizeGroup to make the buttons all the
> same width, like a flowable grid.

That works pretty good - it doesn't use all the horizontal space
available - but it does look a lot neater.

Thanks



--

Mae West  - "I like restraint, if it doesn't go too far." -
http://www.brainyquote.com/quotes/authors/m/mae_west.html
_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list