Actually ran into an issue with TextPropertiesManager and maybe it’s because I am either doing things wrong or thought it should work and it doesn’t.
Code that I use is as follows:
n = DirectLabel(text = text_setText(txt), text_fg = txtColor,
text_scale = (scX, scY) ,
text_mayChange = True,
text_wordwrap = wwX,
relief = None,
state = DGG.NORMAL )
First Issue: Embedded Text Properties
Figured since text.setText() in the manual referredto text nodes and onscreen text that text_setText() would work inside the DirectLabel. Aren’t many posts about embedded text properties and the DGUI system so I think I am the first to do this wrong.
Normally don’t like just copy/pasting other people’s work but I am at a loss for how to get this to work. Spent an inordinate amount of time trying to get this stuff up and running to no avail.
Before someone asks, making it a direct labelinstead of a text node so I can bind events (such as linking in-game items, etc.).
Second Issue: Text W/H
Been noticing that text w/h is scaling with the sixe of the scale of the direct label frame. For instance I have a node that is parented to pixel2d based on data collected from a layout file. When the gui item is opened all elements are parented to this node so moving the entire widget is much easier. Since the node doesn’t have a defined width, height, I pass along either individual w/h or main frame w/h when defining the method. The larger the width, the more stretched the text on a vertical scale (not horizontal).
The workaround I am using is converting current frame scale to the actual size of the text that I am looking for.
Such as this:
def retScale(self, w=40, h=40, scaleX=DESIREDTXTSZX, scaleY=DESIREDTXTSZY): # returns the desired scale based on current w/h
scX = (scaleX[1] / w) * scaleX[0]
scY = (scaleY[1] / h) * scaleY[0]
wwX = scX * w
return scX, scY, wwX
The all cap variables are globals in the module. Only thing I found for absolute text size was defining the amount of pixels per character which I read was to be used for the blurring that may take place with larger text sizes.
Trying to make this part of the code a bit versatile so users can change text size with a GUI slider bar.
As always appreciate people reading/responding. Pardon the lack of correct coding vocabulary and any spelling errors; seems I have been looking at code every hour I haven’t been in the office for the last month.