# 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 ..actions import * class DialogMessage(Action): message = TStringProperty("Message") position = TArrayProperty((0, 0), 2, 2) def __init__(self, message=None, position=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 position A list of the form [x, y] """ super(DialogMessage, self).__init__() self._dialog = None if message: self.message = message if position: self.position = position def do(self, **kwargs): """ 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: