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.
- pyvguicom/browsewin.py +10 -11
- pyvguicom/docs/__index__.py +0 -0
- pyvguicom/docs/browsewin.html +956 -0
- pyvguicom/docs/htmledit.html +903 -0
- pyvguicom/docs/pgbox.html +2470 -0
- pyvguicom/docs/pgbutt.html +727 -0
- pyvguicom/docs/pgentry.html +1024 -0
- pyvguicom/docs/pggui.html +5476 -0
- pyvguicom/docs/pgsel.html +1539 -0
- pyvguicom/docs/pgsimp.html +1048 -0
- pyvguicom/docs/pgtextview.html +2421 -0
- pyvguicom/docs/pgutils.html +2664 -0
- pyvguicom/docs/pgwkit.html +2277 -0
- pyvguicom/docs/sutil.html +907 -0
- pyvguicom/pgentry.py +75 -9
- pyvguicom/pggui.py +191 -92
- pyvguicom/pgsel.py +9 -7
- pyvguicom/pgtests.py +128 -0
- pyvguicom/pgutils.py +42 -394
- pyvguicom/pgwkit.py +36 -27
- pyvguicom/testbutt.py +1 -1
- pyvguicom/testcust.py +1 -1
- pyvguicom/testentry.py +19 -7
- pyvguicom/testgui.py +125 -0
- pyvguicom/testlettsel.py +1 -1
- pyvguicom/testmsgs.py +142 -0
- pyvguicom/testnums.py +1 -1
- pyvguicom/testsimple.py +4 -3
- pyvguicom/testtests.py +79 -0
- pyvguicom/testtextv.py +2 -2
- pyvguicom/testutils.py +139 -0
- {pyvguicom-1.0.1.dist-info → pyvguicom-1.1.2.dist-info}/METADATA +8 -11
- pyvguicom-1.1.2.dist-info/RECORD +45 -0
- pyvguicom-1.0.1.dist-info/RECORD +0 -27
- {pyvguicom-1.0.1.dist-info → pyvguicom-1.1.2.dist-info}/WHEEL +0 -0
- {pyvguicom-1.0.1.dist-info → pyvguicom-1.1.2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,727 @@
|
|
|
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>pgbutt 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>pgbutt</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/env python
|
|
30
|
+
|
|
31
|
+
# Drawing operations done here
|
|
32
|
+
|
|
33
|
+
from __future__ import absolute_import
|
|
34
|
+
|
|
35
|
+
import signal, os, time, sys, codecs
|
|
36
|
+
|
|
37
|
+
import gi
|
|
38
|
+
gi.require_version("Gtk", "3.0")
|
|
39
|
+
from gi.repository import Gtk
|
|
40
|
+
from gi.repository import Gdk
|
|
41
|
+
from gi.repository import GLib
|
|
42
|
+
from gi.repository import GObject
|
|
43
|
+
from gi.repository import Pango
|
|
44
|
+
from gi.repository import GObject
|
|
45
|
+
|
|
46
|
+
gi.require_version('PangoCairo', '1.0')
|
|
47
|
+
from gi.repository import PangoCairo
|
|
48
|
+
|
|
49
|
+
import cairo
|
|
50
|
+
from pgutils import *
|
|
51
|
+
|
|
52
|
+
class smallbutt(Gtk.EventBox):
|
|
53
|
+
|
|
54
|
+
__gsignals__ = {
|
|
55
|
+
#"activate": (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, () ),
|
|
56
|
+
"pressed": (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, () ),
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
def __init__(self, labx, eventx = None, tooltip = None, *args, **kwds):
|
|
60
|
+
super().__init__(*args, **kwds)
|
|
61
|
+
|
|
62
|
+
self.state = 0; self.stat2 = 0
|
|
63
|
+
self.labx = labx; self.orgtext = ""
|
|
64
|
+
self.accel = ""; self.agroup = None
|
|
65
|
+
self.mark = -1;
|
|
66
|
+
self.mnem = self.omnem = 0
|
|
67
|
+
self.lab = Gtk.Label.new_with_mnemonic(labx)
|
|
68
|
+
self.add(self.lab)
|
|
69
|
+
self.set_above_child(True)
|
|
70
|
+
|
|
71
|
+
self.arrow = Gdk.Cursor(Gdk.CursorType.ARROW)
|
|
72
|
+
self.hand = Gdk.Cursor(Gdk.CursorType.HAND1)
|
|
73
|
+
self.down = 0
|
|
74
|
+
|
|
75
|
+
cnt = 0;
|
|
76
|
+
# Process ACCEL Key
|
|
77
|
+
for aa in labx:
|
|
78
|
+
if aa == "_":
|
|
79
|
+
self.mark = cnt
|
|
80
|
+
else:
|
|
81
|
+
if self.mark != -1 and self.accel != "":
|
|
82
|
+
self.accel = aa
|
|
83
|
+
self.orgtext += aa
|
|
84
|
+
cnt += 1
|
|
85
|
+
|
|
86
|
+
#self.set_mnemonic_widget(self)
|
|
87
|
+
#self.set_use_underline(True)
|
|
88
|
+
if tooltip:
|
|
89
|
+
self.lab.set_tooltip_text(tooltip)
|
|
90
|
+
|
|
91
|
+
if eventx:
|
|
92
|
+
self.connect("pressed", eventx)
|
|
93
|
+
|
|
94
|
+
self.set_can_focus(True)
|
|
95
|
+
self.set_can_default(True)
|
|
96
|
+
self.set_sensitive(True)
|
|
97
|
+
|
|
98
|
+
font = "Sans 10"
|
|
99
|
+
self.override_font(Pango.FontDescription(font))
|
|
100
|
+
|
|
101
|
+
#self.set_alignment(0.5, 0.5)
|
|
102
|
+
#self.set_margin_left(0)
|
|
103
|
+
#self.set_margin_right(0)
|
|
104
|
+
#self.set_margin_top(0)
|
|
105
|
+
#self.set_margin_bottom(0)
|
|
106
|
+
|
|
107
|
+
self.layoutx = self.create_pango_layout("a")
|
|
108
|
+
self.layoutx.set_font_description(Pango.FontDescription(font))
|
|
109
|
+
self.layoutx.set_text(self.orgtext, self.mark)
|
|
110
|
+
|
|
111
|
+
(self.charx, self.chary) = self.layoutx.get_extents()
|
|
112
|
+
self.charx.width /= Pango.SCALE; self.charx.height /= Pango.SCALE;
|
|
113
|
+
self.chary.width /= Pango.SCALE; self.chary.height /= Pango.SCALE;
|
|
114
|
+
|
|
115
|
+
self.layout = self.create_pango_layout("a")
|
|
116
|
+
self.layout.set_font_description(Pango.FontDescription(font))
|
|
117
|
+
self.layout.set_text(self.orgtext, len(self.orgtext))
|
|
118
|
+
(pr, lr) = self.layout.get_extents()
|
|
119
|
+
self.ww = lr.width / Pango.SCALE; self.hh = lr.height / Pango.SCALE;
|
|
120
|
+
#print("ww", self.ww, "hh", self.hh)
|
|
121
|
+
|
|
122
|
+
self.set_size_request(self.ww, self.hh)
|
|
123
|
+
self.hand_cursor = Gdk.Cursor(Gdk.CursorType.HAND2)
|
|
124
|
+
|
|
125
|
+
self.set_events(Gdk.EventMask.ALL_EVENTS_MASK)
|
|
126
|
+
|
|
127
|
+
self.connect("enter_notify_event", self.enter_label)
|
|
128
|
+
self.connect("leave_notify_event", self.leave_label)
|
|
129
|
+
self.connect("mnemonic-activate", self.mactivate)
|
|
130
|
+
self.connect("button-release-event", self.buttrel)
|
|
131
|
+
self.connect("button-press-event", self.buttpress)
|
|
132
|
+
self.connect("key-release-event", self.keyrel)
|
|
133
|
+
self.connect("key-press-event", self.keypress)
|
|
134
|
+
|
|
135
|
+
self.show_all()
|
|
136
|
+
GLib.timeout_add(1000, self.stattime, self, 0)
|
|
137
|
+
|
|
138
|
+
def keyrel(self, *args):
|
|
139
|
+
#print("keyrel")
|
|
140
|
+
if args[1].keyval == Gdk.KEY_space or args[1].keyval == Gdk.KEY_Return :
|
|
141
|
+
self.down = 0
|
|
142
|
+
self.queue_draw()
|
|
143
|
+
self.emit('pressed')
|
|
144
|
+
|
|
145
|
+
def keypress(self, *args):
|
|
146
|
+
#print("keypress")
|
|
147
|
+
if args[1].keyval == Gdk.KEY_space or args[1].keyval == Gdk.KEY_Return :
|
|
148
|
+
self.down = 1
|
|
149
|
+
self.queue_draw()
|
|
150
|
+
|
|
151
|
+
def buttrel(self, *args):
|
|
152
|
+
#print("buttrel")
|
|
153
|
+
self.down = 0
|
|
154
|
+
self.queue_draw()
|
|
155
|
+
self.emit('pressed')
|
|
156
|
+
|
|
157
|
+
def buttpress(self, *args):
|
|
158
|
+
# print("buttpress")
|
|
159
|
+
self.down = 1
|
|
160
|
+
self.queue_draw()
|
|
161
|
+
|
|
162
|
+
def mactivate(self):
|
|
163
|
+
print("mactivate")
|
|
164
|
+
|
|
165
|
+
def stattime(self, arg2, arg3):
|
|
166
|
+
|
|
167
|
+
# Test if mnemonic key is down
|
|
168
|
+
kmap = Gdk.Keymap().get_default()
|
|
169
|
+
state = kmap.get_modifier_state()
|
|
170
|
+
#print("mods", state)
|
|
171
|
+
if state == Gdk.ModifierType.MOD1_MASK:
|
|
172
|
+
self.mnem = True
|
|
173
|
+
else:
|
|
174
|
+
self.mnem = False
|
|
175
|
+
|
|
176
|
+
if self.omnem != self.mnem:
|
|
177
|
+
self.omnem = self.mnem
|
|
178
|
+
#print("changed to", self.mnem)
|
|
179
|
+
self.queue_draw()
|
|
180
|
+
|
|
181
|
+
#GLib.timeout_add(1000, self.stattime, self, 0)
|
|
182
|
+
return True
|
|
183
|
+
|
|
184
|
+
def mactivate(self, *arg):
|
|
185
|
+
#print("mactivate", arg)
|
|
186
|
+
self.emit('pressed')
|
|
187
|
+
return True
|
|
188
|
+
|
|
189
|
+
def enter_label(self, arg, arg2):
|
|
190
|
+
#print("Enter")
|
|
191
|
+
self.get_window().set_cursor(self.hand_cursor)
|
|
192
|
+
self.stat2 = 1
|
|
193
|
+
self.queue_draw()
|
|
194
|
+
|
|
195
|
+
def leave_label(self, arg, arg2):
|
|
196
|
+
#print("Leave")
|
|
197
|
+
self.get_window().set_cursor()
|
|
198
|
+
self.stat2 = 0
|
|
199
|
+
self.queue_draw()
|
|
200
|
+
|
|
201
|
+
def do_draw (self, cr):
|
|
202
|
+
|
|
203
|
+
# paint background
|
|
204
|
+
if self.stat2:
|
|
205
|
+
bg_color2 = self.get_style_context().get_background_color(Gtk.StateFlags.NORMAL)
|
|
206
|
+
bg_color = Gdk.RGBA(.9, .9, .9)
|
|
207
|
+
else:
|
|
208
|
+
if 0: #self.has_focus():
|
|
209
|
+
bg_color = Gdk.RGBA(.75, .75, .75)
|
|
210
|
+
else:
|
|
211
|
+
bg_color = self.get_style_context().get_background_color(Gtk.StateFlags.NORMAL)
|
|
212
|
+
|
|
213
|
+
cr.set_source_rgba(*list(bg_color))
|
|
214
|
+
|
|
215
|
+
cr.rectangle(1,1, self.ww-1, self.hh-1)
|
|
216
|
+
cr.clip()
|
|
217
|
+
cr.paint()
|
|
218
|
+
|
|
219
|
+
if 0: #self.stat2:
|
|
220
|
+
fg_color = self.get_style_context().get_color(Gtk.StateFlags.SELECTED)
|
|
221
|
+
else:
|
|
222
|
+
fg_color = self.get_style_context().get_color(Gtk.StateFlags.NORMAL)
|
|
223
|
+
|
|
224
|
+
cr.set_source_rgba(*list(fg_color));
|
|
225
|
+
cr.move_to(0, 0)
|
|
226
|
+
PangoCairo.show_layout(cr, self.layout)
|
|
227
|
+
if self.down:
|
|
228
|
+
cr.move_to(1, 1)
|
|
229
|
+
PangoCairo.show_layout(cr, self.layout)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
if self.mnem:
|
|
233
|
+
#print("corr", self.chary.width, self.chary.height)
|
|
234
|
+
cr.move_to( self.chary.width, self.chary.height-2)
|
|
235
|
+
cr.line_to( self.chary.width + 8, self.chary.height-2)
|
|
236
|
+
cr.stroke()
|
|
237
|
+
|
|
238
|
+
if self.has_focus():
|
|
239
|
+
|
|
240
|
+
#print("focus")
|
|
241
|
+
cr.set_dash([.5, .9])
|
|
242
|
+
cr.move_to( 1, 1)
|
|
243
|
+
cr.line_to( self.ww-1, 1)
|
|
244
|
+
cr.line_to( self.ww-1, self.hh-1)
|
|
245
|
+
cr.line_to( 1, self.hh-1)
|
|
246
|
+
cr.line_to( 1, 1)
|
|
247
|
+
|
|
248
|
+
cr.stroke()
|
|
249
|
+
|
|
250
|
+
# EOF</code></pre>
|
|
251
|
+
</details>
|
|
252
|
+
</section>
|
|
253
|
+
<section>
|
|
254
|
+
</section>
|
|
255
|
+
<section>
|
|
256
|
+
</section>
|
|
257
|
+
<section>
|
|
258
|
+
</section>
|
|
259
|
+
<section>
|
|
260
|
+
<h2 class="section-title" id="header-classes">Classes</h2>
|
|
261
|
+
<dl>
|
|
262
|
+
<dt id="pgbutt.smallbutt"><code class="flex name class">
|
|
263
|
+
<span>class <span class="ident">smallbutt</span></span>
|
|
264
|
+
<span>(</span><span>labx, eventx=None, tooltip=None, *args, **kwds)</span>
|
|
265
|
+
</code></dt>
|
|
266
|
+
<dd>
|
|
267
|
+
<div class="desc"><p>:Constructors:</p>
|
|
268
|
+
<p>::</p>
|
|
269
|
+
<pre><code>EventBox(**properties)
|
|
270
|
+
new() -> Gtk.Widget
|
|
271
|
+
</code></pre></div>
|
|
272
|
+
<details class="source">
|
|
273
|
+
<summary>
|
|
274
|
+
<span>Expand source code</span>
|
|
275
|
+
</summary>
|
|
276
|
+
<pre><code class="python">class smallbutt(Gtk.EventBox):
|
|
277
|
+
|
|
278
|
+
__gsignals__ = {
|
|
279
|
+
#"activate": (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, () ),
|
|
280
|
+
"pressed": (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, () ),
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
def __init__(self, labx, eventx = None, tooltip = None, *args, **kwds):
|
|
284
|
+
super().__init__(*args, **kwds)
|
|
285
|
+
|
|
286
|
+
self.state = 0; self.stat2 = 0
|
|
287
|
+
self.labx = labx; self.orgtext = ""
|
|
288
|
+
self.accel = ""; self.agroup = None
|
|
289
|
+
self.mark = -1;
|
|
290
|
+
self.mnem = self.omnem = 0
|
|
291
|
+
self.lab = Gtk.Label.new_with_mnemonic(labx)
|
|
292
|
+
self.add(self.lab)
|
|
293
|
+
self.set_above_child(True)
|
|
294
|
+
|
|
295
|
+
self.arrow = Gdk.Cursor(Gdk.CursorType.ARROW)
|
|
296
|
+
self.hand = Gdk.Cursor(Gdk.CursorType.HAND1)
|
|
297
|
+
self.down = 0
|
|
298
|
+
|
|
299
|
+
cnt = 0;
|
|
300
|
+
# Process ACCEL Key
|
|
301
|
+
for aa in labx:
|
|
302
|
+
if aa == "_":
|
|
303
|
+
self.mark = cnt
|
|
304
|
+
else:
|
|
305
|
+
if self.mark != -1 and self.accel != "":
|
|
306
|
+
self.accel = aa
|
|
307
|
+
self.orgtext += aa
|
|
308
|
+
cnt += 1
|
|
309
|
+
|
|
310
|
+
#self.set_mnemonic_widget(self)
|
|
311
|
+
#self.set_use_underline(True)
|
|
312
|
+
if tooltip:
|
|
313
|
+
self.lab.set_tooltip_text(tooltip)
|
|
314
|
+
|
|
315
|
+
if eventx:
|
|
316
|
+
self.connect("pressed", eventx)
|
|
317
|
+
|
|
318
|
+
self.set_can_focus(True)
|
|
319
|
+
self.set_can_default(True)
|
|
320
|
+
self.set_sensitive(True)
|
|
321
|
+
|
|
322
|
+
font = "Sans 10"
|
|
323
|
+
self.override_font(Pango.FontDescription(font))
|
|
324
|
+
|
|
325
|
+
#self.set_alignment(0.5, 0.5)
|
|
326
|
+
#self.set_margin_left(0)
|
|
327
|
+
#self.set_margin_right(0)
|
|
328
|
+
#self.set_margin_top(0)
|
|
329
|
+
#self.set_margin_bottom(0)
|
|
330
|
+
|
|
331
|
+
self.layoutx = self.create_pango_layout("a")
|
|
332
|
+
self.layoutx.set_font_description(Pango.FontDescription(font))
|
|
333
|
+
self.layoutx.set_text(self.orgtext, self.mark)
|
|
334
|
+
|
|
335
|
+
(self.charx, self.chary) = self.layoutx.get_extents()
|
|
336
|
+
self.charx.width /= Pango.SCALE; self.charx.height /= Pango.SCALE;
|
|
337
|
+
self.chary.width /= Pango.SCALE; self.chary.height /= Pango.SCALE;
|
|
338
|
+
|
|
339
|
+
self.layout = self.create_pango_layout("a")
|
|
340
|
+
self.layout.set_font_description(Pango.FontDescription(font))
|
|
341
|
+
self.layout.set_text(self.orgtext, len(self.orgtext))
|
|
342
|
+
(pr, lr) = self.layout.get_extents()
|
|
343
|
+
self.ww = lr.width / Pango.SCALE; self.hh = lr.height / Pango.SCALE;
|
|
344
|
+
#print("ww", self.ww, "hh", self.hh)
|
|
345
|
+
|
|
346
|
+
self.set_size_request(self.ww, self.hh)
|
|
347
|
+
self.hand_cursor = Gdk.Cursor(Gdk.CursorType.HAND2)
|
|
348
|
+
|
|
349
|
+
self.set_events(Gdk.EventMask.ALL_EVENTS_MASK)
|
|
350
|
+
|
|
351
|
+
self.connect("enter_notify_event", self.enter_label)
|
|
352
|
+
self.connect("leave_notify_event", self.leave_label)
|
|
353
|
+
self.connect("mnemonic-activate", self.mactivate)
|
|
354
|
+
self.connect("button-release-event", self.buttrel)
|
|
355
|
+
self.connect("button-press-event", self.buttpress)
|
|
356
|
+
self.connect("key-release-event", self.keyrel)
|
|
357
|
+
self.connect("key-press-event", self.keypress)
|
|
358
|
+
|
|
359
|
+
self.show_all()
|
|
360
|
+
GLib.timeout_add(1000, self.stattime, self, 0)
|
|
361
|
+
|
|
362
|
+
def keyrel(self, *args):
|
|
363
|
+
#print("keyrel")
|
|
364
|
+
if args[1].keyval == Gdk.KEY_space or args[1].keyval == Gdk.KEY_Return :
|
|
365
|
+
self.down = 0
|
|
366
|
+
self.queue_draw()
|
|
367
|
+
self.emit('pressed')
|
|
368
|
+
|
|
369
|
+
def keypress(self, *args):
|
|
370
|
+
#print("keypress")
|
|
371
|
+
if args[1].keyval == Gdk.KEY_space or args[1].keyval == Gdk.KEY_Return :
|
|
372
|
+
self.down = 1
|
|
373
|
+
self.queue_draw()
|
|
374
|
+
|
|
375
|
+
def buttrel(self, *args):
|
|
376
|
+
#print("buttrel")
|
|
377
|
+
self.down = 0
|
|
378
|
+
self.queue_draw()
|
|
379
|
+
self.emit('pressed')
|
|
380
|
+
|
|
381
|
+
def buttpress(self, *args):
|
|
382
|
+
# print("buttpress")
|
|
383
|
+
self.down = 1
|
|
384
|
+
self.queue_draw()
|
|
385
|
+
|
|
386
|
+
def mactivate(self):
|
|
387
|
+
print("mactivate")
|
|
388
|
+
|
|
389
|
+
def stattime(self, arg2, arg3):
|
|
390
|
+
|
|
391
|
+
# Test if mnemonic key is down
|
|
392
|
+
kmap = Gdk.Keymap().get_default()
|
|
393
|
+
state = kmap.get_modifier_state()
|
|
394
|
+
#print("mods", state)
|
|
395
|
+
if state == Gdk.ModifierType.MOD1_MASK:
|
|
396
|
+
self.mnem = True
|
|
397
|
+
else:
|
|
398
|
+
self.mnem = False
|
|
399
|
+
|
|
400
|
+
if self.omnem != self.mnem:
|
|
401
|
+
self.omnem = self.mnem
|
|
402
|
+
#print("changed to", self.mnem)
|
|
403
|
+
self.queue_draw()
|
|
404
|
+
|
|
405
|
+
#GLib.timeout_add(1000, self.stattime, self, 0)
|
|
406
|
+
return True
|
|
407
|
+
|
|
408
|
+
def mactivate(self, *arg):
|
|
409
|
+
#print("mactivate", arg)
|
|
410
|
+
self.emit('pressed')
|
|
411
|
+
return True
|
|
412
|
+
|
|
413
|
+
def enter_label(self, arg, arg2):
|
|
414
|
+
#print("Enter")
|
|
415
|
+
self.get_window().set_cursor(self.hand_cursor)
|
|
416
|
+
self.stat2 = 1
|
|
417
|
+
self.queue_draw()
|
|
418
|
+
|
|
419
|
+
def leave_label(self, arg, arg2):
|
|
420
|
+
#print("Leave")
|
|
421
|
+
self.get_window().set_cursor()
|
|
422
|
+
self.stat2 = 0
|
|
423
|
+
self.queue_draw()
|
|
424
|
+
|
|
425
|
+
def do_draw (self, cr):
|
|
426
|
+
|
|
427
|
+
# paint background
|
|
428
|
+
if self.stat2:
|
|
429
|
+
bg_color2 = self.get_style_context().get_background_color(Gtk.StateFlags.NORMAL)
|
|
430
|
+
bg_color = Gdk.RGBA(.9, .9, .9)
|
|
431
|
+
else:
|
|
432
|
+
if 0: #self.has_focus():
|
|
433
|
+
bg_color = Gdk.RGBA(.75, .75, .75)
|
|
434
|
+
else:
|
|
435
|
+
bg_color = self.get_style_context().get_background_color(Gtk.StateFlags.NORMAL)
|
|
436
|
+
|
|
437
|
+
cr.set_source_rgba(*list(bg_color))
|
|
438
|
+
|
|
439
|
+
cr.rectangle(1,1, self.ww-1, self.hh-1)
|
|
440
|
+
cr.clip()
|
|
441
|
+
cr.paint()
|
|
442
|
+
|
|
443
|
+
if 0: #self.stat2:
|
|
444
|
+
fg_color = self.get_style_context().get_color(Gtk.StateFlags.SELECTED)
|
|
445
|
+
else:
|
|
446
|
+
fg_color = self.get_style_context().get_color(Gtk.StateFlags.NORMAL)
|
|
447
|
+
|
|
448
|
+
cr.set_source_rgba(*list(fg_color));
|
|
449
|
+
cr.move_to(0, 0)
|
|
450
|
+
PangoCairo.show_layout(cr, self.layout)
|
|
451
|
+
if self.down:
|
|
452
|
+
cr.move_to(1, 1)
|
|
453
|
+
PangoCairo.show_layout(cr, self.layout)
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
if self.mnem:
|
|
457
|
+
#print("corr", self.chary.width, self.chary.height)
|
|
458
|
+
cr.move_to( self.chary.width, self.chary.height-2)
|
|
459
|
+
cr.line_to( self.chary.width + 8, self.chary.height-2)
|
|
460
|
+
cr.stroke()
|
|
461
|
+
|
|
462
|
+
if self.has_focus():
|
|
463
|
+
|
|
464
|
+
#print("focus")
|
|
465
|
+
cr.set_dash([.5, .9])
|
|
466
|
+
cr.move_to( 1, 1)
|
|
467
|
+
cr.line_to( self.ww-1, 1)
|
|
468
|
+
cr.line_to( self.ww-1, self.hh-1)
|
|
469
|
+
cr.line_to( 1, self.hh-1)
|
|
470
|
+
cr.line_to( 1, 1)
|
|
471
|
+
|
|
472
|
+
cr.stroke()</code></pre>
|
|
473
|
+
</details>
|
|
474
|
+
<h3>Ancestors</h3>
|
|
475
|
+
<ul class="hlist">
|
|
476
|
+
<li>gi.repository.Gtk.EventBox</li>
|
|
477
|
+
<li>gi.repository.Gtk.Bin</li>
|
|
478
|
+
<li>gi.overrides.Gtk.Container</li>
|
|
479
|
+
<li>gi.repository.Gtk.Container</li>
|
|
480
|
+
<li>gi.overrides.Gtk.Widget</li>
|
|
481
|
+
<li>gi.repository.Gtk.Widget</li>
|
|
482
|
+
<li>gi.repository.GObject.InitiallyUnowned</li>
|
|
483
|
+
<li>gi.overrides.GObject.Object</li>
|
|
484
|
+
<li>gi.repository.GObject.Object</li>
|
|
485
|
+
<li>gi._gi.GObject</li>
|
|
486
|
+
<li>gi.repository.Atk.ImplementorIface</li>
|
|
487
|
+
<li>gi.repository.Gtk.Buildable</li>
|
|
488
|
+
<li>gobject.GInterface</li>
|
|
489
|
+
</ul>
|
|
490
|
+
<h3>Methods</h3>
|
|
491
|
+
<dl>
|
|
492
|
+
<dt id="pgbutt.smallbutt.buttpress"><code class="name flex">
|
|
493
|
+
<span>def <span class="ident">buttpress</span></span>(<span>self, *args)</span>
|
|
494
|
+
</code></dt>
|
|
495
|
+
<dd>
|
|
496
|
+
<div class="desc"></div>
|
|
497
|
+
<details class="source">
|
|
498
|
+
<summary>
|
|
499
|
+
<span>Expand source code</span>
|
|
500
|
+
</summary>
|
|
501
|
+
<pre><code class="python">def buttpress(self, *args):
|
|
502
|
+
# print("buttpress")
|
|
503
|
+
self.down = 1
|
|
504
|
+
self.queue_draw()</code></pre>
|
|
505
|
+
</details>
|
|
506
|
+
</dd>
|
|
507
|
+
<dt id="pgbutt.smallbutt.buttrel"><code class="name flex">
|
|
508
|
+
<span>def <span class="ident">buttrel</span></span>(<span>self, *args)</span>
|
|
509
|
+
</code></dt>
|
|
510
|
+
<dd>
|
|
511
|
+
<div class="desc"></div>
|
|
512
|
+
<details class="source">
|
|
513
|
+
<summary>
|
|
514
|
+
<span>Expand source code</span>
|
|
515
|
+
</summary>
|
|
516
|
+
<pre><code class="python">def buttrel(self, *args):
|
|
517
|
+
#print("buttrel")
|
|
518
|
+
self.down = 0
|
|
519
|
+
self.queue_draw()
|
|
520
|
+
self.emit('pressed')</code></pre>
|
|
521
|
+
</details>
|
|
522
|
+
</dd>
|
|
523
|
+
<dt id="pgbutt.smallbutt.do_draw"><code class="name flex">
|
|
524
|
+
<span>def <span class="ident">do_draw</span></span>(<span>self, cr)</span>
|
|
525
|
+
</code></dt>
|
|
526
|
+
<dd>
|
|
527
|
+
<div class="desc"><p>draw(self, cr:cairo.Context) -> bool</p></div>
|
|
528
|
+
<details class="source">
|
|
529
|
+
<summary>
|
|
530
|
+
<span>Expand source code</span>
|
|
531
|
+
</summary>
|
|
532
|
+
<pre><code class="python">def do_draw (self, cr):
|
|
533
|
+
|
|
534
|
+
# paint background
|
|
535
|
+
if self.stat2:
|
|
536
|
+
bg_color2 = self.get_style_context().get_background_color(Gtk.StateFlags.NORMAL)
|
|
537
|
+
bg_color = Gdk.RGBA(.9, .9, .9)
|
|
538
|
+
else:
|
|
539
|
+
if 0: #self.has_focus():
|
|
540
|
+
bg_color = Gdk.RGBA(.75, .75, .75)
|
|
541
|
+
else:
|
|
542
|
+
bg_color = self.get_style_context().get_background_color(Gtk.StateFlags.NORMAL)
|
|
543
|
+
|
|
544
|
+
cr.set_source_rgba(*list(bg_color))
|
|
545
|
+
|
|
546
|
+
cr.rectangle(1,1, self.ww-1, self.hh-1)
|
|
547
|
+
cr.clip()
|
|
548
|
+
cr.paint()
|
|
549
|
+
|
|
550
|
+
if 0: #self.stat2:
|
|
551
|
+
fg_color = self.get_style_context().get_color(Gtk.StateFlags.SELECTED)
|
|
552
|
+
else:
|
|
553
|
+
fg_color = self.get_style_context().get_color(Gtk.StateFlags.NORMAL)
|
|
554
|
+
|
|
555
|
+
cr.set_source_rgba(*list(fg_color));
|
|
556
|
+
cr.move_to(0, 0)
|
|
557
|
+
PangoCairo.show_layout(cr, self.layout)
|
|
558
|
+
if self.down:
|
|
559
|
+
cr.move_to(1, 1)
|
|
560
|
+
PangoCairo.show_layout(cr, self.layout)
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
if self.mnem:
|
|
564
|
+
#print("corr", self.chary.width, self.chary.height)
|
|
565
|
+
cr.move_to( self.chary.width, self.chary.height-2)
|
|
566
|
+
cr.line_to( self.chary.width + 8, self.chary.height-2)
|
|
567
|
+
cr.stroke()
|
|
568
|
+
|
|
569
|
+
if self.has_focus():
|
|
570
|
+
|
|
571
|
+
#print("focus")
|
|
572
|
+
cr.set_dash([.5, .9])
|
|
573
|
+
cr.move_to( 1, 1)
|
|
574
|
+
cr.line_to( self.ww-1, 1)
|
|
575
|
+
cr.line_to( self.ww-1, self.hh-1)
|
|
576
|
+
cr.line_to( 1, self.hh-1)
|
|
577
|
+
cr.line_to( 1, 1)
|
|
578
|
+
|
|
579
|
+
cr.stroke()</code></pre>
|
|
580
|
+
</details>
|
|
581
|
+
</dd>
|
|
582
|
+
<dt id="pgbutt.smallbutt.enter_label"><code class="name flex">
|
|
583
|
+
<span>def <span class="ident">enter_label</span></span>(<span>self, arg, arg2)</span>
|
|
584
|
+
</code></dt>
|
|
585
|
+
<dd>
|
|
586
|
+
<div class="desc"></div>
|
|
587
|
+
<details class="source">
|
|
588
|
+
<summary>
|
|
589
|
+
<span>Expand source code</span>
|
|
590
|
+
</summary>
|
|
591
|
+
<pre><code class="python">def enter_label(self, arg, arg2):
|
|
592
|
+
#print("Enter")
|
|
593
|
+
self.get_window().set_cursor(self.hand_cursor)
|
|
594
|
+
self.stat2 = 1
|
|
595
|
+
self.queue_draw()</code></pre>
|
|
596
|
+
</details>
|
|
597
|
+
</dd>
|
|
598
|
+
<dt id="pgbutt.smallbutt.keypress"><code class="name flex">
|
|
599
|
+
<span>def <span class="ident">keypress</span></span>(<span>self, *args)</span>
|
|
600
|
+
</code></dt>
|
|
601
|
+
<dd>
|
|
602
|
+
<div class="desc"></div>
|
|
603
|
+
<details class="source">
|
|
604
|
+
<summary>
|
|
605
|
+
<span>Expand source code</span>
|
|
606
|
+
</summary>
|
|
607
|
+
<pre><code class="python">def keypress(self, *args):
|
|
608
|
+
#print("keypress")
|
|
609
|
+
if args[1].keyval == Gdk.KEY_space or args[1].keyval == Gdk.KEY_Return :
|
|
610
|
+
self.down = 1
|
|
611
|
+
self.queue_draw()</code></pre>
|
|
612
|
+
</details>
|
|
613
|
+
</dd>
|
|
614
|
+
<dt id="pgbutt.smallbutt.keyrel"><code class="name flex">
|
|
615
|
+
<span>def <span class="ident">keyrel</span></span>(<span>self, *args)</span>
|
|
616
|
+
</code></dt>
|
|
617
|
+
<dd>
|
|
618
|
+
<div class="desc"></div>
|
|
619
|
+
<details class="source">
|
|
620
|
+
<summary>
|
|
621
|
+
<span>Expand source code</span>
|
|
622
|
+
</summary>
|
|
623
|
+
<pre><code class="python">def keyrel(self, *args):
|
|
624
|
+
#print("keyrel")
|
|
625
|
+
if args[1].keyval == Gdk.KEY_space or args[1].keyval == Gdk.KEY_Return :
|
|
626
|
+
self.down = 0
|
|
627
|
+
self.queue_draw()
|
|
628
|
+
self.emit('pressed')</code></pre>
|
|
629
|
+
</details>
|
|
630
|
+
</dd>
|
|
631
|
+
<dt id="pgbutt.smallbutt.leave_label"><code class="name flex">
|
|
632
|
+
<span>def <span class="ident">leave_label</span></span>(<span>self, arg, arg2)</span>
|
|
633
|
+
</code></dt>
|
|
634
|
+
<dd>
|
|
635
|
+
<div class="desc"></div>
|
|
636
|
+
<details class="source">
|
|
637
|
+
<summary>
|
|
638
|
+
<span>Expand source code</span>
|
|
639
|
+
</summary>
|
|
640
|
+
<pre><code class="python">def leave_label(self, arg, arg2):
|
|
641
|
+
#print("Leave")
|
|
642
|
+
self.get_window().set_cursor()
|
|
643
|
+
self.stat2 = 0
|
|
644
|
+
self.queue_draw()</code></pre>
|
|
645
|
+
</details>
|
|
646
|
+
</dd>
|
|
647
|
+
<dt id="pgbutt.smallbutt.mactivate"><code class="name flex">
|
|
648
|
+
<span>def <span class="ident">mactivate</span></span>(<span>self, *arg)</span>
|
|
649
|
+
</code></dt>
|
|
650
|
+
<dd>
|
|
651
|
+
<div class="desc"></div>
|
|
652
|
+
<details class="source">
|
|
653
|
+
<summary>
|
|
654
|
+
<span>Expand source code</span>
|
|
655
|
+
</summary>
|
|
656
|
+
<pre><code class="python">def mactivate(self, *arg):
|
|
657
|
+
#print("mactivate", arg)
|
|
658
|
+
self.emit('pressed')
|
|
659
|
+
return True</code></pre>
|
|
660
|
+
</details>
|
|
661
|
+
</dd>
|
|
662
|
+
<dt id="pgbutt.smallbutt.stattime"><code class="name flex">
|
|
663
|
+
<span>def <span class="ident">stattime</span></span>(<span>self, arg2, arg3)</span>
|
|
664
|
+
</code></dt>
|
|
665
|
+
<dd>
|
|
666
|
+
<div class="desc"></div>
|
|
667
|
+
<details class="source">
|
|
668
|
+
<summary>
|
|
669
|
+
<span>Expand source code</span>
|
|
670
|
+
</summary>
|
|
671
|
+
<pre><code class="python">def stattime(self, arg2, arg3):
|
|
672
|
+
|
|
673
|
+
# Test if mnemonic key is down
|
|
674
|
+
kmap = Gdk.Keymap().get_default()
|
|
675
|
+
state = kmap.get_modifier_state()
|
|
676
|
+
#print("mods", state)
|
|
677
|
+
if state == Gdk.ModifierType.MOD1_MASK:
|
|
678
|
+
self.mnem = True
|
|
679
|
+
else:
|
|
680
|
+
self.mnem = False
|
|
681
|
+
|
|
682
|
+
if self.omnem != self.mnem:
|
|
683
|
+
self.omnem = self.mnem
|
|
684
|
+
#print("changed to", self.mnem)
|
|
685
|
+
self.queue_draw()
|
|
686
|
+
|
|
687
|
+
#GLib.timeout_add(1000, self.stattime, self, 0)
|
|
688
|
+
return True</code></pre>
|
|
689
|
+
</details>
|
|
690
|
+
</dd>
|
|
691
|
+
</dl>
|
|
692
|
+
</dd>
|
|
693
|
+
</dl>
|
|
694
|
+
</section>
|
|
695
|
+
</article>
|
|
696
|
+
<nav id="sidebar">
|
|
697
|
+
<h1>Index</h1>
|
|
698
|
+
<div class="toc">
|
|
699
|
+
<ul></ul>
|
|
700
|
+
</div>
|
|
701
|
+
<ul id="index">
|
|
702
|
+
<li><h3><a href="#header-classes">Classes</a></h3>
|
|
703
|
+
<ul>
|
|
704
|
+
<li>
|
|
705
|
+
<h4><code><a title="pgbutt.smallbutt" href="#pgbutt.smallbutt">smallbutt</a></code></h4>
|
|
706
|
+
<ul class="two-column">
|
|
707
|
+
<li><code><a title="pgbutt.smallbutt.buttpress" href="#pgbutt.smallbutt.buttpress">buttpress</a></code></li>
|
|
708
|
+
<li><code><a title="pgbutt.smallbutt.buttrel" href="#pgbutt.smallbutt.buttrel">buttrel</a></code></li>
|
|
709
|
+
<li><code><a title="pgbutt.smallbutt.do_draw" href="#pgbutt.smallbutt.do_draw">do_draw</a></code></li>
|
|
710
|
+
<li><code><a title="pgbutt.smallbutt.enter_label" href="#pgbutt.smallbutt.enter_label">enter_label</a></code></li>
|
|
711
|
+
<li><code><a title="pgbutt.smallbutt.keypress" href="#pgbutt.smallbutt.keypress">keypress</a></code></li>
|
|
712
|
+
<li><code><a title="pgbutt.smallbutt.keyrel" href="#pgbutt.smallbutt.keyrel">keyrel</a></code></li>
|
|
713
|
+
<li><code><a title="pgbutt.smallbutt.leave_label" href="#pgbutt.smallbutt.leave_label">leave_label</a></code></li>
|
|
714
|
+
<li><code><a title="pgbutt.smallbutt.mactivate" href="#pgbutt.smallbutt.mactivate">mactivate</a></code></li>
|
|
715
|
+
<li><code><a title="pgbutt.smallbutt.stattime" href="#pgbutt.smallbutt.stattime">stattime</a></code></li>
|
|
716
|
+
</ul>
|
|
717
|
+
</li>
|
|
718
|
+
</ul>
|
|
719
|
+
</li>
|
|
720
|
+
</ul>
|
|
721
|
+
</nav>
|
|
722
|
+
</main>
|
|
723
|
+
<footer id="footer">
|
|
724
|
+
<p>Generated by <a href="https://pdoc3.github.io/pdoc" title="pdoc: Python API documentation generator"><cite>pdoc</cite> 0.10.0</a>.</p>
|
|
725
|
+
</footer>
|
|
726
|
+
</body>
|
|
727
|
+
</html>
|