versuche für mein Text Adv n kleines Dialog System zubasteln. Nun scheitere ich daran das ich in einen Fehler laufe sobald ich verschiedene Objekt Typen übergebe... kann mir hier jemand n Tipp in die richtige Richtung geben ?
Das Prozedere...
Ich rufe aus meinem main.py Script aus folgende Funktion aus dialog.py auf:
Code: Alles auswählen
dialog.msg((characters_status(), "Ein paar einzelne text ausgaben in form eines Strings"))
Code: Alles auswählen
('Dude Vitality: 100/100', 'EnemyONE Vitality: 100/100')
Code: Alles auswählen
def msg(message_block):
#frame setup
box_width = 50
box_symbol_horizontal = "-"
box_symbol_side = "| "
#cls()
print(box_symbol_horizontal * box_width) # outer horizontal border
print(box_symbol_side)
if type(message_block) == str:
wraped_text = textwrap.wrap(message_block, 20)
# wrap long string into a list of short ones
for string in wraped_text:
print("{0} {1}".format(box_symbol_side, string))
elif type(message_block) == tuple:
for obj in message_block:
# loop through objects of message_block and check type
if type(obj) == str:
wraped_text = textwrap.wrap(obj, 20)
# wrap long string into a list of short ones
for string in wraped_text:
print("{0} {1}".format(box_symbol_side, string))
elif type(obj) == tuple: #if obj is tuple go through every tuple
for obj in message_block:
wraped_text = textwrap.wrap(obj, 20)
for string in wraped_text:
print("{0} {1}".format(box_symbol_side, string))
print(box_symbol_side) # outer symbols
print(box_symbol_horizontal * box_width)
Fehler ist folgender:
Code: Alles auswählen
File "C:\Python32\lib\textwrap.py", line 126, in _munge_whitespace
text = text.expandtabs()
ttributeError: 'tuple' object has no attribute 'expandtabs'
Danke schonmal für die Mühe.
Greetz Kev.
Achja ich hab schon versucht Expand_tabs auf False zu setzen aber dann kommt n fehler mit "translation" wozu ich in der Doku garnichts gefunden habe... (bei bedarf kann ich den genaue Wortlaut nachreichen)