Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Styling a line in Tk::HList
-----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

Report this thread to moderator Post Follow-up to this message
Old Post
H.Wade Minter
09-13-04 08:57 AM


Re: Styling a line in Tk::HList
> (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


Report this thread to moderator Post Follow-up to this message
Old Post
Ala Qumsieh
09-13-04 08:57 AM


Re: Styling a line in Tk::HList
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

Report this thread to moderator Post Follow-up to this message
Old Post
H. Wade Minter
09-13-04 02:02 PM


Re: Styling a line in Tk::HList
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


Report this thread to moderator Post Follow-up to this message
Old Post
Pit
09-14-04 01:56 AM


Re: Styling a line in Tk::HList
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

Report this thread to moderator Post Follow-up to this message
Old Post
Ala Qumsieh
09-14-04 01:56 AM


Re: Styling a line in Tk::HList
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 Artis
t
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

Report this thread to moderator Post Follow-up to this message
Old Post
H. Wade Minter
09-14-04 01:56 AM


Re: Styling a line in Tk::HList
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)

Report this thread to moderator Post Follow-up to this message
Old Post
Kevin Michael Vail
09-14-04 01:56 AM


Re: Styling a line in Tk::HList
H. Wade Minter wrote:

> Well, the problem is that I've got titles, artists, etc. of pretty differe
nt
> lengths.  So, using the columnar style, I could end up with something like
> this:
>
> Category 1   Short Title                                         Other Art
ist
> Category 2   An Extremely Long Title (With lots of extra info)   Artist Na
me
>
> 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

Report this thread to moderator Post Follow-up to this message
Old Post
Ala Qumsieh
09-14-04 08:56 AM


Re: Styling a line in Tk::HList
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

Report this thread to moderator Post Follow-up to this message
Old Post
H. Wade Minter
09-14-04 02:03 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PerlTk archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:13 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.