4 preferences is a a file of the project pymecavideo:
5 a program to track moving points
in a video frameset
6 Copyright (C) 2007 Jean-Baptiste Butet <ashashiwa
@gmail.com>
8 This program
is free software: you can redistribute it
and/
or modify
9 it under the terms of the GNU General Public License
as published by
10 the Free Software Foundation, either version 3 of the License,
or
11 (at your option) any later version.
13 This program
is distributed
in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License
for more details.
18 You should have received a copy of the GNU General Public License
19 along
with this program. If
not, see <http://www.gnu.org/licenses/>.
22# from interfaces.Ui_preferences import Ui_Dialog
23from PyQt6.QtCore import QObject, QTimer
24from PyQt6.QtWidgets import QMessageBox
26import os, re, configparser, io
28from version import Version
29from vecteur import vecteur
31class MonConfigParser(configparser.ConfigParser):
33 Analiseur de fichier de configuration qui sait triter les vecteurs
36 configparser.ConfigParser. __init__(self)
41 @param section la section où on cherche
42 @param option l
'option que l'on cherche
43 @return la valeur sous forme de vecteur en cas de réussite
46 floatre = r"[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?"
47 m = re.match(f
"\\(({floatre}),[ ]?({floatre})\\)", self[section][option])
49 return vecteur(float(m.group(1)), float(m.group(5)))
54 def __init__(self, parent):
55 QObject.__init__(self)
58 self.
app.dbg.p(3,
"In : Preferences, preferences.py")
60 self.
conffile = os.path.join(self.
app._dir(
"conf"),
"pymecavideo.conf")
65 d[
'version'] = f
"pymecavideo {Version}"
66 d[
'proximite'] =
"False"
68 d[
'videoDir'] = os.getcwd()
72 d[
'taille_image'] =
"(320,240)"
74 d[
'origine'] =
"(320,240)"
75 d[
'index_depart'] =
"1"
76 d[
'etalon_m'] =
"1.00"
77 d[
'etalon_px'] =
"100"
78 d[
'etalon_org'] =
"None"
79 d[
'etalon_ext'] =
"None"
88 donne une représentation lisible de la configuration
90 with io.StringIO()
as outfile:
93 result = outfile.getvalue()
98 Sauvegarde des préférences dans le fichier de configuration.
100 with open(self.
conffile,
"w")
as outfile:
101 d = self.
config[
"DEFAULT"]
102 d[
"version"] = f
"pymecavideo {Version}"
103 d[
"lastvideo"] = str(self.
app.pointage.filename)
104 self.
config.write(outfile)
111 except UnicodeDecodeError:
114 lambda: QMessageBox.information(
116 self.tr(
"Erreur de lecture de la configuration"),
117 self.tr(
"Peut-être un ancien format de fichier de configuration ? On recommence avec une configuration neuve.")))
Analiseur de fichier de configuration qui sait triter les vecteurs.
def getvecteur(self, section, option)
def __str__(self)
donne une représentation lisible de la configuration
def save(self)
Sauvegarde des préférences dans le fichier de configuration.
une classe pour des vecteurs 2D ; les coordonnées sont flottantes, et on peut accéder à celles-ci par...