Page 1 of 1

HowTo get the number of pixels in a text string?

Posted: Fri 23 Apr 2010, 09:11
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.

Posted: Mon 26 Apr 2010, 06:03
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.

Posted: Mon 26 Apr 2010, 08:18
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.

Posted: Mon 26 Apr 2010, 17:56
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.

Posted: Mon 26 Apr 2010, 18:30
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

Posted: Tue 27 Apr 2010, 05:07
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.

Posted: Tue 27 Apr 2010, 06:09
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

Posted: Tue 27 Apr 2010, 19:36
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

Posted: Tue 27 Apr 2010, 21:06
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.