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,956 @@
|
|
|
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>browsewin API documentation</title>
|
|
8
|
+
<meta name="description" content="This encapsulates the browser window wit the webkia an toolbars" />
|
|
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>browsewin</code></h1>
|
|
23
|
+
</header>
|
|
24
|
+
<section id="section-intro">
|
|
25
|
+
<p>This encapsulates the browser window wit the webkia an toolbars</p>
|
|
26
|
+
<details class="source">
|
|
27
|
+
<summary>
|
|
28
|
+
<span>Expand source code</span>
|
|
29
|
+
</summary>
|
|
30
|
+
<pre><code class="python">#!/usr/bin/env python
|
|
31
|
+
|
|
32
|
+
''' This encapsulates the browser window wit the webkia an toolbars '''
|
|
33
|
+
|
|
34
|
+
import os, sys, getopt, signal, random, time, warnings
|
|
35
|
+
|
|
36
|
+
realinc = os.path.realpath(os.path.dirname(__file__) + os.sep + "../pycommon")
|
|
37
|
+
if realinc not in sys.path:
|
|
38
|
+
sys.path.append(realinc)
|
|
39
|
+
|
|
40
|
+
from pgutils import *
|
|
41
|
+
from pggui import *
|
|
42
|
+
from pgsimp import *
|
|
43
|
+
|
|
44
|
+
import gi
|
|
45
|
+
gi.require_version("Gtk", "3.0")
|
|
46
|
+
|
|
47
|
+
from gi.repository import Gtk
|
|
48
|
+
from gi.repository import Gdk
|
|
49
|
+
from gi.repository import GLib
|
|
50
|
+
from gi.repository import GObject
|
|
51
|
+
from gi.repository import Pango
|
|
52
|
+
|
|
53
|
+
from pedlib import pedconfig
|
|
54
|
+
|
|
55
|
+
import pgwkit
|
|
56
|
+
#print("pgwkit:", pgwkit)
|
|
57
|
+
|
|
58
|
+
class browserWin(Gtk.VBox):
|
|
59
|
+
|
|
60
|
+
''' Collection of URL bar, toolbar, status bar '''
|
|
61
|
+
|
|
62
|
+
def __init__(self):
|
|
63
|
+
|
|
64
|
+
try:
|
|
65
|
+
Gtk.VBox.__init__(self)
|
|
66
|
+
except:
|
|
67
|
+
pass
|
|
68
|
+
|
|
69
|
+
# TEST Mnemonic Label
|
|
70
|
+
#bbb = Gtk.Button.new_with_mnemonic("_Hello")
|
|
71
|
+
#self.pack_start(bbb, 0, 0, 0)
|
|
72
|
+
|
|
73
|
+
hbox3 = self.urlbar()
|
|
74
|
+
self.pack_start(hbox3, 0, 0, 0)
|
|
75
|
+
|
|
76
|
+
#if not conf.kiosk:
|
|
77
|
+
# vbox.pack_start(hbox3, False, False, 2)
|
|
78
|
+
|
|
79
|
+
self.scroll_win = Gtk.ScrolledWindow()
|
|
80
|
+
|
|
81
|
+
try:
|
|
82
|
+
self.webview = pgwkit.pgwebw(self)
|
|
83
|
+
except:
|
|
84
|
+
print("Please install WebKit2", sys.exc_info())
|
|
85
|
+
#if pedconfig.conf.verbose:
|
|
86
|
+
put_exception("start webview")
|
|
87
|
+
#sys.exit(1)
|
|
88
|
+
#raise
|
|
89
|
+
|
|
90
|
+
#self.old_html = ""
|
|
91
|
+
self.scroll_win.add(self.webview)
|
|
92
|
+
self.webview.editor = self.webview
|
|
93
|
+
|
|
94
|
+
self.toolbar2 = self.webview.ui.get_widget("/toolbar_format")
|
|
95
|
+
self.pack_start(self.toolbar2, False, False, 0)
|
|
96
|
+
|
|
97
|
+
self.pack_start(self.scroll_win, 1, 1, 2)
|
|
98
|
+
|
|
99
|
+
hbox5 = Gtk.HBox()
|
|
100
|
+
hbox5.pack_start(Gtk.Label(" "), 0, 0, 0)
|
|
101
|
+
self.status = Gtk.Label(" Idle ");
|
|
102
|
+
self.status.set_xalign(0)
|
|
103
|
+
|
|
104
|
+
hbox5.pack_start(self.status, 1, 1, 0)
|
|
105
|
+
hbox5.pack_start(Gtk.Label(" "), 0, 0, 0)
|
|
106
|
+
self.set_status(" Idle State ")
|
|
107
|
+
|
|
108
|
+
self.pack_start(hbox5, 0, 0, 2)
|
|
109
|
+
|
|
110
|
+
#self.add_events(Gdk.EventMask.ALL_EVENTS_MASK)
|
|
111
|
+
#self.set_sensitive(True)
|
|
112
|
+
|
|
113
|
+
# Receive key presses
|
|
114
|
+
self.set_can_focus(True)
|
|
115
|
+
#self.grab_focus()
|
|
116
|
+
|
|
117
|
+
def load_html(self, strx):
|
|
118
|
+
self.webview.load_html(strx)
|
|
119
|
+
|
|
120
|
+
def cut(self):
|
|
121
|
+
#print("cut")
|
|
122
|
+
self.webview.on_action("cut")
|
|
123
|
+
|
|
124
|
+
def copy(self):
|
|
125
|
+
#print("copy")
|
|
126
|
+
self.webview.on_action("copy")
|
|
127
|
+
|
|
128
|
+
def paste(self):
|
|
129
|
+
#print("paste")
|
|
130
|
+
self.webview.on_paste()
|
|
131
|
+
#self.webview.on_action("paste")
|
|
132
|
+
|
|
133
|
+
def open(self):
|
|
134
|
+
dialog = Gtk.FileChooserDialog("Open an HTML file", None,
|
|
135
|
+
Gtk.FileChooserAction.OPEN,
|
|
136
|
+
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
|
137
|
+
Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
|
|
138
|
+
|
|
139
|
+
ret = dialog.run()
|
|
140
|
+
fn = dialog.get_filename()
|
|
141
|
+
dialog.destroy()
|
|
142
|
+
|
|
143
|
+
if ret == Gtk.ResponseType.OK:
|
|
144
|
+
if not fn:
|
|
145
|
+
return
|
|
146
|
+
if os.path.exists(fn):
|
|
147
|
+
self.fname = fn
|
|
148
|
+
with open(fn) as fd:
|
|
149
|
+
self.webview.load_html(fd.read(), "file:///")
|
|
150
|
+
|
|
151
|
+
def save(self):
|
|
152
|
+
|
|
153
|
+
#print("brow_win", "save", self.fname)
|
|
154
|
+
def completion(html, user_data):
|
|
155
|
+
#print("len html", len(html), len(self.webview.old_html) )
|
|
156
|
+
#print("html", html, "old", self.webview.old_html )
|
|
157
|
+
#if self.webview.old_html == html:
|
|
158
|
+
|
|
159
|
+
if not self.webview.modified:
|
|
160
|
+
self.set_status("File NOT modified.") # '%s'" % self.fname)
|
|
161
|
+
else:
|
|
162
|
+
#self.webview.old_html = html
|
|
163
|
+
open_mode = user_data
|
|
164
|
+
with open(self.fname, open_mode) as fd:
|
|
165
|
+
fd.write(html)
|
|
166
|
+
self.set_status("Saved file '%s'" % self.fname)
|
|
167
|
+
self.webview.modified = False
|
|
168
|
+
self.webview.get_html(completion, 'w')
|
|
169
|
+
|
|
170
|
+
def is_modified(self):
|
|
171
|
+
return self.webview.modified
|
|
172
|
+
|
|
173
|
+
def _completion(self, html, user_data):
|
|
174
|
+
self.ret = html
|
|
175
|
+
self.done = True
|
|
176
|
+
self.webview.modified = False
|
|
177
|
+
#print("retx", ret)
|
|
178
|
+
|
|
179
|
+
def get_content(self):
|
|
180
|
+
self.done = 0; self.ret = ""
|
|
181
|
+
self.webview.get_html(self._completion, "w")
|
|
182
|
+
# Wait until done is set
|
|
183
|
+
for aa in range(1000):
|
|
184
|
+
if self.done:
|
|
185
|
+
break
|
|
186
|
+
Gtk.main_iteration_do(False)
|
|
187
|
+
return self.ret
|
|
188
|
+
|
|
189
|
+
def saveas(self):
|
|
190
|
+
def completion(html, user_data):
|
|
191
|
+
open_mode = user_data
|
|
192
|
+
with open(self.fname, open_mode) as fd:
|
|
193
|
+
fd.write(html)
|
|
194
|
+
self.set_status("Saved as '%s'" % self.fname)
|
|
195
|
+
|
|
196
|
+
dialog = Gtk.FileChooserDialog("Select an HTML file", None,
|
|
197
|
+
Gtk.FileChooserAction.SAVE,
|
|
198
|
+
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
|
199
|
+
Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
|
|
200
|
+
|
|
201
|
+
if dialog.run() == Gtk.ResponseType.OK:
|
|
202
|
+
self.fname = dialog.get_filename()
|
|
203
|
+
#print("Saving", self.fname)
|
|
204
|
+
self.webview.get_html(completion, "w+")
|
|
205
|
+
dialog.destroy()
|
|
206
|
+
|
|
207
|
+
def url_callb(self, xtxt):
|
|
208
|
+
self.webview.go(xtxt)
|
|
209
|
+
|
|
210
|
+
def url_callb(self, xtxt):
|
|
211
|
+
self.go(xtxt)
|
|
212
|
+
|
|
213
|
+
def backurl(self, url, parm, buff):
|
|
214
|
+
self.webview.go_back()
|
|
215
|
+
|
|
216
|
+
def baseurl(self, url, parm, buff):
|
|
217
|
+
self.webview.load_uri("file://" + self.fname)
|
|
218
|
+
|
|
219
|
+
def forwurl(self, url, parm, buff):
|
|
220
|
+
self.webview.go_forward()
|
|
221
|
+
|
|
222
|
+
#def gourl(self, url, parm, buff):
|
|
223
|
+
def gourl(self, *url):
|
|
224
|
+
print("gourl", *url)
|
|
225
|
+
self.go(self.edit.get_text())
|
|
226
|
+
|
|
227
|
+
def go(self, xstr):
|
|
228
|
+
print("go", xstr)
|
|
229
|
+
|
|
230
|
+
# Leave known URL scemes alone
|
|
231
|
+
if xstr[:7] == "file://":
|
|
232
|
+
sss = os.path.realpath(xstr[7:])
|
|
233
|
+
xstr = "file://" + sss
|
|
234
|
+
pass
|
|
235
|
+
elif xstr[:7] == "http://":
|
|
236
|
+
pass
|
|
237
|
+
elif xstr[:8] == "https://":
|
|
238
|
+
pass
|
|
239
|
+
elif xstr[:6] == "ftp://":
|
|
240
|
+
pass
|
|
241
|
+
elif str.isdecimal(xstr[0]):
|
|
242
|
+
#print("Possible IP")
|
|
243
|
+
pass
|
|
244
|
+
else:
|
|
245
|
+
# Yeah, padd it
|
|
246
|
+
xstr = "https://" + xstr
|
|
247
|
+
|
|
248
|
+
self.webview.load_uri(xstr)
|
|
249
|
+
|
|
250
|
+
def stattime(self, *arg):
|
|
251
|
+
self.status.set_text("Idle.")
|
|
252
|
+
|
|
253
|
+
def set_status(self, xtxt):
|
|
254
|
+
self.status.set_text(xtxt)
|
|
255
|
+
GLib.timeout_add(3000, self.stattime, self, 0)
|
|
256
|
+
|
|
257
|
+
def urlbar(self):
|
|
258
|
+
|
|
259
|
+
self.edit = SimpleEdit();
|
|
260
|
+
self.edit.setsavecb(self.url_callb)
|
|
261
|
+
self.edit.single_line = True
|
|
262
|
+
|
|
263
|
+
hbox3 = Gtk.HBox()
|
|
264
|
+
uuu = Gtk.Label(" URL: ")
|
|
265
|
+
uuu.set_tooltip_text("Current / New URL; press Enter to go")
|
|
266
|
+
hbox3.pack_start(uuu, 0, 0, 0)
|
|
267
|
+
|
|
268
|
+
hbox3.pack_start(self.edit, True, True, 2)
|
|
269
|
+
|
|
270
|
+
bbb = LabelButt(" _Go ", self.gourl, "Go to speified URL")
|
|
271
|
+
#bbb = Gtk.Button.new_with_mnemonic(" _Go ") #, self.gourl, "Go to speified URL")
|
|
272
|
+
#bbb.connect("clicked", self.gourl)
|
|
273
|
+
|
|
274
|
+
#bbb = LabelButt(" _Go ", self.gourl, "Go to speified URL")
|
|
275
|
+
ccc = LabelButt(" <-_Back ", self.backurl, "Go Back")
|
|
276
|
+
ddd = LabelButt(" For_w-> ", self.forwurl, "Go Forw")
|
|
277
|
+
eee = LabelButt(" B_ase ", self.baseurl, "Go to base URL")
|
|
278
|
+
|
|
279
|
+
hbox3.pack_start(Gtk.Label(" "), 0, 0, 0)
|
|
280
|
+
|
|
281
|
+
hbox3.pack_start(bbb, 0, 0, 0)
|
|
282
|
+
hbox3.pack_start(ccc, 0, 0, 0)
|
|
283
|
+
hbox3.pack_start(ddd, 0, 0, 0)
|
|
284
|
+
hbox3.pack_start(eee, 0, 0, 0)
|
|
285
|
+
|
|
286
|
+
#hbox3.pack_start(Gtk.Label(" ^ "), 0, 0, 0)
|
|
287
|
+
hbox3.pack_start(Gtk.Label(" "), 0, 0, 0)
|
|
288
|
+
|
|
289
|
+
return hbox3
|
|
290
|
+
|
|
291
|
+
# EOF</code></pre>
|
|
292
|
+
</details>
|
|
293
|
+
</section>
|
|
294
|
+
<section>
|
|
295
|
+
</section>
|
|
296
|
+
<section>
|
|
297
|
+
</section>
|
|
298
|
+
<section>
|
|
299
|
+
</section>
|
|
300
|
+
<section>
|
|
301
|
+
<h2 class="section-title" id="header-classes">Classes</h2>
|
|
302
|
+
<dl>
|
|
303
|
+
<dt id="browsewin.browserWin"><code class="flex name class">
|
|
304
|
+
<span>class <span class="ident">browserWin</span></span>
|
|
305
|
+
</code></dt>
|
|
306
|
+
<dd>
|
|
307
|
+
<div class="desc"><p>Collection of URL bar, toolbar, status bar </p>
|
|
308
|
+
<p>Initializer for a GObject based classes with support for property
|
|
309
|
+
sets through the use of explicit keyword arguments.</p></div>
|
|
310
|
+
<details class="source">
|
|
311
|
+
<summary>
|
|
312
|
+
<span>Expand source code</span>
|
|
313
|
+
</summary>
|
|
314
|
+
<pre><code class="python">class browserWin(Gtk.VBox):
|
|
315
|
+
|
|
316
|
+
''' Collection of URL bar, toolbar, status bar '''
|
|
317
|
+
|
|
318
|
+
def __init__(self):
|
|
319
|
+
|
|
320
|
+
try:
|
|
321
|
+
Gtk.VBox.__init__(self)
|
|
322
|
+
except:
|
|
323
|
+
pass
|
|
324
|
+
|
|
325
|
+
# TEST Mnemonic Label
|
|
326
|
+
#bbb = Gtk.Button.new_with_mnemonic("_Hello")
|
|
327
|
+
#self.pack_start(bbb, 0, 0, 0)
|
|
328
|
+
|
|
329
|
+
hbox3 = self.urlbar()
|
|
330
|
+
self.pack_start(hbox3, 0, 0, 0)
|
|
331
|
+
|
|
332
|
+
#if not conf.kiosk:
|
|
333
|
+
# vbox.pack_start(hbox3, False, False, 2)
|
|
334
|
+
|
|
335
|
+
self.scroll_win = Gtk.ScrolledWindow()
|
|
336
|
+
|
|
337
|
+
try:
|
|
338
|
+
self.webview = pgwkit.pgwebw(self)
|
|
339
|
+
except:
|
|
340
|
+
print("Please install WebKit2", sys.exc_info())
|
|
341
|
+
#if pedconfig.conf.verbose:
|
|
342
|
+
put_exception("start webview")
|
|
343
|
+
#sys.exit(1)
|
|
344
|
+
#raise
|
|
345
|
+
|
|
346
|
+
#self.old_html = ""
|
|
347
|
+
self.scroll_win.add(self.webview)
|
|
348
|
+
self.webview.editor = self.webview
|
|
349
|
+
|
|
350
|
+
self.toolbar2 = self.webview.ui.get_widget("/toolbar_format")
|
|
351
|
+
self.pack_start(self.toolbar2, False, False, 0)
|
|
352
|
+
|
|
353
|
+
self.pack_start(self.scroll_win, 1, 1, 2)
|
|
354
|
+
|
|
355
|
+
hbox5 = Gtk.HBox()
|
|
356
|
+
hbox5.pack_start(Gtk.Label(" "), 0, 0, 0)
|
|
357
|
+
self.status = Gtk.Label(" Idle ");
|
|
358
|
+
self.status.set_xalign(0)
|
|
359
|
+
|
|
360
|
+
hbox5.pack_start(self.status, 1, 1, 0)
|
|
361
|
+
hbox5.pack_start(Gtk.Label(" "), 0, 0, 0)
|
|
362
|
+
self.set_status(" Idle State ")
|
|
363
|
+
|
|
364
|
+
self.pack_start(hbox5, 0, 0, 2)
|
|
365
|
+
|
|
366
|
+
#self.add_events(Gdk.EventMask.ALL_EVENTS_MASK)
|
|
367
|
+
#self.set_sensitive(True)
|
|
368
|
+
|
|
369
|
+
# Receive key presses
|
|
370
|
+
self.set_can_focus(True)
|
|
371
|
+
#self.grab_focus()
|
|
372
|
+
|
|
373
|
+
def load_html(self, strx):
|
|
374
|
+
self.webview.load_html(strx)
|
|
375
|
+
|
|
376
|
+
def cut(self):
|
|
377
|
+
#print("cut")
|
|
378
|
+
self.webview.on_action("cut")
|
|
379
|
+
|
|
380
|
+
def copy(self):
|
|
381
|
+
#print("copy")
|
|
382
|
+
self.webview.on_action("copy")
|
|
383
|
+
|
|
384
|
+
def paste(self):
|
|
385
|
+
#print("paste")
|
|
386
|
+
self.webview.on_paste()
|
|
387
|
+
#self.webview.on_action("paste")
|
|
388
|
+
|
|
389
|
+
def open(self):
|
|
390
|
+
dialog = Gtk.FileChooserDialog("Open an HTML file", None,
|
|
391
|
+
Gtk.FileChooserAction.OPEN,
|
|
392
|
+
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
|
393
|
+
Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
|
|
394
|
+
|
|
395
|
+
ret = dialog.run()
|
|
396
|
+
fn = dialog.get_filename()
|
|
397
|
+
dialog.destroy()
|
|
398
|
+
|
|
399
|
+
if ret == Gtk.ResponseType.OK:
|
|
400
|
+
if not fn:
|
|
401
|
+
return
|
|
402
|
+
if os.path.exists(fn):
|
|
403
|
+
self.fname = fn
|
|
404
|
+
with open(fn) as fd:
|
|
405
|
+
self.webview.load_html(fd.read(), "file:///")
|
|
406
|
+
|
|
407
|
+
def save(self):
|
|
408
|
+
|
|
409
|
+
#print("brow_win", "save", self.fname)
|
|
410
|
+
def completion(html, user_data):
|
|
411
|
+
#print("len html", len(html), len(self.webview.old_html) )
|
|
412
|
+
#print("html", html, "old", self.webview.old_html )
|
|
413
|
+
#if self.webview.old_html == html:
|
|
414
|
+
|
|
415
|
+
if not self.webview.modified:
|
|
416
|
+
self.set_status("File NOT modified.") # '%s'" % self.fname)
|
|
417
|
+
else:
|
|
418
|
+
#self.webview.old_html = html
|
|
419
|
+
open_mode = user_data
|
|
420
|
+
with open(self.fname, open_mode) as fd:
|
|
421
|
+
fd.write(html)
|
|
422
|
+
self.set_status("Saved file '%s'" % self.fname)
|
|
423
|
+
self.webview.modified = False
|
|
424
|
+
self.webview.get_html(completion, 'w')
|
|
425
|
+
|
|
426
|
+
def is_modified(self):
|
|
427
|
+
return self.webview.modified
|
|
428
|
+
|
|
429
|
+
def _completion(self, html, user_data):
|
|
430
|
+
self.ret = html
|
|
431
|
+
self.done = True
|
|
432
|
+
self.webview.modified = False
|
|
433
|
+
#print("retx", ret)
|
|
434
|
+
|
|
435
|
+
def get_content(self):
|
|
436
|
+
self.done = 0; self.ret = ""
|
|
437
|
+
self.webview.get_html(self._completion, "w")
|
|
438
|
+
# Wait until done is set
|
|
439
|
+
for aa in range(1000):
|
|
440
|
+
if self.done:
|
|
441
|
+
break
|
|
442
|
+
Gtk.main_iteration_do(False)
|
|
443
|
+
return self.ret
|
|
444
|
+
|
|
445
|
+
def saveas(self):
|
|
446
|
+
def completion(html, user_data):
|
|
447
|
+
open_mode = user_data
|
|
448
|
+
with open(self.fname, open_mode) as fd:
|
|
449
|
+
fd.write(html)
|
|
450
|
+
self.set_status("Saved as '%s'" % self.fname)
|
|
451
|
+
|
|
452
|
+
dialog = Gtk.FileChooserDialog("Select an HTML file", None,
|
|
453
|
+
Gtk.FileChooserAction.SAVE,
|
|
454
|
+
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
|
455
|
+
Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
|
|
456
|
+
|
|
457
|
+
if dialog.run() == Gtk.ResponseType.OK:
|
|
458
|
+
self.fname = dialog.get_filename()
|
|
459
|
+
#print("Saving", self.fname)
|
|
460
|
+
self.webview.get_html(completion, "w+")
|
|
461
|
+
dialog.destroy()
|
|
462
|
+
|
|
463
|
+
def url_callb(self, xtxt):
|
|
464
|
+
self.webview.go(xtxt)
|
|
465
|
+
|
|
466
|
+
def url_callb(self, xtxt):
|
|
467
|
+
self.go(xtxt)
|
|
468
|
+
|
|
469
|
+
def backurl(self, url, parm, buff):
|
|
470
|
+
self.webview.go_back()
|
|
471
|
+
|
|
472
|
+
def baseurl(self, url, parm, buff):
|
|
473
|
+
self.webview.load_uri("file://" + self.fname)
|
|
474
|
+
|
|
475
|
+
def forwurl(self, url, parm, buff):
|
|
476
|
+
self.webview.go_forward()
|
|
477
|
+
|
|
478
|
+
#def gourl(self, url, parm, buff):
|
|
479
|
+
def gourl(self, *url):
|
|
480
|
+
print("gourl", *url)
|
|
481
|
+
self.go(self.edit.get_text())
|
|
482
|
+
|
|
483
|
+
def go(self, xstr):
|
|
484
|
+
print("go", xstr)
|
|
485
|
+
|
|
486
|
+
# Leave known URL scemes alone
|
|
487
|
+
if xstr[:7] == "file://":
|
|
488
|
+
sss = os.path.realpath(xstr[7:])
|
|
489
|
+
xstr = "file://" + sss
|
|
490
|
+
pass
|
|
491
|
+
elif xstr[:7] == "http://":
|
|
492
|
+
pass
|
|
493
|
+
elif xstr[:8] == "https://":
|
|
494
|
+
pass
|
|
495
|
+
elif xstr[:6] == "ftp://":
|
|
496
|
+
pass
|
|
497
|
+
elif str.isdecimal(xstr[0]):
|
|
498
|
+
#print("Possible IP")
|
|
499
|
+
pass
|
|
500
|
+
else:
|
|
501
|
+
# Yeah, padd it
|
|
502
|
+
xstr = "https://" + xstr
|
|
503
|
+
|
|
504
|
+
self.webview.load_uri(xstr)
|
|
505
|
+
|
|
506
|
+
def stattime(self, *arg):
|
|
507
|
+
self.status.set_text("Idle.")
|
|
508
|
+
|
|
509
|
+
def set_status(self, xtxt):
|
|
510
|
+
self.status.set_text(xtxt)
|
|
511
|
+
GLib.timeout_add(3000, self.stattime, self, 0)
|
|
512
|
+
|
|
513
|
+
def urlbar(self):
|
|
514
|
+
|
|
515
|
+
self.edit = SimpleEdit();
|
|
516
|
+
self.edit.setsavecb(self.url_callb)
|
|
517
|
+
self.edit.single_line = True
|
|
518
|
+
|
|
519
|
+
hbox3 = Gtk.HBox()
|
|
520
|
+
uuu = Gtk.Label(" URL: ")
|
|
521
|
+
uuu.set_tooltip_text("Current / New URL; press Enter to go")
|
|
522
|
+
hbox3.pack_start(uuu, 0, 0, 0)
|
|
523
|
+
|
|
524
|
+
hbox3.pack_start(self.edit, True, True, 2)
|
|
525
|
+
|
|
526
|
+
bbb = LabelButt(" _Go ", self.gourl, "Go to speified URL")
|
|
527
|
+
#bbb = Gtk.Button.new_with_mnemonic(" _Go ") #, self.gourl, "Go to speified URL")
|
|
528
|
+
#bbb.connect("clicked", self.gourl)
|
|
529
|
+
|
|
530
|
+
#bbb = LabelButt(" _Go ", self.gourl, "Go to speified URL")
|
|
531
|
+
ccc = LabelButt(" <-_Back ", self.backurl, "Go Back")
|
|
532
|
+
ddd = LabelButt(" For_w-> ", self.forwurl, "Go Forw")
|
|
533
|
+
eee = LabelButt(" B_ase ", self.baseurl, "Go to base URL")
|
|
534
|
+
|
|
535
|
+
hbox3.pack_start(Gtk.Label(" "), 0, 0, 0)
|
|
536
|
+
|
|
537
|
+
hbox3.pack_start(bbb, 0, 0, 0)
|
|
538
|
+
hbox3.pack_start(ccc, 0, 0, 0)
|
|
539
|
+
hbox3.pack_start(ddd, 0, 0, 0)
|
|
540
|
+
hbox3.pack_start(eee, 0, 0, 0)
|
|
541
|
+
|
|
542
|
+
#hbox3.pack_start(Gtk.Label(" ^ "), 0, 0, 0)
|
|
543
|
+
hbox3.pack_start(Gtk.Label(" "), 0, 0, 0)
|
|
544
|
+
|
|
545
|
+
return hbox3</code></pre>
|
|
546
|
+
</details>
|
|
547
|
+
<h3>Ancestors</h3>
|
|
548
|
+
<ul class="hlist">
|
|
549
|
+
<li>gi.repository.Gtk.VBox</li>
|
|
550
|
+
<li>gi.overrides.Gtk.Box</li>
|
|
551
|
+
<li>gi.repository.Gtk.Box</li>
|
|
552
|
+
<li>gi.overrides.Gtk.Container</li>
|
|
553
|
+
<li>gi.repository.Gtk.Container</li>
|
|
554
|
+
<li>gi.overrides.Gtk.Widget</li>
|
|
555
|
+
<li>gi.repository.Gtk.Widget</li>
|
|
556
|
+
<li>gi.repository.GObject.InitiallyUnowned</li>
|
|
557
|
+
<li>gi.overrides.GObject.Object</li>
|
|
558
|
+
<li>gi.repository.GObject.Object</li>
|
|
559
|
+
<li>gi._gi.GObject</li>
|
|
560
|
+
<li>gi.repository.Atk.ImplementorIface</li>
|
|
561
|
+
<li>gi.repository.Gtk.Buildable</li>
|
|
562
|
+
<li>gi.repository.Gtk.Orientable</li>
|
|
563
|
+
<li>gobject.GInterface</li>
|
|
564
|
+
</ul>
|
|
565
|
+
<h3>Methods</h3>
|
|
566
|
+
<dl>
|
|
567
|
+
<dt id="browsewin.browserWin.backurl"><code class="name flex">
|
|
568
|
+
<span>def <span class="ident">backurl</span></span>(<span>self, url, parm, buff)</span>
|
|
569
|
+
</code></dt>
|
|
570
|
+
<dd>
|
|
571
|
+
<div class="desc"></div>
|
|
572
|
+
<details class="source">
|
|
573
|
+
<summary>
|
|
574
|
+
<span>Expand source code</span>
|
|
575
|
+
</summary>
|
|
576
|
+
<pre><code class="python">def backurl(self, url, parm, buff):
|
|
577
|
+
self.webview.go_back()</code></pre>
|
|
578
|
+
</details>
|
|
579
|
+
</dd>
|
|
580
|
+
<dt id="browsewin.browserWin.baseurl"><code class="name flex">
|
|
581
|
+
<span>def <span class="ident">baseurl</span></span>(<span>self, url, parm, buff)</span>
|
|
582
|
+
</code></dt>
|
|
583
|
+
<dd>
|
|
584
|
+
<div class="desc"></div>
|
|
585
|
+
<details class="source">
|
|
586
|
+
<summary>
|
|
587
|
+
<span>Expand source code</span>
|
|
588
|
+
</summary>
|
|
589
|
+
<pre><code class="python">def baseurl(self, url, parm, buff):
|
|
590
|
+
self.webview.load_uri("file://" + self.fname)</code></pre>
|
|
591
|
+
</details>
|
|
592
|
+
</dd>
|
|
593
|
+
<dt id="browsewin.browserWin.copy"><code class="name flex">
|
|
594
|
+
<span>def <span class="ident">copy</span></span>(<span>self)</span>
|
|
595
|
+
</code></dt>
|
|
596
|
+
<dd>
|
|
597
|
+
<div class="desc"></div>
|
|
598
|
+
<details class="source">
|
|
599
|
+
<summary>
|
|
600
|
+
<span>Expand source code</span>
|
|
601
|
+
</summary>
|
|
602
|
+
<pre><code class="python">def copy(self):
|
|
603
|
+
#print("copy")
|
|
604
|
+
self.webview.on_action("copy")</code></pre>
|
|
605
|
+
</details>
|
|
606
|
+
</dd>
|
|
607
|
+
<dt id="browsewin.browserWin.cut"><code class="name flex">
|
|
608
|
+
<span>def <span class="ident">cut</span></span>(<span>self)</span>
|
|
609
|
+
</code></dt>
|
|
610
|
+
<dd>
|
|
611
|
+
<div class="desc"></div>
|
|
612
|
+
<details class="source">
|
|
613
|
+
<summary>
|
|
614
|
+
<span>Expand source code</span>
|
|
615
|
+
</summary>
|
|
616
|
+
<pre><code class="python">def cut(self):
|
|
617
|
+
#print("cut")
|
|
618
|
+
self.webview.on_action("cut")</code></pre>
|
|
619
|
+
</details>
|
|
620
|
+
</dd>
|
|
621
|
+
<dt id="browsewin.browserWin.forwurl"><code class="name flex">
|
|
622
|
+
<span>def <span class="ident">forwurl</span></span>(<span>self, url, parm, buff)</span>
|
|
623
|
+
</code></dt>
|
|
624
|
+
<dd>
|
|
625
|
+
<div class="desc"></div>
|
|
626
|
+
<details class="source">
|
|
627
|
+
<summary>
|
|
628
|
+
<span>Expand source code</span>
|
|
629
|
+
</summary>
|
|
630
|
+
<pre><code class="python">def forwurl(self, url, parm, buff):
|
|
631
|
+
self.webview.go_forward()</code></pre>
|
|
632
|
+
</details>
|
|
633
|
+
</dd>
|
|
634
|
+
<dt id="browsewin.browserWin.get_content"><code class="name flex">
|
|
635
|
+
<span>def <span class="ident">get_content</span></span>(<span>self)</span>
|
|
636
|
+
</code></dt>
|
|
637
|
+
<dd>
|
|
638
|
+
<div class="desc"></div>
|
|
639
|
+
<details class="source">
|
|
640
|
+
<summary>
|
|
641
|
+
<span>Expand source code</span>
|
|
642
|
+
</summary>
|
|
643
|
+
<pre><code class="python">def get_content(self):
|
|
644
|
+
self.done = 0; self.ret = ""
|
|
645
|
+
self.webview.get_html(self._completion, "w")
|
|
646
|
+
# Wait until done is set
|
|
647
|
+
for aa in range(1000):
|
|
648
|
+
if self.done:
|
|
649
|
+
break
|
|
650
|
+
Gtk.main_iteration_do(False)
|
|
651
|
+
return self.ret</code></pre>
|
|
652
|
+
</details>
|
|
653
|
+
</dd>
|
|
654
|
+
<dt id="browsewin.browserWin.go"><code class="name flex">
|
|
655
|
+
<span>def <span class="ident">go</span></span>(<span>self, xstr)</span>
|
|
656
|
+
</code></dt>
|
|
657
|
+
<dd>
|
|
658
|
+
<div class="desc"></div>
|
|
659
|
+
<details class="source">
|
|
660
|
+
<summary>
|
|
661
|
+
<span>Expand source code</span>
|
|
662
|
+
</summary>
|
|
663
|
+
<pre><code class="python">def go(self, xstr):
|
|
664
|
+
print("go", xstr)
|
|
665
|
+
|
|
666
|
+
# Leave known URL scemes alone
|
|
667
|
+
if xstr[:7] == "file://":
|
|
668
|
+
sss = os.path.realpath(xstr[7:])
|
|
669
|
+
xstr = "file://" + sss
|
|
670
|
+
pass
|
|
671
|
+
elif xstr[:7] == "http://":
|
|
672
|
+
pass
|
|
673
|
+
elif xstr[:8] == "https://":
|
|
674
|
+
pass
|
|
675
|
+
elif xstr[:6] == "ftp://":
|
|
676
|
+
pass
|
|
677
|
+
elif str.isdecimal(xstr[0]):
|
|
678
|
+
#print("Possible IP")
|
|
679
|
+
pass
|
|
680
|
+
else:
|
|
681
|
+
# Yeah, padd it
|
|
682
|
+
xstr = "https://" + xstr
|
|
683
|
+
|
|
684
|
+
self.webview.load_uri(xstr)</code></pre>
|
|
685
|
+
</details>
|
|
686
|
+
</dd>
|
|
687
|
+
<dt id="browsewin.browserWin.gourl"><code class="name flex">
|
|
688
|
+
<span>def <span class="ident">gourl</span></span>(<span>self, *url)</span>
|
|
689
|
+
</code></dt>
|
|
690
|
+
<dd>
|
|
691
|
+
<div class="desc"></div>
|
|
692
|
+
<details class="source">
|
|
693
|
+
<summary>
|
|
694
|
+
<span>Expand source code</span>
|
|
695
|
+
</summary>
|
|
696
|
+
<pre><code class="python">def gourl(self, *url):
|
|
697
|
+
print("gourl", *url)
|
|
698
|
+
self.go(self.edit.get_text())</code></pre>
|
|
699
|
+
</details>
|
|
700
|
+
</dd>
|
|
701
|
+
<dt id="browsewin.browserWin.is_modified"><code class="name flex">
|
|
702
|
+
<span>def <span class="ident">is_modified</span></span>(<span>self)</span>
|
|
703
|
+
</code></dt>
|
|
704
|
+
<dd>
|
|
705
|
+
<div class="desc"></div>
|
|
706
|
+
<details class="source">
|
|
707
|
+
<summary>
|
|
708
|
+
<span>Expand source code</span>
|
|
709
|
+
</summary>
|
|
710
|
+
<pre><code class="python">def is_modified(self):
|
|
711
|
+
return self.webview.modified</code></pre>
|
|
712
|
+
</details>
|
|
713
|
+
</dd>
|
|
714
|
+
<dt id="browsewin.browserWin.load_html"><code class="name flex">
|
|
715
|
+
<span>def <span class="ident">load_html</span></span>(<span>self, strx)</span>
|
|
716
|
+
</code></dt>
|
|
717
|
+
<dd>
|
|
718
|
+
<div class="desc"></div>
|
|
719
|
+
<details class="source">
|
|
720
|
+
<summary>
|
|
721
|
+
<span>Expand source code</span>
|
|
722
|
+
</summary>
|
|
723
|
+
<pre><code class="python">def load_html(self, strx):
|
|
724
|
+
self.webview.load_html(strx)</code></pre>
|
|
725
|
+
</details>
|
|
726
|
+
</dd>
|
|
727
|
+
<dt id="browsewin.browserWin.open"><code class="name flex">
|
|
728
|
+
<span>def <span class="ident">open</span></span>(<span>self)</span>
|
|
729
|
+
</code></dt>
|
|
730
|
+
<dd>
|
|
731
|
+
<div class="desc"></div>
|
|
732
|
+
<details class="source">
|
|
733
|
+
<summary>
|
|
734
|
+
<span>Expand source code</span>
|
|
735
|
+
</summary>
|
|
736
|
+
<pre><code class="python">def open(self):
|
|
737
|
+
dialog = Gtk.FileChooserDialog("Open an HTML file", None,
|
|
738
|
+
Gtk.FileChooserAction.OPEN,
|
|
739
|
+
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
|
740
|
+
Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
|
|
741
|
+
|
|
742
|
+
ret = dialog.run()
|
|
743
|
+
fn = dialog.get_filename()
|
|
744
|
+
dialog.destroy()
|
|
745
|
+
|
|
746
|
+
if ret == Gtk.ResponseType.OK:
|
|
747
|
+
if not fn:
|
|
748
|
+
return
|
|
749
|
+
if os.path.exists(fn):
|
|
750
|
+
self.fname = fn
|
|
751
|
+
with open(fn) as fd:
|
|
752
|
+
self.webview.load_html(fd.read(), "file:///")</code></pre>
|
|
753
|
+
</details>
|
|
754
|
+
</dd>
|
|
755
|
+
<dt id="browsewin.browserWin.paste"><code class="name flex">
|
|
756
|
+
<span>def <span class="ident">paste</span></span>(<span>self)</span>
|
|
757
|
+
</code></dt>
|
|
758
|
+
<dd>
|
|
759
|
+
<div class="desc"></div>
|
|
760
|
+
<details class="source">
|
|
761
|
+
<summary>
|
|
762
|
+
<span>Expand source code</span>
|
|
763
|
+
</summary>
|
|
764
|
+
<pre><code class="python">def paste(self):
|
|
765
|
+
#print("paste")
|
|
766
|
+
self.webview.on_paste()
|
|
767
|
+
#self.webview.on_action("paste")</code></pre>
|
|
768
|
+
</details>
|
|
769
|
+
</dd>
|
|
770
|
+
<dt id="browsewin.browserWin.save"><code class="name flex">
|
|
771
|
+
<span>def <span class="ident">save</span></span>(<span>self)</span>
|
|
772
|
+
</code></dt>
|
|
773
|
+
<dd>
|
|
774
|
+
<div class="desc"></div>
|
|
775
|
+
<details class="source">
|
|
776
|
+
<summary>
|
|
777
|
+
<span>Expand source code</span>
|
|
778
|
+
</summary>
|
|
779
|
+
<pre><code class="python">def save(self):
|
|
780
|
+
|
|
781
|
+
#print("brow_win", "save", self.fname)
|
|
782
|
+
def completion(html, user_data):
|
|
783
|
+
#print("len html", len(html), len(self.webview.old_html) )
|
|
784
|
+
#print("html", html, "old", self.webview.old_html )
|
|
785
|
+
#if self.webview.old_html == html:
|
|
786
|
+
|
|
787
|
+
if not self.webview.modified:
|
|
788
|
+
self.set_status("File NOT modified.") # '%s'" % self.fname)
|
|
789
|
+
else:
|
|
790
|
+
#self.webview.old_html = html
|
|
791
|
+
open_mode = user_data
|
|
792
|
+
with open(self.fname, open_mode) as fd:
|
|
793
|
+
fd.write(html)
|
|
794
|
+
self.set_status("Saved file '%s'" % self.fname)
|
|
795
|
+
self.webview.modified = False
|
|
796
|
+
self.webview.get_html(completion, 'w')</code></pre>
|
|
797
|
+
</details>
|
|
798
|
+
</dd>
|
|
799
|
+
<dt id="browsewin.browserWin.saveas"><code class="name flex">
|
|
800
|
+
<span>def <span class="ident">saveas</span></span>(<span>self)</span>
|
|
801
|
+
</code></dt>
|
|
802
|
+
<dd>
|
|
803
|
+
<div class="desc"></div>
|
|
804
|
+
<details class="source">
|
|
805
|
+
<summary>
|
|
806
|
+
<span>Expand source code</span>
|
|
807
|
+
</summary>
|
|
808
|
+
<pre><code class="python">def saveas(self):
|
|
809
|
+
def completion(html, user_data):
|
|
810
|
+
open_mode = user_data
|
|
811
|
+
with open(self.fname, open_mode) as fd:
|
|
812
|
+
fd.write(html)
|
|
813
|
+
self.set_status("Saved as '%s'" % self.fname)
|
|
814
|
+
|
|
815
|
+
dialog = Gtk.FileChooserDialog("Select an HTML file", None,
|
|
816
|
+
Gtk.FileChooserAction.SAVE,
|
|
817
|
+
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
|
818
|
+
Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
|
|
819
|
+
|
|
820
|
+
if dialog.run() == Gtk.ResponseType.OK:
|
|
821
|
+
self.fname = dialog.get_filename()
|
|
822
|
+
#print("Saving", self.fname)
|
|
823
|
+
self.webview.get_html(completion, "w+")
|
|
824
|
+
dialog.destroy()</code></pre>
|
|
825
|
+
</details>
|
|
826
|
+
</dd>
|
|
827
|
+
<dt id="browsewin.browserWin.set_status"><code class="name flex">
|
|
828
|
+
<span>def <span class="ident">set_status</span></span>(<span>self, xtxt)</span>
|
|
829
|
+
</code></dt>
|
|
830
|
+
<dd>
|
|
831
|
+
<div class="desc"></div>
|
|
832
|
+
<details class="source">
|
|
833
|
+
<summary>
|
|
834
|
+
<span>Expand source code</span>
|
|
835
|
+
</summary>
|
|
836
|
+
<pre><code class="python">def set_status(self, xtxt):
|
|
837
|
+
self.status.set_text(xtxt)
|
|
838
|
+
GLib.timeout_add(3000, self.stattime, self, 0)</code></pre>
|
|
839
|
+
</details>
|
|
840
|
+
</dd>
|
|
841
|
+
<dt id="browsewin.browserWin.stattime"><code class="name flex">
|
|
842
|
+
<span>def <span class="ident">stattime</span></span>(<span>self, *arg)</span>
|
|
843
|
+
</code></dt>
|
|
844
|
+
<dd>
|
|
845
|
+
<div class="desc"></div>
|
|
846
|
+
<details class="source">
|
|
847
|
+
<summary>
|
|
848
|
+
<span>Expand source code</span>
|
|
849
|
+
</summary>
|
|
850
|
+
<pre><code class="python">def stattime(self, *arg):
|
|
851
|
+
self.status.set_text("Idle.")</code></pre>
|
|
852
|
+
</details>
|
|
853
|
+
</dd>
|
|
854
|
+
<dt id="browsewin.browserWin.url_callb"><code class="name flex">
|
|
855
|
+
<span>def <span class="ident">url_callb</span></span>(<span>self, xtxt)</span>
|
|
856
|
+
</code></dt>
|
|
857
|
+
<dd>
|
|
858
|
+
<div class="desc"></div>
|
|
859
|
+
<details class="source">
|
|
860
|
+
<summary>
|
|
861
|
+
<span>Expand source code</span>
|
|
862
|
+
</summary>
|
|
863
|
+
<pre><code class="python">def url_callb(self, xtxt):
|
|
864
|
+
self.go(xtxt)</code></pre>
|
|
865
|
+
</details>
|
|
866
|
+
</dd>
|
|
867
|
+
<dt id="browsewin.browserWin.urlbar"><code class="name flex">
|
|
868
|
+
<span>def <span class="ident">urlbar</span></span>(<span>self)</span>
|
|
869
|
+
</code></dt>
|
|
870
|
+
<dd>
|
|
871
|
+
<div class="desc"></div>
|
|
872
|
+
<details class="source">
|
|
873
|
+
<summary>
|
|
874
|
+
<span>Expand source code</span>
|
|
875
|
+
</summary>
|
|
876
|
+
<pre><code class="python">def urlbar(self):
|
|
877
|
+
|
|
878
|
+
self.edit = SimpleEdit();
|
|
879
|
+
self.edit.setsavecb(self.url_callb)
|
|
880
|
+
self.edit.single_line = True
|
|
881
|
+
|
|
882
|
+
hbox3 = Gtk.HBox()
|
|
883
|
+
uuu = Gtk.Label(" URL: ")
|
|
884
|
+
uuu.set_tooltip_text("Current / New URL; press Enter to go")
|
|
885
|
+
hbox3.pack_start(uuu, 0, 0, 0)
|
|
886
|
+
|
|
887
|
+
hbox3.pack_start(self.edit, True, True, 2)
|
|
888
|
+
|
|
889
|
+
bbb = LabelButt(" _Go ", self.gourl, "Go to speified URL")
|
|
890
|
+
#bbb = Gtk.Button.new_with_mnemonic(" _Go ") #, self.gourl, "Go to speified URL")
|
|
891
|
+
#bbb.connect("clicked", self.gourl)
|
|
892
|
+
|
|
893
|
+
#bbb = LabelButt(" _Go ", self.gourl, "Go to speified URL")
|
|
894
|
+
ccc = LabelButt(" <-_Back ", self.backurl, "Go Back")
|
|
895
|
+
ddd = LabelButt(" For_w-> ", self.forwurl, "Go Forw")
|
|
896
|
+
eee = LabelButt(" B_ase ", self.baseurl, "Go to base URL")
|
|
897
|
+
|
|
898
|
+
hbox3.pack_start(Gtk.Label(" "), 0, 0, 0)
|
|
899
|
+
|
|
900
|
+
hbox3.pack_start(bbb, 0, 0, 0)
|
|
901
|
+
hbox3.pack_start(ccc, 0, 0, 0)
|
|
902
|
+
hbox3.pack_start(ddd, 0, 0, 0)
|
|
903
|
+
hbox3.pack_start(eee, 0, 0, 0)
|
|
904
|
+
|
|
905
|
+
#hbox3.pack_start(Gtk.Label(" ^ "), 0, 0, 0)
|
|
906
|
+
hbox3.pack_start(Gtk.Label(" "), 0, 0, 0)
|
|
907
|
+
|
|
908
|
+
return hbox3</code></pre>
|
|
909
|
+
</details>
|
|
910
|
+
</dd>
|
|
911
|
+
</dl>
|
|
912
|
+
</dd>
|
|
913
|
+
</dl>
|
|
914
|
+
</section>
|
|
915
|
+
</article>
|
|
916
|
+
<nav id="sidebar">
|
|
917
|
+
<h1>Index</h1>
|
|
918
|
+
<div class="toc">
|
|
919
|
+
<ul></ul>
|
|
920
|
+
</div>
|
|
921
|
+
<ul id="index">
|
|
922
|
+
<li><h3><a href="#header-classes">Classes</a></h3>
|
|
923
|
+
<ul>
|
|
924
|
+
<li>
|
|
925
|
+
<h4><code><a title="browsewin.browserWin" href="#browsewin.browserWin">browserWin</a></code></h4>
|
|
926
|
+
<ul class="two-column">
|
|
927
|
+
<li><code><a title="browsewin.browserWin.backurl" href="#browsewin.browserWin.backurl">backurl</a></code></li>
|
|
928
|
+
<li><code><a title="browsewin.browserWin.baseurl" href="#browsewin.browserWin.baseurl">baseurl</a></code></li>
|
|
929
|
+
<li><code><a title="browsewin.browserWin.copy" href="#browsewin.browserWin.copy">copy</a></code></li>
|
|
930
|
+
<li><code><a title="browsewin.browserWin.cut" href="#browsewin.browserWin.cut">cut</a></code></li>
|
|
931
|
+
<li><code><a title="browsewin.browserWin.forwurl" href="#browsewin.browserWin.forwurl">forwurl</a></code></li>
|
|
932
|
+
<li><code><a title="browsewin.browserWin.get_content" href="#browsewin.browserWin.get_content">get_content</a></code></li>
|
|
933
|
+
<li><code><a title="browsewin.browserWin.go" href="#browsewin.browserWin.go">go</a></code></li>
|
|
934
|
+
<li><code><a title="browsewin.browserWin.gourl" href="#browsewin.browserWin.gourl">gourl</a></code></li>
|
|
935
|
+
<li><code><a title="browsewin.browserWin.is_modified" href="#browsewin.browserWin.is_modified">is_modified</a></code></li>
|
|
936
|
+
<li><code><a title="browsewin.browserWin.load_html" href="#browsewin.browserWin.load_html">load_html</a></code></li>
|
|
937
|
+
<li><code><a title="browsewin.browserWin.open" href="#browsewin.browserWin.open">open</a></code></li>
|
|
938
|
+
<li><code><a title="browsewin.browserWin.paste" href="#browsewin.browserWin.paste">paste</a></code></li>
|
|
939
|
+
<li><code><a title="browsewin.browserWin.save" href="#browsewin.browserWin.save">save</a></code></li>
|
|
940
|
+
<li><code><a title="browsewin.browserWin.saveas" href="#browsewin.browserWin.saveas">saveas</a></code></li>
|
|
941
|
+
<li><code><a title="browsewin.browserWin.set_status" href="#browsewin.browserWin.set_status">set_status</a></code></li>
|
|
942
|
+
<li><code><a title="browsewin.browserWin.stattime" href="#browsewin.browserWin.stattime">stattime</a></code></li>
|
|
943
|
+
<li><code><a title="browsewin.browserWin.url_callb" href="#browsewin.browserWin.url_callb">url_callb</a></code></li>
|
|
944
|
+
<li><code><a title="browsewin.browserWin.urlbar" href="#browsewin.browserWin.urlbar">urlbar</a></code></li>
|
|
945
|
+
</ul>
|
|
946
|
+
</li>
|
|
947
|
+
</ul>
|
|
948
|
+
</li>
|
|
949
|
+
</ul>
|
|
950
|
+
</nav>
|
|
951
|
+
</main>
|
|
952
|
+
<footer id="footer">
|
|
953
|
+
<p>Generated by <a href="https://pdoc3.github.io/pdoc" title="pdoc: Python API documentation generator"><cite>pdoc</cite> 0.10.0</a>.</p>
|
|
954
|
+
</footer>
|
|
955
|
+
</body>
|
|
956
|
+
</html>
|