]>
git.ipfire.org Git - ipfire-3.x.git/blob - src/pomona/text.py
6 from constants
import *
9 _
= lambda x
: gettext
.ldgettext("pomona", x
)
12 def __init__(self
, screen
):
16 self
.screen
.popWindow()
23 class WaitWindow(TextWindow
):
24 def setText(self
, text
):
29 def __init__(self
, screen
, title
, text
, width
):
30 TextWindow
.__init
__(self
, screen
)
34 if (len(text
) < width
):
37 self
.t
= TextboxReflowed(width
, text
)
39 self
.g
= GridForm(self
.screen
, title
, 1, 1)
40 self
.g
.add(self
.t
, 0, 0)
49 def __init__(self
, screen
, title
, text
):
50 rc
= ButtonChoiceWindow(screen
, title
, text
, buttons
=[TEXT_OK_BUTTON
, _("Cancel")])
51 if rc
== string
.lower(_("Cancel")):
57 class ExceptionWindow(TextWindow
):
58 def __init__ (self
, short
, long=None, screen
=None):
59 TextWindow
.__init
__(self
, screen
)
60 self
.text
= "%s\n\n" % short
61 self
.buttons
=[TEXT_OK_BUTTON
]
64 self
.rc
= ButtonChoiceWindow(self
.screen
, _("Exception Occurred"),
65 self
.text
, self
.buttons
, width
=60)
72 def __init__(self
, log
):
74 self
.screen
= SnackScreen()
76 self
.setRootline(SCREEN_ROOTLINE
)
77 self
.setHelpline(SCREEN_HELPLINE
)
83 def setRootline(self
, msg
):
84 self
.screen
.drawRootText (0, 0, string
.center(msg
, self
.screen
.width
))
85 self
.log
.debug("Set rootline text: %s" % msg
)
87 def setHelpline(self
, msg
):
88 self
.screen
.pushHelpLine(string
.center(msg
, self
.screen
.width
))
89 self
.log
.debug("Set helpline text: %s" % msg
)
92 ### WINDOW DEFINITIONS ###
94 def waitWindow(self
, title
, text
, width
=None):
95 return WaitWindow(self
.screen
, title
, text
, width
)
97 def exceptionWindow(self
, short
, long):
98 self
.log
.critical(short
)
99 return ExceptionWindow(short
, long, self
.screen
)
101 def messageWindow(self
, title
, text
, type="ok", default
= None,
102 custom_icon
=None, custom_buttons
=[]):
104 ButtonChoiceWindow(self
.screen
, title
, text
, buttons
=[TEXT_OK_BUTTON
])
106 elif type == "yesno":
107 if default
and default
== "no":
108 btnlist
= [TEXT_NO_BUTTON
, TEXT_YES_BUTTON
]
110 btnlist
= [TEXT_YES_BUTTON
, TEXT_NO_BUTTON
]
111 rc
= ButtonChoiceWindow(self
.screen
, title
, text
, buttons
=btnlist
)
117 elif type == "custom":
119 for but
in custom_buttons
:
120 tmpbut
.append(string
.replace(but
,"_",""))
121 rc
= ButtonChoiceWindow(self
.screen
, title
, text
, width
=60, buttons
=tmpbut
)
125 if string
.lower(b
) == rc
:
131 return OkCancelWindow(self
.screen
, title
, text
)