Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 19 Apr 2014, 02:34
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
An exec. utility to get text width and height in pixels. PIC
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [3 Posts]  
Author Message
sunburnt


Joined: 08 Jun 2005
Posts: 4981
Location: Arizona, U.S.A.

PostPosted: Sat 24 Aug 2013, 12:23    Post subject:  An exec. utility to get text width and height in pixels. PIC  

### All credit for this utility goes to vovchik who posted the code and helped out at the BaCon forum.

This utility is a life saver for sizing text widgets and their containers and windows.

# With a BaCon label display it can rotate the text and display markup text.

# Very fancy indeed.!

Uses BaCon`s Hug for it`s label widget, so it may not want to work for non-Precise Puppies ( Slacko ).
If I can get more help with it, I`ll use all GTK imports and eliminate Hug. So then it may be more portable.

For help just type: text-size

The caret character "^" is the input separator ( delimiter ).
Code:
Example: text-size ^Many here among us feel that life is but a joke.^Sans Bold 16^0^0


# Figured I ought to show a pic. of what can be done with it. Pretty impressive huh.?

The exec. only calculates the width x height. But additional dialogs can make use of it.

# I could make a text splash dialog like shown here if there`s interest.???
text-size_markup_sm.png
 Description   Pic of vovchik`s BaCon label dialog that can rotate the text, and uses text-size to get the dialog`s size.
 Filesize   73.43 KB
 Viewed   101 Time(s)

text-size_markup_sm.png

text-size.gz
Description 
gz

 Download 
Filename  text-size.gz 
Filesize  16.63 KB 
Downloaded  71 Time(s) 

Last edited by sunburnt on Sun 01 Sep 2013, 01:09; edited 1 time in total
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 3794
Location: Gatineau (Qc), Canada

PostPosted: Sat 31 Aug 2013, 15:24    Post subject:  

Hi, sunburnt.

Good show!

The graphic equivalent of
Code:
wc -l some.txt
, I suppose?

BFN.

musher0

_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send private message Visit poster's website 
sunburnt


Joined: 08 Jun 2005
Posts: 4981
Location: Arizona, U.S.A.

PostPosted: Sun 01 Sep 2013, 01:08    Post subject:  

Hi musher; More or less, like:
W=`wc -c some.txt`
H=`wc -l some.txt`

Except in pixels Wide and High instead of Characters and Lines.
I use to use a mono-font and estimate the text length, it worked fairly well...
But now we can get the exact pixel measurements so you can use any font, style, and size.

GtkDialog and all other GUI kits I`ve seen measure in pixels ( screen measurements ).
Average button is 20 to 25 pixels high, so get the text`s Width and Height + 5 or 10 for padding.

Now I`ve made a menu that allows each button to have an individual font, style, and size.
The same could be done in GtkDialog or most other GUI tool kits.
.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [3 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0397s ][ Queries: 12 (0.0037s) ][ GZIP on ]