fix: fix circler import

This commit is contained in:
shenjack 2023-01-02 17:19:57 +08:00
parent 186a597364
commit 235c010d41
6 changed files with 52 additions and 39 deletions

View File

@ -35,7 +35,7 @@ class _DR_option(Options):
"""
name = 'DR Option'
# runtime options
InputBox_use_TextEntry: bool = False
InputBox_use_TextEntry: bool = True
record_threads: bool = True
use_cProfile: bool = False
use_local_logging: bool = False

View File

@ -15,7 +15,17 @@ import dataclasses
from typing import get_type_hints, Type, List, Union, Dict, Any, Callable, Tuple
# from Difficult Rocket
from Difficult_Rocket.utils import translate
__all__ = ['get_type_hints_',
'Options',
'Fonts',
'FontData',
'OptionsError',
'OptionNotFound',
'OptionNameNotDefined']
def get_type_hints_(cls: Type):
@ -74,8 +84,8 @@ class Options:
if isinstance(a_fun, property):
try:
values[option] = getattr(self, option)
except AttributeError as e:
raise OptionNotFound(f'Option {option} is not found in {self.name}')
except AttributeError:
raise OptionNotFound(f'Option {option} is not found in {self.name}') from None
return values
def flush_option(self) -> Dict[str, Any]:
@ -108,10 +118,38 @@ class Options:
return cls.options
class Fonts(Options):
# font's value
HOS: str = 'HarmonyOS Sans'
HOS_S: str = 'HarmonyOS Sans SC'
HOS_T: str = 'HarmonyOS Sans TC'
HOS_C: str = 'HarmonyOS Sans Condensed'
鸿蒙字体: str = HOS
鸿蒙简体: str = HOS_S
鸿蒙繁体: str = HOS_T
鸿蒙窄体: str = HOS_C
CC: str = 'Cascadia Code'
CM: str = 'Cascadia Mono'
CCPL: str = 'Cascadia Code PL'
CMPL: str = 'Cascadia Mono PL'
微软等宽: str = CC
微软等宽无线: str = CM
微软等宽带电线: str = CCPL
微软等宽带电线无线: str = CMPL
得意黑: str = '得意黑'
# SS = smiley-sans
SS: str = 得意黑
@dataclasses.dataclass
class FontData:
""" 用于保存字体的信息 """
font_name: str = translate.鸿蒙简体
font_name: str = Fonts.鸿蒙简体
font_size: int = 13
bold: bool = False
italic: bool = False
@ -123,4 +161,3 @@ class FontData:
bold=self.bold,
italic=self.italic,
stretch=self.stretch)

View File

@ -13,7 +13,7 @@ gitee: @shenjackyuanjie
import re
from Difficult_Rocket.utils import translate
from Difficult_Rocket.api.types import Fonts
from pyglet.text.formats import structured
@ -216,12 +216,12 @@ default_fonts_config = [
{
'match': re.compile(r''), # 匹配的字符 匹配选项是re.compile()
'shown': re.compile(r''), # 匹配到的字符中显示的部分 匹配选项是re.compile()
'style': SingleTextStyle(font_name=translate.鸿蒙简体, font_size=15, bold=False, italic=False, show=True, color='white'),
'style': SingleTextStyle(font_name=Fonts.鸿蒙简体, font_size=15, bold=False, italic=False, show=True, color='white'),
},
{
'match': re.compile(r'[a-zA-Z0-9]'),
'shown': re.compile(r'[a-zA-Z0-9]'),
'style': SingleTextStyle(font_name=translate.微软等宽, font_size=15)
'style': SingleTextStyle(font_name=Fonts.微软等宽, font_size=15)
},
# Markdown 语法规则匹配
{

View File

@ -29,8 +29,7 @@ from pyglet.text.layout import IncrementalTextLayout
# from libs import pyperclip
# from libs.pyperclip import paste
from Difficult_Rocket.api.types import FontData
from Difficult_Rocket.utils import translate
from Difficult_Rocket.api.types import FontData, Fonts
from Difficult_Rocket.client.guis.format import html
from Difficult_Rocket import DR_option
@ -45,7 +44,7 @@ class TextButton(widgets.WidgetBase):
def __init__(self,
x: int, y: int, width: int, height: int,
text: str,
font: str = translate.鸿蒙简体, font_size: int = 13):
font: str = Fonts.鸿蒙简体, font_size: int = 13):
super().__init__(x, y, width, height)
self.text = text
self.text_label = Label(
@ -72,6 +71,8 @@ if not DR_option.InputBox_use_TextEntry:
text_color: Optional[Tuple[int, int, int, int]] = (0, 0, 0, 255),
caret_color: Optional[Tuple[int, int, int, int]] = (0, 0, 0),
batch: Optional[Batch] = None, group: Optional[Group] = None):
if font_data is None:
font_data = FontData()
self._doc = UnformattedDocument(text)
self._doc.set_style(0, len(self._doc.text), {**font_data.dict(), 'text_color': text_color})
font = self._doc.get_font()

View File

@ -11,6 +11,7 @@ from pyglet.graphics import Batch, Group
from pyglet.clock import get_frequency
# Difficult Rocket function
from Difficult_Rocket.api.types import Fonts
from Difficult_Rocket.utils import translate
from Difficult_Rocket.api.screen import BaseScreen
from Difficult_Rocket.command.tree import CommandTree
@ -32,7 +33,7 @@ class DRDEBUGScreen(BaseScreen):
self.fps_label = Label(x=10, y=main_window.height - 10,
width=main_window.width - 20, height=20,
anchor_x='left', anchor_y='top',
font_name=translate.微软等宽无线, font_size=20,
font_name=Fonts.微软等宽无线, font_size=20,
multiline=True,
batch=self.main_batch, group=self.main_group)
self.fps_label.text = "11111114514"

View File

@ -174,29 +174,3 @@ if not __name__ == '__main__':
tr = Lang()
else:
tr_ = Tr()
# font's value
HOS = 'HarmonyOS Sans'
HOS_S = 'HarmonyOS Sans SC'
HOS_T = 'HarmonyOS Sans TC'
HOS_C = 'HarmonyOS Sans Condensed'
鸿蒙字体 = HOS
鸿蒙简体 = HOS_S
鸿蒙繁体 = HOS_T
鸿蒙窄体 = HOS_C
CC = 'Cascadia Code'
CM = 'Cascadia Mono'
CCPL = 'Cascadia Code PL'
CMPL = 'Cascadia Mono PL'
微软等宽 = CC
微软等宽无线 = CM
微软等宽带电线 = CCPL
微软等宽带电线无线 = CMPL
得意黑 = '得意黑'
# SS = smiley-sans
SS = 得意黑