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/__init__.py +1 -0
- pyvguicom/custwidg.py +110 -0
- pyvguicom/pgbox.py +59 -118
- pyvguicom/pgbutt.py +3 -2
- pyvguicom/pgentry.py +114 -19
- pyvguicom/pggui.py +99 -14
- pyvguicom/pgsel.py +439 -0
- pyvguicom/pgsimp.py +34 -265
- pyvguicom/pgtextview.py +0 -1
- pyvguicom/pgutils.py +495 -157
- pyvguicom/testbutt.py +26 -24
- pyvguicom/testcust.py +49 -0
- pyvguicom/testentry.py +93 -0
- pyvguicom/testlettsel.py +98 -0
- pyvguicom/testnums.py +6 -11
- pyvguicom/testroot.py +7 -6
- pyvguicom/testsimple.py +22 -28
- pyvguicom/testtextv.py +3 -12
- {pyvguicom-1.0.0.dist-info → pyvguicom-1.0.1.dist-info}/METADATA +11 -5
- pyvguicom-1.0.1.dist-info/RECORD +27 -0
- pyvguicom/sutil.py +0 -344
- pyvguicom-1.0.0.dist-info/RECORD +0 -23
- {pyvguicom-1.0.0.dist-info → pyvguicom-1.0.1.dist-info}/WHEEL +0 -0
- {pyvguicom-1.0.0.dist-info → pyvguicom-1.0.1.dist-info}/top_level.txt +0 -0
pyvguicom/__init__.py
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# __init__.py
|
pyvguicom/custwidg.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
import os, sys, getopt, signal, select, string, time
|
|
4
|
+
import struct, stat, base64, random, zlib
|
|
5
|
+
|
|
6
|
+
import gi
|
|
7
|
+
gi.require_version("Gtk", "3.0")
|
|
8
|
+
from gi.repository import Gtk
|
|
9
|
+
from gi.repository import Gdk
|
|
10
|
+
from gi.repository import GObject
|
|
11
|
+
from gi.repository import GLib
|
|
12
|
+
from gi.repository import Pango
|
|
13
|
+
|
|
14
|
+
gi.require_version('PangoCairo', '1.0')
|
|
15
|
+
from gi.repository import PangoCairo
|
|
16
|
+
|
|
17
|
+
class SimpleWidget(Gtk.Widget):
|
|
18
|
+
__gtype_name__ = 'ManualWidget'
|
|
19
|
+
|
|
20
|
+
def __init__(self, *args, **kwds):
|
|
21
|
+
super().__init__(*args, **kwds)
|
|
22
|
+
self.set_size_request(40, 40)
|
|
23
|
+
self.set_can_focus(True)
|
|
24
|
+
self.set_focus_on_click(True)
|
|
25
|
+
self.set_can_default(True)
|
|
26
|
+
self.cnt = 0
|
|
27
|
+
|
|
28
|
+
#cr = self.get_window().cairo_create()
|
|
29
|
+
#self.layout = PangoCairo.create_layout(cr)
|
|
30
|
+
|
|
31
|
+
self.fd = Pango.FontDescription()
|
|
32
|
+
fam = "Monospace"
|
|
33
|
+
size = 24
|
|
34
|
+
self.fd.set_family(fam)
|
|
35
|
+
self.fd.set_absolute_size(size * Pango.SCALE)
|
|
36
|
+
#self.pangolayout = self.create_pango_layout("a")
|
|
37
|
+
#self.pangolayout.set_font_description(self.fd)
|
|
38
|
+
|
|
39
|
+
def do_draw(self, cr):
|
|
40
|
+
|
|
41
|
+
allocation = self.get_allocation()
|
|
42
|
+
|
|
43
|
+
if self.cnt == 0:
|
|
44
|
+
self.layout = PangoCairo.create_layout(cr)
|
|
45
|
+
self.fd.set_absolute_size(allocation.height / 3 * Pango.SCALE)
|
|
46
|
+
self.layout.set_font_description(self.fd)
|
|
47
|
+
self.cnt += 1
|
|
48
|
+
context = self.get_style_context()
|
|
49
|
+
#print("con", context)
|
|
50
|
+
|
|
51
|
+
# paint background
|
|
52
|
+
bg_color = self.get_style_context().get_background_color(Gtk.StateFlags.NORMAL)
|
|
53
|
+
print(bg_color)
|
|
54
|
+
bg_color = Gdk.RGBA(.9, .9, .9, )
|
|
55
|
+
print(bg_color)
|
|
56
|
+
|
|
57
|
+
cr.set_source_rgba(*list(bg_color))
|
|
58
|
+
cr.paint()
|
|
59
|
+
Gtk.render_background(context, cr, 0, 0, 100,100)
|
|
60
|
+
|
|
61
|
+
# draw a diagonal line
|
|
62
|
+
#fg_color = self.get_style_context().get_color(Gtk.StateFlags.NORMAL)
|
|
63
|
+
fg_color = Gdk.RGBA(.7, .7, .7)
|
|
64
|
+
cr.set_source_rgba(*list(fg_color));
|
|
65
|
+
cr.set_line_width(2)
|
|
66
|
+
cr.move_to(0, 0) # top left of the widget
|
|
67
|
+
cr.line_to(allocation.width, allocation.height)
|
|
68
|
+
cr.stroke()
|
|
69
|
+
|
|
70
|
+
cr.move_to(0, allocation.height)
|
|
71
|
+
cr.line_to(allocation.width, 0)
|
|
72
|
+
cr.stroke()
|
|
73
|
+
|
|
74
|
+
fg_color = Gdk.RGBA(.2, .2, .2)
|
|
75
|
+
cr.set_source_rgba(*list(fg_color));
|
|
76
|
+
|
|
77
|
+
self.layout.set_text("Hello %d" % self.cnt)
|
|
78
|
+
sss = self.layout.get_size()
|
|
79
|
+
#print("sss", sss[0] / Pango.SCALE, sss[1] / Pango.SCALE )
|
|
80
|
+
xxx = allocation.width / 2 - (sss[0] / 2) / Pango.SCALE
|
|
81
|
+
yyy = allocation.height / 2 - (sss[1] / 2) / Pango.SCALE
|
|
82
|
+
|
|
83
|
+
cr.move_to(xxx, yyy)
|
|
84
|
+
PangoCairo.show_layout(cr, self.layout)
|
|
85
|
+
#Gtk.render_layout(context, cr, xxx, yyy, self.layout)
|
|
86
|
+
|
|
87
|
+
#Gtk.render_frame(context, cr, 0, 0, 100,100)
|
|
88
|
+
if self.is_focus():
|
|
89
|
+
Gtk.render_focus(context, cr, 0, 0, allocation.width, allocation.height)
|
|
90
|
+
#Gtk.render_arrow(context, cr, 0, 0, 100,100)
|
|
91
|
+
|
|
92
|
+
def do_realize(self):
|
|
93
|
+
allocation = self.get_allocation()
|
|
94
|
+
attr = Gdk.WindowAttr()
|
|
95
|
+
attr.window_type = Gdk.WindowType.CHILD
|
|
96
|
+
attr.x = allocation.x
|
|
97
|
+
attr.y = allocation.y
|
|
98
|
+
attr.width = allocation.width
|
|
99
|
+
attr.height = allocation.height
|
|
100
|
+
attr.visual = self.get_visual()
|
|
101
|
+
attr.event_mask = self.get_events() | Gdk.EventMask.EXPOSURE_MASK
|
|
102
|
+
WAT = Gdk.WindowAttributesType
|
|
103
|
+
mask = WAT.X | WAT.Y | WAT.VISUAL
|
|
104
|
+
window = Gdk.Window(self.get_parent_window(), attr, mask);
|
|
105
|
+
self.set_window(window)
|
|
106
|
+
self.register_window(window)
|
|
107
|
+
self.set_realized(True)
|
|
108
|
+
#window.set_background_pattern(None)
|
|
109
|
+
|
|
110
|
+
|
pyvguicom/pgbox.py
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
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")
|
|
@@ -12,16 +8,16 @@ gi.require_version('PangoCairo', '1.0')
|
|
|
12
8
|
|
|
13
9
|
from gi.repository import Gtk
|
|
14
10
|
from gi.repository import Gdk
|
|
15
|
-
from gi.repository import GLib
|
|
16
11
|
from gi.repository import GObject
|
|
17
12
|
from gi.repository import Pango
|
|
18
13
|
from gi.repository import PangoCairo
|
|
19
14
|
|
|
20
|
-
import
|
|
15
|
+
import pgutils
|
|
21
16
|
|
|
22
|
-
|
|
23
|
-
import pycommon.pgutils
|
|
17
|
+
''' PgGui documentaation '''
|
|
24
18
|
|
|
19
|
+
#sys.path.append('..')
|
|
20
|
+
#import pycommon.pgutils
|
|
25
21
|
|
|
26
22
|
box_testmode = False
|
|
27
23
|
|
|
@@ -68,8 +64,9 @@ class Rectangle():
|
|
|
68
64
|
idx += 1
|
|
69
65
|
else:
|
|
70
66
|
for aaa in rrr:
|
|
71
|
-
self.x = aaa[0]
|
|
72
|
-
self.
|
|
67
|
+
self.x = aaa[0]
|
|
68
|
+
self.y = aaa[1]
|
|
69
|
+
self.w = aaa[2]
|
|
73
70
|
#self.width = aaa[2];
|
|
74
71
|
self.h = aaa[3]
|
|
75
72
|
#self.height = aaa[3]
|
|
@@ -137,17 +134,17 @@ class Rectangle():
|
|
|
137
134
|
|
|
138
135
|
# X intersect
|
|
139
136
|
if rect2.x >= self.x and rect2.x <= urx:
|
|
140
|
-
inter += 1
|
|
137
|
+
inter += 1
|
|
141
138
|
# Y intersect
|
|
142
139
|
if rect2.y >= self.y and rect2.y <= lry:
|
|
143
|
-
inter += 1
|
|
140
|
+
inter += 1
|
|
144
141
|
|
|
145
142
|
# X intersect rev
|
|
146
143
|
if self.x >= rect2.x and self.x <= urx2:
|
|
147
|
-
inter += 1
|
|
144
|
+
inter += 1
|
|
148
145
|
# Y intersect rev
|
|
149
146
|
if self.y >= rect2.y and self.y <= lry2:
|
|
150
|
-
inter += 1
|
|
147
|
+
inter += 1
|
|
151
148
|
|
|
152
149
|
#print("inter", inter, str(self), "->", str(rect2))
|
|
153
150
|
return (inter >= 2, self.x)
|
|
@@ -159,10 +156,10 @@ class Rectangle():
|
|
|
159
156
|
inter = 0
|
|
160
157
|
# X intersect
|
|
161
158
|
if rect2.x >= self.x and rect2.x + rect2.w <= self.x + self.w:
|
|
162
|
-
inter += 1
|
|
159
|
+
inter += 1
|
|
163
160
|
# Y intersect
|
|
164
161
|
if rect2.y >= self.y and rect2.y + rect2.h <= self.y + self.h:
|
|
165
|
-
inter += 1
|
|
162
|
+
inter += 1
|
|
166
163
|
#print("inter", inter)
|
|
167
164
|
return (inter == 2, self.x)
|
|
168
165
|
|
|
@@ -177,7 +174,7 @@ class Rectangle():
|
|
|
177
174
|
elif key == 3:
|
|
178
175
|
return self.h
|
|
179
176
|
else:
|
|
180
|
-
raise IndexError
|
|
177
|
+
raise IndexError
|
|
181
178
|
|
|
182
179
|
def dump(self):
|
|
183
180
|
return (self.x, self.y, self.w, self.h)
|
|
@@ -204,59 +201,6 @@ class Rectangle():
|
|
|
204
201
|
def __str__(self):
|
|
205
202
|
return "R: x=%d y=%d w=%d h=%d" % (self.x, self.y, self.w, self.h)
|
|
206
203
|
|
|
207
|
-
# ------------------------------------------------------------------------
|
|
208
|
-
# An N pixel horizontal spacer. Defaults to X pix
|
|
209
|
-
|
|
210
|
-
class xSpacer(Gtk.HBox):
|
|
211
|
-
|
|
212
|
-
def __init__(self, sp = None):
|
|
213
|
-
GObject.GObject.__init__(self)
|
|
214
|
-
#self.pack_start()
|
|
215
|
-
if box_testmode:
|
|
216
|
-
col = pgutils.randcolstr(100, 200)
|
|
217
|
-
self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(col))
|
|
218
|
-
if sp == None:
|
|
219
|
-
sp = 6
|
|
220
|
-
self.set_size_request(sp, sp)
|
|
221
|
-
|
|
222
|
-
# ------------------------------------------------------------------------
|
|
223
|
-
# An N pixel spacer. Defaults to 1 char height / width
|
|
224
|
-
|
|
225
|
-
class Spacer(Gtk.Label):
|
|
226
|
-
|
|
227
|
-
global box_testmode
|
|
228
|
-
|
|
229
|
-
def __init__(self, sp = 1, title=None, left=False, bottom=False, test=False):
|
|
230
|
-
|
|
231
|
-
GObject.GObject.__init__(self)
|
|
232
|
-
|
|
233
|
-
#sp *= 1000
|
|
234
|
-
#self.set_markup("<span size=\"" + str(sp) + "\"> </span>")
|
|
235
|
-
#self.set_text(" " * sp)
|
|
236
|
-
|
|
237
|
-
if title:
|
|
238
|
-
self.set_text(title)
|
|
239
|
-
else:
|
|
240
|
-
self.set_text(" " * sp)
|
|
241
|
-
|
|
242
|
-
if left:
|
|
243
|
-
self.set_xalign(0)
|
|
244
|
-
|
|
245
|
-
if bottom:
|
|
246
|
-
self.set_yalign(1)
|
|
247
|
-
|
|
248
|
-
if test or box_testmode:
|
|
249
|
-
self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("#888888"))
|
|
250
|
-
|
|
251
|
-
#self.set_property("angle", 15)
|
|
252
|
-
#attr = self.get_property("attributes")
|
|
253
|
-
#attr2 = Pango.AttrList()
|
|
254
|
-
#print ("attr", dir(attr))
|
|
255
|
-
#attr.
|
|
256
|
-
#self.set_property("attributes", attr)
|
|
257
|
-
#self.set_property("label", "wtf")
|
|
258
|
-
#self.set_property("background-set", True)
|
|
259
|
-
|
|
260
204
|
# ------------------------------------------------------------------------
|
|
261
205
|
# This override covers / hides the complexity of the treeview and the
|
|
262
206
|
# textlisbox did not have the needed detail
|
|
@@ -321,42 +265,42 @@ class ListBox(Gtk.TreeView):
|
|
|
321
265
|
if idx == -1:
|
|
322
266
|
ts.unselect_all()
|
|
323
267
|
return
|
|
324
|
-
|
|
268
|
+
iterx = self.treestore.get_iter_first()
|
|
325
269
|
for aa in range(idx):
|
|
326
|
-
|
|
327
|
-
if not
|
|
270
|
+
iterx = self.treestore.iter_next(iter)
|
|
271
|
+
if not iterx:
|
|
328
272
|
break
|
|
329
|
-
if not
|
|
273
|
+
if not iterx:
|
|
330
274
|
pass
|
|
331
275
|
#raise ValueError("Invalid selection index.")
|
|
332
|
-
ts.select_iter(
|
|
276
|
+
ts.select_iter(iterx)
|
|
333
277
|
|
|
334
278
|
# Return the number of list items
|
|
335
279
|
def get_size(self):
|
|
336
280
|
cnt = 0
|
|
337
|
-
|
|
338
|
-
if not
|
|
281
|
+
iterx = self.treestore.get_iter_first()
|
|
282
|
+
if not iterx:
|
|
339
283
|
return cnt
|
|
340
284
|
cnt = 1
|
|
341
285
|
while True:
|
|
342
|
-
|
|
343
|
-
if not
|
|
286
|
+
iterx = self.treestore.iter_next(iter)
|
|
287
|
+
if not iterx:
|
|
344
288
|
break
|
|
345
289
|
cnt += 1
|
|
346
290
|
return cnt
|
|
347
291
|
|
|
348
292
|
def get_item(self, idx):
|
|
349
293
|
cnt = 0; res = ""
|
|
350
|
-
|
|
351
|
-
if not
|
|
294
|
+
iterx = self.treestore.get_iter_first()
|
|
295
|
+
if not iterx:
|
|
352
296
|
return ""
|
|
353
297
|
cnt = 1
|
|
354
298
|
while True:
|
|
355
|
-
|
|
356
|
-
if not
|
|
299
|
+
iterx = self.treestore.iter_next(iter)
|
|
300
|
+
if not iterx:
|
|
357
301
|
break
|
|
358
302
|
if cnt == idx:
|
|
359
|
-
res = self.treestore.get_value(
|
|
303
|
+
res = self.treestore.get_value(iterx, 0)
|
|
360
304
|
break
|
|
361
305
|
cnt += 1
|
|
362
306
|
return res
|
|
@@ -367,11 +311,11 @@ class ListBox(Gtk.TreeView):
|
|
|
367
311
|
cnt = self.get_size()
|
|
368
312
|
#print("limiting cnt=", cnt, "limit=", self.limit)
|
|
369
313
|
for aa in range(cnt - self.limit):
|
|
370
|
-
|
|
371
|
-
if not
|
|
314
|
+
iterx = self.treestore.get_iter_first()
|
|
315
|
+
if not iterx:
|
|
372
316
|
break
|
|
373
317
|
try:
|
|
374
|
-
self.treestore.remove(
|
|
318
|
+
self.treestore.remove(iterx)
|
|
375
319
|
except:
|
|
376
320
|
print("except: treestore remove lim")
|
|
377
321
|
|
|
@@ -452,7 +396,7 @@ class ComboBox(Gtk.ComboBox):
|
|
|
452
396
|
self.callme(name)
|
|
453
397
|
except:
|
|
454
398
|
print("Callback:", sys.exc_info())
|
|
455
|
-
|
|
399
|
+
pgutils.print_exception("callb")
|
|
456
400
|
|
|
457
401
|
else:
|
|
458
402
|
entry = combo.get_child()
|
|
@@ -485,26 +429,26 @@ class ComboBox(Gtk.ComboBox):
|
|
|
485
429
|
#print("Sel combo text")
|
|
486
430
|
|
|
487
431
|
model = self.get_model()
|
|
488
|
-
|
|
489
|
-
if
|
|
432
|
+
iterx = model.get_iter_first()
|
|
433
|
+
if iterx:
|
|
490
434
|
cnt = 0
|
|
491
435
|
while True:
|
|
492
436
|
|
|
493
|
-
#print("entry %d" % cnt, model[
|
|
494
|
-
if model[
|
|
495
|
-
#print("Found %d" % cnt, model[
|
|
496
|
-
self.set_active_iter(
|
|
437
|
+
#print("entry %d" % cnt, model[iterx][0], txt)
|
|
438
|
+
if model[iterx][0] == txt:
|
|
439
|
+
#print("Found %d" % cnt, model[iterx][0])
|
|
440
|
+
self.set_active_iter(iterx)
|
|
497
441
|
break
|
|
498
442
|
|
|
499
|
-
|
|
500
|
-
if not
|
|
443
|
+
iterx = model.iter_next(iterx)
|
|
444
|
+
if not iterx:
|
|
501
445
|
break
|
|
502
446
|
cnt += 1
|
|
503
447
|
|
|
504
448
|
def sel_first(self):
|
|
505
449
|
model = self.get_model()
|
|
506
|
-
|
|
507
|
-
self.set_active_iter(
|
|
450
|
+
iterx = model.get_iter_first()
|
|
451
|
+
self.set_active_iter(iterx)
|
|
508
452
|
|
|
509
453
|
# ------------------------------------------------------------------------
|
|
510
454
|
# Gtk.TreeView simpler combo for color selection
|
|
@@ -514,10 +458,10 @@ class ColorRenderer(Gtk.CellRenderer):
|
|
|
514
458
|
__gproperties__ = {
|
|
515
459
|
'text' : (GObject.TYPE_STRING, 'text',
|
|
516
460
|
'string that represents the item',
|
|
517
|
-
'hello', GObject.
|
|
461
|
+
'hello', GObject.ParamFlags.READWRITE),
|
|
518
462
|
'bgcolor' : (GObject.TYPE_STRING, 'bgcolor',
|
|
519
463
|
'string that represents the RGB color',
|
|
520
|
-
'white', GObject.
|
|
464
|
+
'white', GObject.ParamFlags.READWRITE),
|
|
521
465
|
}
|
|
522
466
|
|
|
523
467
|
def __init__(self):
|
|
@@ -570,7 +514,7 @@ class ColorRenderer(Gtk.CellRenderer):
|
|
|
570
514
|
cr.set_source_rgba (*ddd)
|
|
571
515
|
|
|
572
516
|
(pr, lr) = layout.get_extents()
|
|
573
|
-
xx = lr.width / Pango.SCALE; yy = lr.height / Pango.SCALE
|
|
517
|
+
xx = lr.width / Pango.SCALE; yy = lr.height / Pango.SCALE
|
|
574
518
|
|
|
575
519
|
cr.move_to((background_area.width - xx)/2, (background_area.height - yy)/2)
|
|
576
520
|
PangoCairo.show_layout (cr, layout)
|
|
@@ -620,10 +564,10 @@ class ColorCombo(Gtk.ComboBox):
|
|
|
620
564
|
print("Focus", arg1, arg2)
|
|
621
565
|
|
|
622
566
|
#def data_func(self, arg1, arg2, arg3, arg4):
|
|
623
|
-
'''def data_func(self, column, renderer, model,
|
|
567
|
+
'''def data_func(self, column, renderer, model, iterx):
|
|
624
568
|
#print("data_func called", arg1, arg2, arg3, arg4)
|
|
625
|
-
#print("data_func ", model,
|
|
626
|
-
val = model.get_value(
|
|
569
|
+
#print("data_func ", model, iterx)
|
|
570
|
+
val = model.get_value(iterx, 0)
|
|
627
571
|
#print("val", val)
|
|
628
572
|
#renderer.set_property("cell-background", val)
|
|
629
573
|
renderer.set_property("background", val)
|
|
@@ -685,26 +629,26 @@ class ColorCombo(Gtk.ComboBox):
|
|
|
685
629
|
#print("Sel combo text")
|
|
686
630
|
|
|
687
631
|
model = self.get_model()
|
|
688
|
-
|
|
689
|
-
if
|
|
632
|
+
iterx = model.get_iter_first()
|
|
633
|
+
if iterx:
|
|
690
634
|
cnt = 0
|
|
691
635
|
while True:
|
|
692
636
|
|
|
693
|
-
#print("entry %d" % cnt, model[
|
|
694
|
-
if model[
|
|
695
|
-
#print("Found %d" % cnt, model[
|
|
696
|
-
self.set_active_iter(
|
|
637
|
+
#print("entry %d" % cnt, model[iterx][0], txt)
|
|
638
|
+
if model[iterx][0] == txt:
|
|
639
|
+
#print("Found %d" % cnt, model[iterx][0])
|
|
640
|
+
self.set_active_iter(iterx)
|
|
697
641
|
break
|
|
698
642
|
|
|
699
|
-
|
|
700
|
-
if not
|
|
643
|
+
iterx = model.iter_next(iterx)
|
|
644
|
+
if not iterx:
|
|
701
645
|
break
|
|
702
646
|
cnt += 1
|
|
703
647
|
|
|
704
648
|
def sel_first(self):
|
|
705
649
|
model = self.get_model()
|
|
706
|
-
|
|
707
|
-
self.set_active_iter(
|
|
650
|
+
iterx = model.get_iter_first()
|
|
651
|
+
self.set_active_iter(iterx)
|
|
708
652
|
|
|
709
653
|
|
|
710
654
|
# ------------------------------------------------------------------------
|
|
@@ -746,7 +690,4 @@ class xHBox(Gtk.HBox):
|
|
|
746
690
|
pad = self.pad
|
|
747
691
|
self.pack_start(obj, expand, expand, pad)
|
|
748
692
|
|
|
749
|
-
|
|
750
693
|
# EOF
|
|
751
|
-
|
|
752
|
-
|
pyvguicom/pgbutt.py
CHANGED
|
@@ -19,7 +19,7 @@ gi.require_version('PangoCairo', '1.0')
|
|
|
19
19
|
from gi.repository import PangoCairo
|
|
20
20
|
|
|
21
21
|
import cairo
|
|
22
|
-
from
|
|
22
|
+
from pgutils import *
|
|
23
23
|
|
|
24
24
|
class smallbutt(Gtk.EventBox):
|
|
25
25
|
|
|
@@ -150,7 +150,8 @@ class smallbutt(Gtk.EventBox):
|
|
|
150
150
|
#print("changed to", self.mnem)
|
|
151
151
|
self.queue_draw()
|
|
152
152
|
|
|
153
|
-
GLib.timeout_add(1000, self.stattime, self, 0)
|
|
153
|
+
#GLib.timeout_add(1000, self.stattime, self, 0)
|
|
154
|
+
return True
|
|
154
155
|
|
|
155
156
|
def mactivate(self, *arg):
|
|
156
157
|
#print("mactivate", arg)
|
pyvguicom/pgentry.py
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
|
|
3
|
-
from __future__ import absolute_import
|
|
4
|
-
from __future__ import print_function
|
|
5
|
-
|
|
6
3
|
import sys, traceback, os, time, warnings
|
|
7
4
|
|
|
8
5
|
import gi
|
|
@@ -12,6 +9,17 @@ from gi.repository import Gdk
|
|
|
12
9
|
from gi.repository import GObject
|
|
13
10
|
from gi.repository import GLib
|
|
14
11
|
|
|
12
|
+
import pgutils, pggui, pgtextview
|
|
13
|
+
|
|
14
|
+
def wrap(cont):
|
|
15
|
+
fr = Gtk.Frame()
|
|
16
|
+
sc = Gtk.ScrolledWindow()
|
|
17
|
+
sc.set_hexpand(True)
|
|
18
|
+
sc.set_vexpand(True)
|
|
19
|
+
sc.add(cont)
|
|
20
|
+
fr.add(sc)
|
|
21
|
+
return fr, cont
|
|
22
|
+
|
|
15
23
|
# Expects two tuples of stuff
|
|
16
24
|
# labtext, labname, tip, defval = None:
|
|
17
25
|
|
|
@@ -52,7 +60,7 @@ def entryquad(arr, vbox, entry1, entry2):
|
|
|
52
60
|
hbox2.pack_start(lab3b, False, 0, 0)
|
|
53
61
|
arr.append((entry2[1], headx2))
|
|
54
62
|
|
|
55
|
-
#self.
|
|
63
|
+
#self.ySpacer(vbox)
|
|
56
64
|
vbox.pack_start(hbox2, True, True, 0)
|
|
57
65
|
return lab1, lab2
|
|
58
66
|
|
|
@@ -79,7 +87,7 @@ def entrypair(vbox, labtext, labname, tip, defval = None):
|
|
|
79
87
|
hbox2.pack_start(lab3, False, 0, 0)
|
|
80
88
|
arr.append((labname, headx))
|
|
81
89
|
|
|
82
|
-
|
|
90
|
+
pggui.ySpacer(vbox)
|
|
83
91
|
vbox.pack_start(hbox2, False, 0, 0)
|
|
84
92
|
lab1.set_tooltip_text(tip)
|
|
85
93
|
|
|
@@ -88,7 +96,7 @@ def entrypair(vbox, labtext, labname, tip, defval = None):
|
|
|
88
96
|
def textviewpair(arr, vbox, labtext, labname, tip, defval=None, expand=False):
|
|
89
97
|
|
|
90
98
|
hbox2 = Gtk.HBox();
|
|
91
|
-
|
|
99
|
+
pggui.xSpacer(hbox2)
|
|
92
100
|
|
|
93
101
|
lab2a = Gtk.Label(label=" ")
|
|
94
102
|
hbox2.pack_start(lab2a, False , 0, 0)
|
|
@@ -103,16 +111,113 @@ def textviewpair(arr, vbox, labtext, labname, tip, defval=None, expand=False):
|
|
|
103
111
|
|
|
104
112
|
lab2.set_mnemonic_widget(sw.textx)
|
|
105
113
|
|
|
106
|
-
|
|
114
|
+
pggui.xSpacer(hbox2)
|
|
107
115
|
hbox2.pack_start(sw, True, True, 0)
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
pggui.xSpacer(hbox2)
|
|
117
|
+
pggui.ySpacer(vbox)
|
|
110
118
|
|
|
111
119
|
lab2b = Gtk.Label(label=" ")
|
|
112
120
|
hbox2.pack_start(lab2b, False , 0, 0)
|
|
113
121
|
vbox.pack_start(hbox2, True, True, 0)
|
|
114
122
|
return lab2
|
|
115
123
|
|
|
124
|
+
def gridquad(gridx, left, top, entry1, entry2, butt = None):
|
|
125
|
+
lab1 = Gtk.Label.new_with_mnemonic(entry1[0] + " ")
|
|
126
|
+
lab1.set_alignment(1, 0)
|
|
127
|
+
lab1.set_tooltip_text(entry1[2])
|
|
128
|
+
gridx.attach(lab1, left, top, 1, 1)
|
|
129
|
+
|
|
130
|
+
headx = Gtk.Entry();
|
|
131
|
+
lab1.set_mnemonic_widget(headx)
|
|
132
|
+
headx.set_width_chars(20)
|
|
133
|
+
if entry1[3] != None:
|
|
134
|
+
headx.set_text(entry1[3])
|
|
135
|
+
gridx.attach(headx, left+1, top, 1, 1)
|
|
136
|
+
|
|
137
|
+
lab2 = Gtk.Label.new_with_mnemonic(" " + entry2[0] + " ")
|
|
138
|
+
lab2.set_alignment(1, 0)
|
|
139
|
+
lab2.set_tooltip_text(entry2[2])
|
|
140
|
+
gridx.attach(lab2, left+2, top, 1, 1)
|
|
141
|
+
|
|
142
|
+
headx2 = Gtk.Entry();
|
|
143
|
+
lab2.set_mnemonic_widget(headx2)
|
|
144
|
+
|
|
145
|
+
headx2.set_width_chars(20)
|
|
146
|
+
if entry2[3] != None:
|
|
147
|
+
headx2.set_text(entry2[3])
|
|
148
|
+
gridx.attach(headx2, left+3, top, 1, 1)
|
|
149
|
+
if butt:
|
|
150
|
+
gridx.attach(butt, left+4, top, 1, 1)
|
|
151
|
+
return headx, headx2
|
|
152
|
+
|
|
153
|
+
def griddouble(gridx, left, top, entry1, buttx = None):
|
|
154
|
+
lab1 = Gtk.Label(entry1[0] + " ")
|
|
155
|
+
lab1.set_alignment(1, 0)
|
|
156
|
+
lab1.set_tooltip_text(entry1[2])
|
|
157
|
+
gridx.attach(lab1, left, top, 1, 1)
|
|
158
|
+
|
|
159
|
+
headx = Gtk.Entry();
|
|
160
|
+
headx.set_width_chars(40)
|
|
161
|
+
if entry1[3] != None:
|
|
162
|
+
headx.set_text(entry1[3])
|
|
163
|
+
gridx.attach(headx, left+1, top, 2, 1)
|
|
164
|
+
if buttx:
|
|
165
|
+
gridx.attach(buttx, left+3, top, 1, 1)
|
|
166
|
+
return headx
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
class TextViewx(Gtk.TextView):
|
|
170
|
+
|
|
171
|
+
def __init__(self):
|
|
172
|
+
super(TextViewx).__init__()
|
|
173
|
+
GObject.GObject.__init__(self)
|
|
174
|
+
self.buffer = Gtk.TextBuffer()
|
|
175
|
+
self.set_buffer(self.buffer)
|
|
176
|
+
self.single_line = False
|
|
177
|
+
self.connect("key-press-event", self.key_press_event)
|
|
178
|
+
|
|
179
|
+
def key_press_event(self, arg1, event):
|
|
180
|
+
|
|
181
|
+
if event.keyval == Gdk.KEY_Tab or event.keyval == Gdk.KEY_ISO_Left_Tab:
|
|
182
|
+
#print("tab keypress ", event.keyval, event.state)
|
|
183
|
+
if event.state & Gdk.ModifierType.SHIFT_MASK:
|
|
184
|
+
self.emit("move-focus", Gtk.DirectionType.TAB_BACKWARD)
|
|
185
|
+
else:
|
|
186
|
+
self.emit("move-focus", Gtk.DirectionType.TAB_FORWARD)
|
|
187
|
+
|
|
188
|
+
if event.keyval == Gdk.KEY_Return:
|
|
189
|
+
if event.state & Gdk.ModifierType.SHIFT_MASK:
|
|
190
|
+
#print("keypress shift ", event)
|
|
191
|
+
self.emit("move-focus", Gtk.DirectionType.TAB_FORWARD)
|
|
192
|
+
return True
|
|
193
|
+
|
|
194
|
+
def get_text(self):
|
|
195
|
+
startt = self.buffer.get_start_iter()
|
|
196
|
+
endd = self.buffer.get_end_iter()
|
|
197
|
+
return self.buffer.get_text(startt, endd, False)
|
|
198
|
+
|
|
199
|
+
def set_text(self, txt, eventx = False):
|
|
200
|
+
if eventx:
|
|
201
|
+
self.check_saved()
|
|
202
|
+
startt = self.buffer.get_start_iter()
|
|
203
|
+
endd = self.buffer.get_end_iter()
|
|
204
|
+
self.buffer.delete(startt, endd)
|
|
205
|
+
self.buffer.insert(startt, txt)
|
|
206
|
+
self.buffer.set_modified(True)
|
|
207
|
+
|
|
208
|
+
def gridsingle(gridx, left, top, entry1):
|
|
209
|
+
lab1 = Gtk.Label(entry1[0] + " ")
|
|
210
|
+
lab1.set_alignment(1, 0)
|
|
211
|
+
lab1.set_tooltip_text(entry1[2])
|
|
212
|
+
gridx.attach(lab1, left, top, 1, 1)
|
|
213
|
+
|
|
214
|
+
headx, cont = wrap(TextViewx())
|
|
215
|
+
if entry1[3] != None:
|
|
216
|
+
headx.set_text(entry1[3])
|
|
217
|
+
gridx.attach(headx, left+1, top, 3, 1)
|
|
218
|
+
|
|
219
|
+
return cont
|
|
220
|
+
|
|
116
221
|
def scrolledtext(arr, name, body = None):
|
|
117
222
|
textx = Gtk.TextView();
|
|
118
223
|
textx.set_border_width(4)
|
|
@@ -152,14 +257,4 @@ def imgbutt(imgfile, txt, func, win):
|
|
|
152
257
|
|
|
153
258
|
return hbb
|
|
154
259
|
|
|
155
|
-
# --------------------------------------------------------------------
|
|
156
|
-
|
|
157
|
-
def spacer(hbox, xstr = " ", expand = False):
|
|
158
|
-
lab = Gtk.Label(label=xstr)
|
|
159
|
-
hbox.pack_start(lab, expand, 0, 0)
|
|
160
|
-
|
|
161
|
-
def vspacer(vbox, xstr = " ", expand = False):
|
|
162
|
-
lab = Gtk.Label(label=xstr)
|
|
163
|
-
vbox.pack_start(lab, expand , 0, 0)
|
|
164
|
-
|
|
165
260
|
# eof
|