Skip to content

Commit 8c44afb

Browse files
committed
add ui example and update to pyglet text parameter enums
1 parent af4077b commit 8c44afb

File tree

7 files changed

+74
-8
lines changed

7 files changed

+74
-8
lines changed

arcade/text.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from typing import Any
88

99
import pyglet
10+
from pyglet.enums import Weight, Style
1011

1112
import arcade
1213
from arcade.exceptions import PerformanceWarning, warning
@@ -285,8 +286,8 @@ def __init__(
285286
width=width,
286287
align=align,
287288
font_name=font_name,
288-
weight=pyglet.text.Weight.BOLD if bold else pyglet.text.Weight.NORMAL,
289-
italic=italic,
289+
weight=Weight.BOLD if bold else Weight.NORMAL,
290+
style=Style.ITALIC if italic else Style.NORMAL,
290291
anchor_x=anchor_x,
291292
anchor_y=anchor_y,
292293
multiline=multiline,
@@ -609,11 +610,11 @@ def bold(self) -> bool | str:
609610
* ``"light"``
610611
611612
"""
612-
return self.label.weight == pyglet.text.Weight.BOLD
613+
return self.label.weight == Weight.BOLD
613614

614615
@bold.setter
615616
def bold(self, bold: bool | str):
616-
self.label.weight = pyglet.text.Weight.BOLD if bold else pyglet.text.Weight.NORMAL
617+
self.label.weight = Weight.BOLD if bold else Weight.NORMAL
617618

618619
@property
619620
def italic(self) -> bool | str:

webplayground/basic_renderer/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33

44
<head>
5-
<script src="https://cdn.jsdelivr.net/pyodide/v0.27.6/full/pyodide.js"></script>
5+
<script src="https://cdn.jsdelivr.net/pyodide/v0.28.1/full/pyodide.js"></script>
66
</head>
77

88
<body>
@@ -15,7 +15,7 @@
1515
await micropip.install("http://localhost:8000/pyglet-3.0.0a1-py3-none-any.whl");
1616
await micropip.install("http://localhost:8000/arcade-3.2.0-py3-none-any.whl");
1717

18-
let response = await fetch("http://localhost:8000/basic_renderer/package.zip");
18+
let response = await fetch("./package.zip");
1919
let buffer = await response.arrayBuffer();
2020
await pyodide.unpackArchive(buffer, "zip", "package");
2121
pkg = pyodide.pyimport("package");

webplayground/instancing/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33

44
<head>
5-
<script src="https://cdn.jsdelivr.net/pyodide/v0.27.6/full/pyodide.js"></script>
5+
<script src="https://cdn.jsdelivr.net/pyodide/v0.28.1/full/pyodide.js"></script>
66
</head>
77

88
<body>
@@ -15,7 +15,7 @@
1515
await micropip.install("http://localhost:8000/pyglet-3.0.0a1-py3-none-any.whl");
1616
await micropip.install("http://localhost:8000/arcade-3.2.0-py3-none-any.whl");
1717

18-
let response = await fetch("http://localhost:8000/instancing/package.zip");
18+
let response = await fetch("./package.zip");
1919
let buffer = await response.arrayBuffer();
2020
await pyodide.unpackArchive(buffer, "zip", "package");
2121
pkg = pyodide.pyimport("package");
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<script src="https://cdn.jsdelivr.net/pyodide/v0.28.1/full/pyodide.js"></script>
6+
</head>
7+
8+
<body>
9+
<script type="text/javascript">
10+
async function main() {
11+
let pyodide = await loadPyodide();
12+
await pyodide.loadPackage("micropip");
13+
const micropip = pyodide.pyimport("micropip");
14+
await pyodide.loadPackage("pillow"); // Arcade needs Pillow
15+
await micropip.install("http://localhost:8000/pyglet-3.0.0a1-py3-none-any.whl");
16+
await micropip.install("http://localhost:8000/arcade-3.2.0-py3-none-any.whl");
17+
18+
let response = await fetch("./package.zip");
19+
let buffer = await response.arrayBuffer();
20+
await pyodide.unpackArchive(buffer, "zip", "package");
21+
pkg = pyodide.pyimport("package");
22+
pkg.main();
23+
}
24+
main();
25+
</script>
26+
</body>
27+
28+
</html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .main import main
1.17 MB
Loading
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import arcade
2+
from arcade.gui import UIView, UILabel, UIAnchorLayout, NinePatchTexture
3+
4+
TEX_NINEPATCH_BASE = arcade.load_texture(":resources:gui_basic_assets/window/grey_panel.png")
5+
6+
7+
class MyView(UIView):
8+
def __init__(self):
9+
super().__init__()
10+
self.background_color = arcade.color.GREEN
11+
12+
root = self.ui.add(UIAnchorLayout())
13+
root.with_background(
14+
texture=NinePatchTexture(
15+
texture=TEX_NINEPATCH_BASE,
16+
left=7,
17+
right=7,
18+
bottom=7,
19+
top=7,
20+
)
21+
)
22+
root.with_border(width=2, color=arcade.color.RED)
23+
24+
root.add(UILabel(text="Hello World")).with_background(color=(255, 0, 0, 255))
25+
26+
def on_key_press(self, symbol, mod):
27+
print(self.window.size)
28+
29+
30+
def main():
31+
window = arcade.Window()
32+
window.run(MyView())
33+
34+
35+
if __name__ == "__main__":
36+
main()

0 commit comments

Comments
 (0)