Hello, list. I'm trying to make a new widget, (after searching and
not finding one already, which could be called wxTagCloud, and which
should look like a traditional web-based tag cloud (like
http://isp.webopedia.com/FIG/tag_cloud.jpg). But I have two issues so
far. Two runnable code examples attached. The problems are:
1) scrolledpanel + FlowSizer = no scroll bars
I am using a FlowSizer (where the widgets wrap or "flow" down to the
next row), and have started with this one I found on this list:
http://groups.google.com/group/wxpython-users/browse_thread/thread/7822b4aae1629121?fwc=2&pli=1
(I also realize a new one is coming with wxPython 2.9, but I wanted to
get started now)
The problem is, there may be more tags than can fit in the space
provided (assuming that space can only be expanded so much), and so at
that point I would like to have scroll bars to allow the user to see
the remaining tags.
[Human usage note: I think it's best that a tag cloud is all seen at
once, so every tag has a chance to jog the user's memory to possibly
use it, but on the other hand sometimes it is also important to
constrain the size of the space allotted, so I think scroll bars to
reveal the remainder of the tag cloud is not going to bias the user
too much toward ignoring the lower tags.]
I am not even sure where to begin to make it such that scroll bars
will appear when the tag cloud can be compressed no further. They do
appear if I change the FlowSizer to a wxBoxSizer, so it is something
about the FlowSizer which is not compatible with the scrolledpanel. I
tried with a scrolledwindow, too, but was unable to get it to do more
than just initially put scroll bars--resizing caused them to
disappear.
So, any ideas how I can make scroll bars to kick in when needed?
Problem 2: The words are unevenly vertically aligned
This has nothing to do with the FlowSizer, as I have the same problem
using a BoxSizer. It's just that staticTexts of different font sizes
don't line up well (see 2nd attached example), at least the way I'm
doing it. This makes the cloud of words look messier than it ought
to. Again, compare the ideal image here
(http://isp.webopedia.com/FIG/tag_cloud.jpg), which shows each word
aligned to the bottom of each row. I imagine this is a simple fix,
but I don't know it and would rather not reinvent the wheel w/
something more complex than it need be.
I think if I can get past these two problems and then just bind events
to the words and make it into a class which accepts a list of tags, it
can be a nice tag cloud widget. Previously, I had been using just
checkboxes all neatly aligned in a flexGridSizer, but that looks kind
of rigid and uninspiring compared to a tag cloud. And any suggestions
for changes to the overall thinking are very welcome. [wxPython
2.8.10.1, winXP, Python 2.5]
Thanks,
Che
tag_cloud.py (8.57 KB)
uneven_text.py (2.34 KB)