summaryrefslogtreecommitdiffstats
path: root/examples/uimodules/uimisc.py
blob: 0dd4124fe55c1809def4f4626ba2d8c825f170bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
import os, time

from qt import TQImage, TQLabel, TQPixmap, TQPushButton, SIGNAL, TQColor, TQValidator

from tdeui import KMessageBox, KDateValidator, KFloatValidator, KIntValidator, KLineEdit, KLed



class Page3:
    def __init__ (self, parent):
        self.page = parent.addPage ()

        x = 10
        y = 15

        green  = TQColor (0, 255, 0)
        yellow = TQColor (255, 255, 0)
        red    = TQColor (255, 0, 0)

        ivLbl  = TQLabel ("KIntValidator", self.page)
        ivLbl.setGeometry (x, y, 100, 20)
        ivLbl.show ()

        self.iv = KLineEdit (self.page)
        self.iv.setGeometry (x, y + 20, 100, 20)
        self.iv.show ()
        self.page.connect (self.iv, SIGNAL("textChanged (const TQString &)"), self.ivChanged)

        self.ivVal = KIntValidator (self.page)
        self.ivVal.setRange (20, 50)

        ivRngLbl = TQLabel ("Range is 20 - 50", self.page)
        ivRngLbl.setGeometry (x, y + 45, 100, 20)
        ivRngLbl.show ()

        ivAccLbl   = TQLabel ("Acceptable", self.page)
        ivAccLbl.setGeometry (x + 125, y + 45, 85, 20)
        ivAccLbl.show ()
        ivInterLbl = TQLabel ("Intermediate", self.page)
        ivInterLbl.setGeometry (x + 125, y + 20, 85, 20)
        ivInterLbl.show ()
        ivInvalLbl = TQLabel ("Invalid", self.page)
        ivInvalLbl.setGeometry (x + 125, y - 5, 85, 20)
        ivInvalLbl.show ()
        self.ivInvalLed = KLed (red, KLed.Off, KLed.Sunken, KLed.Circular,self.page)
        self.ivInvalLed.setGeometry (x + 215, y - 5, 18, 18)
        self.ivInvalLed.show ()
        self.ivInterLed = KLed (yellow, KLed.Off, KLed.Sunken, KLed.Circular,self.page)
        self.ivInterLed.setGeometry (x + 215, y + 20, 18, 18)
        self.ivInterLed.show ()
        self.ivAccLed = KLed (green, KLed.On, KLed.Sunken, KLed.Circular,self.page)
        self.ivAccLed.setGeometry (x + 215, y + 45, 18, 18)
        self.ivAccLed.show ()

        y = y + 100

        fvLbl  = TQLabel ("KFloatValidator", self.page)
        fvLbl.setGeometry (x, y, 100, 20)
        fvLbl.show ()

        self.fv = KLineEdit (self.page)
        self.fv.setGeometry (x, y + 20, 100, 20)
        self.fv.show ()
        self.page.connect (self.fv, SIGNAL("textChanged (const TQString &)"), self.fvChanged)

        self.fvVal = KFloatValidator (self.page)
        self.fvVal.setRange (10.0, 40.0)

        fvRngLbl = TQLabel ("Range is 10.0 - 40.0", self.page)
        fvRngLbl.setGeometry (x, y + 45, 100, 20)
        fvRngLbl.show ()

        fvAccLbl   = TQLabel ("Acceptable", self.page)
        fvAccLbl.setGeometry (x + 125, y + 45, 85, 20)
        fvAccLbl.show ()
        fvInterLbl = TQLabel ("Intermediate", self.page)
        fvInterLbl.setGeometry (x + 125, y + 20, 95, 20)
        fvInterLbl.show ()
        fvInvalLbl = TQLabel ("Invalid", self.page)
        fvInvalLbl.setGeometry (x + 125, y - 5, 85, 20)
        fvInvalLbl.show ()
        self.fvInvalLed = KLed (red, KLed.Off, KLed.Sunken, KLed.Circular,self.page)
        self.fvInvalLed.setGeometry (x + 215, y - 5, 18, 18)
        self.fvInvalLed.show ()
        self.fvInterLed = KLed (yellow, KLed.Off, KLed.Sunken, KLed.Circular,self.page)
        self.fvInterLed.setGeometry (x + 215, y + 20, 18, 18)
        self.fvInterLed.show ()
        self.fvAccLed = KLed (green, KLed.On, KLed.Sunken, KLed.Circular,self.page)
        self.fvAccLed.setGeometry (x + 215, y + 45, 18, 18)
        self.fvAccLed.show ()

        y = y + 100

        dvLbl  = TQLabel ("KDateValidator", self.page)
        dvLbl.setGeometry (x, y, 100, 20)
        dvLbl.show ()

        self.dv = KLineEdit (self.page)
        self.dv.setGeometry (x, y + 20, 100, 20)
        self.dv.show ()
#        self.page.connect (self.dv, SIGNAL("textChanged (const TQString &)"), self.dvChanged)

        self.dvVal = KDateValidator (self.page)
