Open cklkevin127 opened 2 years ago
I get the same error. Commenting out the custom_alignment = 'center'
in the WesnothForm class removes the error, but also removes the center alignment, as you can imagine.
Sorry, this dropped off my radar. I'll try to look into in this weekend.
Specifically, I've narrowed it down to EditableLabel as what's causing the issue. Even trying to use it on its own causes the ArgumentError. Replacing the EditableLabel in Form with Label also causes Form to stop breaking (though it does cause Form not to work in the expected manner).
OK, so the specific issue here is that in pyglet's text/layout.py, a glScissor is called with (float, float, int, int), instead of (int, int, int, int). That is because the _clip_x and _clip_y, which is set from the rect, is float values. They're float values because in widget.py, line 1447, you do aligned_rect.round()
, saying it rounds the rectable to the nearest integer pixel.
That's incorrect- if you look at vecrec/shapes.py line 709, which is Rect's round() function, it's this:
def round(self, digits=0):
""" Round the dimensions of the given rectangle to the given number of digits. """
self._left = round(self._left, digits)
self._bottom = round(self._bottom, digits)
self._width = round(self._width, digits)
self._height = round(self._height, digits)
round(<float>, 0)
will give you a float.
>>> round(5.3, 0)
5.0
What we actually need is for line 1447 to be replaced with
aligned_rect._bottom = int(aligned_rect._bottom)
aligned_rect._height = int(aligned_rect._height)
aligned_rect._left = int(aligned_rect._left)
aligned_rect._width = int(aligned_rect._width)
I've got an error while trying to run the code from the tutorial:
How to fix this error? I'm using Python 3.9.7, pyglet 1.5.21 and glooey 0.3.6.