mirror of
https://github.com/ksherlock/prez.git
synced 2024-11-26 00:49:16 +00:00
strings - join multiple arguments (so bytes and text can be passed in together)
This commit is contained in:
parent
c4c833c898
commit
b6cf8f1a76
11
base.py
11
base.py
@ -325,11 +325,13 @@ class rTextObject(rObject):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, text, **kwargs): # id=None, attr=None):
|
def __init__(self, *text, **kwargs): # id=None, attr=None):
|
||||||
super().__init__(**kwargs) # id=id, attr=attr
|
super().__init__(**kwargs) # id=id, attr=attr
|
||||||
# text is a string or bytes.
|
# text is a string or bytes.
|
||||||
# bytes is assumed to be macroman
|
# bytes is assumed to be macroman
|
||||||
self.text = str_to_bytes(text)
|
# self.text = str_to_bytes(text)
|
||||||
|
|
||||||
|
self.text = b"".join([str_to_bytes(x) for x in text])
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self.text)
|
return len(self.text)
|
||||||
@ -356,6 +358,9 @@ class rTextForLETextBox2(rTextObject):
|
|||||||
rName = "rTextForLETextBox2"
|
rName = "rTextForLETextBox2"
|
||||||
rType = 0x800b
|
rType = 0x800b
|
||||||
|
|
||||||
|
# TODO - rAlertString and rError string are
|
||||||
|
# both formatted c-strings used by AlertWindow.
|
||||||
|
# see TB 3 52-6. size, optional icon, text, buttons.
|
||||||
class rAlertString(rTextObject):
|
class rAlertString(rTextObject):
|
||||||
rName = "rAlertString"
|
rName = "rAlertString"
|
||||||
rType = 0x8015
|
rType = 0x8015
|
||||||
@ -411,7 +416,7 @@ class rStringList(rObject):
|
|||||||
self.children = [str_to_bytes(x) for x in strings]
|
self.children = [str_to_bytes(x) for x in strings]
|
||||||
|
|
||||||
def __bytes__(self):
|
def __bytes__(self):
|
||||||
bb = struct.pack("<H", len(self._strings))
|
bb = struct.pack("<H", len(self.children))
|
||||||
for x in self.children:
|
for x in self.children:
|
||||||
bb += bytes( [len(x)] ) # pstring
|
bb += bytes( [len(x)] ) # pstring
|
||||||
bb += x
|
bb += x
|
||||||
|
@ -9,7 +9,14 @@
|
|||||||
|
|
||||||
rText("rText")
|
rText("rText")
|
||||||
rTextBlock(b"rTextBlock") # bytes
|
rTextBlock(b"rTextBlock") # bytes
|
||||||
rTextForLETextBox2("rTextForLETextBox2")
|
rTextForLETextBox2(
|
||||||
|
|
||||||
|
TBStylePlain,
|
||||||
|
"rTextForLETextBox2",
|
||||||
|
TBStyleBold, TBCenterJust,
|
||||||
|
b"rTextForLETextBox2",
|
||||||
|
|
||||||
|
)
|
||||||
rAlertString("rAlertString")
|
rAlertString("rAlertString")
|
||||||
rErrorString("rErrorString")
|
rErrorString("rErrorString")
|
||||||
|
|
||||||
@ -26,3 +33,5 @@ rWString("rWString")
|
|||||||
rC1InputString("rC1InputString")
|
rC1InputString("rC1InputString")
|
||||||
|
|
||||||
rStringList('rStringList', b"rStringList", r"rStringList")
|
rStringList('rStringList', b"rStringList", r"rStringList")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user