Browse code
little fixes: title and python entry
- made the window title correspond to the web view title
- replaced the evalhistory listbox with a combobox.
Showing 2 changed files
... | ... |
@@ -4,9 +4,10 @@ builder = Gtk.Builder() |
4 | 4 |
builder.add_from_file("pybrowse.glade") |
5 | 5 |
window = builder.get_object("mainWindow") |
6 | 6 |
webview = WebKit.WebView() |
7 |
-def onLoad(*a): |
|
8 |
- if a[0].get_load_status() == WebKit.LoadStatus.FINISHED: |
|
7 |
+def onLoad(webview, stat_type): |
|
8 |
+ if webview.get_load_status() == WebKit.LoadStatus.FINISHED: |
|
9 | 9 |
builder.get_object("goTxt").set_text(webview.get_uri()) |
10 |
+ window.set_title(webview.get_title()) |
|
10 | 11 |
webview.connect("notify::load-status", onLoad) |
11 | 12 |
mv = builder.get_object("mainview") |
12 | 13 |
mv.add(webview) |
... | ... |
@@ -22,8 +23,7 @@ class SigHandler(object): |
22 | 23 |
def evalBtn_clicked_cb(self, v): |
23 | 24 |
txt = v.get_text() |
24 | 25 |
exec(txt, globals(), self.eval_locals) |
25 |
- path = self.eval_model.get_path(self.eval_model.append([txt])) |
|
26 |
- builder.get_object("evalHistory").scroll_to_cell(path) |
|
26 |
+ self.eval_model.append([txt]) |
|
27 | 27 |
def row_activated(self, s, *a): |
28 | 28 |
model, itr = s.get_selected() |
29 | 29 |
eval_txt = builder.get_object('evalTxt') |
... | ... |
@@ -44,9 +44,4 @@ parser.add_argument('uri', nargs='?', default='http://google.com') |
44 | 44 |
args = parser.parse_args() |
45 | 45 |
webview.load_uri(args.uri) |
46 | 46 |
|
47 |
-try: |
|
48 |
- Gtk.main() |
|
49 |
-except: |
|
50 |
- import sys |
|
51 |
- sys.exit(1) |
|
52 |
- raise |
|
47 |
+Gtk.main() |
... | ... |
@@ -2,6 +2,16 @@ |
2 | 2 |
<!-- Generated with glade 3.18.3 --> |
3 | 3 |
<interface> |
4 | 4 |
<requires lib="gtk+" version="3.12"/> |
5 |
+ <object class="GtkImage" id="evalImage"> |
|
6 |
+ <property name="visible">True</property> |
|
7 |
+ <property name="can_focus">False</property> |
|
8 |
+ <property name="stock">gtk-execute</property> |
|
9 |
+ </object> |
|
10 |
+ <object class="GtkImage" id="goImage"> |
|
11 |
+ <property name="visible">True</property> |
|
12 |
+ <property name="can_focus">False</property> |
|
13 |
+ <property name="stock">gtk-media-play</property> |
|
14 |
+ </object> |
|
5 | 15 |
<object class="GtkListStore" id="historyModel"> |
6 | 16 |
<columns> |
7 | 17 |
<!-- column-name item --> |
... | ... |
@@ -10,6 +20,7 @@ |
10 | 20 |
</object> |
11 | 21 |
<object class="GtkApplicationWindow" id="mainWindow"> |
12 | 22 |
<property name="can_focus">False</property> |
23 |
+ <property name="title" translatable="yes">pyBrowse</property> |
|
13 | 24 |
<property name="default_width">500</property> |
14 | 25 |
<property name="default_height">600</property> |
15 | 26 |
<property name="show_menubar">False</property> |
... | ... |
@@ -37,11 +48,12 @@ |
37 | 48 |
</child> |
38 | 49 |
<child> |
39 | 50 |
<object class="GtkButton" id="goBtn"> |
40 |
- <property name="label">gtk-ok</property> |
|
51 |
+ <property name="label">_Go</property> |
|
41 | 52 |
<property name="visible">True</property> |
42 | 53 |
<property name="can_focus">True</property> |
43 | 54 |
<property name="receives_default">True</property> |
44 |
- <property name="use_stock">True</property> |
|
55 |
+ <property name="image">goImage</property> |
|
56 |
+ <property name="use_underline">True</property> |
|
45 | 57 |
<signal name="clicked" handler="goBtn_clicked_cb" object="goTxt" swapped="yes"/> |
46 | 58 |
</object> |
47 | 59 |
<packing> |
... | ... |
@@ -59,129 +71,74 @@ |
59 | 71 |
</packing> |
60 | 72 |
</child> |
61 | 73 |
<child> |
62 |
- <object class="GtkPaned" id="paned1"> |
|
74 |
+ <object class="GtkScrolledWindow" id="mainview"> |
|
63 | 75 |
<property name="visible">True</property> |
64 | 76 |
<property name="can_focus">True</property> |
65 |
- <property name="orientation">vertical</property> |
|
77 |
+ <property name="shadow_type">in</property> |
|
66 | 78 |
<child> |
67 |
- <object class="GtkScrolledWindow" id="mainview"> |
|
68 |
- <property name="height_request">768</property> |
|
79 |
+ <placeholder/> |
|
80 |
+ </child> |
|
81 |
+ </object> |
|
82 |
+ <packing> |
|
83 |
+ <property name="expand">True</property> |
|
84 |
+ <property name="fill">True</property> |
|
85 |
+ <property name="position">1</property> |
|
86 |
+ </packing> |
|
87 |
+ </child> |
|
88 |
+ <child> |
|
89 |
+ <object class="GtkBox" id="box1"> |
|
90 |
+ <property name="visible">True</property> |
|
91 |
+ <property name="can_focus">False</property> |
|
92 |
+ <child> |
|
93 |
+ <object class="GtkComboBox" id="combobox1"> |
|
69 | 94 |
<property name="visible">True</property> |
70 | 95 |
<property name="can_focus">True</property> |
71 |
- <property name="vexpand">True</property> |
|
72 |
- <property name="vscrollbar_policy">always</property> |
|
73 |
- <property name="shadow_type">in</property> |
|
74 |
- <property name="min_content_height">500</property> |
|
96 |
+ <property name="model">historyModel</property> |
|
97 |
+ <property name="button_sensitivity">on</property> |
|
98 |
+ <property name="has_entry">True</property> |
|
99 |
+ <property name="entry_text_column">0</property> |
|
75 | 100 |
<child> |
76 |
- <placeholder/> |
|
101 |
+ <object class="GtkCellRendererText" id="cellrenderertext1"/> |
|
102 |
+ <attributes> |
|
103 |
+ <attribute name="text">0</attribute> |
|
104 |
+ </attributes> |
|
105 |
+ </child> |
|
106 |
+ <child internal-child="entry"> |
|
107 |
+ <object class="GtkEntry" id="evalTxt"> |
|
108 |
+ <property name="can_focus">True</property> |
|
109 |
+ <property name="text" translatable="yes">print('hi')</property> |
|
110 |
+ <property name="placeholder_text" translatable="yes"><python code here></property> |
|
111 |
+ <signal name="activate" handler="evalBtn_clicked_cb" object="evalTxt" swapped="yes"/> |
|
112 |
+ </object> |
|
77 | 113 |
</child> |
78 | 114 |
</object> |
79 | 115 |
<packing> |
80 |
- <property name="resize">True</property> |
|
81 |
- <property name="shrink">False</property> |
|
116 |
+ <property name="expand">True</property> |
|
117 |
+ <property name="fill">True</property> |
|
118 |
+ <property name="position">0</property> |
|
82 | 119 |
</packing> |
83 | 120 |
</child> |
84 | 121 |
<child> |
85 |
- <object class="GtkBox" id="box1"> |
|
86 |
- <property name="height_request">120</property> |
|
122 |
+ <object class="GtkButton" id="evalBtn"> |
|
123 |
+ <property name="label" translatable="yes">_Eval</property> |
|
87 | 124 |
<property name="visible">True</property> |
88 |
- <property name="can_focus">False</property> |
|
89 |
- <property name="orientation">vertical</property> |
|
90 |
- <child> |
|
91 |
- <object class="GtkScrolledWindow" id="scrolledwindow1"> |
|
92 |
- <property name="height_request">20</property> |
|
93 |
- <property name="visible">True</property> |
|
94 |
- <property name="can_focus">True</property> |
|
95 |
- <property name="shadow_type">in</property> |
|
96 |
- <property name="min_content_height">20</property> |
|
97 |
- <child> |
|
98 |
- <object class="GtkTreeView" id="evalHistory"> |
|
99 |
- <property name="visible">True</property> |
|
100 |
- <property name="can_focus">True</property> |
|
101 |
- <property name="model">historyModel</property> |
|
102 |
- <property name="headers_visible">False</property> |
|
103 |
- <property name="search_column">0</property> |
|
104 |
- <property name="show_expanders">False</property> |
|
105 |
- <property name="enable_grid_lines">both</property> |
|
106 |
- <signal name="add" handler="row_added" swapped="no"/> |
|
107 |
- <signal name="row-activated" handler="row_activated" object="evalHistory-selection" swapped="no"/> |
|
108 |
- <child internal-child="selection"> |
|
109 |
- <object class="GtkTreeSelection" id="evalHistory-selection"/> |
|
110 |
- </child> |
|
111 |
- <child> |
|
112 |
- <object class="GtkTreeViewColumn" id="itemcol"> |
|
113 |
- <property name="title" translatable="yes">Item</property> |
|
114 |
- <child> |
|
115 |
- <object class="GtkCellRendererText" id="cellrenderertext1"/> |
|
116 |
- <attributes> |
|
117 |
- <attribute name="text">0</attribute> |
|
118 |
- </attributes> |
|
119 |
- </child> |
|
120 |
- </object> |
|
121 |
- </child> |
|
122 |
- </object> |
|
123 |
- </child> |
|
124 |
- </object> |
|
125 |
- <packing> |
|
126 |
- <property name="expand">True</property> |
|
127 |
- <property name="fill">True</property> |
|
128 |
- <property name="position">0</property> |
|
129 |
- </packing> |
|
130 |
- </child> |
|
131 |
- <child> |
|
132 |
- <object class="GtkBox" id="box3"> |
|
133 |
- <property name="visible">True</property> |
|
134 |
- <property name="can_focus">False</property> |
|
135 |
- <child> |
|
136 |
- <object class="GtkEntry" id="evalTxt"> |
|
137 |
- <property name="visible">True</property> |
|
138 |
- <property name="can_focus">True</property> |
|
139 |
- <signal name="activate" handler="evalBtn_clicked_cb" object="evalTxt" swapped="no"/> |
|
140 |
- </object> |
|
141 |
- <packing> |
|
142 |
- <property name="expand">True</property> |
|
143 |
- <property name="fill">True</property> |
|
144 |
- <property name="position">0</property> |
|
145 |
- </packing> |
|
146 |
- </child> |
|
147 |
- <child> |
|
148 |
- <object class="GtkButton" id="evalBtn"> |
|
149 |
- <property name="label">gtk-execute</property> |
|
150 |
- <property name="visible">True</property> |
|
151 |
- <property name="can_focus">True</property> |
|
152 |
- <property name="receives_default">True</property> |
|
153 |
- <property name="use_stock">True</property> |
|
154 |
- <property name="yalign">0.49000000953674316</property> |
|
155 |
- <property name="always_show_image">True</property> |
|
156 |
- <signal name="clicked" handler="evalBtn_clicked_cb" object="evalTxt" swapped="no"/> |
|
157 |
- </object> |
|
158 |
- <packing> |
|
159 |
- <property name="expand">False</property> |
|
160 |
- <property name="fill">True</property> |
|
161 |
- <property name="pack_type">end</property> |
|
162 |
- <property name="position">1</property> |
|
163 |
- </packing> |
|
164 |
- </child> |
|
165 |
- </object> |
|
166 |
- <packing> |
|
167 |
- <property name="expand">False</property> |
|
168 |
- <property name="fill">True</property> |
|
169 |
- <property name="pack_type">end</property> |
|
170 |
- <property name="position">1</property> |
|
171 |
- </packing> |
|
172 |
- </child> |
|
125 |
+ <property name="can_focus">True</property> |
|
126 |
+ <property name="receives_default">True</property> |
|
127 |
+ <property name="image">evalImage</property> |
|
128 |
+ <property name="use_underline">True</property> |
|
129 |
+ <signal name="clicked" handler="evalBtn_clicked_cb" object="evalTxt" swapped="no"/> |
|
173 | 130 |
</object> |
174 | 131 |
<packing> |
175 |
- <property name="resize">True</property> |
|
176 |
- <property name="shrink">True</property> |
|
132 |
+ <property name="expand">False</property> |
|
133 |
+ <property name="fill">True</property> |
|
134 |
+ <property name="position">1</property> |
|
177 | 135 |
</packing> |
178 | 136 |
</child> |
179 | 137 |
</object> |
180 | 138 |
<packing> |
181 |
- <property name="expand">True</property> |
|
139 |
+ <property name="expand">False</property> |
|
182 | 140 |
<property name="fill">True</property> |
183 |
- <property name="pack_type">end</property> |
|
184 |
- <property name="position">1</property> |
|
141 |
+ <property name="position">2</property> |
|
185 | 142 |
</packing> |
186 | 143 |
</child> |
187 | 144 |
</object> |