#        self.dvVal.setRange (10.0, 40.0)

#        dvRngLbl = TQLabel ("Range is 10.0 - 40.0", self.page)
#        dvRngLbl.setGeometry (x, y + 45, 100, 20)
#        dvRngLbl.show ()

        dvBtn = TQPushButton ("Validate", self.page)
        dvBtn.setGeometry (x, y + 45, 60, 22)
        dvBtn.show ()
        self.page.connect (dvBtn, SIGNAL ("clicked ()"), self.dvChanged)

        dvNoteLbl = TQLabel ("Format is locale dependent\nShort date only\nTry DD-MM-YY", self.page)
        dvNoteLbl.setGeometry (x, y + 70, 150, 60)
        dvNoteLbl.show ()

        dvAccLbl   = TQLabel ("Acceptable", self.page)
        dvAccLbl.setGeometry (x + 125, y + 45, 85, 20)
        dvAccLbl.show ()
        dvInterLbl = TQLabel ("Intermediate", self.page)
        dvInterLbl.setGeometry (x + 125, y + 20, 85, 20)
        dvInterLbl.show ()
        dvInvalLbl = TQLabel ("Invalid", self.page)
        dvInvalLbl.setGeometry (x + 125, y - 5, 85, 20)
        dvInvalLbl.show ()
        self.dvInvalLed = KLed (red, KLed.Off, KLed.Sunken, KLed.Circular,self.page)
        self.dvInvalLed.setGeometry (x + 215, y - 5, 18, 18)
        self.dvInvalLed.show ()
        self.dvInterLed = KLed (yellow, KLed.Off, KLed.Sunken, KLed.Circular,self.page)
        self.dvInterLed.setGeometry (x + 215, y + 20, 18, 18)
        self.dvInterLed.show ()
        self.dvAccLed = KLed (green, KLed.On, KLed.Sunken, KLed.Circular,self.page)
        self.dvAccLed.setGeometry (x + 215, y + 45, 18, 18)
        self.dvAccLed.show ()

    def ivChanged (self):
        self.ivInvalLed.off ()
        self.ivInterLed.off ()
        self.ivAccLed.off ()

        state, i = self.ivVal.validate (self.iv.text ())

        if state == TQValidator.Acceptable:
            self.ivAccLed.on ()
        elif state == TQValidator.Intermediate:
            self.ivInterLed.on ()
        else:
            self.ivInvalLed.on ()

    def fvChanged (self):
        self.fvInvalLed.off ()
        self.fvInterLed.off ()
        self.fvAccLed.off ()

        state, i = self.fvVal.validate (self.fv.text ())

        if state == TQValidator.Acceptable:
            self.fvAccLed.on ()
        elif state == TQValidator.Intermediate:
            self.fvInterLed.on ()
        else:
            self.fvInvalLed.on ()

    def dvChanged (self):
        self.dvInvalLed.off ()
        self.dvInterLed.off ()
        self.dvAccLed.off ()

        state, i = self.dvVal.validate (self.dv.text ())

        if state == TQValidator.Acceptable:
            self.dvAccLed.on ()
        elif state == TQValidator.Intermediate:
            self.dvInterLed.on ()
        else:
            self.dvInvalLed.on ()

class PageNotImpl:
    def __init__ (self, parent):
        self.page = parent.addPage ()

        x = 10
        y = 10

        niLbl   = TQLabel ("Nothing is currently implemented for this widget", self.page)
        niLbl.setGeometry (x, y, 300, 20)
        niLbl.show ()

def miscKAlphaPainter (parent):
    parent.currentPageObj = PageNotImpl (parent)

def miscTDECModule (parent):
    parent.currentPageObj = PageNotImpl (parent)

def miscKColor (parent):
    parent.currentPageObj = PageNotImpl (parent)

def miscKColorDrag (parent):
    parent.currentPageObj = PageNotImpl (parent)

def miscKCommand (parent):
    parent.currentPageObj = PageNotImpl (parent)

def miscKCommandHistory (parent):
    parent.currentPageObj = PageNotImpl (parent)

def miscKDockWindow (parent):
    parent.currentPageObj = PageNotImpl (parent)

def miscKFloatValidator (parent):
    parent.currentPageObj = Page3 (parent)

def miscKDateValidator (parent):
    parent.currentPageObj = Page3 (parent)

def miscKIntValidator (parent):
    parent.currentPageObj = Page3 (parent)

def miscKPixmapIO (parent):
    parent.currentPageObj = PageNotImpl (parent)

def miscTDESharedPixmap (parent):
    parent.currentPageObj = PageNotImpl (parent)

def miscKSystemTray (parent):
    KMessageBox.information (parent, "See the systray.py example in the templates/ subdirectories")

def miscKThemeBase (parent):
    parent.currentPageObj = PageNotImpl (parent)

def miscQXEmbed (parent):
    parent.currentPageObj = PageNotImpl (parent)

if __name__ == "__main__":
    print
    print "Please run uisampler.py"
    print