wcs-dynexport : intégration du basculement vers PostgreSQL (suite)
[progfou.git] / outils / auf-reportbug
CommitLineData
8a7d5f6f
P
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# Depends: python-gtk2
4import sys
5try:
6 import gtk
7except:
8 print "Support PyGTK non disponible. Installer le paquet 'python-gtk2'."
9 sys.exit(1)
10
11TITLE = u"AuF — Envoi d'un rapport de bogue"
12EMAIL_LABEL = u"Entrez votre adresse électronique : "
13TEXT_LABEL = u"Décrivez votre problème ci-dessous :"
14
15HR = "-" * 78
16REPPORT = "\n".join([HR, "Rapport de bogue de %(email)s :", HR, "%(text)s", HR])
17
18def bugreport_print(email, text):
19 print REPPORT % {'email': email, 'text': text}
20
21def bugreport_http(email, text):
22 # on imagine ici une procédure d'envoi via HTTP
23 pass
24
25def cancel_clicked(btn):
26 gtk.main_quit()
27
28def ok_clicked(btn, email, text):
29 email = email.get_text()
30 start, end = text.get_buffer().get_bounds()
31 text = start.get_text(end)
32 bugreport_print(email, text)
33 bugreport_http(email, text)
34 gtk.main_quit()
35
36def run_gui():
37 email_label = gtk.Label(EMAIL_LABEL)
38 email = gtk.Entry()
39
40 email_hbox = gtk.HBox()
41 email_hbox.pack_start(email_label, False)
42 email_hbox.pack_start(email)
43
44 ruler = gtk.Ruler()
45 ruler.set_size_request(0, 1)
46
47 text_label = gtk.Label(TEXT_LABEL)
48 text = gtk.TextView()
49
50 scroller = gtk.ScrolledWindow()
51 scroller.add(text)
52
53 cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
54 cancel.connect("clicked", cancel_clicked)
55
56 ok = gtk.Button(stock=gtk.STOCK_OK)
57 ok.connect("clicked", ok_clicked, email, text)
58
59 buttons_hbox = gtk.HBox()
60 buttons_hbox.pack_start(cancel)
61 buttons_hbox.pack_start(ok)
62
63 vbox = gtk.VBox()
64 vbox.pack_start(email_hbox, False)
65 vbox.pack_start(ruler, False)
66 vbox.pack_start(text_label, False)
67 vbox.pack_start(scroller)
68 vbox.pack_start(buttons_hbox, False)
69
70 window = gtk.Window()
71 window.set_title(TITLE)
72 window.resize(500, 400)
73 window.add(vbox)
74
75 window.show_all()
76 gtk.main()
77
78if __name__ == '__main__':
79 run_gui()
80 sys.exit(0)
81