ScolaSync  4.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 python3safe=True
27 
28 from PyQt4.QtCore import *
29 from PyQt4.QtGui import *
30 
32  ##
33  #
34  # Le constructeur
35  # @param parent un QWidget
36  # @param percent un pourcentage de remplissage de disque
37  # @param total place totale en kilo-octets
38  # @param used place utilisée en kilo-octets
39  # @param title le titre pour la fenêtre
40  #
41  def __init__(self, parent, percent, total=0, used=0, title="Disk"):
42  QMainWindow.__init__(self)
43  QWidget.__init__(self, parent)
44  from Ui_diskFull import Ui_MainWindow
45  self.ui = Ui_MainWindow()
46  self.ui.setupUi(self)
47  self.setWindowTitle(title)
48  self.v=self.ui.graphicsView
49  self.total=self.ui.label_total
50  self.used=self.ui.label_used
51  self.v.setScene(sceneWithUsage(self.v, QRectF(5,5,230,230), percent))
52  self.total.setText(QApplication.translate("diskFull","Place totale : {size} kilo-octets",None, QApplication.UnicodeUTF8).format(size=total))
53  self.used.setText(QApplication.translate("diskFull","Place utilisée : {size} kilo-octets",None, QApplication.UnicodeUTF8).format(size=used))
54 
55 ##
56 #
57 # @param parent le widget père
58 # @param rect le QRect contenant la scène
59 # @param percent pourcentage utilisé
60 # @return une QGraphicsScene avec un symbole d'occupation du disque
61 #
62 def sceneWithUsage(parent, rect, percent):
63  scene=QGraphicsScene(parent)
64  scene.addEllipse ( rect, QPen(), QBrush(QColor("lightyellow")) )
65  usedEllipse=scene.addEllipse (rect, QPen(), QBrush(QColor("slateblue")) )
66  usedEllipse.setStartAngle(0)
67  usedEllipse.setSpanAngle(360 * 16 * percent / 100)
68  return scene
69