Skip to content

Commit 42c5419

Browse files
authored
Switch to Pyglet 2.1 or dev releases (#2043)
* Temp add 2.1 + comment out 2.0.14 * Import from pyglet.display instead of pyglet.canvas * change pyglet.display to canvas in a second place * Remove commented out old versions of pyglet * Replace pyglet.canvas in clock_window * Replace display.canvas in get_dispaly_size * Remove canvas from type annotation in clock_window * Replace pyglet.canvas usage in application.py * Attempt to fix text layout * Fix whitespace in gui's text.py * Fix type issue from Literal usage in pyglet via type: ignore * Use pyglet==2.1dev2 * Temp pre-float width/height pyright fix
1 parent 47fd3cb commit 42c5419

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

arcade/application.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import pyglet.gl as gl
1515
import pyglet.window.mouse
16-
from pyglet.canvas.base import ScreenMode
16+
from pyglet.display.base import ScreenMode
1717

1818
import arcade
1919
from arcade import get_display_size
@@ -54,7 +54,7 @@ def get_screens() -> List:
5454
5555
:returns: List of screens, one for each monitor.
5656
"""
57-
display = pyglet.canvas.get_display()
57+
display = pyglet.display.get_display()
5858
return display.get_screens()
5959

6060

@@ -83,7 +83,7 @@ class Window(pyglet.window.Window):
8383
:param antialiasing: Should OpenGL's anti-aliasing be enabled?
8484
:param gl_version: What OpenGL version to request. This is ``(3, 3)`` by default \
8585
and can be overridden when using more advanced OpenGL features.
86-
:param screen: Pass a pyglet :py:class:`~pyglet.canvas.Screen` to
86+
:param screen: Pass a pyglet :py:class:`~pyglet.display.Screen` to
8787
request the window be placed on it. See `pyglet's window size &
8888
position guide <pyglet_pg_window_size_position_>`_ to learn more.
8989
:param style: Request a non-default window style, such as borderless.
@@ -110,7 +110,7 @@ def __init__(
110110
update_rate: float = 1 / 60,
111111
antialiasing: bool = True,
112112
gl_version: Tuple[int, int] = (3, 3),
113-
screen: Optional[pyglet.canvas.Screen] = None,
113+
screen: Optional[pyglet.display.Screen] = None,
114114
style: Optional[str] = pyglet.window.Window.WINDOW_STYLE_DEFAULT,
115115
visible: bool = True,
116116
vsync: bool = False,
@@ -152,7 +152,7 @@ def __init__(
152152
blue_size=8,
153153
alpha_size=8,
154154
)
155-
display = pyglet.canvas.get_display()
155+
display = pyglet.display.get_display()
156156
screen = display.get_default_screen()
157157
if screen:
158158
config = screen.get_best_config(config)

arcade/experimental/clock/clock_window.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import pyglet.gl as gl
2121
import pyglet.window.mouse
22-
from pyglet.canvas.base import ScreenMode
22+
from pyglet.display.base import ScreenMode
2323

2424
import arcade
2525
from arcade import get_display_size
@@ -70,7 +70,7 @@ class for more info.
7070
:param antialiasing: Should OpenGL's anti-aliasing be enabled?
7171
:param gl_version: What OpenGL version to request. This is ``(3, 3)`` by default \
7272
and can be overridden when using more advanced OpenGL features.
73-
:param screen: Pass a pyglet :py:class:`~pyglet.canvas.Screen` to
73+
:param screen: Pass a pyglet :py:class:`~pyglet.display.Screen` to
7474
request the window be placed on it. See `pyglet's window size &
7575
position guide <pyglet_pg_window_size_position_>`_ to learn more.
7676
:param style: Request a non-default window style, such as borderless.
@@ -97,7 +97,7 @@ def __init__(
9797
update_rate: float = 1 / 60,
9898
antialiasing: bool = True,
9999
gl_version: Tuple[int, int] = (3, 3),
100-
screen: Optional[pyglet.canvas.Screen] = None,
100+
screen: Optional[pyglet.display.Screen] = None,
101101
style: Optional[str] = pyglet.window.Window.WINDOW_STYLE_DEFAULT,
102102
visible: bool = True,
103103
vsync: bool = False,
@@ -141,7 +141,7 @@ def __init__(
141141
blue_size=8,
142142
alpha_size=8,
143143
)
144-
display = pyglet.canvas.get_display()
144+
display = pyglet.display.get_display()
145145
screen = display.get_default_screen()
146146
if screen:
147147
config = screen.get_best_config(config)

arcade/gui/widgets/text.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,11 @@ def __init__(
352352
)
353353

354354
self.layout = pyglet.text.layout.IncrementalTextLayout(
355-
self.doc, int(width - self.LAYOUT_OFFSET), int(height), multiline=multiline
355+
self.doc,
356+
x=x + self.LAYOUT_OFFSET, y=y, z=0.0, # Position
357+
width=int(width - self.LAYOUT_OFFSET), height=int(height), # Size
358+
multiline=multiline
356359
)
357-
self.layout.x += self.LAYOUT_OFFSET
358360
self.caret = Caret(self.layout, color=Color.from_iterable(caret_color))
359361
self.caret.visible = False
360362

arcade/text.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,9 @@ def __init__(
213213
z=z,
214214
font_name=adjusted_font,
215215
font_size=font_size,
216-
anchor_x=anchor_x,
217-
anchor_y=anchor_y,
216+
# use type: ignore since cast is slow & pyglet used Literal
217+
anchor_x=anchor_x, # type: ignore
218+
anchor_y=anchor_y, # type: ignore
218219
color=Color.from_iterable(color),
219220
width=width,
220221
align=align,

arcade/window_commands.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def get_display_size(screen_id: int = 0) -> Tuple[int, int]:
4949
:param screen_id: The screen number
5050
:return: Tuple containing the width and height of the screen
5151
"""
52-
display = pyglet.canvas.Display()
52+
display = pyglet.display.Display()
5353
screen = display.get_screens()[screen_id]
5454
return screen.width, screen.height
5555

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ classifiers = [
2222
"Topic :: Software Development :: Libraries :: Python Modules"
2323
]
2424
dependencies = [
25-
"pyglet>=2.0.14,<2.1",
25+
"pyglet == 2.1dev2",
2626
"pillow~=10.2.0",
2727
"pymunk~=6.6.0",
2828
"pytiled-parser~=2.2.3"

0 commit comments

Comments
 (0)