pyvguicom 1.0.1__py3-none-any.whl → 1.1.2__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.

@@ -0,0 +1,2470 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
6
+ <meta name="generator" content="pdoc 0.10.0" />
7
+ <title>pgbox API documentation</title>
8
+ <meta name="description" content="" />
9
+ <link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
10
+ <link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
11
+ <link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
12
+ <style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
13
+ <style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
14
+ <style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
15
+ <script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
16
+ <script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
17
+ </head>
18
+ <body>
19
+ <main>
20
+ <article id="content">
21
+ <header>
22
+ <h1 class="title">Module <code>pgbox</code></h1>
23
+ </header>
24
+ <section id="section-intro">
25
+ <details class="source">
26
+ <summary>
27
+ <span>Expand source code</span>
28
+ </summary>
29
+ <pre><code class="python">#!/usr/bin/python
30
+
31
+ import sys
32
+
33
+ import gi
34
+ gi.require_version(&#34;Gtk&#34;, &#34;3.0&#34;)
35
+ gi.require_version(&#39;PangoCairo&#39;, &#39;1.0&#39;)
36
+
37
+ from gi.repository import Gtk
38
+ from gi.repository import Gdk
39
+ from gi.repository import GObject
40
+ from gi.repository import Pango
41
+ from gi.repository import PangoCairo
42
+
43
+ import pgutils
44
+
45
+ &#39;&#39;&#39; PgGui documentaation &#39;&#39;&#39;
46
+
47
+ #sys.path.append(&#39;..&#39;)
48
+ #import pycommon.pgutils
49
+
50
+ box_testmode = False
51
+
52
+ def str2rgb(col):
53
+
54
+ #print(&#34;in&#34;, col)
55
+ aa = int(col[1:3], base=16)
56
+ bb = int(col[3:5], base=16)
57
+ cc = int(col[5:7], base=16)
58
+ return aa, bb, cc
59
+
60
+ def str2rgba(col):
61
+
62
+ #print(&#34;in&#34;, col)
63
+ aa = float(int(col[1:3], base=16)) / 256
64
+ bb = float(int(col[3:5], base=16)) / 256
65
+ cc = float(int(col[5:7], base=16)) / 256
66
+ dd = float(int(col[7:9], base=16)) / 256
67
+ return aa, bb, cc, dd
68
+
69
+ # ------------------------------------------------------------------------
70
+
71
+ class Rectangle():
72
+
73
+ # Accept rect, array, integers
74
+ def __init__(self, *rrr):
75
+ #Gdk.Rectangle.__init__(self)
76
+ if len(rrr) == 4:
77
+ idx = 0
78
+ for aa in rrr:
79
+ bb = int(aa)
80
+ if idx == 0:
81
+ self.x = bb
82
+ elif idx == 1:
83
+ self.y = bb
84
+ elif idx == 2:
85
+ #self.width = bb
86
+ self.w = bb
87
+ elif idx == 3:
88
+ #self.height = bb
89
+ self.h = bb
90
+ else:
91
+ raise ValueError
92
+ idx += 1
93
+ else:
94
+ for aaa in rrr:
95
+ self.x = aaa[0]
96
+ self.y = aaa[1]
97
+ self.w = aaa[2]
98
+ #self.width = aaa[2];
99
+ self.h = aaa[3]
100
+ #self.height = aaa[3]
101
+ break
102
+ pass
103
+
104
+ # Make it smaller
105
+ def resize(self, ww, hh = 0):
106
+ if hh == 0:
107
+ hh = ww
108
+
109
+ #if ww + self.w &lt;= 0 or hh + self.h &lt;= 0:
110
+ # raise (ValuError, &#34;Cannot have negative rect size&#34;)
111
+
112
+ self.x -= ww/2; self.w += ww
113
+ self.y -= hh/2; self.h += hh
114
+
115
+ def copy(self):
116
+ #print(&#34;rect to copy&#34;, str(self))
117
+ #print(&#34;rect to copy&#34;, dir(self))
118
+ nnn = Rectangle() # New Instance
119
+ &#39;&#39;&#39;
120
+ # Self
121
+ for aa in dir(self):
122
+ try:
123
+ #nnn.__setattr__(aa, self.__getattribute__(aa))
124
+ nnn.aa = self.__getattribute__(aa)
125
+ #print(&#34;cp:&#34;, aa, end = &#34;&#34;)
126
+ #if type(self.__getattribute__(aa)) == int:
127
+ # print(&#34; -&gt; &#34;, self.__getattribute__(aa), end= &#34; &#34;)
128
+ #print(&#34; --- &#34;, end = &#34;&#34;)
129
+ except:
130
+ #print(sys.exc_info())
131
+ print(&#34;no&#34;, aa)
132
+ pass
133
+ &#39;&#39;&#39;
134
+
135
+ # Assign explictly
136
+ nnn.x = self.x + 0
137
+ nnn.y = self.y + 0
138
+ nnn.w = self.w + 0
139
+ nnn.h = self.h + 0
140
+
141
+ #nnn.width = self.width + 1
142
+ #nnn.height = self.height + 1
143
+
144
+ #print(&#34;rect out&#34;, str(nnn))
145
+ #print(&#34;rect out&#34;, dir(nnn))
146
+ return nnn
147
+
148
+ # I was too lazy to write it; Crappy Gdt rect kicked me to it
149
+
150
+ # ========== self
151
+ # = =
152
+ # = ----=----
153
+ # ====|====== | rect2
154
+ # | |
155
+ # ---------
156
+
157
+ def intersect(self, rect2):
158
+
159
+ urx = self.x + self.w; lry = self.y + self.h
160
+ urx2 = rect2.x + rect2.w; lry2 = rect2.y + rect2.h
161
+ inter = 0
162
+
163
+ # X intersect
164
+ if rect2.x &gt;= self.x and rect2.x &lt;= urx:
165
+ inter += 1
166
+ # Y intersect
167
+ if rect2.y &gt;= self.y and rect2.y &lt;= lry:
168
+ inter += 1
169
+
170
+ # X intersect rev
171
+ if self.x &gt;= rect2.x and self.x &lt;= urx2:
172
+ inter += 1
173
+ # Y intersect rev
174
+ if self.y &gt;= rect2.y and self.y &lt;= lry2:
175
+ inter += 1
176
+
177
+ #print(&#34;inter&#34;, inter, str(self), &#34;-&gt;&#34;, str(rect2))
178
+ return (inter &gt;= 2, self.x)
179
+
180
+ # I was too lazy to write it; Crappy Gdt rect kicked me to it
181
+ def contain(self, rect2):
182
+ #self.dump()
183
+ #rect2.dump()
184
+ inter = 0
185
+ # X intersect
186
+ if rect2.x &gt;= self.x and rect2.x + rect2.w &lt;= self.x + self.w:
187
+ inter += 1
188
+ # Y intersect
189
+ if rect2.y &gt;= self.y and rect2.y + rect2.h &lt;= self.y + self.h:
190
+ inter += 1
191
+ #print(&#34;inter&#34;, inter)
192
+ return (inter == 2, self.x)
193
+
194
+ # Convert index to values
195
+ def __getitem__(self, key):
196
+ if key == 0:
197
+ return self.x
198
+ elif key == 1:
199
+ return self.y
200
+ elif key == 2:
201
+ return self.w
202
+ elif key == 3:
203
+ return self.h
204
+ else:
205
+ raise IndexError
206
+
207
+ def dump(self):
208
+ return (self.x, self.y, self.w, self.h)
209
+
210
+ &#39;&#39;&#39;
211
+ # This was killed in favour of self implemented Rectangle class
212
+ def __getattr__(self, attr):
213
+ if attr == &#34;w&#34;:
214
+ return self.width
215
+ elif attr == &#34;h&#34;:
216
+ return self.height
217
+ else:
218
+ return super(Gdk.Rectangle, self).__getattr__(attr)
219
+
220
+ def __setattr__(self, attr, val):
221
+ if attr == &#34;w&#34;:
222
+ self.width = val
223
+ elif attr == &#34;h&#34;:
224
+ self.height = val
225
+ else:
226
+ super(Gdk.Rectangle, self).__setattr__(attr, val)
227
+ &#39;&#39;&#39;
228
+
229
+ def __str__(self):
230
+ return &#34;R: x=%d y=%d w=%d h=%d&#34; % (self.x, self.y, self.w, self.h)
231
+
232
+ # ------------------------------------------------------------------------
233
+ # This override covers / hides the complexity of the treeview and the
234
+ # textlisbox did not have the needed detail
235
+
236
+ class ListBox(Gtk.TreeView):
237
+
238
+ def __init__(self, limit = -1, colname = &#39;&#39;):
239
+
240
+ self.limit = limit
241
+ self.treestore = Gtk.TreeStore(str, str)
242
+ Gtk.TreeView.__init__(self, self.treestore)
243
+
244
+ cell = Gtk.CellRendererText()
245
+ # create the TreeViewColumn to display the data
246
+ tvcolumn = Gtk.TreeViewColumn(colname)
247
+ # add the cell to the tvcolumn and allow it to expand
248
+ tvcolumn.pack_start(cell, True)
249
+
250
+ # set the cell &#34;text&#34; attribute to column 0 - retrieve text
251
+ tvcolumn.add_attribute(cell, &#39;text&#39;, 0)
252
+
253
+ # add tvcolumn to treeview
254
+ self.append_column(tvcolumn)
255
+ self.set_activate_on_single_click (True)
256
+
257
+ self.callb = None
258
+ self.connect(&#34;row-activated&#34;, self.tree_sel)
259
+
260
+ def tree_sel(self, xtree, xiter, xpath):
261
+ #print(&#34;tree_sel&#34;, xtree, xiter, xpath)
262
+ sel = xtree.get_selection()
263
+ xmodel, xiter = sel.get_selected()
264
+ if xiter:
265
+ xstr = xmodel.get_value(xiter, 0)
266
+ #print(&#34;Selected&#34;, xstr)
267
+ if self.callb:
268
+ self.callb(xstr)
269
+ pass
270
+
271
+ def set_callback(self, funcx):
272
+ self.callb = funcx
273
+
274
+ # Delete previous contents
275
+ def clear(self):
276
+ try:
277
+ while True:
278
+ root = self.treestore.get_iter_first()
279
+ if not root:
280
+ break
281
+ try:
282
+ self.treestore.remove(root)
283
+ except:
284
+ print(&#34;except: treestore remove&#34;)
285
+
286
+ except:
287
+ print(&#34;update_tree&#34;, sys.exc_info())
288
+ pass
289
+
290
+ # Select Item. -1 for select none; Rase Valuerror for wrong index.
291
+ def select(self, idx):
292
+ ts = self.get_selection()
293
+ if idx == -1:
294
+ ts.unselect_all()
295
+ return
296
+ iterx = self.treestore.get_iter_first()
297
+ for aa in range(idx):
298
+ iterx = self.treestore.iter_next(iter)
299
+ if not iterx:
300
+ break
301
+ if not iterx:
302
+ pass
303
+ #raise ValueError(&#34;Invalid selection index.&#34;)
304
+ ts.select_iter(iterx)
305
+
306
+ # Return the number of list items
307
+ def get_size(self):
308
+ cnt = 0
309
+ iterx = self.treestore.get_iter_first()
310
+ if not iterx:
311
+ return cnt
312
+ cnt = 1
313
+ while True:
314
+ iterx = self.treestore.iter_next(iter)
315
+ if not iterx:
316
+ break
317
+ cnt += 1
318
+ return cnt
319
+
320
+ def get_item(self, idx):
321
+ cnt = 0; res = &#34;&#34;
322
+ iterx = self.treestore.get_iter_first()
323
+ if not iterx:
324
+ return &#34;&#34;
325
+ cnt = 1
326
+ while True:
327
+ iterx = self.treestore.iter_next(iter)
328
+ if not iterx:
329
+ break
330
+ if cnt == idx:
331
+ res = self.treestore.get_value(iterx, 0)
332
+ break
333
+ cnt += 1
334
+ return res
335
+
336
+ def append(self, strx):
337
+ if self.limit != -1:
338
+ # count them
339
+ cnt = self.get_size()
340
+ #print(&#34;limiting cnt=&#34;, cnt, &#34;limit=&#34;, self.limit)
341
+ for aa in range(cnt - self.limit):
342
+ iterx = self.treestore.get_iter_first()
343
+ if not iterx:
344
+ break
345
+ try:
346
+ self.treestore.remove(iterx)
347
+ except:
348
+ print(&#34;except: treestore remove lim&#34;)
349
+
350
+ last = self.treestore.append(None, [strx])
351
+ self.set_cursor_on_cell(self.treestore.get_path(last), None, None, False)
352
+
353
+ def get_text(self):
354
+ sel = self.get_selection()
355
+ xmodel, xiter = sel.get_selected()
356
+ if xiter:
357
+ return xmodel.get_value(xiter, 0)
358
+
359
+ # Get current IDX -1 for none
360
+ def get_curridx(self):
361
+ sel = self.get_selection()
362
+ xmodel, xiter = sel.get_selected()
363
+ if not xiter:
364
+ return -1
365
+
366
+ # Count back from match
367
+ cnt = 0
368
+ while True:
369
+ xiter = self.treestore.iter_previous(xiter)
370
+ if not xiter:
371
+ break
372
+ #print (&#34;xiter:&#34;, xiter)
373
+ cnt += 1
374
+ return cnt
375
+
376
+ # ------------------------------------------------------------------------
377
+
378
+ class ComboBox(Gtk.ComboBox):
379
+
380
+ def __init__(self, init_cont = [], callme = None):
381
+
382
+ self.store = Gtk.ListStore(str)
383
+ Gtk.ComboBox.__init__(self)
384
+
385
+ self.set_model(self.store)
386
+ cell = Gtk.CellRendererText()
387
+
388
+ cell.set_property(&#34;text&#34;, &#34;hello&#34;)
389
+ #cell.set_property(&#34;background&#34;, &#34;#ffff00&#34;)
390
+ #cell.set_property(&#34;background-set&#34;, True)
391
+ cell.set_padding(10, 0)
392
+
393
+ self.callme = callme
394
+ #if callme:
395
+ # self.connect(&#34;changed&#34;, callme)
396
+
397
+ #cell.set_property(&#34;foreground&#34;, &#34;#ffff00&#34;)
398
+ #cell.set_property(&#34;foreground-set&#34;, True)
399
+ #print(&#34;background-set&#34;, cell.get_property(&#34;background-set&#34;))
400
+ #print(&#34;foreground-set&#34;, cell.get_property(&#34;foreground-set&#34;))
401
+
402
+ #print(&#34; list_properties&#34;, cell.list_properties())
403
+
404
+ self.pack_start(cell, True)
405
+ self.add_attribute(cell, &#39;text&#39;, 0)
406
+ self.set_entry_text_column(0)
407
+
408
+ for bb in init_cont:
409
+ self.store.append([bb])
410
+
411
+ self.connect(&#34;changed&#34;, self.combo_changed)
412
+
413
+ def combo_changed(self, combo):
414
+ name = &#34;&#34;
415
+ tree_iter = combo.get_active_iter()
416
+ try:
417
+ if tree_iter is not None:
418
+ model = combo.get_model()
419
+ name = model[tree_iter][0]
420
+ #print(&#34;Selected: name=%s&#34; % (name))
421
+
422
+ if self.callme:
423
+ try:
424
+ self.callme(name)
425
+ except:
426
+ print(&#34;Callback:&#34;, sys.exc_info())
427
+ pgutils.print_exception(&#34;callb&#34;)
428
+
429
+ else:
430
+ entry = combo.get_child()
431
+ name = entry.get_text()
432
+ #print(&#34;Entered: %s&#34; % name)
433
+
434
+ except:
435
+ pass
436
+
437
+ #print(&#34;Combo new selection / entry: &#39;%s&#39;&#34; % name)
438
+
439
+ def delall(self):
440
+ # Delete previous contents
441
+ try:
442
+ while True:
443
+ root = self.store.get_iter_first()
444
+ if not root:
445
+ break
446
+ try:
447
+ self.store.remove(root)
448
+ except:
449
+ print(&#34;except: self.store remove&#34;)
450
+ except:
451
+ print(&#34;combo delall&#34;, sys.exc_info())
452
+ pass
453
+
454
+ # --------------------------------------------------------------------
455
+ def sel_text(self, txt):
456
+
457
+ #print(&#34;Sel combo text&#34;)
458
+
459
+ model = self.get_model()
460
+ iterx = model.get_iter_first()
461
+ if iterx:
462
+ cnt = 0
463
+ while True:
464
+
465
+ #print(&#34;entry %d&#34; % cnt, model[iterx][0], txt)
466
+ if model[iterx][0] == txt:
467
+ #print(&#34;Found %d&#34; % cnt, model[iterx][0])
468
+ self.set_active_iter(iterx)
469
+ break
470
+
471
+ iterx = model.iter_next(iterx)
472
+ if not iterx:
473
+ break
474
+ cnt += 1
475
+
476
+ def sel_first(self):
477
+ model = self.get_model()
478
+ iterx = model.get_iter_first()
479
+ self.set_active_iter(iterx)
480
+
481
+ # ------------------------------------------------------------------------
482
+ # Gtk.TreeView simpler combo for color selection
483
+
484
+ class ColorRenderer(Gtk.CellRenderer):
485
+
486
+ __gproperties__ = {
487
+ &#39;text&#39; : (GObject.TYPE_STRING, &#39;text&#39;,
488
+ &#39;string that represents the item&#39;,
489
+ &#39;hello&#39;, GObject.ParamFlags.READWRITE),
490
+ &#39;bgcolor&#39; : (GObject.TYPE_STRING, &#39;bgcolor&#39;,
491
+ &#39;string that represents the RGB color&#39;,
492
+ &#39;white&#39;, GObject.ParamFlags.READWRITE),
493
+ }
494
+
495
+ def __init__(self):
496
+ Gtk.CellRenderer.__init__(self)
497
+ # Create placeholders
498
+ self.text = &#34;None&#34;
499
+ self.bgcolor = &#34;None&#34;
500
+
501
+ self.font_size=10
502
+ self.font = &#34;Sans {}&#34;.format(self.font_size)
503
+ #print(self.list_properties())
504
+
505
+ def do_get_size(self, widget, cell_area):
506
+
507
+ # Get this from the client -&gt; original display values
508
+ #pg = Gtk.Widget.create_pango_context(widget)
509
+ #myfd = pg.get_font_description()
510
+ #self.font_size = myfd.get_size() / Pango.SCALE
511
+
512
+ tsize = len(self.text)
513
+ return (0, 0, self.font_size * (tsize - 2), self.font_size * 3)
514
+
515
+ def do_render(self, cr, widget, background_area, cell_area, expose_area, flags = 0):
516
+ #ccc = str2rgb(self.bgcolor)
517
+ ccc = str2rgba(self.bgcolor)
518
+ #avg = (ccc[0] + ccc[1] + ccc[2] ) / 3
519
+ #print(&#34;text&#34;, self.text, &#34;bgcolor&#34;, self.bgcolor, ccc) #, &#34;avg&#34;, avg)
520
+
521
+ cr.translate (0, 0)
522
+ layout = PangoCairo.create_layout(cr)
523
+ # ---Note--- changing default
524
+ desc = Pango.font_description_from_string(self.font)
525
+ layout.set_font_description(desc)
526
+ layout.set_text(self.text)
527
+ cr.save()
528
+ cr.set_source_rgba(*ccc)
529
+
530
+ cr.rectangle(0, 0, background_area.width, background_area.height)
531
+ cr.fill()
532
+ PangoCairo.update_layout (cr, layout)
533
+
534
+ # Make it sensitive to dark / light
535
+ ddd = []
536
+ for aa in ccc[:-1]:
537
+ if aa &lt; .5:
538
+ ddd.append(1)
539
+ else:
540
+ ddd.append(0)
541
+ ddd.append(1.)
542
+ cr.set_source_rgba (*ddd)
543
+
544
+ (pr, lr) = layout.get_extents()
545
+ xx = lr.width / Pango.SCALE; yy = lr.height / Pango.SCALE
546
+
547
+ cr.move_to((background_area.width - xx)/2, (background_area.height - yy)/2)
548
+ PangoCairo.show_layout (cr, layout)
549
+
550
+ cr.restore()
551
+
552
+ def do_get_property(self, property):
553
+ #print(&#34;get prop&#34;, property)
554
+ return getattr(self, property.name)
555
+
556
+ def do_set_property(self, property, val):
557
+ #print(&#34;set prop&#34;, property, val)
558
+ setattr(self, property.name, val)
559
+ pass
560
+
561
+ class ColorCombo(Gtk.ComboBox):
562
+
563
+ def __init__(self, init_cont = [], callme = None):
564
+
565
+ self.store = Gtk.ListStore(str, str)
566
+ Gtk.ComboBox.__init__(self)
567
+ self.callme = callme
568
+
569
+ self.set_model(self.store)
570
+ cell = ColorRenderer()
571
+ cell2 = ColorRenderer()
572
+ #print(&#34;cell&#34;, cell)
573
+ #print(&#34; list_properties&#34;, cell.list_properties())
574
+
575
+ self.pack_start(cell, True)
576
+ self.add_attribute(cell, &#39;text&#39;, 0)
577
+ self.add_attribute(cell, &#39;bgcolor&#39;, 1)
578
+ #self.set_entry_text_column(0)
579
+ #self.set_entry_text_column(1)
580
+ #self.set_cell_data_func(cell, self.data_func)
581
+
582
+ for bb, cc in init_cont:
583
+ self.store.append((bb, cc))
584
+
585
+ #print(&#34;self.GET_MODEL&#34;, self.get_model() )
586
+ #self.get_model().foreach(self.printdetails)
587
+
588
+ self.connect(&#34;changed&#34;, self.combo_changed)
589
+ #self.connect(&#34;notify::popup-shown&#34;, self.combo_focus)
590
+
591
+ def combo_focus(self, arg1, arg2):
592
+ print(&#34;Focus&#34;, arg1, arg2)
593
+
594
+ #def data_func(self, arg1, arg2, arg3, arg4):
595
+ &#39;&#39;&#39;def data_func(self, column, renderer, model, iterx):
596
+ #print(&#34;data_func called&#34;, arg1, arg2, arg3, arg4)
597
+ #print(&#34;data_func &#34;, model, iterx)
598
+ val = model.get_value(iterx, 0)
599
+ #print(&#34;val&#34;, val)
600
+ #renderer.set_property(&#34;cell-background&#34;, val)
601
+ renderer.set_property(&#34;background&#34;, val)
602
+ renderer.set_property(&#34;xpad&#34;, 0)
603
+ &#39;&#39;&#39;
604
+
605
+ def printdetails(self, arg, arg2, arg3):
606
+ #print(arg, arg2, arg3)
607
+ #print(self.store[arg2], arg3.stamp)
608
+ print(dir(self.store[arg2] )) #.iterchildren())
609
+ #print(aa)
610
+ print()
611
+
612
+ def combo_changed(self, combo):
613
+ #print(&#34;combo_changed&#34;)
614
+ name = &#34;&#34;
615
+ tree_iter = combo.get_active_iter()
616
+ try:
617
+ if tree_iter is not None:
618
+ model = combo.get_model()
619
+ name = model[tree_iter][0]
620
+
621
+ if box_testmode:
622
+ print(&#34;Selected: name=%s&#34; % (name))
623
+
624
+ if self.callme:
625
+ try:
626
+ self.callme(name)
627
+ except:
628
+ print(&#34;Color sel callback&#34;, sys.exc_info())
629
+ else:
630
+ entry = combo.get_child()
631
+ name = entry.get_text()
632
+ #print(&#34;Entered: %s&#34; % name)
633
+
634
+ except:
635
+ pass
636
+
637
+ #print(&#34;Combo new selection / entry: &#39;%s&#39;&#34; % name)
638
+
639
+ def delall(self):
640
+ # Delete previous contents
641
+ try:
642
+ while True:
643
+ root = self.store.get_iter_first()
644
+ if not root:
645
+ break
646
+ try:
647
+ self.store.remove(root)
648
+ except:
649
+ print(&#34;except: self.store remove&#34;)
650
+ except:
651
+ print(&#34;combo delall&#34;, sys.exc_info())
652
+ pass
653
+
654
+ # --------------------------------------------------------------------
655
+ def sel_text(self, txt):
656
+
657
+ #print(&#34;Sel combo text&#34;)
658
+
659
+ model = self.get_model()
660
+ iterx = model.get_iter_first()
661
+ if iterx:
662
+ cnt = 0
663
+ while True:
664
+
665
+ #print(&#34;entry %d&#34; % cnt, model[iterx][0], txt)
666
+ if model[iterx][0] == txt:
667
+ #print(&#34;Found %d&#34; % cnt, model[iterx][0])
668
+ self.set_active_iter(iterx)
669
+ break
670
+
671
+ iterx = model.iter_next(iterx)
672
+ if not iterx:
673
+ break
674
+ cnt += 1
675
+
676
+ def sel_first(self):
677
+ model = self.get_model()
678
+ iterx = model.get_iter_first()
679
+ self.set_active_iter(iterx)
680
+
681
+
682
+ # ------------------------------------------------------------------------
683
+ # Added convenience methods
684
+
685
+ class xVBox(Gtk.VBox):
686
+
687
+ def __init__(self, col = None):
688
+ GObject.GObject.__init__(self)
689
+ self.pad = 0
690
+ if box_testmode:
691
+ if not col:
692
+ col = pgutils.randcolstr(100, 200)
693
+ self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(col))
694
+
695
+ def set_padding(self, pad):
696
+ self.pad = pad
697
+
698
+ def pack(self, obj, expand = False, pad = 0):
699
+ if pad == 0:
700
+ pad = self.pad
701
+ self.pack_start(obj, expand, expand, pad)
702
+
703
+ class xHBox(Gtk.HBox):
704
+
705
+ def __init__(self, col = None):
706
+ GObject.GObject.__init__(self)
707
+ self.pad = 0
708
+ if box_testmode:
709
+ if not col:
710
+ col = pgutils.randcolstr(100, 200)
711
+ self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(col))
712
+
713
+ def set_padding(self, pad):
714
+ self.pad = pad
715
+
716
+ def pack(self, obj, expand = False, pad = 0):
717
+ if pad == 0:
718
+ pad = self.pad
719
+ self.pack_start(obj, expand, expand, pad)
720
+
721
+ # EOF</code></pre>
722
+ </details>
723
+ </section>
724
+ <section>
725
+ </section>
726
+ <section>
727
+ </section>
728
+ <section>
729
+ <h2 class="section-title" id="header-functions">Functions</h2>
730
+ <dl>
731
+ <dt id="pgbox.str2rgb"><code class="name flex">
732
+ <span>def <span class="ident">str2rgb</span></span>(<span>col)</span>
733
+ </code></dt>
734
+ <dd>
735
+ <div class="desc"></div>
736
+ <details class="source">
737
+ <summary>
738
+ <span>Expand source code</span>
739
+ </summary>
740
+ <pre><code class="python">def str2rgb(col):
741
+
742
+ #print(&#34;in&#34;, col)
743
+ aa = int(col[1:3], base=16)
744
+ bb = int(col[3:5], base=16)
745
+ cc = int(col[5:7], base=16)
746
+ return aa, bb, cc</code></pre>
747
+ </details>
748
+ </dd>
749
+ <dt id="pgbox.str2rgba"><code class="name flex">
750
+ <span>def <span class="ident">str2rgba</span></span>(<span>col)</span>
751
+ </code></dt>
752
+ <dd>
753
+ <div class="desc"></div>
754
+ <details class="source">
755
+ <summary>
756
+ <span>Expand source code</span>
757
+ </summary>
758
+ <pre><code class="python">def str2rgba(col):
759
+
760
+ #print(&#34;in&#34;, col)
761
+ aa = float(int(col[1:3], base=16)) / 256
762
+ bb = float(int(col[3:5], base=16)) / 256
763
+ cc = float(int(col[5:7], base=16)) / 256
764
+ dd = float(int(col[7:9], base=16)) / 256
765
+ return aa, bb, cc, dd</code></pre>
766
+ </details>
767
+ </dd>
768
+ </dl>
769
+ </section>
770
+ <section>
771
+ <h2 class="section-title" id="header-classes">Classes</h2>
772
+ <dl>
773
+ <dt id="pgbox.ColorCombo"><code class="flex name class">
774
+ <span>class <span class="ident">ColorCombo</span></span>
775
+ <span>(</span><span>init_cont=[], callme=None)</span>
776
+ </code></dt>
777
+ <dd>
778
+ <div class="desc"><p>:Constructors:</p>
779
+ <p>::</p>
780
+ <pre><code>ComboBox(**properties)
781
+ new() -&gt; Gtk.Widget
782
+ new_with_area(area:Gtk.CellArea) -&gt; Gtk.Widget
783
+ new_with_area_and_entry(area:Gtk.CellArea) -&gt; Gtk.Widget
784
+ new_with_entry() -&gt; Gtk.Widget
785
+ new_with_model(model:Gtk.TreeModel) -&gt; Gtk.Widget
786
+ new_with_model_and_entry(model:Gtk.TreeModel) -&gt; Gtk.Widget
787
+ </code></pre></div>
788
+ <details class="source">
789
+ <summary>
790
+ <span>Expand source code</span>
791
+ </summary>
792
+ <pre><code class="python">class ColorCombo(Gtk.ComboBox):
793
+
794
+ def __init__(self, init_cont = [], callme = None):
795
+
796
+ self.store = Gtk.ListStore(str, str)
797
+ Gtk.ComboBox.__init__(self)
798
+ self.callme = callme
799
+
800
+ self.set_model(self.store)
801
+ cell = ColorRenderer()
802
+ cell2 = ColorRenderer()
803
+ #print(&#34;cell&#34;, cell)
804
+ #print(&#34; list_properties&#34;, cell.list_properties())
805
+
806
+ self.pack_start(cell, True)
807
+ self.add_attribute(cell, &#39;text&#39;, 0)
808
+ self.add_attribute(cell, &#39;bgcolor&#39;, 1)
809
+ #self.set_entry_text_column(0)
810
+ #self.set_entry_text_column(1)
811
+ #self.set_cell_data_func(cell, self.data_func)
812
+
813
+ for bb, cc in init_cont:
814
+ self.store.append((bb, cc))
815
+
816
+ #print(&#34;self.GET_MODEL&#34;, self.get_model() )
817
+ #self.get_model().foreach(self.printdetails)
818
+
819
+ self.connect(&#34;changed&#34;, self.combo_changed)
820
+ #self.connect(&#34;notify::popup-shown&#34;, self.combo_focus)
821
+
822
+ def combo_focus(self, arg1, arg2):
823
+ print(&#34;Focus&#34;, arg1, arg2)
824
+
825
+ #def data_func(self, arg1, arg2, arg3, arg4):
826
+ &#39;&#39;&#39;def data_func(self, column, renderer, model, iterx):
827
+ #print(&#34;data_func called&#34;, arg1, arg2, arg3, arg4)
828
+ #print(&#34;data_func &#34;, model, iterx)
829
+ val = model.get_value(iterx, 0)
830
+ #print(&#34;val&#34;, val)
831
+ #renderer.set_property(&#34;cell-background&#34;, val)
832
+ renderer.set_property(&#34;background&#34;, val)
833
+ renderer.set_property(&#34;xpad&#34;, 0)
834
+ &#39;&#39;&#39;
835
+
836
+ def printdetails(self, arg, arg2, arg3):
837
+ #print(arg, arg2, arg3)
838
+ #print(self.store[arg2], arg3.stamp)
839
+ print(dir(self.store[arg2] )) #.iterchildren())
840
+ #print(aa)
841
+ print()
842
+
843
+ def combo_changed(self, combo):
844
+ #print(&#34;combo_changed&#34;)
845
+ name = &#34;&#34;
846
+ tree_iter = combo.get_active_iter()
847
+ try:
848
+ if tree_iter is not None:
849
+ model = combo.get_model()
850
+ name = model[tree_iter][0]
851
+
852
+ if box_testmode:
853
+ print(&#34;Selected: name=%s&#34; % (name))
854
+
855
+ if self.callme:
856
+ try:
857
+ self.callme(name)
858
+ except:
859
+ print(&#34;Color sel callback&#34;, sys.exc_info())
860
+ else:
861
+ entry = combo.get_child()
862
+ name = entry.get_text()
863
+ #print(&#34;Entered: %s&#34; % name)
864
+
865
+ except:
866
+ pass
867
+
868
+ #print(&#34;Combo new selection / entry: &#39;%s&#39;&#34; % name)
869
+
870
+ def delall(self):
871
+ # Delete previous contents
872
+ try:
873
+ while True:
874
+ root = self.store.get_iter_first()
875
+ if not root:
876
+ break
877
+ try:
878
+ self.store.remove(root)
879
+ except:
880
+ print(&#34;except: self.store remove&#34;)
881
+ except:
882
+ print(&#34;combo delall&#34;, sys.exc_info())
883
+ pass
884
+
885
+ # --------------------------------------------------------------------
886
+ def sel_text(self, txt):
887
+
888
+ #print(&#34;Sel combo text&#34;)
889
+
890
+ model = self.get_model()
891
+ iterx = model.get_iter_first()
892
+ if iterx:
893
+ cnt = 0
894
+ while True:
895
+
896
+ #print(&#34;entry %d&#34; % cnt, model[iterx][0], txt)
897
+ if model[iterx][0] == txt:
898
+ #print(&#34;Found %d&#34; % cnt, model[iterx][0])
899
+ self.set_active_iter(iterx)
900
+ break
901
+
902
+ iterx = model.iter_next(iterx)
903
+ if not iterx:
904
+ break
905
+ cnt += 1
906
+
907
+ def sel_first(self):
908
+ model = self.get_model()
909
+ iterx = model.get_iter_first()
910
+ self.set_active_iter(iterx)</code></pre>
911
+ </details>
912
+ <h3>Ancestors</h3>
913
+ <ul class="hlist">
914
+ <li>gi.overrides.Gtk.ComboBox</li>
915
+ <li>gi.repository.Gtk.ComboBox</li>
916
+ <li>gi.repository.Gtk.Bin</li>
917
+ <li>gi.overrides.Gtk.Container</li>
918
+ <li>gi.repository.Gtk.Container</li>
919
+ <li>gi.overrides.Gtk.Widget</li>
920
+ <li>gi.repository.Gtk.Widget</li>
921
+ <li>gi.repository.GObject.InitiallyUnowned</li>
922
+ <li>gi.overrides.GObject.Object</li>
923
+ <li>gi.repository.GObject.Object</li>
924
+ <li>gi._gi.GObject</li>
925
+ <li>gi.repository.Atk.ImplementorIface</li>
926
+ <li>gi.repository.Gtk.Buildable</li>
927
+ <li>gi.repository.Gtk.CellEditable</li>
928
+ <li>gi.repository.Gtk.CellLayout</li>
929
+ <li>gobject.GInterface</li>
930
+ </ul>
931
+ <h3>Methods</h3>
932
+ <dl>
933
+ <dt id="pgbox.ColorCombo.combo_changed"><code class="name flex">
934
+ <span>def <span class="ident">combo_changed</span></span>(<span>self, combo)</span>
935
+ </code></dt>
936
+ <dd>
937
+ <div class="desc"></div>
938
+ <details class="source">
939
+ <summary>
940
+ <span>Expand source code</span>
941
+ </summary>
942
+ <pre><code class="python">def combo_changed(self, combo):
943
+ #print(&#34;combo_changed&#34;)
944
+ name = &#34;&#34;
945
+ tree_iter = combo.get_active_iter()
946
+ try:
947
+ if tree_iter is not None:
948
+ model = combo.get_model()
949
+ name = model[tree_iter][0]
950
+
951
+ if box_testmode:
952
+ print(&#34;Selected: name=%s&#34; % (name))
953
+
954
+ if self.callme:
955
+ try:
956
+ self.callme(name)
957
+ except:
958
+ print(&#34;Color sel callback&#34;, sys.exc_info())
959
+ else:
960
+ entry = combo.get_child()
961
+ name = entry.get_text()
962
+ #print(&#34;Entered: %s&#34; % name)
963
+
964
+ except:
965
+ pass
966
+
967
+ #print(&#34;Combo new selection / entry: &#39;%s&#39;&#34; % name)</code></pre>
968
+ </details>
969
+ </dd>
970
+ <dt id="pgbox.ColorCombo.combo_focus"><code class="name flex">
971
+ <span>def <span class="ident">combo_focus</span></span>(<span>self, arg1, arg2)</span>
972
+ </code></dt>
973
+ <dd>
974
+ <div class="desc"></div>
975
+ <details class="source">
976
+ <summary>
977
+ <span>Expand source code</span>
978
+ </summary>
979
+ <pre><code class="python">def combo_focus(self, arg1, arg2):
980
+ print(&#34;Focus&#34;, arg1, arg2)</code></pre>
981
+ </details>
982
+ </dd>
983
+ <dt id="pgbox.ColorCombo.delall"><code class="name flex">
984
+ <span>def <span class="ident">delall</span></span>(<span>self)</span>
985
+ </code></dt>
986
+ <dd>
987
+ <div class="desc"></div>
988
+ <details class="source">
989
+ <summary>
990
+ <span>Expand source code</span>
991
+ </summary>
992
+ <pre><code class="python">def delall(self):
993
+ # Delete previous contents
994
+ try:
995
+ while True:
996
+ root = self.store.get_iter_first()
997
+ if not root:
998
+ break
999
+ try:
1000
+ self.store.remove(root)
1001
+ except:
1002
+ print(&#34;except: self.store remove&#34;)
1003
+ except:
1004
+ print(&#34;combo delall&#34;, sys.exc_info())
1005
+ pass</code></pre>
1006
+ </details>
1007
+ </dd>
1008
+ <dt id="pgbox.ColorCombo.printdetails"><code class="name flex">
1009
+ <span>def <span class="ident">printdetails</span></span>(<span>self, arg, arg2, arg3)</span>
1010
+ </code></dt>
1011
+ <dd>
1012
+ <div class="desc"></div>
1013
+ <details class="source">
1014
+ <summary>
1015
+ <span>Expand source code</span>
1016
+ </summary>
1017
+ <pre><code class="python">def printdetails(self, arg, arg2, arg3):
1018
+ #print(arg, arg2, arg3)
1019
+ #print(self.store[arg2], arg3.stamp)
1020
+ print(dir(self.store[arg2] )) #.iterchildren())
1021
+ #print(aa)
1022
+ print()</code></pre>
1023
+ </details>
1024
+ </dd>
1025
+ <dt id="pgbox.ColorCombo.sel_first"><code class="name flex">
1026
+ <span>def <span class="ident">sel_first</span></span>(<span>self)</span>
1027
+ </code></dt>
1028
+ <dd>
1029
+ <div class="desc"></div>
1030
+ <details class="source">
1031
+ <summary>
1032
+ <span>Expand source code</span>
1033
+ </summary>
1034
+ <pre><code class="python">def sel_first(self):
1035
+ model = self.get_model()
1036
+ iterx = model.get_iter_first()
1037
+ self.set_active_iter(iterx)</code></pre>
1038
+ </details>
1039
+ </dd>
1040
+ <dt id="pgbox.ColorCombo.sel_text"><code class="name flex">
1041
+ <span>def <span class="ident">sel_text</span></span>(<span>self, txt)</span>
1042
+ </code></dt>
1043
+ <dd>
1044
+ <div class="desc"></div>
1045
+ <details class="source">
1046
+ <summary>
1047
+ <span>Expand source code</span>
1048
+ </summary>
1049
+ <pre><code class="python">def sel_text(self, txt):
1050
+
1051
+ #print(&#34;Sel combo text&#34;)
1052
+
1053
+ model = self.get_model()
1054
+ iterx = model.get_iter_first()
1055
+ if iterx:
1056
+ cnt = 0
1057
+ while True:
1058
+
1059
+ #print(&#34;entry %d&#34; % cnt, model[iterx][0], txt)
1060
+ if model[iterx][0] == txt:
1061
+ #print(&#34;Found %d&#34; % cnt, model[iterx][0])
1062
+ self.set_active_iter(iterx)
1063
+ break
1064
+
1065
+ iterx = model.iter_next(iterx)
1066
+ if not iterx:
1067
+ break
1068
+ cnt += 1</code></pre>
1069
+ </details>
1070
+ </dd>
1071
+ </dl>
1072
+ </dd>
1073
+ <dt id="pgbox.ColorRenderer"><code class="flex name class">
1074
+ <span>class <span class="ident">ColorRenderer</span></span>
1075
+ </code></dt>
1076
+ <dd>
1077
+ <div class="desc"><p>:Constructors:</p>
1078
+ <p>::</p>
1079
+ <pre><code>CellRenderer(**properties)
1080
+ </code></pre></div>
1081
+ <details class="source">
1082
+ <summary>
1083
+ <span>Expand source code</span>
1084
+ </summary>
1085
+ <pre><code class="python">class ColorRenderer(Gtk.CellRenderer):
1086
+
1087
+ __gproperties__ = {
1088
+ &#39;text&#39; : (GObject.TYPE_STRING, &#39;text&#39;,
1089
+ &#39;string that represents the item&#39;,
1090
+ &#39;hello&#39;, GObject.ParamFlags.READWRITE),
1091
+ &#39;bgcolor&#39; : (GObject.TYPE_STRING, &#39;bgcolor&#39;,
1092
+ &#39;string that represents the RGB color&#39;,
1093
+ &#39;white&#39;, GObject.ParamFlags.READWRITE),
1094
+ }
1095
+
1096
+ def __init__(self):
1097
+ Gtk.CellRenderer.__init__(self)
1098
+ # Create placeholders
1099
+ self.text = &#34;None&#34;
1100
+ self.bgcolor = &#34;None&#34;
1101
+
1102
+ self.font_size=10
1103
+ self.font = &#34;Sans {}&#34;.format(self.font_size)
1104
+ #print(self.list_properties())
1105
+
1106
+ def do_get_size(self, widget, cell_area):
1107
+
1108
+ # Get this from the client -&gt; original display values
1109
+ #pg = Gtk.Widget.create_pango_context(widget)
1110
+ #myfd = pg.get_font_description()
1111
+ #self.font_size = myfd.get_size() / Pango.SCALE
1112
+
1113
+ tsize = len(self.text)
1114
+ return (0, 0, self.font_size * (tsize - 2), self.font_size * 3)
1115
+
1116
+ def do_render(self, cr, widget, background_area, cell_area, expose_area, flags = 0):
1117
+ #ccc = str2rgb(self.bgcolor)
1118
+ ccc = str2rgba(self.bgcolor)
1119
+ #avg = (ccc[0] + ccc[1] + ccc[2] ) / 3
1120
+ #print(&#34;text&#34;, self.text, &#34;bgcolor&#34;, self.bgcolor, ccc) #, &#34;avg&#34;, avg)
1121
+
1122
+ cr.translate (0, 0)
1123
+ layout = PangoCairo.create_layout(cr)
1124
+ # ---Note--- changing default
1125
+ desc = Pango.font_description_from_string(self.font)
1126
+ layout.set_font_description(desc)
1127
+ layout.set_text(self.text)
1128
+ cr.save()
1129
+ cr.set_source_rgba(*ccc)
1130
+
1131
+ cr.rectangle(0, 0, background_area.width, background_area.height)
1132
+ cr.fill()
1133
+ PangoCairo.update_layout (cr, layout)
1134
+
1135
+ # Make it sensitive to dark / light
1136
+ ddd = []
1137
+ for aa in ccc[:-1]:
1138
+ if aa &lt; .5:
1139
+ ddd.append(1)
1140
+ else:
1141
+ ddd.append(0)
1142
+ ddd.append(1.)
1143
+ cr.set_source_rgba (*ddd)
1144
+
1145
+ (pr, lr) = layout.get_extents()
1146
+ xx = lr.width / Pango.SCALE; yy = lr.height / Pango.SCALE
1147
+
1148
+ cr.move_to((background_area.width - xx)/2, (background_area.height - yy)/2)
1149
+ PangoCairo.show_layout (cr, layout)
1150
+
1151
+ cr.restore()
1152
+
1153
+ def do_get_property(self, property):
1154
+ #print(&#34;get prop&#34;, property)
1155
+ return getattr(self, property.name)
1156
+
1157
+ def do_set_property(self, property, val):
1158
+ #print(&#34;set prop&#34;, property, val)
1159
+ setattr(self, property.name, val)
1160
+ pass</code></pre>
1161
+ </details>
1162
+ <h3>Ancestors</h3>
1163
+ <ul class="hlist">
1164
+ <li>gi.repository.Gtk.CellRenderer</li>
1165
+ <li>gi.repository.GObject.InitiallyUnowned</li>
1166
+ <li>gi.overrides.GObject.Object</li>
1167
+ <li>gi.repository.GObject.Object</li>
1168
+ <li>gi._gi.GObject</li>
1169
+ </ul>
1170
+ <h3>Methods</h3>
1171
+ <dl>
1172
+ <dt id="pgbox.ColorRenderer.do_get_property"><code class="name flex">
1173
+ <span>def <span class="ident">do_get_property</span></span>(<span>self, property)</span>
1174
+ </code></dt>
1175
+ <dd>
1176
+ <div class="desc"></div>
1177
+ <details class="source">
1178
+ <summary>
1179
+ <span>Expand source code</span>
1180
+ </summary>
1181
+ <pre><code class="python">def do_get_property(self, property):
1182
+ #print(&#34;get prop&#34;, property)
1183
+ return getattr(self, property.name)</code></pre>
1184
+ </details>
1185
+ </dd>
1186
+ <dt id="pgbox.ColorRenderer.do_get_size"><code class="name flex">
1187
+ <span>def <span class="ident">do_get_size</span></span>(<span>self, widget, cell_area)</span>
1188
+ </code></dt>
1189
+ <dd>
1190
+ <div class="desc"><p>get_size(self, widget:Gtk.Widget, cell_area:Gdk.Rectangle=None) -&gt; x_offset:int, y_offset:int, width:int, height:int</p></div>
1191
+ <details class="source">
1192
+ <summary>
1193
+ <span>Expand source code</span>
1194
+ </summary>
1195
+ <pre><code class="python">def do_get_size(self, widget, cell_area):
1196
+
1197
+ # Get this from the client -&gt; original display values
1198
+ #pg = Gtk.Widget.create_pango_context(widget)
1199
+ #myfd = pg.get_font_description()
1200
+ #self.font_size = myfd.get_size() / Pango.SCALE
1201
+
1202
+ tsize = len(self.text)
1203
+ return (0, 0, self.font_size * (tsize - 2), self.font_size * 3)</code></pre>
1204
+ </details>
1205
+ </dd>
1206
+ <dt id="pgbox.ColorRenderer.do_render"><code class="name flex">
1207
+ <span>def <span class="ident">do_render</span></span>(<span>self, cr, widget, background_area, cell_area, expose_area, flags=0)</span>
1208
+ </code></dt>
1209
+ <dd>
1210
+ <div class="desc"><p>render(self, cr:cairo.Context, widget:Gtk.Widget, background_area:Gdk.Rectangle, cell_area:Gdk.Rectangle, flags:Gtk.CellRendererState)</p></div>
1211
+ <details class="source">
1212
+ <summary>
1213
+ <span>Expand source code</span>
1214
+ </summary>
1215
+ <pre><code class="python">def do_render(self, cr, widget, background_area, cell_area, expose_area, flags = 0):
1216
+ #ccc = str2rgb(self.bgcolor)
1217
+ ccc = str2rgba(self.bgcolor)
1218
+ #avg = (ccc[0] + ccc[1] + ccc[2] ) / 3
1219
+ #print(&#34;text&#34;, self.text, &#34;bgcolor&#34;, self.bgcolor, ccc) #, &#34;avg&#34;, avg)
1220
+
1221
+ cr.translate (0, 0)
1222
+ layout = PangoCairo.create_layout(cr)
1223
+ # ---Note--- changing default
1224
+ desc = Pango.font_description_from_string(self.font)
1225
+ layout.set_font_description(desc)
1226
+ layout.set_text(self.text)
1227
+ cr.save()
1228
+ cr.set_source_rgba(*ccc)
1229
+
1230
+ cr.rectangle(0, 0, background_area.width, background_area.height)
1231
+ cr.fill()
1232
+ PangoCairo.update_layout (cr, layout)
1233
+
1234
+ # Make it sensitive to dark / light
1235
+ ddd = []
1236
+ for aa in ccc[:-1]:
1237
+ if aa &lt; .5:
1238
+ ddd.append(1)
1239
+ else:
1240
+ ddd.append(0)
1241
+ ddd.append(1.)
1242
+ cr.set_source_rgba (*ddd)
1243
+
1244
+ (pr, lr) = layout.get_extents()
1245
+ xx = lr.width / Pango.SCALE; yy = lr.height / Pango.SCALE
1246
+
1247
+ cr.move_to((background_area.width - xx)/2, (background_area.height - yy)/2)
1248
+ PangoCairo.show_layout (cr, layout)
1249
+
1250
+ cr.restore()</code></pre>
1251
+ </details>
1252
+ </dd>
1253
+ <dt id="pgbox.ColorRenderer.do_set_property"><code class="name flex">
1254
+ <span>def <span class="ident">do_set_property</span></span>(<span>self, property, val)</span>
1255
+ </code></dt>
1256
+ <dd>
1257
+ <div class="desc"></div>
1258
+ <details class="source">
1259
+ <summary>
1260
+ <span>Expand source code</span>
1261
+ </summary>
1262
+ <pre><code class="python">def do_set_property(self, property, val):
1263
+ #print(&#34;set prop&#34;, property, val)
1264
+ setattr(self, property.name, val)
1265
+ pass</code></pre>
1266
+ </details>
1267
+ </dd>
1268
+ </dl>
1269
+ </dd>
1270
+ <dt id="pgbox.ComboBox"><code class="flex name class">
1271
+ <span>class <span class="ident">ComboBox</span></span>
1272
+ <span>(</span><span>init_cont=[], callme=None)</span>
1273
+ </code></dt>
1274
+ <dd>
1275
+ <div class="desc"><p>:Constructors:</p>
1276
+ <p>::</p>
1277
+ <pre><code>ComboBox(**properties)
1278
+ new() -&gt; Gtk.Widget
1279
+ new_with_area(area:Gtk.CellArea) -&gt; Gtk.Widget
1280
+ new_with_area_and_entry(area:Gtk.CellArea) -&gt; Gtk.Widget
1281
+ new_with_entry() -&gt; Gtk.Widget
1282
+ new_with_model(model:Gtk.TreeModel) -&gt; Gtk.Widget
1283
+ new_with_model_and_entry(model:Gtk.TreeModel) -&gt; Gtk.Widget
1284
+ </code></pre></div>
1285
+ <details class="source">
1286
+ <summary>
1287
+ <span>Expand source code</span>
1288
+ </summary>
1289
+ <pre><code class="python">class ComboBox(Gtk.ComboBox):
1290
+
1291
+ def __init__(self, init_cont = [], callme = None):
1292
+
1293
+ self.store = Gtk.ListStore(str)
1294
+ Gtk.ComboBox.__init__(self)
1295
+
1296
+ self.set_model(self.store)
1297
+ cell = Gtk.CellRendererText()
1298
+
1299
+ cell.set_property(&#34;text&#34;, &#34;hello&#34;)
1300
+ #cell.set_property(&#34;background&#34;, &#34;#ffff00&#34;)
1301
+ #cell.set_property(&#34;background-set&#34;, True)
1302
+ cell.set_padding(10, 0)
1303
+
1304
+ self.callme = callme
1305
+ #if callme:
1306
+ # self.connect(&#34;changed&#34;, callme)
1307
+
1308
+ #cell.set_property(&#34;foreground&#34;, &#34;#ffff00&#34;)
1309
+ #cell.set_property(&#34;foreground-set&#34;, True)
1310
+ #print(&#34;background-set&#34;, cell.get_property(&#34;background-set&#34;))
1311
+ #print(&#34;foreground-set&#34;, cell.get_property(&#34;foreground-set&#34;))
1312
+
1313
+ #print(&#34; list_properties&#34;, cell.list_properties())
1314
+
1315
+ self.pack_start(cell, True)
1316
+ self.add_attribute(cell, &#39;text&#39;, 0)
1317
+ self.set_entry_text_column(0)
1318
+
1319
+ for bb in init_cont:
1320
+ self.store.append([bb])
1321
+
1322
+ self.connect(&#34;changed&#34;, self.combo_changed)
1323
+
1324
+ def combo_changed(self, combo):
1325
+ name = &#34;&#34;
1326
+ tree_iter = combo.get_active_iter()
1327
+ try:
1328
+ if tree_iter is not None:
1329
+ model = combo.get_model()
1330
+ name = model[tree_iter][0]
1331
+ #print(&#34;Selected: name=%s&#34; % (name))
1332
+
1333
+ if self.callme:
1334
+ try:
1335
+ self.callme(name)
1336
+ except:
1337
+ print(&#34;Callback:&#34;, sys.exc_info())
1338
+ pgutils.print_exception(&#34;callb&#34;)
1339
+
1340
+ else:
1341
+ entry = combo.get_child()
1342
+ name = entry.get_text()
1343
+ #print(&#34;Entered: %s&#34; % name)
1344
+
1345
+ except:
1346
+ pass
1347
+
1348
+ #print(&#34;Combo new selection / entry: &#39;%s&#39;&#34; % name)
1349
+
1350
+ def delall(self):
1351
+ # Delete previous contents
1352
+ try:
1353
+ while True:
1354
+ root = self.store.get_iter_first()
1355
+ if not root:
1356
+ break
1357
+ try:
1358
+ self.store.remove(root)
1359
+ except:
1360
+ print(&#34;except: self.store remove&#34;)
1361
+ except:
1362
+ print(&#34;combo delall&#34;, sys.exc_info())
1363
+ pass
1364
+
1365
+ # --------------------------------------------------------------------
1366
+ def sel_text(self, txt):
1367
+
1368
+ #print(&#34;Sel combo text&#34;)
1369
+
1370
+ model = self.get_model()
1371
+ iterx = model.get_iter_first()
1372
+ if iterx:
1373
+ cnt = 0
1374
+ while True:
1375
+
1376
+ #print(&#34;entry %d&#34; % cnt, model[iterx][0], txt)
1377
+ if model[iterx][0] == txt:
1378
+ #print(&#34;Found %d&#34; % cnt, model[iterx][0])
1379
+ self.set_active_iter(iterx)
1380
+ break
1381
+
1382
+ iterx = model.iter_next(iterx)
1383
+ if not iterx:
1384
+ break
1385
+ cnt += 1
1386
+
1387
+ def sel_first(self):
1388
+ model = self.get_model()
1389
+ iterx = model.get_iter_first()
1390
+ self.set_active_iter(iterx)</code></pre>
1391
+ </details>
1392
+ <h3>Ancestors</h3>
1393
+ <ul class="hlist">
1394
+ <li>gi.overrides.Gtk.ComboBox</li>
1395
+ <li>gi.repository.Gtk.ComboBox</li>
1396
+ <li>gi.repository.Gtk.Bin</li>
1397
+ <li>gi.overrides.Gtk.Container</li>
1398
+ <li>gi.repository.Gtk.Container</li>
1399
+ <li>gi.overrides.Gtk.Widget</li>
1400
+ <li>gi.repository.Gtk.Widget</li>
1401
+ <li>gi.repository.GObject.InitiallyUnowned</li>
1402
+ <li>gi.overrides.GObject.Object</li>
1403
+ <li>gi.repository.GObject.Object</li>
1404
+ <li>gi._gi.GObject</li>
1405
+ <li>gi.repository.Atk.ImplementorIface</li>
1406
+ <li>gi.repository.Gtk.Buildable</li>
1407
+ <li>gi.repository.Gtk.CellEditable</li>
1408
+ <li>gi.repository.Gtk.CellLayout</li>
1409
+ <li>gobject.GInterface</li>
1410
+ </ul>
1411
+ <h3>Methods</h3>
1412
+ <dl>
1413
+ <dt id="pgbox.ComboBox.combo_changed"><code class="name flex">
1414
+ <span>def <span class="ident">combo_changed</span></span>(<span>self, combo)</span>
1415
+ </code></dt>
1416
+ <dd>
1417
+ <div class="desc"></div>
1418
+ <details class="source">
1419
+ <summary>
1420
+ <span>Expand source code</span>
1421
+ </summary>
1422
+ <pre><code class="python">def combo_changed(self, combo):
1423
+ name = &#34;&#34;
1424
+ tree_iter = combo.get_active_iter()
1425
+ try:
1426
+ if tree_iter is not None:
1427
+ model = combo.get_model()
1428
+ name = model[tree_iter][0]
1429
+ #print(&#34;Selected: name=%s&#34; % (name))
1430
+
1431
+ if self.callme:
1432
+ try:
1433
+ self.callme(name)
1434
+ except:
1435
+ print(&#34;Callback:&#34;, sys.exc_info())
1436
+ pgutils.print_exception(&#34;callb&#34;)
1437
+
1438
+ else:
1439
+ entry = combo.get_child()
1440
+ name = entry.get_text()
1441
+ #print(&#34;Entered: %s&#34; % name)
1442
+
1443
+ except:
1444
+ pass
1445
+
1446
+ #print(&#34;Combo new selection / entry: &#39;%s&#39;&#34; % name)</code></pre>
1447
+ </details>
1448
+ </dd>
1449
+ <dt id="pgbox.ComboBox.delall"><code class="name flex">
1450
+ <span>def <span class="ident">delall</span></span>(<span>self)</span>
1451
+ </code></dt>
1452
+ <dd>
1453
+ <div class="desc"></div>
1454
+ <details class="source">
1455
+ <summary>
1456
+ <span>Expand source code</span>
1457
+ </summary>
1458
+ <pre><code class="python">def delall(self):
1459
+ # Delete previous contents
1460
+ try:
1461
+ while True:
1462
+ root = self.store.get_iter_first()
1463
+ if not root:
1464
+ break
1465
+ try:
1466
+ self.store.remove(root)
1467
+ except:
1468
+ print(&#34;except: self.store remove&#34;)
1469
+ except:
1470
+ print(&#34;combo delall&#34;, sys.exc_info())
1471
+ pass</code></pre>
1472
+ </details>
1473
+ </dd>
1474
+ <dt id="pgbox.ComboBox.sel_first"><code class="name flex">
1475
+ <span>def <span class="ident">sel_first</span></span>(<span>self)</span>
1476
+ </code></dt>
1477
+ <dd>
1478
+ <div class="desc"></div>
1479
+ <details class="source">
1480
+ <summary>
1481
+ <span>Expand source code</span>
1482
+ </summary>
1483
+ <pre><code class="python">def sel_first(self):
1484
+ model = self.get_model()
1485
+ iterx = model.get_iter_first()
1486
+ self.set_active_iter(iterx)</code></pre>
1487
+ </details>
1488
+ </dd>
1489
+ <dt id="pgbox.ComboBox.sel_text"><code class="name flex">
1490
+ <span>def <span class="ident">sel_text</span></span>(<span>self, txt)</span>
1491
+ </code></dt>
1492
+ <dd>
1493
+ <div class="desc"></div>
1494
+ <details class="source">
1495
+ <summary>
1496
+ <span>Expand source code</span>
1497
+ </summary>
1498
+ <pre><code class="python">def sel_text(self, txt):
1499
+
1500
+ #print(&#34;Sel combo text&#34;)
1501
+
1502
+ model = self.get_model()
1503
+ iterx = model.get_iter_first()
1504
+ if iterx:
1505
+ cnt = 0
1506
+ while True:
1507
+
1508
+ #print(&#34;entry %d&#34; % cnt, model[iterx][0], txt)
1509
+ if model[iterx][0] == txt:
1510
+ #print(&#34;Found %d&#34; % cnt, model[iterx][0])
1511
+ self.set_active_iter(iterx)
1512
+ break
1513
+
1514
+ iterx = model.iter_next(iterx)
1515
+ if not iterx:
1516
+ break
1517
+ cnt += 1</code></pre>
1518
+ </details>
1519
+ </dd>
1520
+ </dl>
1521
+ </dd>
1522
+ <dt id="pgbox.ListBox"><code class="flex name class">
1523
+ <span>class <span class="ident">ListBox</span></span>
1524
+ <span>(</span><span>limit=-1, colname='')</span>
1525
+ </code></dt>
1526
+ <dd>
1527
+ <div class="desc"><p>:Constructors:</p>
1528
+ <p>::</p>
1529
+ <pre><code>TreeView(**properties)
1530
+ new() -&gt; Gtk.Widget
1531
+ new_with_model(model:Gtk.TreeModel) -&gt; Gtk.Widget
1532
+ </code></pre>
1533
+ <p>Initializer for a GObject based classes with support for property
1534
+ sets through the use of explicit keyword arguments.</p></div>
1535
+ <details class="source">
1536
+ <summary>
1537
+ <span>Expand source code</span>
1538
+ </summary>
1539
+ <pre><code class="python">class ListBox(Gtk.TreeView):
1540
+
1541
+ def __init__(self, limit = -1, colname = &#39;&#39;):
1542
+
1543
+ self.limit = limit
1544
+ self.treestore = Gtk.TreeStore(str, str)
1545
+ Gtk.TreeView.__init__(self, self.treestore)
1546
+
1547
+ cell = Gtk.CellRendererText()
1548
+ # create the TreeViewColumn to display the data
1549
+ tvcolumn = Gtk.TreeViewColumn(colname)
1550
+ # add the cell to the tvcolumn and allow it to expand
1551
+ tvcolumn.pack_start(cell, True)
1552
+
1553
+ # set the cell &#34;text&#34; attribute to column 0 - retrieve text
1554
+ tvcolumn.add_attribute(cell, &#39;text&#39;, 0)
1555
+
1556
+ # add tvcolumn to treeview
1557
+ self.append_column(tvcolumn)
1558
+ self.set_activate_on_single_click (True)
1559
+
1560
+ self.callb = None
1561
+ self.connect(&#34;row-activated&#34;, self.tree_sel)
1562
+
1563
+ def tree_sel(self, xtree, xiter, xpath):
1564
+ #print(&#34;tree_sel&#34;, xtree, xiter, xpath)
1565
+ sel = xtree.get_selection()
1566
+ xmodel, xiter = sel.get_selected()
1567
+ if xiter:
1568
+ xstr = xmodel.get_value(xiter, 0)
1569
+ #print(&#34;Selected&#34;, xstr)
1570
+ if self.callb:
1571
+ self.callb(xstr)
1572
+ pass
1573
+
1574
+ def set_callback(self, funcx):
1575
+ self.callb = funcx
1576
+
1577
+ # Delete previous contents
1578
+ def clear(self):
1579
+ try:
1580
+ while True:
1581
+ root = self.treestore.get_iter_first()
1582
+ if not root:
1583
+ break
1584
+ try:
1585
+ self.treestore.remove(root)
1586
+ except:
1587
+ print(&#34;except: treestore remove&#34;)
1588
+
1589
+ except:
1590
+ print(&#34;update_tree&#34;, sys.exc_info())
1591
+ pass
1592
+
1593
+ # Select Item. -1 for select none; Rase Valuerror for wrong index.
1594
+ def select(self, idx):
1595
+ ts = self.get_selection()
1596
+ if idx == -1:
1597
+ ts.unselect_all()
1598
+ return
1599
+ iterx = self.treestore.get_iter_first()
1600
+ for aa in range(idx):
1601
+ iterx = self.treestore.iter_next(iter)
1602
+ if not iterx:
1603
+ break
1604
+ if not iterx:
1605
+ pass
1606
+ #raise ValueError(&#34;Invalid selection index.&#34;)
1607
+ ts.select_iter(iterx)
1608
+
1609
+ # Return the number of list items
1610
+ def get_size(self):
1611
+ cnt = 0
1612
+ iterx = self.treestore.get_iter_first()
1613
+ if not iterx:
1614
+ return cnt
1615
+ cnt = 1
1616
+ while True:
1617
+ iterx = self.treestore.iter_next(iter)
1618
+ if not iterx:
1619
+ break
1620
+ cnt += 1
1621
+ return cnt
1622
+
1623
+ def get_item(self, idx):
1624
+ cnt = 0; res = &#34;&#34;
1625
+ iterx = self.treestore.get_iter_first()
1626
+ if not iterx:
1627
+ return &#34;&#34;
1628
+ cnt = 1
1629
+ while True:
1630
+ iterx = self.treestore.iter_next(iter)
1631
+ if not iterx:
1632
+ break
1633
+ if cnt == idx:
1634
+ res = self.treestore.get_value(iterx, 0)
1635
+ break
1636
+ cnt += 1
1637
+ return res
1638
+
1639
+ def append(self, strx):
1640
+ if self.limit != -1:
1641
+ # count them
1642
+ cnt = self.get_size()
1643
+ #print(&#34;limiting cnt=&#34;, cnt, &#34;limit=&#34;, self.limit)
1644
+ for aa in range(cnt - self.limit):
1645
+ iterx = self.treestore.get_iter_first()
1646
+ if not iterx:
1647
+ break
1648
+ try:
1649
+ self.treestore.remove(iterx)
1650
+ except:
1651
+ print(&#34;except: treestore remove lim&#34;)
1652
+
1653
+ last = self.treestore.append(None, [strx])
1654
+ self.set_cursor_on_cell(self.treestore.get_path(last), None, None, False)
1655
+
1656
+ def get_text(self):
1657
+ sel = self.get_selection()
1658
+ xmodel, xiter = sel.get_selected()
1659
+ if xiter:
1660
+ return xmodel.get_value(xiter, 0)
1661
+
1662
+ # Get current IDX -1 for none
1663
+ def get_curridx(self):
1664
+ sel = self.get_selection()
1665
+ xmodel, xiter = sel.get_selected()
1666
+ if not xiter:
1667
+ return -1
1668
+
1669
+ # Count back from match
1670
+ cnt = 0
1671
+ while True:
1672
+ xiter = self.treestore.iter_previous(xiter)
1673
+ if not xiter:
1674
+ break
1675
+ #print (&#34;xiter:&#34;, xiter)
1676
+ cnt += 1
1677
+ return cnt</code></pre>
1678
+ </details>
1679
+ <h3>Ancestors</h3>
1680
+ <ul class="hlist">
1681
+ <li>gi.overrides.Gtk.TreeView</li>
1682
+ <li>gi.repository.Gtk.TreeView</li>
1683
+ <li>gi.overrides.Gtk.Container</li>
1684
+ <li>gi.repository.Gtk.Container</li>
1685
+ <li>gi.overrides.Gtk.Widget</li>
1686
+ <li>gi.repository.Gtk.Widget</li>
1687
+ <li>gi.repository.GObject.InitiallyUnowned</li>
1688
+ <li>gi.overrides.GObject.Object</li>
1689
+ <li>gi.repository.GObject.Object</li>
1690
+ <li>gi._gi.GObject</li>
1691
+ <li>gi.repository.Atk.ImplementorIface</li>
1692
+ <li>gi.repository.Gtk.Buildable</li>
1693
+ <li>gi.repository.Gtk.Scrollable</li>
1694
+ <li>gobject.GInterface</li>
1695
+ </ul>
1696
+ <h3>Methods</h3>
1697
+ <dl>
1698
+ <dt id="pgbox.ListBox.append"><code class="name flex">
1699
+ <span>def <span class="ident">append</span></span>(<span>self, strx)</span>
1700
+ </code></dt>
1701
+ <dd>
1702
+ <div class="desc"></div>
1703
+ <details class="source">
1704
+ <summary>
1705
+ <span>Expand source code</span>
1706
+ </summary>
1707
+ <pre><code class="python">def append(self, strx):
1708
+ if self.limit != -1:
1709
+ # count them
1710
+ cnt = self.get_size()
1711
+ #print(&#34;limiting cnt=&#34;, cnt, &#34;limit=&#34;, self.limit)
1712
+ for aa in range(cnt - self.limit):
1713
+ iterx = self.treestore.get_iter_first()
1714
+ if not iterx:
1715
+ break
1716
+ try:
1717
+ self.treestore.remove(iterx)
1718
+ except:
1719
+ print(&#34;except: treestore remove lim&#34;)
1720
+
1721
+ last = self.treestore.append(None, [strx])
1722
+ self.set_cursor_on_cell(self.treestore.get_path(last), None, None, False)</code></pre>
1723
+ </details>
1724
+ </dd>
1725
+ <dt id="pgbox.ListBox.clear"><code class="name flex">
1726
+ <span>def <span class="ident">clear</span></span>(<span>self)</span>
1727
+ </code></dt>
1728
+ <dd>
1729
+ <div class="desc"></div>
1730
+ <details class="source">
1731
+ <summary>
1732
+ <span>Expand source code</span>
1733
+ </summary>
1734
+ <pre><code class="python">def clear(self):
1735
+ try:
1736
+ while True:
1737
+ root = self.treestore.get_iter_first()
1738
+ if not root:
1739
+ break
1740
+ try:
1741
+ self.treestore.remove(root)
1742
+ except:
1743
+ print(&#34;except: treestore remove&#34;)
1744
+
1745
+ except:
1746
+ print(&#34;update_tree&#34;, sys.exc_info())
1747
+ pass</code></pre>
1748
+ </details>
1749
+ </dd>
1750
+ <dt id="pgbox.ListBox.get_curridx"><code class="name flex">
1751
+ <span>def <span class="ident">get_curridx</span></span>(<span>self)</span>
1752
+ </code></dt>
1753
+ <dd>
1754
+ <div class="desc"></div>
1755
+ <details class="source">
1756
+ <summary>
1757
+ <span>Expand source code</span>
1758
+ </summary>
1759
+ <pre><code class="python">def get_curridx(self):
1760
+ sel = self.get_selection()
1761
+ xmodel, xiter = sel.get_selected()
1762
+ if not xiter:
1763
+ return -1
1764
+
1765
+ # Count back from match
1766
+ cnt = 0
1767
+ while True:
1768
+ xiter = self.treestore.iter_previous(xiter)
1769
+ if not xiter:
1770
+ break
1771
+ #print (&#34;xiter:&#34;, xiter)
1772
+ cnt += 1
1773
+ return cnt</code></pre>
1774
+ </details>
1775
+ </dd>
1776
+ <dt id="pgbox.ListBox.get_item"><code class="name flex">
1777
+ <span>def <span class="ident">get_item</span></span>(<span>self, idx)</span>
1778
+ </code></dt>
1779
+ <dd>
1780
+ <div class="desc"></div>
1781
+ <details class="source">
1782
+ <summary>
1783
+ <span>Expand source code</span>
1784
+ </summary>
1785
+ <pre><code class="python">def get_item(self, idx):
1786
+ cnt = 0; res = &#34;&#34;
1787
+ iterx = self.treestore.get_iter_first()
1788
+ if not iterx:
1789
+ return &#34;&#34;
1790
+ cnt = 1
1791
+ while True:
1792
+ iterx = self.treestore.iter_next(iter)
1793
+ if not iterx:
1794
+ break
1795
+ if cnt == idx:
1796
+ res = self.treestore.get_value(iterx, 0)
1797
+ break
1798
+ cnt += 1
1799
+ return res</code></pre>
1800
+ </details>
1801
+ </dd>
1802
+ <dt id="pgbox.ListBox.get_size"><code class="name flex">
1803
+ <span>def <span class="ident">get_size</span></span>(<span>self)</span>
1804
+ </code></dt>
1805
+ <dd>
1806
+ <div class="desc"></div>
1807
+ <details class="source">
1808
+ <summary>
1809
+ <span>Expand source code</span>
1810
+ </summary>
1811
+ <pre><code class="python">def get_size(self):
1812
+ cnt = 0
1813
+ iterx = self.treestore.get_iter_first()
1814
+ if not iterx:
1815
+ return cnt
1816
+ cnt = 1
1817
+ while True:
1818
+ iterx = self.treestore.iter_next(iter)
1819
+ if not iterx:
1820
+ break
1821
+ cnt += 1
1822
+ return cnt</code></pre>
1823
+ </details>
1824
+ </dd>
1825
+ <dt id="pgbox.ListBox.get_text"><code class="name flex">
1826
+ <span>def <span class="ident">get_text</span></span>(<span>self)</span>
1827
+ </code></dt>
1828
+ <dd>
1829
+ <div class="desc"></div>
1830
+ <details class="source">
1831
+ <summary>
1832
+ <span>Expand source code</span>
1833
+ </summary>
1834
+ <pre><code class="python">def get_text(self):
1835
+ sel = self.get_selection()
1836
+ xmodel, xiter = sel.get_selected()
1837
+ if xiter:
1838
+ return xmodel.get_value(xiter, 0)</code></pre>
1839
+ </details>
1840
+ </dd>
1841
+ <dt id="pgbox.ListBox.select"><code class="name flex">
1842
+ <span>def <span class="ident">select</span></span>(<span>self, idx)</span>
1843
+ </code></dt>
1844
+ <dd>
1845
+ <div class="desc"></div>
1846
+ <details class="source">
1847
+ <summary>
1848
+ <span>Expand source code</span>
1849
+ </summary>
1850
+ <pre><code class="python">def select(self, idx):
1851
+ ts = self.get_selection()
1852
+ if idx == -1:
1853
+ ts.unselect_all()
1854
+ return
1855
+ iterx = self.treestore.get_iter_first()
1856
+ for aa in range(idx):
1857
+ iterx = self.treestore.iter_next(iter)
1858
+ if not iterx:
1859
+ break
1860
+ if not iterx:
1861
+ pass
1862
+ #raise ValueError(&#34;Invalid selection index.&#34;)
1863
+ ts.select_iter(iterx)</code></pre>
1864
+ </details>
1865
+ </dd>
1866
+ <dt id="pgbox.ListBox.set_callback"><code class="name flex">
1867
+ <span>def <span class="ident">set_callback</span></span>(<span>self, funcx)</span>
1868
+ </code></dt>
1869
+ <dd>
1870
+ <div class="desc"></div>
1871
+ <details class="source">
1872
+ <summary>
1873
+ <span>Expand source code</span>
1874
+ </summary>
1875
+ <pre><code class="python">def set_callback(self, funcx):
1876
+ self.callb = funcx</code></pre>
1877
+ </details>
1878
+ </dd>
1879
+ <dt id="pgbox.ListBox.tree_sel"><code class="name flex">
1880
+ <span>def <span class="ident">tree_sel</span></span>(<span>self, xtree, xiter, xpath)</span>
1881
+ </code></dt>
1882
+ <dd>
1883
+ <div class="desc"></div>
1884
+ <details class="source">
1885
+ <summary>
1886
+ <span>Expand source code</span>
1887
+ </summary>
1888
+ <pre><code class="python">def tree_sel(self, xtree, xiter, xpath):
1889
+ #print(&#34;tree_sel&#34;, xtree, xiter, xpath)
1890
+ sel = xtree.get_selection()
1891
+ xmodel, xiter = sel.get_selected()
1892
+ if xiter:
1893
+ xstr = xmodel.get_value(xiter, 0)
1894
+ #print(&#34;Selected&#34;, xstr)
1895
+ if self.callb:
1896
+ self.callb(xstr)
1897
+ pass</code></pre>
1898
+ </details>
1899
+ </dd>
1900
+ </dl>
1901
+ </dd>
1902
+ <dt id="pgbox.Rectangle"><code class="flex name class">
1903
+ <span>class <span class="ident">Rectangle</span></span>
1904
+ <span>(</span><span>*rrr)</span>
1905
+ </code></dt>
1906
+ <dd>
1907
+ <div class="desc"></div>
1908
+ <details class="source">
1909
+ <summary>
1910
+ <span>Expand source code</span>
1911
+ </summary>
1912
+ <pre><code class="python">class Rectangle():
1913
+
1914
+ # Accept rect, array, integers
1915
+ def __init__(self, *rrr):
1916
+ #Gdk.Rectangle.__init__(self)
1917
+ if len(rrr) == 4:
1918
+ idx = 0
1919
+ for aa in rrr:
1920
+ bb = int(aa)
1921
+ if idx == 0:
1922
+ self.x = bb
1923
+ elif idx == 1:
1924
+ self.y = bb
1925
+ elif idx == 2:
1926
+ #self.width = bb
1927
+ self.w = bb
1928
+ elif idx == 3:
1929
+ #self.height = bb
1930
+ self.h = bb
1931
+ else:
1932
+ raise ValueError
1933
+ idx += 1
1934
+ else:
1935
+ for aaa in rrr:
1936
+ self.x = aaa[0]
1937
+ self.y = aaa[1]
1938
+ self.w = aaa[2]
1939
+ #self.width = aaa[2];
1940
+ self.h = aaa[3]
1941
+ #self.height = aaa[3]
1942
+ break
1943
+ pass
1944
+
1945
+ # Make it smaller
1946
+ def resize(self, ww, hh = 0):
1947
+ if hh == 0:
1948
+ hh = ww
1949
+
1950
+ #if ww + self.w &lt;= 0 or hh + self.h &lt;= 0:
1951
+ # raise (ValuError, &#34;Cannot have negative rect size&#34;)
1952
+
1953
+ self.x -= ww/2; self.w += ww
1954
+ self.y -= hh/2; self.h += hh
1955
+
1956
+ def copy(self):
1957
+ #print(&#34;rect to copy&#34;, str(self))
1958
+ #print(&#34;rect to copy&#34;, dir(self))
1959
+ nnn = Rectangle() # New Instance
1960
+ &#39;&#39;&#39;
1961
+ # Self
1962
+ for aa in dir(self):
1963
+ try:
1964
+ #nnn.__setattr__(aa, self.__getattribute__(aa))
1965
+ nnn.aa = self.__getattribute__(aa)
1966
+ #print(&#34;cp:&#34;, aa, end = &#34;&#34;)
1967
+ #if type(self.__getattribute__(aa)) == int:
1968
+ # print(&#34; -&gt; &#34;, self.__getattribute__(aa), end= &#34; &#34;)
1969
+ #print(&#34; --- &#34;, end = &#34;&#34;)
1970
+ except:
1971
+ #print(sys.exc_info())
1972
+ print(&#34;no&#34;, aa)
1973
+ pass
1974
+ &#39;&#39;&#39;
1975
+
1976
+ # Assign explictly
1977
+ nnn.x = self.x + 0
1978
+ nnn.y = self.y + 0
1979
+ nnn.w = self.w + 0
1980
+ nnn.h = self.h + 0
1981
+
1982
+ #nnn.width = self.width + 1
1983
+ #nnn.height = self.height + 1
1984
+
1985
+ #print(&#34;rect out&#34;, str(nnn))
1986
+ #print(&#34;rect out&#34;, dir(nnn))
1987
+ return nnn
1988
+
1989
+ # I was too lazy to write it; Crappy Gdt rect kicked me to it
1990
+
1991
+ # ========== self
1992
+ # = =
1993
+ # = ----=----
1994
+ # ====|====== | rect2
1995
+ # | |
1996
+ # ---------
1997
+
1998
+ def intersect(self, rect2):
1999
+
2000
+ urx = self.x + self.w; lry = self.y + self.h
2001
+ urx2 = rect2.x + rect2.w; lry2 = rect2.y + rect2.h
2002
+ inter = 0
2003
+
2004
+ # X intersect
2005
+ if rect2.x &gt;= self.x and rect2.x &lt;= urx:
2006
+ inter += 1
2007
+ # Y intersect
2008
+ if rect2.y &gt;= self.y and rect2.y &lt;= lry:
2009
+ inter += 1
2010
+
2011
+ # X intersect rev
2012
+ if self.x &gt;= rect2.x and self.x &lt;= urx2:
2013
+ inter += 1
2014
+ # Y intersect rev
2015
+ if self.y &gt;= rect2.y and self.y &lt;= lry2:
2016
+ inter += 1
2017
+
2018
+ #print(&#34;inter&#34;, inter, str(self), &#34;-&gt;&#34;, str(rect2))
2019
+ return (inter &gt;= 2, self.x)
2020
+
2021
+ # I was too lazy to write it; Crappy Gdt rect kicked me to it
2022
+ def contain(self, rect2):
2023
+ #self.dump()
2024
+ #rect2.dump()
2025
+ inter = 0
2026
+ # X intersect
2027
+ if rect2.x &gt;= self.x and rect2.x + rect2.w &lt;= self.x + self.w:
2028
+ inter += 1
2029
+ # Y intersect
2030
+ if rect2.y &gt;= self.y and rect2.y + rect2.h &lt;= self.y + self.h:
2031
+ inter += 1
2032
+ #print(&#34;inter&#34;, inter)
2033
+ return (inter == 2, self.x)
2034
+
2035
+ # Convert index to values
2036
+ def __getitem__(self, key):
2037
+ if key == 0:
2038
+ return self.x
2039
+ elif key == 1:
2040
+ return self.y
2041
+ elif key == 2:
2042
+ return self.w
2043
+ elif key == 3:
2044
+ return self.h
2045
+ else:
2046
+ raise IndexError
2047
+
2048
+ def dump(self):
2049
+ return (self.x, self.y, self.w, self.h)
2050
+
2051
+ &#39;&#39;&#39;
2052
+ # This was killed in favour of self implemented Rectangle class
2053
+ def __getattr__(self, attr):
2054
+ if attr == &#34;w&#34;:
2055
+ return self.width
2056
+ elif attr == &#34;h&#34;:
2057
+ return self.height
2058
+ else:
2059
+ return super(Gdk.Rectangle, self).__getattr__(attr)
2060
+
2061
+ def __setattr__(self, attr, val):
2062
+ if attr == &#34;w&#34;:
2063
+ self.width = val
2064
+ elif attr == &#34;h&#34;:
2065
+ self.height = val
2066
+ else:
2067
+ super(Gdk.Rectangle, self).__setattr__(attr, val)
2068
+ &#39;&#39;&#39;
2069
+
2070
+ def __str__(self):
2071
+ return &#34;R: x=%d y=%d w=%d h=%d&#34; % (self.x, self.y, self.w, self.h)</code></pre>
2072
+ </details>
2073
+ <h3>Methods</h3>
2074
+ <dl>
2075
+ <dt id="pgbox.Rectangle.contain"><code class="name flex">
2076
+ <span>def <span class="ident">contain</span></span>(<span>self, rect2)</span>
2077
+ </code></dt>
2078
+ <dd>
2079
+ <div class="desc"></div>
2080
+ <details class="source">
2081
+ <summary>
2082
+ <span>Expand source code</span>
2083
+ </summary>
2084
+ <pre><code class="python">def contain(self, rect2):
2085
+ #self.dump()
2086
+ #rect2.dump()
2087
+ inter = 0
2088
+ # X intersect
2089
+ if rect2.x &gt;= self.x and rect2.x + rect2.w &lt;= self.x + self.w:
2090
+ inter += 1
2091
+ # Y intersect
2092
+ if rect2.y &gt;= self.y and rect2.y + rect2.h &lt;= self.y + self.h:
2093
+ inter += 1
2094
+ #print(&#34;inter&#34;, inter)
2095
+ return (inter == 2, self.x)</code></pre>
2096
+ </details>
2097
+ </dd>
2098
+ <dt id="pgbox.Rectangle.copy"><code class="name flex">
2099
+ <span>def <span class="ident">copy</span></span>(<span>self)</span>
2100
+ </code></dt>
2101
+ <dd>
2102
+ <div class="desc"></div>
2103
+ <details class="source">
2104
+ <summary>
2105
+ <span>Expand source code</span>
2106
+ </summary>
2107
+ <pre><code class="python">def copy(self):
2108
+ #print(&#34;rect to copy&#34;, str(self))
2109
+ #print(&#34;rect to copy&#34;, dir(self))
2110
+ nnn = Rectangle() # New Instance
2111
+ &#39;&#39;&#39;
2112
+ # Self
2113
+ for aa in dir(self):
2114
+ try:
2115
+ #nnn.__setattr__(aa, self.__getattribute__(aa))
2116
+ nnn.aa = self.__getattribute__(aa)
2117
+ #print(&#34;cp:&#34;, aa, end = &#34;&#34;)
2118
+ #if type(self.__getattribute__(aa)) == int:
2119
+ # print(&#34; -&gt; &#34;, self.__getattribute__(aa), end= &#34; &#34;)
2120
+ #print(&#34; --- &#34;, end = &#34;&#34;)
2121
+ except:
2122
+ #print(sys.exc_info())
2123
+ print(&#34;no&#34;, aa)
2124
+ pass
2125
+ &#39;&#39;&#39;
2126
+
2127
+ # Assign explictly
2128
+ nnn.x = self.x + 0
2129
+ nnn.y = self.y + 0
2130
+ nnn.w = self.w + 0
2131
+ nnn.h = self.h + 0
2132
+
2133
+ #nnn.width = self.width + 1
2134
+ #nnn.height = self.height + 1
2135
+
2136
+ #print(&#34;rect out&#34;, str(nnn))
2137
+ #print(&#34;rect out&#34;, dir(nnn))
2138
+ return nnn</code></pre>
2139
+ </details>
2140
+ </dd>
2141
+ <dt id="pgbox.Rectangle.dump"><code class="name flex">
2142
+ <span>def <span class="ident">dump</span></span>(<span>self)</span>
2143
+ </code></dt>
2144
+ <dd>
2145
+ <div class="desc"></div>
2146
+ <details class="source">
2147
+ <summary>
2148
+ <span>Expand source code</span>
2149
+ </summary>
2150
+ <pre><code class="python">def dump(self):
2151
+ return (self.x, self.y, self.w, self.h)</code></pre>
2152
+ </details>
2153
+ </dd>
2154
+ <dt id="pgbox.Rectangle.intersect"><code class="name flex">
2155
+ <span>def <span class="ident">intersect</span></span>(<span>self, rect2)</span>
2156
+ </code></dt>
2157
+ <dd>
2158
+ <div class="desc"></div>
2159
+ <details class="source">
2160
+ <summary>
2161
+ <span>Expand source code</span>
2162
+ </summary>
2163
+ <pre><code class="python">def intersect(self, rect2):
2164
+
2165
+ urx = self.x + self.w; lry = self.y + self.h
2166
+ urx2 = rect2.x + rect2.w; lry2 = rect2.y + rect2.h
2167
+ inter = 0
2168
+
2169
+ # X intersect
2170
+ if rect2.x &gt;= self.x and rect2.x &lt;= urx:
2171
+ inter += 1
2172
+ # Y intersect
2173
+ if rect2.y &gt;= self.y and rect2.y &lt;= lry:
2174
+ inter += 1
2175
+
2176
+ # X intersect rev
2177
+ if self.x &gt;= rect2.x and self.x &lt;= urx2:
2178
+ inter += 1
2179
+ # Y intersect rev
2180
+ if self.y &gt;= rect2.y and self.y &lt;= lry2:
2181
+ inter += 1
2182
+
2183
+ #print(&#34;inter&#34;, inter, str(self), &#34;-&gt;&#34;, str(rect2))
2184
+ return (inter &gt;= 2, self.x)</code></pre>
2185
+ </details>
2186
+ </dd>
2187
+ <dt id="pgbox.Rectangle.resize"><code class="name flex">
2188
+ <span>def <span class="ident">resize</span></span>(<span>self, ww, hh=0)</span>
2189
+ </code></dt>
2190
+ <dd>
2191
+ <div class="desc"></div>
2192
+ <details class="source">
2193
+ <summary>
2194
+ <span>Expand source code</span>
2195
+ </summary>
2196
+ <pre><code class="python">def resize(self, ww, hh = 0):
2197
+ if hh == 0:
2198
+ hh = ww
2199
+
2200
+ #if ww + self.w &lt;= 0 or hh + self.h &lt;= 0:
2201
+ # raise (ValuError, &#34;Cannot have negative rect size&#34;)
2202
+
2203
+ self.x -= ww/2; self.w += ww
2204
+ self.y -= hh/2; self.h += hh</code></pre>
2205
+ </details>
2206
+ </dd>
2207
+ </dl>
2208
+ </dd>
2209
+ <dt id="pgbox.xHBox"><code class="flex name class">
2210
+ <span>class <span class="ident">xHBox</span></span>
2211
+ <span>(</span><span>col=None)</span>
2212
+ </code></dt>
2213
+ <dd>
2214
+ <div class="desc"><p>:Constructors:</p>
2215
+ <p>::</p>
2216
+ <pre><code>HBox(**properties)
2217
+ new(homogeneous:bool, spacing:int) -&gt; Gtk.Widget
2218
+ </code></pre>
2219
+ <p>Initializer for a GObject based classes with support for property
2220
+ sets through the use of explicit keyword arguments.</p></div>
2221
+ <details class="source">
2222
+ <summary>
2223
+ <span>Expand source code</span>
2224
+ </summary>
2225
+ <pre><code class="python">class xHBox(Gtk.HBox):
2226
+
2227
+ def __init__(self, col = None):
2228
+ GObject.GObject.__init__(self)
2229
+ self.pad = 0
2230
+ if box_testmode:
2231
+ if not col:
2232
+ col = pgutils.randcolstr(100, 200)
2233
+ self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(col))
2234
+
2235
+ def set_padding(self, pad):
2236
+ self.pad = pad
2237
+
2238
+ def pack(self, obj, expand = False, pad = 0):
2239
+ if pad == 0:
2240
+ pad = self.pad
2241
+ self.pack_start(obj, expand, expand, pad)</code></pre>
2242
+ </details>
2243
+ <h3>Ancestors</h3>
2244
+ <ul class="hlist">
2245
+ <li>gi.repository.Gtk.HBox</li>
2246
+ <li>gi.overrides.Gtk.Box</li>
2247
+ <li>gi.repository.Gtk.Box</li>
2248
+ <li>gi.overrides.Gtk.Container</li>
2249
+ <li>gi.repository.Gtk.Container</li>
2250
+ <li>gi.overrides.Gtk.Widget</li>
2251
+ <li>gi.repository.Gtk.Widget</li>
2252
+ <li>gi.repository.GObject.InitiallyUnowned</li>
2253
+ <li>gi.overrides.GObject.Object</li>
2254
+ <li>gi.repository.GObject.Object</li>
2255
+ <li>gi._gi.GObject</li>
2256
+ <li>gi.repository.Atk.ImplementorIface</li>
2257
+ <li>gi.repository.Gtk.Buildable</li>
2258
+ <li>gi.repository.Gtk.Orientable</li>
2259
+ <li>gobject.GInterface</li>
2260
+ </ul>
2261
+ <h3>Methods</h3>
2262
+ <dl>
2263
+ <dt id="pgbox.xHBox.pack"><code class="name flex">
2264
+ <span>def <span class="ident">pack</span></span>(<span>self, obj, expand=False, pad=0)</span>
2265
+ </code></dt>
2266
+ <dd>
2267
+ <div class="desc"></div>
2268
+ <details class="source">
2269
+ <summary>
2270
+ <span>Expand source code</span>
2271
+ </summary>
2272
+ <pre><code class="python">def pack(self, obj, expand = False, pad = 0):
2273
+ if pad == 0:
2274
+ pad = self.pad
2275
+ self.pack_start(obj, expand, expand, pad)</code></pre>
2276
+ </details>
2277
+ </dd>
2278
+ <dt id="pgbox.xHBox.set_padding"><code class="name flex">
2279
+ <span>def <span class="ident">set_padding</span></span>(<span>self, pad)</span>
2280
+ </code></dt>
2281
+ <dd>
2282
+ <div class="desc"></div>
2283
+ <details class="source">
2284
+ <summary>
2285
+ <span>Expand source code</span>
2286
+ </summary>
2287
+ <pre><code class="python">def set_padding(self, pad):
2288
+ self.pad = pad</code></pre>
2289
+ </details>
2290
+ </dd>
2291
+ </dl>
2292
+ </dd>
2293
+ <dt id="pgbox.xVBox"><code class="flex name class">
2294
+ <span>class <span class="ident">xVBox</span></span>
2295
+ <span>(</span><span>col=None)</span>
2296
+ </code></dt>
2297
+ <dd>
2298
+ <div class="desc"><p>:Constructors:</p>
2299
+ <p>::</p>
2300
+ <pre><code>VBox(**properties)
2301
+ new(homogeneous:bool, spacing:int) -&gt; Gtk.Widget
2302
+ </code></pre>
2303
+ <p>Initializer for a GObject based classes with support for property
2304
+ sets through the use of explicit keyword arguments.</p></div>
2305
+ <details class="source">
2306
+ <summary>
2307
+ <span>Expand source code</span>
2308
+ </summary>
2309
+ <pre><code class="python">class xVBox(Gtk.VBox):
2310
+
2311
+ def __init__(self, col = None):
2312
+ GObject.GObject.__init__(self)
2313
+ self.pad = 0
2314
+ if box_testmode:
2315
+ if not col:
2316
+ col = pgutils.randcolstr(100, 200)
2317
+ self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(col))
2318
+
2319
+ def set_padding(self, pad):
2320
+ self.pad = pad
2321
+
2322
+ def pack(self, obj, expand = False, pad = 0):
2323
+ if pad == 0:
2324
+ pad = self.pad
2325
+ self.pack_start(obj, expand, expand, pad)</code></pre>
2326
+ </details>
2327
+ <h3>Ancestors</h3>
2328
+ <ul class="hlist">
2329
+ <li>gi.repository.Gtk.VBox</li>
2330
+ <li>gi.overrides.Gtk.Box</li>
2331
+ <li>gi.repository.Gtk.Box</li>
2332
+ <li>gi.overrides.Gtk.Container</li>
2333
+ <li>gi.repository.Gtk.Container</li>
2334
+ <li>gi.overrides.Gtk.Widget</li>
2335
+ <li>gi.repository.Gtk.Widget</li>
2336
+ <li>gi.repository.GObject.InitiallyUnowned</li>
2337
+ <li>gi.overrides.GObject.Object</li>
2338
+ <li>gi.repository.GObject.Object</li>
2339
+ <li>gi._gi.GObject</li>
2340
+ <li>gi.repository.Atk.ImplementorIface</li>
2341
+ <li>gi.repository.Gtk.Buildable</li>
2342
+ <li>gi.repository.Gtk.Orientable</li>
2343
+ <li>gobject.GInterface</li>
2344
+ </ul>
2345
+ <h3>Methods</h3>
2346
+ <dl>
2347
+ <dt id="pgbox.xVBox.pack"><code class="name flex">
2348
+ <span>def <span class="ident">pack</span></span>(<span>self, obj, expand=False, pad=0)</span>
2349
+ </code></dt>
2350
+ <dd>
2351
+ <div class="desc"></div>
2352
+ <details class="source">
2353
+ <summary>
2354
+ <span>Expand source code</span>
2355
+ </summary>
2356
+ <pre><code class="python">def pack(self, obj, expand = False, pad = 0):
2357
+ if pad == 0:
2358
+ pad = self.pad
2359
+ self.pack_start(obj, expand, expand, pad)</code></pre>
2360
+ </details>
2361
+ </dd>
2362
+ <dt id="pgbox.xVBox.set_padding"><code class="name flex">
2363
+ <span>def <span class="ident">set_padding</span></span>(<span>self, pad)</span>
2364
+ </code></dt>
2365
+ <dd>
2366
+ <div class="desc"></div>
2367
+ <details class="source">
2368
+ <summary>
2369
+ <span>Expand source code</span>
2370
+ </summary>
2371
+ <pre><code class="python">def set_padding(self, pad):
2372
+ self.pad = pad</code></pre>
2373
+ </details>
2374
+ </dd>
2375
+ </dl>
2376
+ </dd>
2377
+ </dl>
2378
+ </section>
2379
+ </article>
2380
+ <nav id="sidebar">
2381
+ <h1>Index</h1>
2382
+ <div class="toc">
2383
+ <ul></ul>
2384
+ </div>
2385
+ <ul id="index">
2386
+ <li><h3><a href="#header-functions">Functions</a></h3>
2387
+ <ul class="">
2388
+ <li><code><a title="pgbox.str2rgb" href="#pgbox.str2rgb">str2rgb</a></code></li>
2389
+ <li><code><a title="pgbox.str2rgba" href="#pgbox.str2rgba">str2rgba</a></code></li>
2390
+ </ul>
2391
+ </li>
2392
+ <li><h3><a href="#header-classes">Classes</a></h3>
2393
+ <ul>
2394
+ <li>
2395
+ <h4><code><a title="pgbox.ColorCombo" href="#pgbox.ColorCombo">ColorCombo</a></code></h4>
2396
+ <ul class="two-column">
2397
+ <li><code><a title="pgbox.ColorCombo.combo_changed" href="#pgbox.ColorCombo.combo_changed">combo_changed</a></code></li>
2398
+ <li><code><a title="pgbox.ColorCombo.combo_focus" href="#pgbox.ColorCombo.combo_focus">combo_focus</a></code></li>
2399
+ <li><code><a title="pgbox.ColorCombo.delall" href="#pgbox.ColorCombo.delall">delall</a></code></li>
2400
+ <li><code><a title="pgbox.ColorCombo.printdetails" href="#pgbox.ColorCombo.printdetails">printdetails</a></code></li>
2401
+ <li><code><a title="pgbox.ColorCombo.sel_first" href="#pgbox.ColorCombo.sel_first">sel_first</a></code></li>
2402
+ <li><code><a title="pgbox.ColorCombo.sel_text" href="#pgbox.ColorCombo.sel_text">sel_text</a></code></li>
2403
+ </ul>
2404
+ </li>
2405
+ <li>
2406
+ <h4><code><a title="pgbox.ColorRenderer" href="#pgbox.ColorRenderer">ColorRenderer</a></code></h4>
2407
+ <ul class="">
2408
+ <li><code><a title="pgbox.ColorRenderer.do_get_property" href="#pgbox.ColorRenderer.do_get_property">do_get_property</a></code></li>
2409
+ <li><code><a title="pgbox.ColorRenderer.do_get_size" href="#pgbox.ColorRenderer.do_get_size">do_get_size</a></code></li>
2410
+ <li><code><a title="pgbox.ColorRenderer.do_render" href="#pgbox.ColorRenderer.do_render">do_render</a></code></li>
2411
+ <li><code><a title="pgbox.ColorRenderer.do_set_property" href="#pgbox.ColorRenderer.do_set_property">do_set_property</a></code></li>
2412
+ </ul>
2413
+ </li>
2414
+ <li>
2415
+ <h4><code><a title="pgbox.ComboBox" href="#pgbox.ComboBox">ComboBox</a></code></h4>
2416
+ <ul class="">
2417
+ <li><code><a title="pgbox.ComboBox.combo_changed" href="#pgbox.ComboBox.combo_changed">combo_changed</a></code></li>
2418
+ <li><code><a title="pgbox.ComboBox.delall" href="#pgbox.ComboBox.delall">delall</a></code></li>
2419
+ <li><code><a title="pgbox.ComboBox.sel_first" href="#pgbox.ComboBox.sel_first">sel_first</a></code></li>
2420
+ <li><code><a title="pgbox.ComboBox.sel_text" href="#pgbox.ComboBox.sel_text">sel_text</a></code></li>
2421
+ </ul>
2422
+ </li>
2423
+ <li>
2424
+ <h4><code><a title="pgbox.ListBox" href="#pgbox.ListBox">ListBox</a></code></h4>
2425
+ <ul class="two-column">
2426
+ <li><code><a title="pgbox.ListBox.append" href="#pgbox.ListBox.append">append</a></code></li>
2427
+ <li><code><a title="pgbox.ListBox.clear" href="#pgbox.ListBox.clear">clear</a></code></li>
2428
+ <li><code><a title="pgbox.ListBox.get_curridx" href="#pgbox.ListBox.get_curridx">get_curridx</a></code></li>
2429
+ <li><code><a title="pgbox.ListBox.get_item" href="#pgbox.ListBox.get_item">get_item</a></code></li>
2430
+ <li><code><a title="pgbox.ListBox.get_size" href="#pgbox.ListBox.get_size">get_size</a></code></li>
2431
+ <li><code><a title="pgbox.ListBox.get_text" href="#pgbox.ListBox.get_text">get_text</a></code></li>
2432
+ <li><code><a title="pgbox.ListBox.select" href="#pgbox.ListBox.select">select</a></code></li>
2433
+ <li><code><a title="pgbox.ListBox.set_callback" href="#pgbox.ListBox.set_callback">set_callback</a></code></li>
2434
+ <li><code><a title="pgbox.ListBox.tree_sel" href="#pgbox.ListBox.tree_sel">tree_sel</a></code></li>
2435
+ </ul>
2436
+ </li>
2437
+ <li>
2438
+ <h4><code><a title="pgbox.Rectangle" href="#pgbox.Rectangle">Rectangle</a></code></h4>
2439
+ <ul class="">
2440
+ <li><code><a title="pgbox.Rectangle.contain" href="#pgbox.Rectangle.contain">contain</a></code></li>
2441
+ <li><code><a title="pgbox.Rectangle.copy" href="#pgbox.Rectangle.copy">copy</a></code></li>
2442
+ <li><code><a title="pgbox.Rectangle.dump" href="#pgbox.Rectangle.dump">dump</a></code></li>
2443
+ <li><code><a title="pgbox.Rectangle.intersect" href="#pgbox.Rectangle.intersect">intersect</a></code></li>
2444
+ <li><code><a title="pgbox.Rectangle.resize" href="#pgbox.Rectangle.resize">resize</a></code></li>
2445
+ </ul>
2446
+ </li>
2447
+ <li>
2448
+ <h4><code><a title="pgbox.xHBox" href="#pgbox.xHBox">xHBox</a></code></h4>
2449
+ <ul class="">
2450
+ <li><code><a title="pgbox.xHBox.pack" href="#pgbox.xHBox.pack">pack</a></code></li>
2451
+ <li><code><a title="pgbox.xHBox.set_padding" href="#pgbox.xHBox.set_padding">set_padding</a></code></li>
2452
+ </ul>
2453
+ </li>
2454
+ <li>
2455
+ <h4><code><a title="pgbox.xVBox" href="#pgbox.xVBox">xVBox</a></code></h4>
2456
+ <ul class="">
2457
+ <li><code><a title="pgbox.xVBox.pack" href="#pgbox.xVBox.pack">pack</a></code></li>
2458
+ <li><code><a title="pgbox.xVBox.set_padding" href="#pgbox.xVBox.set_padding">set_padding</a></code></li>
2459
+ </ul>
2460
+ </li>
2461
+ </ul>
2462
+ </li>
2463
+ </ul>
2464
+ </nav>
2465
+ </main>
2466
+ <footer id="footer">
2467
+ <p>Generated by <a href="https://pdoc3.github.io/pdoc" title="pdoc: Python API documentation generator"><cite>pdoc</cite> 0.10.0</a>.</p>
2468
+ </footer>
2469
+ </body>
2470
+ </html>