pyvguicom 1.0.0__py3-none-any.whl → 1.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pyvguicom might be problematic. Click here for more details.
- pyvguicom/__init__.py +1 -0
- pyvguicom/browsewin.py +10 -11
- pyvguicom/custwidg.py +110 -0
- pyvguicom/pgbox.py +59 -118
- pyvguicom/pgbutt.py +3 -2
- pyvguicom/pgentry.py +183 -22
- pyvguicom/pggui.py +239 -55
- pyvguicom/pgsel.py +441 -0
- pyvguicom/pgsimp.py +34 -265
- pyvguicom/pgtests.py +128 -0
- pyvguicom/pgtextview.py +0 -1
- pyvguicom/pgutils.py +391 -405
- pyvguicom/pgwkit.py +36 -27
- pyvguicom/testbutt.py +27 -25
- pyvguicom/testcust.py +49 -0
- pyvguicom/testentry.py +105 -0
- pyvguicom/testgui.py +125 -0
- pyvguicom/testlettsel.py +98 -0
- pyvguicom/testmsgs.py +142 -0
- pyvguicom/testnums.py +7 -12
- pyvguicom/testroot.py +7 -6
- pyvguicom/testsimple.py +24 -29
- pyvguicom/testtests.py +79 -0
- pyvguicom/testtextv.py +5 -14
- pyvguicom/testutils.py +139 -0
- {pyvguicom-1.0.0.dist-info → pyvguicom-1.1.1.dist-info}/METADATA +11 -5
- pyvguicom-1.1.1.dist-info/RECORD +32 -0
- pyvguicom/sutil.py +0 -344
- pyvguicom-1.0.0.dist-info/RECORD +0 -23
- {pyvguicom-1.0.0.dist-info → pyvguicom-1.1.1.dist-info}/WHEEL +0 -0
- {pyvguicom-1.0.0.dist-info → pyvguicom-1.1.1.dist-info}/top_level.txt +0 -0
pyvguicom/pgsimp.py
CHANGED
|
@@ -1,46 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/python
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
from __future__ import print_function
|
|
5
|
-
|
|
6
|
-
import os, sys, getopt, signal, string, fnmatch, math
|
|
7
|
-
import random, time, subprocess, traceback, glob
|
|
3
|
+
import sys
|
|
8
4
|
|
|
9
5
|
import gi
|
|
10
6
|
gi.require_version("Gtk", "3.0")
|
|
11
7
|
from gi.repository import Gtk
|
|
12
8
|
from gi.repository import Gdk
|
|
13
|
-
from gi.repository import GLib
|
|
14
9
|
from gi.repository import GObject
|
|
15
10
|
from gi.repository import Pango
|
|
16
11
|
|
|
17
|
-
|
|
18
|
-
import pgbox
|
|
19
|
-
|
|
20
|
-
#print("pyedpro pgsimp", __file__)
|
|
21
|
-
|
|
22
|
-
#print("pgsimp", __file__)
|
|
12
|
+
''' Simplified controls '''
|
|
23
13
|
|
|
24
|
-
|
|
25
|
-
# An N pixel horizontal spacer. Defaults to X pix get_center
|
|
26
|
-
# Re-created for no dependency include of this module
|
|
27
|
-
|
|
28
|
-
class zSpacer(Gtk.HBox):
|
|
14
|
+
gui_testmode = False
|
|
29
15
|
|
|
30
|
-
|
|
31
|
-
GObject.GObject.__init__(self)
|
|
32
|
-
#self.pack_start()
|
|
33
|
-
#if gui_testmode:
|
|
34
|
-
# col = randcolstr(100, 200)
|
|
35
|
-
# self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(col))
|
|
36
|
-
if sp == None:
|
|
37
|
-
sp = 6
|
|
38
|
-
self.set_size_request(sp, sp)
|
|
16
|
+
import pgutils
|
|
39
17
|
|
|
40
18
|
# ------------------------------------------------------------------------
|
|
41
19
|
|
|
42
20
|
class SimpleTree(Gtk.TreeView):
|
|
43
21
|
|
|
22
|
+
''' Simplified Tree control '''
|
|
23
|
+
|
|
44
24
|
def __init__(self, head = [], editx = [], skipedit = 0, xalign = 0.5):
|
|
45
25
|
|
|
46
26
|
Gtk.TreeView.__init__(self)
|
|
@@ -67,8 +47,8 @@ class SimpleTree(Gtk.TreeView):
|
|
|
67
47
|
for aa in head:
|
|
68
48
|
# Create a CellRendererText to render the data
|
|
69
49
|
cell = Gtk.CellRendererText()
|
|
70
|
-
|
|
71
|
-
|
|
50
|
+
cell.set_property("alignment", Pango.Alignment.LEFT)
|
|
51
|
+
cell.set_property("align-set", True)
|
|
72
52
|
cell.set_property("xalign", xalign)
|
|
73
53
|
|
|
74
54
|
if cnt > skipedit:
|
|
@@ -101,7 +81,8 @@ class SimpleTree(Gtk.TreeView):
|
|
|
101
81
|
args = []
|
|
102
82
|
for aa in self.treestore[path]:
|
|
103
83
|
args.append(aa)
|
|
104
|
-
self.chcallb
|
|
84
|
+
if self.chcallb:
|
|
85
|
+
self.chcallb(args)
|
|
105
86
|
|
|
106
87
|
def selection(self, xtree):
|
|
107
88
|
#print("simple tree sel", xtree)
|
|
@@ -138,29 +119,31 @@ class SimpleTree(Gtk.TreeView):
|
|
|
138
119
|
#print("sel first ...")
|
|
139
120
|
sel = self.get_selection()
|
|
140
121
|
xmodel, xiter = sel.get_selected()
|
|
141
|
-
|
|
142
|
-
sel.select_iter(
|
|
143
|
-
ppp = self.treestore.get_path(
|
|
144
|
-
self.scroll_to_cell(ppp, None, 0, 0, 0 )
|
|
122
|
+
iterx = self.treestore.get_iter_first()
|
|
123
|
+
sel.select_iter(iterx)
|
|
124
|
+
ppp = self.treestore.get_path(iterx)
|
|
145
125
|
self.set_cursor(ppp, self.get_column(0), False)
|
|
126
|
+
pgutils.usleep(5)
|
|
127
|
+
self.scroll_to_cell(ppp, None, 0, 0, 0 )
|
|
146
128
|
|
|
147
129
|
def sel_last(self):
|
|
148
130
|
#print("sel last ...")
|
|
149
131
|
sel = self.get_selection()
|
|
150
132
|
xmodel, xiter = sel.get_selected()
|
|
151
|
-
|
|
152
|
-
if not
|
|
133
|
+
iterx = self.treestore.get_iter_first()
|
|
134
|
+
if not iterx:
|
|
153
135
|
return
|
|
154
136
|
while True:
|
|
155
|
-
iter2 = self.treestore.iter_next(
|
|
137
|
+
iter2 = self.treestore.iter_next(iterx)
|
|
156
138
|
if not iter2:
|
|
157
139
|
break
|
|
158
|
-
|
|
159
|
-
sel.select_iter(
|
|
160
|
-
ppp = self.treestore.get_path(
|
|
161
|
-
self.scroll_to_cell(ppp, None, 0, 0, 0 )
|
|
140
|
+
iterx = iter2.copy()
|
|
141
|
+
sel.select_iter(iterx)
|
|
142
|
+
ppp = self.treestore.get_path(iterx)
|
|
162
143
|
self.set_cursor(ppp, self.get_column(0), False)
|
|
163
|
-
|
|
144
|
+
pgutils.usleep(5)
|
|
145
|
+
self.scroll_to_cell(ppp, None, True, 0., 0. )
|
|
146
|
+
#sel.select_path(self.treestore.get_path(iterx))
|
|
164
147
|
|
|
165
148
|
def find_item(self, item):
|
|
166
149
|
|
|
@@ -168,19 +151,19 @@ class SimpleTree(Gtk.TreeView):
|
|
|
168
151
|
|
|
169
152
|
#print("find", item)
|
|
170
153
|
found = 0
|
|
171
|
-
|
|
172
|
-
if not
|
|
173
|
-
return
|
|
154
|
+
iterx = self.treestore.get_iter_first()
|
|
155
|
+
if not iterx:
|
|
156
|
+
return found
|
|
174
157
|
while True:
|
|
175
|
-
value = self.treestore.get_value(
|
|
158
|
+
value = self.treestore.get_value(iterx, 0)
|
|
176
159
|
#print("item:", value)
|
|
177
160
|
if item == value:
|
|
178
161
|
found = True
|
|
179
162
|
break
|
|
180
|
-
iter2 = self.treestore.iter_next(
|
|
163
|
+
iter2 = self.treestore.iter_next(iterx)
|
|
181
164
|
if not iter2:
|
|
182
165
|
break
|
|
183
|
-
|
|
166
|
+
iterx = iter2.copy()
|
|
184
167
|
return found
|
|
185
168
|
|
|
186
169
|
def clear(self):
|
|
@@ -190,6 +173,8 @@ class SimpleTree(Gtk.TreeView):
|
|
|
190
173
|
|
|
191
174
|
class SimpleEdit(Gtk.TextView):
|
|
192
175
|
|
|
176
|
+
''' Simplified Edit controol '''
|
|
177
|
+
|
|
193
178
|
def __init__(self, head = []):
|
|
194
179
|
|
|
195
180
|
Gtk.TextView.__init__(self)
|
|
@@ -245,8 +230,8 @@ class SimpleEdit(Gtk.TextView):
|
|
|
245
230
|
|
|
246
231
|
def append(self, strx):
|
|
247
232
|
self.check_saved()
|
|
248
|
-
|
|
249
|
-
self.buffer.insert(
|
|
233
|
+
iterx = self.buffer.get_end_iter()
|
|
234
|
+
self.buffer.insert(iterx, strx)
|
|
250
235
|
self.buffer.set_modified(False)
|
|
251
236
|
|
|
252
237
|
def clear(self):
|
|
@@ -274,220 +259,4 @@ class SimpleEdit(Gtk.TextView):
|
|
|
274
259
|
self.buffer.set_modified(True)
|
|
275
260
|
|
|
276
261
|
|
|
277
|
-
# ------------------------------------------------------------------------
|
|
278
|
-
# Letter selection control
|
|
279
|
-
|
|
280
|
-
class LetterNumberSel(Gtk.VBox):
|
|
281
|
-
|
|
282
|
-
def __init__(self, callb = None, font="Mono 13"):
|
|
283
|
-
|
|
284
|
-
Gtk.VBox.__init__(self)
|
|
285
|
-
self.callb = callb
|
|
286
|
-
|
|
287
|
-
strx = "abcdefghijklmnopqrstuvwxyz"
|
|
288
|
-
hbox3a = Gtk.HBox()
|
|
289
|
-
hbox3a.pack_start(Gtk.Label(label=" "), 1, 1, 0)
|
|
290
|
-
self.simsel = internal_SimpleSel(strx, self.letter, font)
|
|
291
|
-
|
|
292
|
-
hbox3a.pack_start(self.simsel, 0, 0, 0)
|
|
293
|
-
hbox3a.pack_start(Gtk.Label(label=" "), 1, 1, 0)
|
|
294
|
-
|
|
295
|
-
strn = "1234567890!@#$^&*_+ [All]"
|
|
296
|
-
hbox3b = Gtk.HBox()
|
|
297
|
-
hbox3b.pack_start(Gtk.Label(label=" "), 1, 1, 0)
|
|
298
|
-
self.simsel2 = internal_SimpleSel(strn, self.letter, font)
|
|
299
|
-
hbox3b.pack_start(self.simsel2, 0, 0, 0)
|
|
300
|
-
hbox3b.pack_start(Gtk.Label(label=" "), 1, 1, 0)
|
|
301
|
-
|
|
302
|
-
self.hand_cursor = Gdk.Cursor(Gdk.CursorType.HAND2)
|
|
303
|
-
self.simsel.connect("enter_notify_event", self.enter_label)
|
|
304
|
-
self.simsel.connect("leave_notify_event", self.leave_label)
|
|
305
|
-
self.simsel2.connect("enter_notify_event", self.enter_label)
|
|
306
|
-
self.simsel2.connect("leave_notify_event", self.leave_label)
|
|
307
|
-
|
|
308
|
-
self.simsel2.other = self.simsel
|
|
309
|
-
self.simsel.other = self.simsel2
|
|
310
|
-
|
|
311
|
-
self.pack_start(hbox3a, 0, 0, False)
|
|
312
|
-
self.pack_start(zSpacer(4), 0, 0, False)
|
|
313
|
-
self.pack_start(hbox3b, 0, 0, False)
|
|
314
|
-
|
|
315
|
-
def enter_label(self, arg, arg2):
|
|
316
|
-
#print("Enter")
|
|
317
|
-
self.get_window().set_cursor(self.hand_cursor)
|
|
318
|
-
|
|
319
|
-
def leave_label(self, arg, arg2):
|
|
320
|
-
#print("Leave")
|
|
321
|
-
self.get_window().set_cursor()
|
|
322
|
-
|
|
323
|
-
def letter(self, letter):
|
|
324
|
-
#print("LetterSel::letterx:", letter)
|
|
325
|
-
if self.callb:
|
|
326
|
-
self.callb(letter)
|
|
327
|
-
|
|
328
|
-
# Select character by index (do not call directly)
|
|
329
|
-
|
|
330
|
-
class internal_SimpleSel(Gtk.Label):
|
|
331
|
-
|
|
332
|
-
def __init__(self, text = " ", callb = None, font="Mono 13"):
|
|
333
|
-
self.text = text
|
|
334
|
-
self.callb = callb
|
|
335
|
-
self.axx = self.text.find("[All]")
|
|
336
|
-
#self.axx = -1
|
|
337
|
-
Gtk.Label.__init__(self, text)
|
|
338
|
-
self.set_has_window(True)
|
|
339
|
-
self.set_events(Gdk.EventMask.ALL_EVENTS_MASK )
|
|
340
|
-
self.connect("button-press-event", self.area_button)
|
|
341
|
-
self.modify_font(Pango.FontDescription(font))
|
|
342
|
-
self.lastsel = "All"
|
|
343
|
-
self.lastidx = 0
|
|
344
|
-
self.other = None
|
|
345
|
-
|
|
346
|
-
def area_button(self, but, event):
|
|
347
|
-
|
|
348
|
-
prop = event.x / float(self.get_allocation().width)
|
|
349
|
-
idx = int(prop * len(self.text))
|
|
350
|
-
#print("width =", self.get_allocation().width)
|
|
351
|
-
#print("idx", idx, )
|
|
352
|
-
#print("click", event.x, event.y)
|
|
353
|
-
try:
|
|
354
|
-
# See of it is all
|
|
355
|
-
if self.axx >= 0:
|
|
356
|
-
if idx > self.axx:
|
|
357
|
-
#print("all", idx, self.text[idx-5:idx+7])
|
|
358
|
-
self.lastsel = "All"
|
|
359
|
-
self.newtext = self.text[:self.axx] + self.text[self.axx:].upper()
|
|
360
|
-
self.set_text(self.newtext)
|
|
361
|
-
else:
|
|
362
|
-
if self.text[idx].isalpha():
|
|
363
|
-
self.newtext = self.text[:self.axx] + self.text[self.axx:].lower()
|
|
364
|
-
else:
|
|
365
|
-
#print("Non alpha, filling pipe char")
|
|
366
|
-
#print("old sel", self.lastidx, "new sel", idx, self.text[:idx])
|
|
367
|
-
if self.lastidx + 2 < idx:
|
|
368
|
-
idx -= 1
|
|
369
|
-
self.lastsel = self.text[idx]
|
|
370
|
-
self.newtext = self.text[:idx] + "|" + self.text[idx] + "|" + self.text[idx+1:]
|
|
371
|
-
self.lastidx = idx
|
|
372
|
-
|
|
373
|
-
self.set_text(self.newtext)
|
|
374
|
-
|
|
375
|
-
else:
|
|
376
|
-
self.lastsel = self.text[idx]
|
|
377
|
-
self.newtext = self.text[:idx] + self.text[idx].upper() + self.text[idx+1:]
|
|
378
|
-
self.set_text(self.newtext)
|
|
379
|
-
|
|
380
|
-
# Clear the other
|
|
381
|
-
if self.other:
|
|
382
|
-
self.other.newtext = self.other.text[:]
|
|
383
|
-
self.other.set_text(self.other.newtext)
|
|
384
|
-
|
|
385
|
-
if self.callb:
|
|
386
|
-
self.callb(self.lastsel)
|
|
387
|
-
|
|
388
|
-
except:
|
|
389
|
-
print(sys.exc_info())
|
|
390
|
-
|
|
391
|
-
# Give a proportional answer
|
|
392
|
-
|
|
393
|
-
class NumberSel(Gtk.Label):
|
|
394
|
-
|
|
395
|
-
def __init__(self, text = " ", callb = None, font="Mono 13"):
|
|
396
|
-
self.text = text
|
|
397
|
-
self.callb = callb
|
|
398
|
-
self.axx = self.text.find("[All]")
|
|
399
|
-
Gtk.Label.__init__(self, text)
|
|
400
|
-
self.set_has_window(True)
|
|
401
|
-
self.set_events(Gdk.EventMask.ALL_EVENTS_MASK )
|
|
402
|
-
self.connect("button-press-event", self.area_button)
|
|
403
|
-
self.override_font(Pango.FontDescription(font))
|
|
404
|
-
self.lastsel = "All"
|
|
405
|
-
|
|
406
|
-
def area_button(self, but, event):
|
|
407
|
-
|
|
408
|
-
#print("sss =", self.get_allocation().width)
|
|
409
|
-
#print("click", event.x, event.y)
|
|
410
|
-
|
|
411
|
-
prop = event.x / float(self.get_allocation().width)
|
|
412
|
-
idx = int(prop * len(self.text))
|
|
413
|
-
|
|
414
|
-
# Navigate to IDX
|
|
415
|
-
if self.text[idx] == " ":
|
|
416
|
-
idx += 1
|
|
417
|
-
else:
|
|
418
|
-
if self.text[idx-1] != " ":
|
|
419
|
-
idx -= 1
|
|
420
|
-
if idx >= len(self.text):
|
|
421
|
-
return
|
|
422
|
-
|
|
423
|
-
try:
|
|
424
|
-
# See of it is all
|
|
425
|
-
if self.axx >= 0:
|
|
426
|
-
if idx > self.axx:
|
|
427
|
-
#print("all", idx, self.text[idx-5:idx+7])
|
|
428
|
-
self.lastsel = "All"
|
|
429
|
-
self.newtext = self.text[:self.axx] + self.text[self.axx:].upper()
|
|
430
|
-
self.set_text(self.newtext)
|
|
431
|
-
else:
|
|
432
|
-
self.newtext = self.text[:self.axx] + self.text[self.axx:].lower()
|
|
433
|
-
self.set_text(self.newtext)
|
|
434
|
-
|
|
435
|
-
else:
|
|
436
|
-
self.lastsel = self.text[idx:idx+2]
|
|
437
|
-
#print("lastsel", self.lastsel)
|
|
438
|
-
self.newtext = self.text[:idx] + self.text[idx].upper() + self.text[idx+1:]
|
|
439
|
-
self.set_text(self.newtext)
|
|
440
|
-
|
|
441
|
-
if self.callb:
|
|
442
|
-
self.callb(self.lastsel)
|
|
443
|
-
|
|
444
|
-
except:
|
|
445
|
-
print(sys.exc_info())
|
|
446
|
-
|
|
447
|
-
class HourSel(Gtk.VBox):
|
|
448
|
-
|
|
449
|
-
def __init__(self, callb = None):
|
|
450
|
-
|
|
451
|
-
Gtk.VBox.__init__(self)
|
|
452
|
-
self.callb = callb
|
|
453
|
-
|
|
454
|
-
strx = " 8 10 12 14 16 "
|
|
455
|
-
hbox3a = Gtk.HBox()
|
|
456
|
-
hbox3a.pack_start(Gtk.Label(label=" "), 1, 1, 0)
|
|
457
|
-
self.simsel = NumberSel(strx, self.letter)
|
|
458
|
-
hbox3a.pack_start(self.simsel, 0, 0, 0)
|
|
459
|
-
hbox3a.pack_start(Gtk.Label(label=" "), 1, 1, 0)
|
|
460
|
-
|
|
461
|
-
self.pack_start(hbox3a, 0, 0, False)
|
|
462
|
-
|
|
463
|
-
def letter(self, letter):
|
|
464
|
-
#print("LetterSel::letterx:", letter)
|
|
465
|
-
if self.callb:
|
|
466
|
-
self.callb(letter)
|
|
467
|
-
|
|
468
|
-
class MinSel(Gtk.VBox):
|
|
469
|
-
|
|
470
|
-
def __init__(self, callb = None):
|
|
471
|
-
|
|
472
|
-
Gtk.VBox.__init__(self)
|
|
473
|
-
self.callb = callb
|
|
474
|
-
|
|
475
|
-
strx = " 0 10 20 30 40 50 "
|
|
476
|
-
hbox3a = Gtk.HBox()
|
|
477
|
-
hbox3a.pack_start(Gtk.Label(label=" "), 1, 1, 0)
|
|
478
|
-
self.simsel = NumberSel(strx, self.letter)
|
|
479
|
-
hbox3a.pack_start(self.simsel, 0, 0, 0)
|
|
480
|
-
hbox3a.pack_start(Gtk.Label(label=" "), 1, 1, 0)
|
|
481
|
-
|
|
482
|
-
self.pack_start(hbox3a, 0, 0, False)
|
|
483
|
-
|
|
484
|
-
def letter(self, letter):
|
|
485
|
-
#print("LetterSel::letterx:", letter)
|
|
486
|
-
if self.callb:
|
|
487
|
-
self.callb(letter)
|
|
488
|
-
|
|
489
|
-
# ------------------------------------------------------------------------
|
|
490
|
-
|
|
491
|
-
|
|
492
262
|
# EOF
|
|
493
|
-
|
pyvguicom/pgtests.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/python
|
|
2
|
+
|
|
3
|
+
# pylint: disable=C0103
|
|
4
|
+
# pylint: disable=C0209
|
|
5
|
+
# pylint: disable=C0321
|
|
6
|
+
|
|
7
|
+
import os, sys, getopt, string, math
|
|
8
|
+
import random, time, traceback, stat
|
|
9
|
+
import platform, datetime
|
|
10
|
+
|
|
11
|
+
# Add the new line twice for more balaced string
|
|
12
|
+
|
|
13
|
+
allcr = " " + "\r" + "\n" + \
|
|
14
|
+
"\r" + "\n"
|
|
15
|
+
|
|
16
|
+
allstr = " " + \
|
|
17
|
+
string.ascii_lowercase + string.ascii_uppercase + \
|
|
18
|
+
string.digits
|
|
19
|
+
|
|
20
|
+
allasc = string.ascii_lowercase + string.ascii_uppercase + \
|
|
21
|
+
string.digits + "_"
|
|
22
|
+
alllett = string.ascii_lowercase + string.ascii_uppercase
|
|
23
|
+
testmode = 0
|
|
24
|
+
|
|
25
|
+
alllett = string.ascii_lowercase + string.ascii_uppercase
|
|
26
|
+
|
|
27
|
+
# ------------------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
def randascii(lenx):
|
|
30
|
+
|
|
31
|
+
''' Spew a lot of chars, simulate txt by add ' ' an '\n' '''
|
|
32
|
+
|
|
33
|
+
strx = ""
|
|
34
|
+
for aa in range(lenx):
|
|
35
|
+
ridx = random.randint(0x20, 0x7d)
|
|
36
|
+
rr = chr(ridx)
|
|
37
|
+
strx += str(rr)
|
|
38
|
+
if random.randint(0x00, 40) == 30:
|
|
39
|
+
strx += "\n"
|
|
40
|
+
if random.randint(0x00, 12) == 10:
|
|
41
|
+
strx += " "
|
|
42
|
+
return strx
|
|
43
|
+
|
|
44
|
+
def simname(lenx):
|
|
45
|
+
strx = ""
|
|
46
|
+
lenz = len(alllett)-1
|
|
47
|
+
spidx = random.randint(0, lenx - 4)
|
|
48
|
+
ridx = random.randint(0, len(string.ascii_uppercase)-1)
|
|
49
|
+
strx += string.ascii_uppercase[ridx]
|
|
50
|
+
for aa in range(spidx):
|
|
51
|
+
ridx = random.randint(0, len(string.ascii_lowercase)-1)
|
|
52
|
+
rr = string.ascii_lowercase[ridx]
|
|
53
|
+
strx += str(rr)
|
|
54
|
+
strx += " "
|
|
55
|
+
ridx = random.randint(0, len(string.ascii_uppercase)-1)
|
|
56
|
+
strx += string.ascii_uppercase[ridx]
|
|
57
|
+
for aa in range(lenx - spidx):
|
|
58
|
+
ridx = random.randint(0, len(string.ascii_lowercase)-1)
|
|
59
|
+
rr = string.ascii_lowercase[ridx]
|
|
60
|
+
strx += str(rr)
|
|
61
|
+
return strx
|
|
62
|
+
|
|
63
|
+
def randisodate():
|
|
64
|
+
dd = datetime.datetime.now()
|
|
65
|
+
dd = dd.replace(microsecond=0)
|
|
66
|
+
return dd.isoformat()
|
|
67
|
+
|
|
68
|
+
def randate():
|
|
69
|
+
|
|
70
|
+
''' Give us a random date in str '''
|
|
71
|
+
|
|
72
|
+
dd = datetime.datetime.now()
|
|
73
|
+
dd = dd.replace(year=random.randint(1980, 2024),
|
|
74
|
+
month=random.randint(1, 12),
|
|
75
|
+
day=random.randint(1, 28),
|
|
76
|
+
hour=0, minute=0, second=0, microsecond=0)
|
|
77
|
+
|
|
78
|
+
return dd.strftime("%Y/%m/%d")
|
|
79
|
+
|
|
80
|
+
# ------------------------------------------------------------------------
|
|
81
|
+
# Get random str
|
|
82
|
+
|
|
83
|
+
def randstr(lenx):
|
|
84
|
+
|
|
85
|
+
strx = ""
|
|
86
|
+
for aa in range(lenx):
|
|
87
|
+
ridx = random.randint(0, len(allstr)-1)
|
|
88
|
+
rr = allstr[ridx]
|
|
89
|
+
strx += str(rr)
|
|
90
|
+
|
|
91
|
+
return strx
|
|
92
|
+
|
|
93
|
+
def randasc(lenx):
|
|
94
|
+
|
|
95
|
+
strx = ""
|
|
96
|
+
for aa in range(lenx):
|
|
97
|
+
ridx = random.randint(0, len(allasc)-1)
|
|
98
|
+
rr = allasc[ridx]
|
|
99
|
+
strx += str(rr)
|
|
100
|
+
|
|
101
|
+
return strx
|
|
102
|
+
|
|
103
|
+
def randlett(lenx):
|
|
104
|
+
|
|
105
|
+
strx = ""
|
|
106
|
+
for aa in range(lenx):
|
|
107
|
+
ridx = random.randint(0, len(alllett)-1)
|
|
108
|
+
rr = alllett[ridx]
|
|
109
|
+
strx += str(rr)
|
|
110
|
+
|
|
111
|
+
return strx
|
|
112
|
+
|
|
113
|
+
# ------------------------------------------------------------------------
|
|
114
|
+
# Random colors
|
|
115
|
+
|
|
116
|
+
def randcol():
|
|
117
|
+
return random.randint(0, 255)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def randcolstr(start = 0, endd = 255):
|
|
121
|
+
rr = random.randint(start, endd)
|
|
122
|
+
gg = random.randint(start, endd)
|
|
123
|
+
bb = random.randint(start, endd)
|
|
124
|
+
strx = "#%02x%02x%02x" % (rr, gg, bb)
|
|
125
|
+
return strx
|
|
126
|
+
|
|
127
|
+
# EOF
|
|
128
|
+
|