pyvguicom 1.0.0__py3-none-any.whl → 1.0.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/pgsimp.py CHANGED
@@ -1,46 +1,26 @@
1
1
  #!/usr/bin/python
2
2
 
3
- from __future__ import absolute_import
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
- gui_testmode = False
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
- def __init__(self, sp = None):
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
- #cell.set_property("alignment", Pango.Alignment.CENTER)
71
- #cell.set_property("align-set", True)
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(args)
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
- iter = self.treestore.get_iter_first()
142
- sel.select_iter(iter)
143
- ppp = self.treestore.get_path(iter)
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
- iter = self.treestore.get_iter_first()
152
- if not iter:
133
+ iterx = self.treestore.get_iter_first()
134
+ if not iterx:
153
135
  return
154
136
  while True:
155
- iter2 = self.treestore.iter_next(iter)
137
+ iter2 = self.treestore.iter_next(iterx)
156
138
  if not iter2:
157
139
  break
158
- iter = iter2.copy()
159
- sel.select_iter(iter)
160
- ppp = self.treestore.get_path(iter)
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
- #sel.select_path(self.treestore.get_path(iter))
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
- iter = self.treestore.get_iter_first()
172
- if not iter:
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(iter, 0)
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(iter)
163
+ iter2 = self.treestore.iter_next(iterx)
181
164
  if not iter2:
182
165
  break
183
- iter = iter2.copy()
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
- iter = self.buffer.get_end_iter()
249
- self.buffer.insert(iter, strx)
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/pgtextview.py CHANGED
@@ -16,7 +16,6 @@ from gi.repository import GObject
16
16
  from gi.repository import Pango
17
17
 
18
18
  import pgbox
19
- import sutil
20
19
 
21
20
  # Colors for editor selection. Use X11 color names.
22
21