ScolaSync  1.0
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
diskFull.py
Aller à la documentation de ce fichier.
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # $Id: diskFull.py 33 2010-12-12 00:39:46Z georgesk $
4 
5 licence={}
6 licence['en']="""
7  file diskFull.py
8  this file is part of the project scolasync
9 
10  Copyright (C) 2010 Georges Khaznadar <georgesk@ofset.org>
11 
12  This program is free software: you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation, either version3 of the License, or
15  (at your option) any later version.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program. If not, see <http://www.gnu.org/licenses/>.
24 """
25 
26 from PyQt4.QtCore import *
27 from PyQt4.QtGui import *
28 
30  ##
31  #
32  # Le constructeur
33  # @param parent un QWidget
34  # @param percent un pourcentage de remplissage de disque
35  # @param total place totale en kilo-octets
36  # @param used place utilisée en kilo-octets
37  # @param title le titre pour la fenêtre
38  #
39  def __init__(self, parent, percent, total=0, used=0, title="Disk"):
40  QMainWindow.__init__(self)
41  QWidget.__init__(self, parent)
42  from Ui_diskFull import Ui_MainWindow
43  self.ui = Ui_MainWindow()
44  self.ui.setupUi(self)
45  self.setWindowTitle(title)
46  self.v=self.ui.graphicsView
47  self.total=self.ui.label_total
48  self.used=self.ui.label_used
49  self.v.setScene(sceneWithUsage(self.v, QRectF(5,5,230,230), percent))
50  self.total.setText(QApplication.translate("diskFull","Place totale : %1 kilo-octets",None, QApplication.UnicodeUTF8).arg(total))
51  self.used.setText(QApplication.translate("diskFull","Place utilisée : %1 kilo-octets",None, QApplication.UnicodeUTF8).arg(used))
52 
53 ##
54 #
55 # @param parent le widget père
56 # @param rect le QRect contenant la scène
57 # @param percent pourcentage utilisé
58 # @return une QGraphicsScene avec un symbole d'occupation du disque
59 #
60 def sceneWithUsage(parent, rect, percent):
61  scene=QGraphicsScene(parent)
62  scene.addEllipse ( rect, QPen(), QBrush(QColor("lightyellow")) )
63  usedEllipse=scene.addEllipse (rect, QPen(), QBrush(QColor("slateblue")) )
64  usedEllipse.setStartAngle(0)
65  usedEllipse.setSpanAngle(360 * 16 * percent / 100)
66  return scene
67