diff options
author | Martin Sivak <msivak@redhat.com> | 2012-08-06 15:44:13 +0200 |
---|---|---|
committer | Martin Sivak <msivak@redhat.com> | 2012-08-06 15:44:13 +0200 |
commit | 05b7d431064c5374262346b805eea6bfe93952cc (patch) | |
tree | 44baa86b19a193bbf563e812b02581795a37aa83 | |
parent | a518f8919488710842dc50d6e28f1d9bea5a186d (diff) | |
download | anaconda-05b7d431064c5374262346b805eea6bfe93952cc.tar.gz anaconda-05b7d431064c5374262346b805eea6bfe93952cc.tar.xz anaconda-05b7d431064c5374262346b805eea6bfe93952cc.zip |
Pass screen args argument to prompt and input methods + fix for run-text-spoke
-rw-r--r-- | pyanaconda/ui/tui/__init__.py | 8 | ||||
-rw-r--r-- | pyanaconda/ui/tui/hubs/__init__.py | 2 | ||||
-rw-r--r-- | pyanaconda/ui/tui/simpleline/base.py | 23 | ||||
-rw-r--r-- | pyanaconda/ui/tui/spokes/__init__.py | 2 | ||||
-rw-r--r-- | pyanaconda/ui/tui/spokes/password.py | 2 | ||||
-rwxr-xr-x | pyanaconda/ui/tui/tools/run-text-spoke.py | 4 |
6 files changed, 25 insertions, 16 deletions
diff --git a/pyanaconda/ui/tui/__init__.py b/pyanaconda/ui/tui/__init__.py index 5f45c578e..9b49d66e3 100644 --- a/pyanaconda/ui/tui/__init__.py +++ b/pyanaconda/ui/tui/__init__.py @@ -26,10 +26,10 @@ class ErrorDialog(tui.UIScreen): text = tui.TextWidget(self._message) self._window.append(tui.CenterWidget(text)) - def prompt(self): + def prompt(self, args = None): return u"Press enter to exit." - def input(self, key): + def input(self, args, key): """This dialog is closed by any input.""" self.close() @@ -58,10 +58,10 @@ class YesNoDialog(tui.UIScreen): self._window.append(u"") return True - def prompt(self): + def prompt(self, args): return u"Please respond 'yes' or 'no': " - def input(self, key): + def input(self, args, key): if key == "yes": self._response = True self.close() diff --git a/pyanaconda/ui/tui/hubs/__init__.py b/pyanaconda/ui/tui/hubs/__init__.py index 9d4937adb..d6ee5b216 100644 --- a/pyanaconda/ui/tui/hubs/__init__.py +++ b/pyanaconda/ui/tui/hubs/__init__.py @@ -64,7 +64,7 @@ class TUIHub(TUIObject, common.Hub): return True - def input(self, key): + def input(self, args, key): """Handle user input. Numbers are used to show a spoke, the rest is passed to the higher level for processing.""" try: diff --git a/pyanaconda/ui/tui/simpleline/base.py b/pyanaconda/ui/tui/simpleline/base.py index 1a0721194..a79adbc89 100644 --- a/pyanaconda/ui/tui/simpleline/base.py +++ b/pyanaconda/ui/tui/simpleline/base.py @@ -234,7 +234,7 @@ class App(object): last_screen = self._screens[-1][0] # get the screen's prompt - prompt = last_screen.prompt() + prompt = last_screen.prompt(self._screens[-1][1]) # None means prompt handled the input by itself # ask for redraw and continue @@ -247,7 +247,7 @@ class App(object): # process the input, if it wasn't processed (valid) # increment the error counter - if not self.input(c): + if not self.input(self._screens[-1][1], c): error_counter += 1 # redraw the screen after 5 bad inputs @@ -269,10 +269,13 @@ class App(object): but we might need to override it for more complex apps or testing.""" return raw_input(prompt) - def input(self, key): + def input(self, args, key): """Method called internally to process unhandled input key presses. Also handles the main quit and close commands. + :param args: optional argument passed from switch_screen calls + :type args: anything + :param key: the string entered by user :type key: unicode @@ -283,7 +286,7 @@ class App(object): # delegate the handling to active screen first if self._screens: - key = self._screens[-1][0].input(key) + key = self._screens[-1][0].input(args, key) if key is None: return True @@ -368,12 +371,15 @@ class UIScreen(object): """This does nothing in TUI, it is here to make API similar.""" pass - def input(self, key): + def input(self, args, key): """Method called to process input. If the input is not handled here, return it. :param key: input string to process :type key: unicode + :param args: optional argument passed from switch_screen calls + :type args: anything + :return: return True or None if key was handled, False if the screen should not process input on the App and key if you want it to. :rtype: True|False|None|unicode @@ -381,13 +387,16 @@ class UIScreen(object): return key - def prompt(self): + def prompt(self, args = None): """Return the text to be shown as prompt or handle the prompt and return None. + :param args: optional argument passed from switch_screen calls + :type args: anything + :return: returns text to be shown next to the prompt for input or None to skip further input processing :rtype: unicode|None -""" + """ return u"\tPlease make your choice from above ['q' to quit]: " @property diff --git a/pyanaconda/ui/tui/spokes/__init__.py b/pyanaconda/ui/tui/spokes/__init__.py index 07fc3d135..fc6124813 100644 --- a/pyanaconda/ui/tui/spokes/__init__.py +++ b/pyanaconda/ui/tui/spokes/__init__.py @@ -38,7 +38,7 @@ class TUISpoke(TUIObject, tui.Widget, Spoke): TUIObject.refresh(self, args) return True - def input(self, key): + def input(self, args, key): """Handle the input, the base class just forwards it to the App level.""" return key diff --git a/pyanaconda/ui/tui/spokes/password.py b/pyanaconda/ui/tui/spokes/password.py index db65b25e7..64ed1708e 100644 --- a/pyanaconda/ui/tui/spokes/password.py +++ b/pyanaconda/ui/tui/spokes/password.py @@ -28,7 +28,7 @@ class PasswordSpoke(NormalTUISpoke): return True - def prompt(self): + def prompt(self, args = None): """Overriden prompt as password typing is special.""" p1 = getpass.getpass("Password: ") p2 = getpass.getpass("Password (confirm): ") diff --git a/pyanaconda/ui/tui/tools/run-text-spoke.py b/pyanaconda/ui/tui/tools/run-text-spoke.py index d5e9c5730..b542fcb8b 100755 --- a/pyanaconda/ui/tui/tools/run-text-spoke.py +++ b/pyanaconda/ui/tui/tools/run-text-spoke.py @@ -30,13 +30,13 @@ initThreading() # Figure out the part we are about to show: hub/spoke? # And get the name of the module which represents it -if os.path.basename(sys.argv[0]) == "run-spoke.py": +if os.path.basename(sys.argv[0]) == "run-text-spoke.py": spokeModuleName = "pyanaconda.ui.tui.spokes.%s" % sys.argv[1] from pyanaconda.ui.common import Spoke spokeBaseClass = Spoke spokeText = "spoke" SpokeText = "Spoke" -elif os.path.basename(sys.argv[0]) == "run-hub.py": +elif os.path.basename(sys.argv[0]) == "run-text-hub.py": spokeModuleName = "pyanaconda.ui.tui.hubs.%s" % sys.argv[1] from pyanaconda.ui.common import Hub spokeBaseClass = Hub |