ChangeLog | 1
examples/dialog | 26 +++++++++++++++++++++++
newt_syrup/dialogscreen.py | 49 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 76 insertions(+)
New commits:
commit f6b6c0981d96d3694af32fd2b2f6db7277e319a1
Author: Darryl L. Pierce <dpierce(a)redhat.com>
Date: Fri Sep 10 15:11:59 2010 -0400
Added support for dialog boxes.
Created a new class, named DialogScreen, that takes a title and a
message. It then shows those when the dialog is started.
Dialog boxes support colorsets in the same way as other screen types.
diff --git a/ChangeLog b/ChangeLog
index 6cf5860..574fb0c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@ Change Log:
- Added support for using compact buttons.
- Fixed the option model for SelectionListConfigScreen.
- Added support for full screen applications.
+ - Added dialog boxes.
* Version 0.1.0:
- Added SelectionListConfigScreen.
diff --git a/examples/dialog b/examples/dialog
new file mode 100755
index 0000000..9415934
--- /dev/null
+++ b/examples/dialog
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+#
+# dialog - Copyright (C) 2010 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce(a)redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at
http://www.gnu.org/copyleft/gpl.html.
+
+from newt_syrup.dialogscreen import *
+
+if __name__ == "__main__":
+ dialog = DialogScreen("This is the title",
+ "And this is an informative message.")
+ dialog.show()
diff --git a/newt_syrup/dialogscreen.py b/newt_syrup/dialogscreen.py
new file mode 100644
index 0000000..6b8c9a9
--- /dev/null
+++ b/newt_syrup/dialogscreen.py
@@ -0,0 +1,49 @@
+# dialogscreens.py - Copyright (C) 2009 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce(a)redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at
http://www.gnu.org/copyleft/gpl.html.
+
+from snack import *
+
+import _snack
+import traceback
+
+class DialogScreen:
+ """
+ Lets the user present a single dialog box with a message.
+ """
+
+ def __init__(self, title, message, colorset = None):
+ self.__title = title
+ self.__message = message
+ self.__colorset = colorset
+
+ def show(self):
+ screen = SnackScreen()
+
+ # apply the colorset
+ if self.__colorset is not None:
+ for item in self.__colorset.keys():
+ colors = self.__colorset.get(item)
+ screen.setColor(item, colors[0], colors[1])
+
+ ButtonChoiceWindow(screen,
+ self.__title,
+ self.__message,
+ buttons = ["Close"])
+ screen.popWindow()
+ screen.finish()
+