summaryrefslogtreecommitdiff
path: root/ui/dialog.py
diff options
context:
space:
mode:
Diffstat (limited to 'ui/dialog.py')
-rw-r--r--ui/dialog.py164
1 files changed, 82 insertions, 82 deletions
diff --git a/ui/dialog.py b/ui/dialog.py
index f5aa4ad7..27131c72 100644
--- a/ui/dialog.py
+++ b/ui/dialog.py
@@ -134,7 +134,7 @@ operation" (e.g., a system call) that should work in "normal" situations.
"""
ExceptionShortDescription = "System error"
-
+
class PythonDialogIOError(PythonDialogSystemError):
"""Exception raised when pythondialog catches an IOError exception that \
should be passed to the calling program."""
@@ -244,7 +244,7 @@ _common_args_syntax = {
"title": lambda title: ("--title", title),
"trim": lambda enable: _simple_option("--trim", enable),
"version": lambda enable: _simple_option("--version", enable)}
-
+
def _simple_option(option, enable):
"""Turn on or off the simplest dialog Common Options."""
@@ -298,7 +298,7 @@ def _path_to_executable(f):
ExecutableNotFound
PythonDialogOSError
-
+
"""
try:
if '/' in f:
@@ -570,7 +570,7 @@ class Dialog:
ExecutableNotFound
PythonDialogOSError
- """
+ """
# DIALOGRC differs from the other DIALOG* variables in that:
# 1. It should be a string if not None
# 2. We may very well want it to be unset
@@ -612,18 +612,18 @@ class Dialog:
This method is obsolete. Please remove calls to it from your
programs.
- """
- self.add_persistent_args(("--backtitle", text))
+ """
+ self.add_persistent_args(("--backtitle", text))
def _call_program(self, redirect_child_stdin, cmdargs, **kwargs):
- """Do the actual work of invoking the dialog-like program.
+ """Do the actual work of invoking the dialog-like program.
Communication with the dialog-like program is performed
through one or two pipes, depending on
`redirect_child_stdin'. There is always one pipe that is
created to allow the parent process to read what dialog
writes on its standard error stream.
-
+
If `redirect_child_stdin' is True, an additional pipe is
created whose reading end is connected to dialog's standard
input. This is used by the gauge widget to feed data to
@@ -771,7 +771,7 @@ class Dialog:
"be the exit status of the dialog-like program, for some "
"unknown reason (-> probably a bug in the dialog-like "
"program); otherwise, we have probably found a python bug")
-
+
# We might want to check here whether exit_code is really one of
# DIALOG_OK, DIALOG_CANCEL, etc. However, I prefer not doing it
# because it would break pythondialog for no strong reason when new
@@ -806,7 +806,7 @@ class Dialog:
return (exit_code, child_output)
def _perform(self, cmdargs, **kwargs):
- """Perform a complete dialog-like program invocation.
+ """Perform a complete dialog-like program invocation.
This function invokes the dialog-like program, waits for its
termination and returns its exit status and whatever it wrote
@@ -823,7 +823,7 @@ class Dialog:
(exit_code, output) = \
self._wait_for_program_termination(child_pid,
child_rfd)
- return (exit_code, output)
+ return (exit_code, output)
def _strip_xdialog_newline(self, output):
"""Remove trailing newline (if any), if using Xdialog"""
@@ -833,18 +833,18 @@ class Dialog:
# This is for compatibility with the old dialog.py
def _perform_no_options(self, cmd):
- """Call dialog without passing any more options."""
- return os.system(self._dialog_prg + ' ' + cmd)
+ """Call dialog without passing any more options."""
+ return os.system(self._dialog_prg + ' ' + cmd)
# For compatibility with the old dialog.py
def clear(self):
- """Clear the screen. Equivalent to the dialog --clear option.
+ """Clear the screen. Equivalent to the dialog --clear option.
This method is obsolete. Please remove calls to it from your
programs.
- """
- self._perform_no_options('--clear')
+ """
+ self._perform_no_options('--clear')
def calendar(self, text, height=6, width=0, day=0, month=0, year=0,
**kwargs):
@@ -857,7 +857,7 @@ class Dialog:
month -- inititial month displayed
year -- inititial year selected (0 causes the current date
to be used as the initial date)
-
+
A calendar box displays month, day and year in separately
adjustable windows. If the values for day, month or year are
missing or negative, the current date's corresponding values
@@ -878,8 +878,8 @@ class Dialog:
- UnexpectedDialogOutput
- PythonDialogReModuleError
- """
- (code, output) = self._perform(
+ """
+ (code, output) = self._perform(
*(["--calendar", text, str(height), str(width), str(day),
str(month), str(year)],),
**kwargs)
@@ -888,7 +888,7 @@ class Dialog:
mo = _calendar_date_rec.match(output)
except re.error, v:
raise PythonDialogReModuleError(v)
-
+
if mo is None:
raise UnexpectedDialogOutput(
"the dialog-like program returned the following "
@@ -900,7 +900,7 @@ class Dialog:
def checklist(self, text, height=15, width=54, list_height=7,
choices=[], **kwargs):
- """Display a checklist box.
+ """Display a checklist box.
text -- text to display in the box
height -- height of the box
@@ -937,7 +937,7 @@ class Dialog:
# double-quote).
kwargs["separate_output"] = True
- (code, output) = self._perform(*(cmd,), **kwargs)
+ (code, output) = self._perform(*(cmd,), **kwargs)
# Since we used --separate-output, the tags are separated by a newline
# in the output. There is also a final newline after the last tag.
@@ -952,7 +952,7 @@ class Dialog:
filepath -- initial file path
height -- height of the box
width -- width of the box
-
+
The file-selection dialog displays a text-entry window in
which you can type a filename (or directory), and above that
two windows with directory names and filenames.
@@ -979,22 +979,22 @@ class Dialog:
exit status (an integer) of the dialog-like program and
`path' is the path chosen by the user (whose last element may
be a directory or a file).
-
+
Notable exceptions:
any exception raised by self._perform()
- """
+ """
(code, output) = self._perform(
*(["--fselect", filepath, str(height), str(width)],),
**kwargs)
output = self._strip_xdialog_newline(output)
-
- return (code, output)
-
+
+ return (code, output)
+
def gauge_start(self, text="", height=8, width=54, percent=0, **kwargs):
- """Display gauge box.
+ """Display gauge box.
text -- text to display in the box
height -- height of the box
@@ -1015,20 +1015,20 @@ class Dialog:
-------------------
Gauge typical usage (assuming that `d' is an instance of the
- Dialog class) looks like this:
- d.gauge_start()
- # do something
- d.gauge_update(10) # 10% of the whole task is done
- # ...
- d.gauge_update(100, "any text here") # work is done
- exit_code = d.gauge_stop() # cleanup actions
+ Dialog class) looks like this:
+ d.gauge_start()
+ # do something
+ d.gauge_update(10) # 10% of the whole task is done
+ # ...
+ d.gauge_update(100, "any text here") # work is done
+ exit_code = d.gauge_stop() # cleanup actions
Notable exceptions:
- any exception raised by self._call_program()
- PythonDialogOSError
- """
+ """
(child_pid, child_rfd, child_stdin_wfd) = self._call_program(
True,
*(["--gauge", text, str(height), str(width), str(percent)],),
@@ -1041,10 +1041,10 @@ class Dialog:
}
except os.error, v:
raise PythonDialogOSError(v.strerror)
-
+
def gauge_update(self, percent, text="", update_text=0):
- """Update a running gauge box.
-
+ """Update a running gauge box.
+
percent -- new percentage to show in the gauge meter
text -- new text to optionally display in the box
update-text -- boolean indicating whether to update the
@@ -1055,8 +1055,8 @@ class Dialog:
called previously). If update_text is true (for instance, 1),
the text displayed in the box is also updated.
- See the `gauge_start' function's documentation for
- information about how to use a gauge.
+ See the `gauge_start' function's documentation for
+ information about how to use a gauge.
Return value: undefined.
@@ -1064,28 +1064,28 @@ class Dialog:
is an I/O error while writing to the pipe
used to talk to the dialog-like program.
- """
- if update_text:
- gauge_data = "%d\nXXX\n%s\nXXX\n" % (percent, text)
- else:
- gauge_data = "%d\n" % percent
- try:
+ """
+ if update_text:
+ gauge_data = "%d\nXXX\n%s\nXXX\n" % (percent, text)
+ else:
+ gauge_data = "%d\n" % percent
+ try:
self._gauge_process["stdin"].write(gauge_data)
self._gauge_process["stdin"].flush()
except IOError, v:
raise PythonDialogIOError(v)
-
+
# For "compatibility" with the old dialog.py...
gauge_iterate = gauge_update
def gauge_stop(self):
- """Terminate a running gauge.
+ """Terminate a running gauge.
This function performs the appropriate cleanup actions to
terminate a running gauge (started with `gauge_start').
-
- See the `gauge_start' function's documentation for
- information about how to use a gauge.
+
+ See the `gauge_start' function's documentation for
+ information about how to use a gauge.
Return value: undefined.
@@ -1095,7 +1095,7 @@ class Dialog:
- PythonDialogIOError can be raised if closing the pipe
used to talk to the dialog-like program fails.
- """
+ """
p = self._gauge_process
# Close the pipe that we are using to feed dialog's stdin
try:
@@ -1129,8 +1129,8 @@ class Dialog:
any exception raised by self._perform()
- """
- return self._perform(
+ """
+ return self._perform(
*(["--infobox", text, str(height), str(width)],),
**kwargs)[0]
@@ -1157,14 +1157,14 @@ class Dialog:
any exception raised by self._perform()
- """
+ """
(code, tag) = self._perform(
*(["--inputbox", text, str(height), str(width), init],),
**kwargs)
tag = self._strip_xdialog_newline(tag)
-
- return (code, tag)
+
+ return (code, tag)
def menu(self, text, height=15, width=54, menu_height=7, choices=[],
**kwargs):
@@ -1246,14 +1246,14 @@ class Dialog:
any exception raised by self._perform()
- """
+ """
cmd = ["--menu", text, str(height), str(width), str(menu_height)]
for t in choices:
cmd.extend(t)
- (code, output) = self._perform(*(cmd,), **kwargs)
+ (code, output) = self._perform(*(cmd,), **kwargs)
output = self._strip_xdialog_newline(output)
-
+
if "help_button" in kwargs.keys() and output.startswith("HELP "):
return ("help", output[5:])
else:
@@ -1281,8 +1281,8 @@ class Dialog:
any exception raised by self._perform()
- """
- return self._perform(
+ """
+ return self._perform(
*(["--msgbox", text, str(height), str(width)],),
**kwargs)[0]
@@ -1311,8 +1311,8 @@ class Dialog:
any exception raised by self._perform()
- """
- (code, password) = self._perform(
+ """
+ (code, password) = self._perform(
*(["--passwordbox", text, str(height), str(width), init],),
**kwargs)
@@ -1322,7 +1322,7 @@ class Dialog:
def radiolist(self, text, height=15, width=54, list_height=7,
choices=[], **kwargs):
- """Display a radiolist box.
+ """Display a radiolist box.
text -- text to display in the box
height -- height of the box
@@ -1352,7 +1352,7 @@ class Dialog:
any exception raised by self._perform() or _to_onoff()
- """
+ """
cmd = ["--radiolist", text, str(height), str(width), str(list_height)]
for t in choices:
cmd.extend(((t[0], t[1], _to_onoff(t[2]))))
@@ -1360,11 +1360,11 @@ class Dialog:
(code, tag) = self._perform(*(cmd,), **kwargs)
tag = self._strip_xdialog_newline(tag)
-
- return (code, tag)
+
+ return (code, tag)
def scrollbox(self, text, height=20, width=78, **kwargs):
- """Display a string in a scrollable box.
+ """Display a string in a scrollable box.
text -- text to display in the box
height -- height of the box
@@ -1386,7 +1386,7 @@ class Dialog:
unfortunately not mentioned in its documentation, at
least in Python 2.3.3...)
- """
+ """
# In Python < 2.3, the standard library does not have
# tempfile.mkstemp(), and unfortunately, tempfile.mktemp() is
# insecure. So, I create a non-world-writable temporary directory and
@@ -1450,8 +1450,8 @@ class Dialog:
any exception raised by self._perform()
- """
- return self._perform(
+ """
+ return self._perform(
*(["--tailbox", filename, str(height), str(width)],),
**kwargs)[0]
# No tailboxbg widget, at least for now.
@@ -1480,12 +1480,12 @@ class Dialog:
any exception raised by self._perform()
- """
+ """
# This is for backward compatibility... not that it is
# stupid, but I prefer explicit programming.
if not "title" in kwargs.keys():
- kwargs["title"] = filename
- return self._perform(
+ kwargs["title"] = filename
+ return self._perform(
*(["--textbox", filename, str(height), str(width)],),
**kwargs)[0]
@@ -1499,7 +1499,7 @@ class Dialog:
hour -- inititial hour selected
minute -- inititial minute selected
second -- inititial second selected
-
+
A dialog is displayed which allows you to select hour, minute
and second. If the values for hour, minute or second are
negative (or not explicitely provided, as they default to
@@ -1520,8 +1520,8 @@ class Dialog:
- PythonDialogReModuleError
- UnexpectedDialogOutput
- """
- (code, output) = self._perform(
+ """
+ (code, output) = self._perform(
*(["--timebox", text, str(height), str(width),
str(hour), str(minute), str(second)],),
**kwargs)
@@ -1565,7 +1565,7 @@ class Dialog:
any exception raised by self._perform()
- """
- return self._perform(
+ """
+ return self._perform(
*(["--yesno", text, str(height), str(width)],),
**kwargs)[0]