I am fairly sure I have gone about screen-scaling incorrectly, but my approach is as follows:
I have a popup that displays information, whose height may change, dependant on the number of lines presented to the user. As I roughly know the height in pixels per line (due to knowing the font size), I have incremented i
counting the \n
's in the message being presented. I then divided this by the Window.height
to give me a percentage of the screen required to properly display the information.
I know this information is displayed properly, when I hard code in the value resulted from the following equation;
TwoDecPoints = Decimal(10) ** -2
popupScale = (Decimal(i) / Decimal(Window.height)).quantize(TwoDecPoints)
But when I apply the popupScale
(nn.nn) to the popup
's size_hint
;
InformationScreen.ResultsPopup.size_hint = 0.95, popupScale
I receive this error;
Popup.size_hint_y have an invalid format (got Decimal('0.25'))
This eludes me, because I have a 2 decimal number, 0.95
which it never complains about. I have attempted to use it as a string;
InformationScreen.ResultsPopup.size_hint = 0.95, str(popupScale)
As well as using the original popupScale
without quantize
, and trimming the number;
popupScale = (Decimal(i) / Decimal(Window.height))
InformationScreen.ResultsPopup.size_hint = 0.95, str(popupScale)[:4]
Neither of which work.
I have looked around the documentation about size_hint, but could not find any relevant information to the data-type that size_hint
requires. Any help would be greatly appreciated. Thanks
size_hint
is a ReferenceListProperty, a tuple of size_hint_x
and size_hint_y
.
size_hint_x
(resp size_hint_y
) is a NumericProperty it takes a float or an int. So float(popupScale)
should do it.
Edit: if that didn't help the exact exception is raised in this line