From 0c3f127c86af818d260966d2292b199757087157 Mon Sep 17 00:00:00 2001 From: Simon Poirier Date: Sat, 11 Jul 2009 21:39:46 +0000 Subject: repackage --- (limited to 'addons/dialogmessage.py') diff --git a/addons/dialogmessage.py b/addons/dialogmessage.py new file mode 100644 index 0000000..22a223b --- /dev/null +++ b/addons/dialogmessage.py @@ -0,0 +1,66 @@ +# Copyright (C) 2009, Tutorius.org +# Copyright (C) 2009, Simon Poirier +# +# +# 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; either version 2 of the License, or +# (at your option) any later version. +# +# 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 St, Fifth Floor, Boston, MA 02110-1301 USA + +from sugar.tutorius.actions import * + +class DialogMessage(Action): + message = TStringProperty("Message") + position = TArrayProperty([0, 0], 2, 2) + + def __init__(self, message=None, pos=None): + """ + Shows a dialog with a given text, at the given position on the screen. + + @param message A string to display to the user + @param pos A list of the form [x, y] + """ + super(DialogMessage, self).__init__() + self._dialog = None + + if message: + self.message = message + if pos: self.position = pos + + def do(self): + """ + Show the dialog + """ + self._dialog = TutoriusDialog(self.message) + self._dialog.set_button_clicked_cb(self._dialog.close_self) + self._dialog.set_modal(False) + self._dialog.move(self.position[0], self.position[1]) + self._dialog.show() + + def undo(self): + """ + Destroy the dialog + """ + if self._dialog: + self._dialog.destroy() + self._dialog = None + +__action__ = { + "name" : "DialogMessage", + "display_name" : "Message Dialog", + "icon" : "window_fullscreen", + "class" : DialogMessage, + "mandatory_props" : ["message"] +} + +# vim:set ts=4 sts=4 sw=4 et: + -- cgit v0.9.1