2021-10-01 23:12:01 +08:00
|
|
|
|
# -------------------------------
|
|
|
|
|
# Difficult Rocket
|
2023-01-20 14:08:12 +08:00
|
|
|
|
# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
|
2021-10-01 23:12:01 +08:00
|
|
|
|
# All rights reserved
|
|
|
|
|
# -------------------------------
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
writen by shenjackyuanjie
|
|
|
|
|
mail: 3695888@qq.com
|
|
|
|
|
github: @shenjackyuanjie
|
|
|
|
|
gitee: @shenjackyuanjie
|
|
|
|
|
"""
|
|
|
|
|
|
2023-01-01 17:58:40 +08:00
|
|
|
|
from typing import Optional, Union, Tuple
|
|
|
|
|
|
2021-11-06 19:07:32 +08:00
|
|
|
|
# from libs import pyglet
|
2023-02-25 09:18:41 +08:00
|
|
|
|
# from pyglet import font
|
2022-10-29 19:13:00 +08:00
|
|
|
|
from pyglet.text import Label, HTMLLabel
|
2023-01-01 17:58:40 +08:00
|
|
|
|
# from pyglet.window import key
|
2022-10-29 19:13:00 +08:00
|
|
|
|
from pyglet.gui import widgets
|
2023-01-01 17:58:40 +08:00
|
|
|
|
# from pyglet.sprite import Sprite
|
2022-10-29 19:13:00 +08:00
|
|
|
|
from pyglet.shapes import Rectangle
|
2023-01-01 17:58:40 +08:00
|
|
|
|
# from pyglet.image import AbstractImage
|
2022-10-29 19:13:00 +08:00
|
|
|
|
from pyglet.graphics import Batch, Group
|
2023-01-01 21:54:59 +08:00
|
|
|
|
from pyglet.text.caret import Caret
|
2023-02-25 09:18:41 +08:00
|
|
|
|
from pyglet.text.document import UnformattedDocument
|
2022-10-29 19:13:00 +08:00
|
|
|
|
from pyglet.text.layout import IncrementalTextLayout
|
2022-12-20 16:31:08 +08:00
|
|
|
|
|
2023-08-12 00:28:31 +08:00
|
|
|
|
from Difficult_Rocket.api.types import Fonts
|
2023-06-16 23:36:24 +08:00
|
|
|
|
from Difficult_Rocket import DR_status
|
2022-12-20 16:31:08 +08:00
|
|
|
|
|
2021-10-01 23:12:01 +08:00
|
|
|
|
|
2022-12-20 16:31:08 +08:00
|
|
|
|
class TextButton(widgets.WidgetBase):
|
|
|
|
|
"""
|
2023-08-12 00:28:31 +08:00
|
|
|
|
自带 字符 + 材质 的按钮,就不用单独做材质了
|
2022-12-20 16:31:08 +08:00
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def __init__(self,
|
2023-08-12 00:28:31 +08:00
|
|
|
|
x: int,
|
|
|
|
|
y: int,
|
|
|
|
|
width: int,
|
|
|
|
|
height: int,
|
2022-12-20 16:31:08 +08:00
|
|
|
|
text: str,
|
2023-01-02 17:19:57 +08:00
|
|
|
|
font: str = Fonts.鸿蒙简体, font_size: int = 13):
|
2022-12-20 16:31:08 +08:00
|
|
|
|
super().__init__(x, y, width, height)
|
|
|
|
|
self.text = text
|
2023-08-12 00:28:31 +08:00
|
|
|
|
self.text_label = Label(font_name=font, font_size=font_size)
|
2022-12-20 16:31:08 +08:00
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def value(self):
|
|
|
|
|
return self.text
|
|
|
|
|
|
|
|
|
|
def _update_position(self):
|
|
|
|
|
self.text_label.position = self._x, self._y
|
|
|
|
|
...
|