MCPcopy Create free account
hub / github.com/AstroPrint/AstroBox / PromptManager

Class PromptManager

src/astroprint/printer/__init__.py:1017–1047  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1015 }
1016
1017class PromptManager(object):
1018 def __init__(self):
1019 self._currentPrompt = None
1020
1021 def begin_prompt(self, message):
1022 if self._currentPrompt is None:
1023 self._currentPrompt = {
1024 'message': message,
1025 'choices': []
1026 }
1027
1028 def end_prompt(self):
1029 if self._currentPrompt:
1030 eventManager().fire(Events.PRINTER_PROMPT, {"type": 'close'})
1031 self._currentPrompt = None
1032
1033 def add_choice(self, text):
1034 if self._currentPrompt:
1035 self._currentPrompt['choices'].append(text)
1036
1037 def show(self):
1038 if self._currentPrompt:
1039 eventManager().fire(Events.PRINTER_PROMPT, {"type": 'show', 'prompt': self._currentPrompt})
1040
1041 @property
1042 def hasPrompt(self):
1043 return self._currentPrompt is not None
1044
1045 @property
1046 def prompt(self):
1047 return self._currentPrompt

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected