Home > Archive > PerlTk > September 2004 > Styling a line in Tk::HList
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Styling a line in Tk::HList
|
|
| H.Wade Minter 2004-09-13, 3:57 am |
| -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'm switching from a Tk::Listbox to a Tk::HList in my application to
take advantage of the -data option in HList. While I'm converting, I
wonder if it's possible to take care of another nagging issue.
My listbox contains lines of text like this:
(Category) "The Title Here" by Artist Name
Is it possible, using the styles in HList, to put JUST the "The Title
Here" part in boldface?
Thanks,
Wade
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)
iD8DBQFBRQH7o4DwsyRGDscRAlu/AJ9s71KBMjbgFc0cZUtL3m2bwvFYHACgjExI
XWXcTKhVWqxT6I8XwmhbJq0=
=xejI
-----END PGP SIGNATURE-----
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| Ala Qumsieh 2004-09-13, 3:57 am |
| > (Category) "The Title Here" by Artist Name
>
> Is it possible, using the styles in HList, to put JUST the "The Title
> Here" part in boldface?
Yes:
use strict;
use Tk;
use Tk::HList;
use Tk::ItemStyle;
my $mw = new MainWindow;
my $hl = $mw->HList(-columns => 3,
)->pack(qw/-fill both -expand 1/);
my $bold = $hl->ItemStyle('text', -font => ['Helvetica 9 bold']);
$hl->add('entry0');
$hl->itemCreate(entry0 => 0, -text => '(Category)');
$hl->itemCreate(entry0 => 1, -text => '"The Title Here"',
-style => $bold);
$hl->itemCreate(entry0 => 2, -text => 'by Artist Name');
MainLoop;
--Ala
| |
| H. Wade Minter 2004-09-13, 9:02 am |
| Ala Qumsieh <notvalid@email.com> wrote:
>
> Yes:
>
> my $hl = $mw->HList(-columns => 3,
> )->pack(qw/-fill both -expand 1/);
>
> my $bold = $hl->ItemStyle('text', -font => ['Helvetica 9 bold']);
>
> $hl->add('entry0');
> $hl->itemCreate(entry0 => 0, -text => '(Category)');
> $hl->itemCreate(entry0 => 1, -text => '"The Title Here"',
> -style => $bold);
> $hl->itemCreate(entry0 => 2, -text => 'by Artist Name');
Ala,
Thanks for the tip. However, I don't (currently) display my output in
columnar form, so the example you gave doesn't really fit with the way he
data is arranged in the listbox.
I suppose it's not possible to have multiple styles within a single column,
is it?
Thanks,
Wade
| |
|
| Hi Wade,
if you only use the itemtype 'text' for column, you can only have one
style, but you can use i.e, the itemtype 'window'. so you can place every
other widget type in a hlist column. in an entry widget you can fotmatting
every sign for itself.
Pit
| |
| Ala Qumsieh 2004-09-13, 8:56 pm |
| H. Wade Minter wrote:
> I suppose it's not possible to have multiple styles within a single column,
> is it?
Not to my knowledge. But, the multiple columns looks almost identical to
the single column solution, so why not go that way?
Otherwise, you can use a Text widget with the proper tags, but it'll
probably be a pain to make it behave as a listbox.
--Ala
| |
| H. Wade Minter 2004-09-13, 8:56 pm |
| Ala Qumsieh <notvalid@email.com> wrote:
> H. Wade Minter wrote:
>
>
> Not to my knowledge. But, the multiple columns looks almost identical to
> the single column solution, so why not go that way?
Well, the problem is that I've got titles, artists, etc. of pretty different
lengths. So, using the columnar style, I could end up with something like
this:
Category 1 Short Title Other Artist
Category 2 An Extremely Long Title (With lots of extra info) Artist Name
Which means that one long column could scroll the listbox horizontally
past the viewport, which would be inconvenient for the user. Using a
noncolumnar setup, only the long entries are scrolled horizontally.
> Otherwise, you can use a Text widget with the proper tags, but it'll
> probably be a pain to make it behave as a listbox.
Yeah - I guess I'll just stick with unbolded titles in the HList.
Thanks,
Wade
| |
| Kevin Michael Vail 2004-09-13, 8:56 pm |
| In article <NHf1d.15409$ci3.232312@twister.southeast.rr.com>,
"H. Wade Minter" <minter@lunenburg.org> wrote:
> I suppose it's not possible to have multiple styles within a single column,
> is it?
Look at Tk::Compound.
--
Kevin Michael Vail | a billion stars go spinning through the night,
kevin@vaildc.net | blazing high above your head.
. . . . . . . . . | But _in_ you is the presence that
. . . . . . . . | will be, when all the stars are dead.
. . . . . . . . . | (Rainer Maria Rilke)
| |
| Ala Qumsieh 2004-09-14, 3:56 am |
| H. Wade Minter wrote:
> Well, the problem is that I've got titles, artists, etc. of pretty different
> lengths. So, using the columnar style, I could end up with something like
> this:
>
> Category 1 Short Title Other Artist
> Category 2 An Extremely Long Title (With lots of extra info) Artist Name
>
> Which means that one long column could scroll the listbox horizontally
> past the viewport, which would be inconvenient for the user. Using a
> noncolumnar setup, only the long entries are scrolled horizontally.
I would consider that a Feature (tm) ;-)
It might even look better. One "solution" to the scrolling problem is to
make the width of the title column fixed, and any titles that are too
wide would look something like:
An Extremely Long T...
Hovering the mouse over it would show the complete title in a Balloon.
You might even consider sorting by different columns.
Ok ok .. enough for me :)
--Ala
| |
| H. Wade Minter 2004-09-14, 9:03 am |
| Ala Qumsieh <notvalid@email.com> wrote:
> I would consider that a Feature (tm) ;-)
> It might even look better. One "solution" to the scrolling problem is to
> make the width of the title column fixed, and any titles that are too
> wide would look something like:
>
> An Extremely Long T...
>
> Hovering the mouse over it would show the complete title in a Balloon.
> You might even consider sorting by different columns.
>
> Ok ok .. enough for me :)
That's an interesting idea - I'll do some coding and see how it looks.
Thanks,
Wade
|
|
|
|
|