Fri, 25 Jan 2008 20:50:50 +0100
removed useless png files (using SVG everywhere)
23
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
1 | import os |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
2 | from PyQt4 import QtCore, QtGui, uic |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
3 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
4 | def fromVariant(v): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
5 | _cvrts = {0: lambda x:None, |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
6 | 1: lambda x:x.toBool(), |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
7 | 2: lambda x:x.toInt()[0], |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
8 | 6: lambda x:x.toDouble()[0], |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
9 | 10: lambda x:unicode(x.toString()), |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
10 | 12: lambda x:x.toByteArray(), |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
11 | 21: lambda x:x.toSize(), |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
12 | 22: lambda x:x.toSizeF(), |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
13 | 25: lambda x:x.toPoint(), |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
14 | 26: lambda x:x.toPointF(), |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
15 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
16 | } |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
17 | t = v.userType() |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
18 | return _cvrts[t](v) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
19 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
20 | class PreferenceItem(object): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
21 | _id = 0 |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
22 | def __init__(self, default=None, basetype=None, name=None, description=None): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
23 | self._default = default |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
24 | self._basetype = basetype |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
25 | if self._basetype is None: |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
26 | self._basetype = self._default.__class__ |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
27 | self._id = "_pref%X"%self.__class__._id |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
28 | self._name = name |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
29 | self._description = description |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
30 | self.__class__._id += 1 |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
31 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
32 | def __get__(self, obj, cls): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
33 | if obj is None: |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
34 | return self |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
35 | try: |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
36 | return obj.getPref(self._id) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
37 | except Exception, e: |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
38 | #print "humm", e |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
39 | return None |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
40 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
41 | def __set__(self, obj, value): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
42 | obj.setPref(self._id, value) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
43 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
44 | class AbstractPreferences(QtCore.QObject): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
45 | def __init__(self): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
46 | QtCore.QObject.__init__(self) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
47 | self._settings = QtCore.QSettings(QtCore.QSettings.UserScope, |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
48 | self.ORGANISATION, self.APPLICATION) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
49 | self._prefs = {} |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
50 | for k in dir(self.__class__): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
51 | item = getattr(self.__class__, k) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
52 | if isinstance(item, PreferenceItem): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
53 | self._prefs[item._id] = k |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
54 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
55 | def getPref(self, key): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
56 | key = self._prefs.get(key, key) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
57 | default = getattr(self.__class__, key)._default |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
58 | if default is not None: |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
59 | default = QtCore.QVariant(default) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
60 | else: |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
61 | default = QtCore.QVariant() |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
62 | val = self._settings.value(key, default) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
63 | return fromVariant(val) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
64 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
65 | def setPref(self, key, value): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
66 | key = self._prefs.get(key, key) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
67 | self._settings.setValue(key, QtCore.QVariant(value)) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
68 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
69 | def keys(self): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
70 | return [k for k in self._prefs.values() if not k.startswith('_')] |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
71 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
72 | def getName(self, key): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
73 | item = getattr(self.__class__, key) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
74 | return item._name |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
75 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
76 | def getDescription(self, key): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
77 | item = getattr(self.__class__, key) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
78 | return item._description |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
79 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
80 | form_class, base_class = uic.loadUiType(os.path.join(os.path.dirname(__file__), "qpreferences_dialog.ui")) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
81 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
82 | class PreferencesEditor(QtGui.QDialog, form_class): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
83 | def __init__(self, preferences, parent=None): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
84 | QtGui.QDialog.__init__(self, parent) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
85 | self.setupUi(self) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
86 | self._prefs = preferences |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
87 | self.buildUI() |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
88 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
89 | def buildUI(self): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
90 | w = self.centralFrame |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
91 | g = QtGui.QGridLayout(w) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
92 | p = self._prefs |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
93 | eds = {} |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
94 | self._editors = eds |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
95 | for i, k in enumerate(p.keys()): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
96 | name = p.getName(k) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
97 | if not name: |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
98 | name = k |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
99 | l = QtGui.QLabel(name, w) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
100 | g.addWidget(l, i, 0) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
101 | if p.getDescription(k): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
102 | l.setToolTip(p.getDescription(k)) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
103 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
104 | e = QtGui.QLineEdit(w) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
105 | eds[k] = e |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
106 | g.addWidget(e, i, 1) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
107 | val = p.getPref(k) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
108 | if val is None: |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
109 | val = '' |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
110 | if not isinstance(val, basestring): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
111 | val = unicode(val) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
112 | e.setText(val) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
113 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
114 | g.addWidget(QtGui.QWidget(w), i+1, 0) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
115 | g.setRowStretch(i+1,1) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
116 | g.setColumnStretch(1,1) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
117 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
118 | def accept(self): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
119 | p=self._prefs |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
120 | for k in p.keys(): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
121 | newval = unicode(self._editors[k].text()) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
122 | p.setPref(k, newval) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
123 | return QtGui.QDialog.accept(self) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
124 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
125 | if __name__ == '__main__': |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
126 | class TestPreferences(AbstractPreferences): |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
127 | ORGANISATION="Logilab" |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
128 | APPLICATION="test_qpref_editor" |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
129 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
130 | device = PreferenceItem('/dev/ttyUSB0', name="the device") |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
131 | address = PreferenceItem(5, description="GPIB address of the plotter") |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
132 | _pos = PreferenceItem(None) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
133 | _size = PreferenceItem(None) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
134 | _appState = PreferenceItem(None) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
135 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
136 | a = QtGui.QApplication([]) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
137 | |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
138 | prefs = TestPreferences() |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
139 | w = PreferencesEditor(prefs) |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
140 | w.show() |
cb97962a1ae9
make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
141 | a.exec_() |