HowTo get the number of pixels in a text string?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

HowTo get the number of pixels in a text string?

#1 Post by sunburnt »

I`m trying to auto. set the width and height of PopMenus.
I have the height done, but the width is trickier of course.

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#2 Post by 8-bit »

I seem to recall that one can use an option to set width and height with a character option rather than a pixel one.
But honestly, I cannot remember where I saw it.
But just maybe it was a geometry option.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#3 Post by sunburnt »

I was thinking a hidden textbox and get it`s width, crude but simple if it works.
The problem is <visible>false</visible> isn`t invisible in gtkdialog, it`s grayed out.
But pop up a textbox only GUI off screen, get it`s width and then kill it may work.
It`ll only be there a split second and it`ll be off screen so it`s not visible.

Update: I tested it and it will allow a GUI to be off the bottom of the screen just a little bit.
I think as the screen resolution changes the allowable off screen area moves with it.
And perhaps the area`s height expands and contracts in a ratio to the screen resolution.

It seems gtkdialog doesn`t like negative numbers for geometry, and X off right side of screen.
I`m at resolution 1024x768 ( can`t get it to go higher ), and X=900 is OK, but X=1000 nope.
But even though screen Y=768, Y=900 is OK, so I can hide the textbox GUI below the bottom.

Can anyone with their screen at a higher resolution please verify this?
Code for test textbox GUI:

Code: Select all

#! /bin/sh
export TEXT_W="<window title=\"TEXTW\"><vbox>
  <text><label>0123456789</label><visible>false</visible></text>
</vbox></window>" ; gtkdialog3 -p TEXT_W +900+900 &
Change the second 900 (Y) at the last of the code to a bit more than your screen resolution Y.

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#4 Post by 8-bit »

I tested on a screen resolution of 1280x1024 and the program was shown as running on the taskbar even though I could not see the window.
I set the Y value to 1050.
Also, you forgot "-G" in your code so no geometry settings were passed to the program.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#5 Post by sunburnt »

Yep, forgot to correct the pasted first code... I think this will probably work as needed.
It`s good it shows in the taskbar, easy to close it that way, but it`ll be "nolist" in jwmrc.
I think a general class for "nolist" that all gtkdialog GUIs can use. Like: -class NOLIST

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#6 Post by 8-bit »

As to the Class and nolist, I tried at technasaurous suggestion to make a separate file containing the additions to be made to .jwmrc and then writing a little code that would put and include line in /etc/xdg/templates/_root_.jwmrc.
I tried it with a restart of JWM and it did not work.
The only way I could get the nolist to work for the DM window was just the way you did it.
Either I am missing something or just plain dumb!
There is commented lines at the start of the .jwmrc file that modifications should be made to the jwmrc configuration file.
But there are cautions there also.
So I am still at a loss as to the approved correct way to do it.

Still lost and still trying to learn!

Also, here is a thought.
Are all bash versions included with Puppy versions the same?
How does one check this?
I have heard comments on things being left out of bash when it is compiled to keep Puppy small.

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#7 Post by Lobster »

8-bit wrote:Are all bash versions included with Puppy versions the same?
How does one check this?
I have heard comments on things being left out of bash when it is compiled to keep Puppy small.
type busybox at the console
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#8 Post by seaside »

8-bit,
I tried it with a restart of JWM and it did not work.
Did you run fixmenus?

Does the code work when placed in "/root/.jwm/jwmrc-personal"?

Cheers,
s

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#9 Post by 8-bit »

seaside, Don't know, never tried putting it there.
Will have to get back to you on that one.
It would be interesting to know.

Post Reply