source: epoptes/trunk/fuentes/epoptes-client/message @ 295

Last change on this file since 295 was 295, checked in by mabarracus, 3 years ago

copy trusty epoptes code

  • Property svn:executable set to *
File size: 2.2 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4###########################################################################
5# Show a message using gtk.MessageDialog.
6#
7# Copyright (C) 2012 Alkis Georgopoulos <alkisg@gmail.com>
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FINESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21#
22# On Debian GNU/Linux systems, the complete text of the GNU General
23# Public License can be found in `/usr/share/common-licenses/GPL".
24############################################################################
25
26import gtk
27
28def MessageDialog(text, title="Epoptes", markup=True, icon="dialog-information"):
29    if icon == "dialog-error":
30        type = gtk.MESSAGE_ERROR
31    elif icon == "dialog-question":
32        type = gtk.MESSAGE_QUESTION
33    elif icon == "dialog-warning":
34        type = gtk.MESSAGE_WARNING
35    else:
36        type = gtk.MESSAGE_INFO
37    dlg = gtk.MessageDialog(None, 0, type, gtk.BUTTONS_CLOSE, text)
38    dlg.set_modal(True)
39    dlg.set_title(title)
40    dlg.set_property('use-markup', markup)
41    dlg.set_property('skip-taskbar-hint', False)
42    dlg.set_property('icon-name', icon)
43    dlg.run()
44    dlg.destroy()
45
46
47if __name__ == '__main__':
48    from sys import argv
49
50    if not (len(argv) >= 1 and len(argv) <= 5):
51        print "Usage: message text [title] [markup] [icon]"
52        exit(1)
53
54    if len(argv) == 5:
55        type = argv[4]
56    else:
57        type = "dialog-information"
58
59    if len(argv) >= 4:
60        markup = argv[3] == "True"
61    else:
62        markup = "False"
63
64    if len(argv) >= 3:
65        title = argv[2]
66    else:
67        title = 'Epoptes'
68
69    if len(argv) >= 2:
70        text = argv[1]
71
72    MessageDialog(text, title, markup, type)
Note: See TracBrowser for help on using the repository browser.