Added a new function to ConfigScreen. It returns either True or False to
indicate whether compact buttons should used, with a default of False.
Signed-off-by: Darryl L. Pierce <dpierce(a)redhat.com>
---
doc/ChangeLog | 1 +
examples/selections | 3 +++
newt_syrup/configscreen.py | 25 +++++++++++++++++++++----
3 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/doc/ChangeLog b/doc/ChangeLog
index ba6d6bd..a66436c 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,6 +1,7 @@
Change Log:
* Version 0.1.1:
- Added support for color sets.
+ - Added support for using compact buttons.
* Version 0.1.0:
- Added SelectionListConfigScreen.
diff --git a/examples/selections b/examples/selections
index 4ba41b0..469ee60 100755
--- a/examples/selections
+++ b/examples/selections
@@ -50,6 +50,9 @@ class SelectionsScreen(SelectionListConfigScreen):
if page == SELECTION_MADE: return True
return False
+ def use_compact_buttons(self):
+ return True
+
if __name__ == "__main__":
screen = SelectionsScreen()
screen.start()
diff --git a/newt_syrup/configscreen.py b/newt_syrup/configscreen.py
index e516056..448d1a6 100644
--- a/newt_syrup/configscreen.py
+++ b/newt_syrup/configscreen.py
@@ -81,6 +81,15 @@ class ConfigScreen:
def get_current_page(self):
0
+ def use_compact_buttons(self):
+ """
+ If this returns True, then compact buttons will be used
+ on all displays.
+
+ The default is to use normal buttons.
+ """
+ False
+
def start(self):
active = True
while active and (self.__finished == False):
@@ -115,14 +124,22 @@ class ConfigScreen:
for element in elements:
content.setField(element, 0, current_element)
current_element += 1
+
# create the navigation buttons
buttons = []
- if self.__current_page > 1: buttons.append(["Back", BACK_BUTTON,
"F11"])
- if self.page_has_next(self.__current_page): buttons.append(["Next",
NEXT_BUTTON, "F12"])
- if self.page_has_finish(self.__current_page):
buttons.append(["Finish", FINISH_BUTTON, "F10"])
+ compact_buttons = 0
+ if self.use_compact_buttons():
+ compact_buttons = 1
+ if self.__current_page > 1:
+ buttons.append(["Back", BACK_BUTTON, "F11"])
+ if self.page_has_next(self.__current_page):
+ buttons.append(["Next", NEXT_BUTTON, "F12"])
+ if self.page_has_finish(self.__current_page):
+ buttons.append(["Finish", FINISH_BUTTON, "F10"])
buttons.append(["Cancel", CANCEL_BUTTON, "ESC"])
- buttonbar = ButtonBar(screen, buttons)
+ buttonbar = ButtonBar(screen, buttons, compact = compact_buttons)
content.setField(buttonbar, 0, current_element, growx = 1)
+
gridform.add(content, 1, 0, anchorTop = 1)
current_element += 1
try:
--
1.7.2.1
Show replies by date