how to determine the pixel-width of a widgets text
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2006-06-26
02:36 PM
- last edited on
2023-08-07
11:08 AM
by
Doreena Deng
2006-06-26
02:36 PM
Hi 🙂
My addon is dynamically creating widgets.
Example:
Buttons are created and the width of the buttons should fit the width of text of the buttons.
The buttons text is not known before so i need to get the pixel width of the text at run time.
I see a way to get the maximum length of the widgets font. (API_FontType.widMax)
("w" is longer than "i"...)
I could multiply that with the number of characters, but perhaps someone has a hint how to determine the exact length of a widget-text?
greetings,
John
My addon is dynamically creating widgets.
Example:
Buttons are created and the width of the buttons should fit the width of text of the buttons.
The buttons text is not known before so i need to get the pixel width of the text at run time.
I see a way to get the maximum length of the widgets font. (API_FontType.widMax)
("w" is longer than "i"...)
I could multiply that with the number of characters, but perhaps someone has a hint how to determine the exact length of a widget-text?
greetings,
John
Labels:
- Labels:
-
Add-On (C++)
1 REPLY 1
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2006-06-27 05:00 PM
2006-06-27
05:00 PM
John wrote:
Hi🙂
I see a way to get the maximum length of the widgets font. (API_FontType.widMax)
oh, i think these has nothing to do with the fonts of GUI-Widgets.
I just tried a little bit and choosed 5.4 as standard width of a letter.
Hmm.
Example:
Creation of two labels:
Text of Label1 = "iiiiiiiiii" (10 letters)
Text of Label2 = "wwwwwwwwww" (10 letters)
the labels will look like that:
<_iiiiiiiiii__________>
<_wwwwwwwwww_>
but i'am searching for a way to let them look like that:
<_iiiiiiiiii_>
<_wwwwwwwwww_>
any hints?