Typo in the regular expression...
[rox-archive.git] / support.py
blobd0b24aee882a22d187558481e9617ff3bd25bfc2
1 from os import _exit, fork, execvp, waitpid, dup2
3 from rox.MultipleChoice import MultipleChoice
4 from rox.support import *
6 from gtk import *
8 # Open a modal dialog box showing a message.
9 # The user can choose from a selection of buttons at the bottom.
10 # Returns -1 if the window is destroyed, or the number of the button
11 # if one is clicked (starting from zero).
13 # If a dialog is already open, returns -1 without waiting AND
14 # brings the current dialog to the front.
15 current_dialog = None
16 def get_choice(message, title, buttons):
17 global current_dialog
19 if current_dialog:
20 current_dialog.hide()
21 current_dialog.show()
22 return -1
24 current_dialog = MultipleChoice(message, buttons)
25 current_dialog.set_title(title)
26 choice_return = current_dialog.wait()
28 print "Return", choice_return
30 current_dialog = None
32 return choice_return
34 def child(*argv):
35 """Spawn a new process. Connect stderr to stdout."""
36 child = fork()
37 if child == 0:
38 # We are the child
39 try:
40 dup2(1, 2)
41 execvp(argv[0], argv)
42 except:
43 pass
44 print "Warning: exec('%s') failed!" % argv[0]
45 _exit(1)
46 elif child == -1:
47 print "Error: fork() failed!"