Browse code
minor tweaks: urls correctly handled
- renamed 'main.py' -> pybrowse
- pybrowse: fixed uri handling, uris without scheme now work correctly
- pybrowse.glade: not quite sure
- added gitignore for vim swap files and glade backups
Showing 3 changed files
0 | 3 |
old mode 100644 |
1 | 4 |
new mode 100755 |
2 | 5 |
similarity index 81% |
3 | 6 |
rename from main.py |
4 | 7 |
rename to pybrowse |
... | ... |
@@ -1,7 +1,11 @@ |
1 |
+#!/usr/bin/env python3.4 |
|
1 | 2 |
from gi.repository import Gtk, WebKit |
3 |
+import os.path |
|
4 |
+print(__file__) |
|
5 |
+basepath = os.path.dirname(__file__) |
|
2 | 6 |
|
3 | 7 |
builder = Gtk.Builder() |
4 |
-builder.add_from_file("pybrowse.glade") |
|
8 |
+builder.add_from_file(os.path.join(basepath,"pybrowse.glade")) |
|
5 | 9 |
window = builder.get_object("mainWindow") |
6 | 10 |
webview = WebKit.WebView() |
7 | 11 |
def onLoad(webview, stat_type): |
... | ... |
@@ -42,6 +46,12 @@ import argparse |
42 | 46 |
parser = argparse.ArgumentParser() |
43 | 47 |
parser.add_argument('uri', nargs='?', default='http://google.com') |
44 | 48 |
args = parser.parse_args() |
45 |
-webview.load_uri(args.uri) |
|
49 |
+ |
|
50 |
+import urllib.parse |
|
51 |
+def fix_uri(uri): |
|
52 |
+ if '://' not in uri: |
|
53 |
+ uri = 'http://%s' % uri |
|
54 |
+ return uri |
|
55 |
+webview.load_uri(fix_uri(args.uri)) |
|
46 | 56 |
|
47 | 57 |
Gtk.main() |
... | ... |
@@ -106,7 +106,6 @@ |
106 | 106 |
<child internal-child="entry"> |
107 | 107 |
<object class="GtkEntry" id="evalTxt"> |
108 | 108 |
<property name="can_focus">True</property> |
109 |
- <property name="text" translatable="yes">print('hi')</property> |
|
110 | 109 |
<property name="placeholder_text" translatable="yes"><python code here></property> |
111 | 110 |
<signal name="activate" handler="evalBtn_clicked_cb" object="evalTxt" swapped="yes"/> |
112 | 111 |
</object> |