Merge lp:~rick-rickspencer3/quidgets/gio_prompts into lp:quidgets
- gio_prompts
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Didier Roche-Tolomelli |
Approved revision: | 168 |
Merge reported by: | Rick Spencer |
Merged at revision: | not available |
Proposed branch: | lp:~rick-rickspencer3/quidgets/gio_prompts |
Merge into: | lp:quidgets |
Diff against target: |
860 lines (+173/-166) 1 file modified
quickly/prompts/__init__.py (+173/-166) |
To merge this branch: | bzr merge lp:~rick-rickspencer3/quidgets/gio_prompts |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Didier Roche-Tolomelli | Approve | ||
Review via email: mp+93938@code.launchpad.net |
Commit message
Description of the change
Update the code to use gobject introspection instead of pygtk
Rick Spencer (rick-rickspencer3) wrote : | # |
> From the tests:
> if I answer "Cancel" on the first "Open" dialog, I get a traceback:
> python prompts/__init__.py
> response was not OK
> Traceback (most recent call last):
> File "prompts/
> print "selected directory was " + val
> TypeError: cannot concatenate 'str' and 'NoneType' objects
>
> All the rest of the tests are passing fine with both "ok" and "cancel".
>
Thanks for the catch, I'll fix that right away. I think it's actually in the test, not in the API.
> Some remarks:
>
> - gtk.Dialog.
> gtk.DIALOG_
> gtk.RESPONSE_OK))
> 69 - self.set_
> 70 + Gtk.Dialog.
> Gtk.DialogFlags
> Gtk.STOCK_OK, Gtk.ResponseTyp
> 71 + #self.set_
> -> is this wanted that it's commented right now? (it was used before) Same
> with a lot of other set_has_separator. It seems to be in pygi and is even ued
> in the Gtk override file: /usr/share/
>
set_has_separator doesnt seem to be in the API anymore when I probe it with iPtyhon, and it seems to work without it.
> 242 + self._spinner.
> 243 + #adj,1,0
> -> same comment (you added adj, 1, 0 before)
>
The API changed. Now you can only set the adjustment, the other values you have to set in separate calls.
> 314 - self._spinner = gtk.SpinButton(
> 315 + self._spinner = Gtk.SpinButton()
> 316 + self._spinner.
> 317 + self._spinner.
> -> same :)
As above, I have to call set_digits instead of including the value in set_adjustment
>
>
> 451 - yes_button.
> 452 -
> 453 -
> 454 - self.set_
> 455 + yes_button.
> 456 +
> 457 +
> 458 + #self.set_
> -> same :)
>
> 559 - gtk.Dialog.
> title,None,
> 560 - self.set_
> 561 + Gtk.Dialog.
> title,None,
> 562 + #self.set_
> -> same same same ;)
- 168. By Rick Spencer
-
fixed crasher in open dialog test, deleted some cruft comments
Didier Roche-Tolomelli (didrocks) wrote : | # |
all looks good, please merge :)
Preview Diff
1 | === modified file 'quickly/prompts/__init__.py' |
2 | --- quickly/prompts/__init__.py 2011-01-17 20:36:14 +0000 |
3 | +++ quickly/prompts/__init__.py 2012-02-21 10:01:20 +0000 |
4 | @@ -13,17 +13,21 @@ |
5 | #with this program. If not, see <http://www.gnu.org/licenses/>. |
6 | ### END LICENSE |
7 | |
8 | -import gtk |
9 | -import gobject |
10 | +#import Gtk |
11 | +#import gobject |
12 | +#import GLib |
13 | +from gi.repository import Gtk |
14 | +from gi.repository import GObject |
15 | +from gi.repository import GLib |
16 | + |
17 | import os |
18 | -import glib |
19 | import gettext |
20 | from gettext import gettext as _ |
21 | gettext.textdomain('quickly-widgets') |
22 | |
23 | #TODO: stop using **kwargs and go back to named arguments so you can pass them from the function to the class |
24 | |
25 | -class Prompt(gtk.Dialog): |
26 | +class Prompt(Gtk.Dialog): |
27 | """A base class for some quickly.prompts - creates Ok and Cancel buttons, |
28 | displays a title and a label. |
29 | |
30 | @@ -45,20 +49,20 @@ |
31 | |
32 | Configuring |
33 | #add some widgets to the prompt using the |
34 | - #the prompt's content_box member (which is a gtk.VBox) |
35 | + #the prompt's content_box member (which is a Gtk.VBox) |
36 | #These widgets will appear below the label |
37 | #StringPrompt works similar to this: |
38 | p = quickly.prompts.Prompt(title,text) |
39 | - entry = gtk.Entry() |
40 | + entry = Gtk.Entry() |
41 | entry.set_text(default_value) |
42 | entry.set_activates_default(True) |
43 | entry.show() |
44 | p.content_box.pack_end(entry, True, True, 5) |
45 | response = p.run() |
46 | - if response = gtk.RESPONSE_OK: |
47 | + if response = Gtk.ResponseType.OK: |
48 | my_string = entry.get_text() |
49 | |
50 | - #A Prompt is a gtk.Dialog, so you can use gtk.DialogMembers |
51 | + #A Prompt is a Gtk.Dialog, so you can use Gtk.DialogMembers |
52 | action_area = p.get_action_area() |
53 | |
54 | Extending |
55 | @@ -69,7 +73,7 @@ |
56 | def __init__(self, title = "Input String", |
57 | text = "Input a String:", default_value = ""): |
58 | Prompt.__init__(self, title, text) |
59 | - self._entry = gtk.Entry() |
60 | + self._entry = Gtk.Entry() |
61 | self._entry.set_text(default_value) |
62 | self._entry.set_activates_default(True) |
63 | self._entry.show() |
64 | @@ -88,17 +92,17 @@ |
65 | |
66 | """ |
67 | |
68 | - gtk.Dialog.__init__(self, title, None, gtk.DIALOG_MODAL,(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK)) |
69 | - self.set_has_separator(False) |
70 | + Gtk.Dialog.__init__(self, title, None, Gtk.DialogFlags.MODAL,(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) |
71 | + #self.set_has_separator(False) |
72 | content_area = self.get_content_area() |
73 | content_area.set_border_width(5) |
74 | - self.set_default_response(gtk.RESPONSE_OK) |
75 | + self.set_default_response(Gtk.ResponseType.OK) |
76 | |
77 | - self.content_box = gtk.VBox(False, 10) |
78 | - label = gtk.Label(text) |
79 | + self.content_box = Gtk.VBox(False, 10) |
80 | + label = Gtk.Label(text) |
81 | label.set_line_wrap(True) |
82 | self.content_box.pack_start(label,False, False, 5) |
83 | - content_area.pack_start(self.content_box) |
84 | + content_area.pack_start(self.content_box,False, False, 5) |
85 | self.content_box.show() |
86 | label.show() |
87 | |
88 | @@ -110,10 +114,10 @@ |
89 | text - a string to provide a prompt for the user within dialog |
90 | default_value - a string to see the entry in the dialog box |
91 | |
92 | - returns a tuple of (gtk.DialogResponse, string value) |
93 | - gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise |
94 | - the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog |
95 | - (gtk.RESPONSE_DELETE_EVENT) |
96 | + returns a tuple of (Gtk.DialogResponse, string value) |
97 | + Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise |
98 | + the user cancelled (Gtk.ResponseType.CANCEL) or dismissed the dialog |
99 | + (Gtk.ResponseType.DELETE_EVENT) |
100 | |
101 | """ |
102 | |
103 | @@ -130,19 +134,19 @@ |
104 | #Collect a string from the user by using the |
105 | #quickly.prompts.string() helper function |
106 | reponse, val = string("String select test","String select test") |
107 | - if response == gtk.RESPONSE_OK: |
108 | + if response == Gtk.ResponseType.OK: |
109 | my_string = val |
110 | |
111 | Configuring |
112 | #Add widgets to the conent_box member |
113 | sp = StringPrompt(title, text, default_string) |
114 | - sp.content_box.pack_end(my_additional_widget) |
115 | + sp.content_box.pack_end(my_additional_widget, False, False, 5) |
116 | |
117 | #Modify the _entry member |
118 | sp._entry.set_max_length(144) |
119 | |
120 | Extending |
121 | - A StringPrompt is a Prompt which is gtk.Dialog |
122 | + A StringPrompt is a Prompt which is Gtk.Dialog |
123 | |
124 | """ |
125 | |
126 | @@ -156,14 +160,14 @@ |
127 | """ |
128 | |
129 | Prompt.__init__(self, title, text) |
130 | - self._entry = gtk.Entry() |
131 | + self._entry = Gtk.Entry() |
132 | self._entry.set_text(default_value) |
133 | self._entry.set_activates_default(True) |
134 | self._entry.show() |
135 | self.content_box.pack_end(self._entry, True, True, 5) |
136 | |
137 | def get_value(self): |
138 | - """get_value - returns the value the user has entered into the gtk.Entry |
139 | + """get_value - returns the value the user has entered into the Gtk.Entry |
140 | |
141 | """ |
142 | |
143 | @@ -178,13 +182,13 @@ |
144 | default_value - a tuple in the form of integers for (year,month,day) |
145 | where month is zero indexed (Jaunary is 0, December is 11) |
146 | |
147 | - returns a tuple of (gtk.DialogResponse, tuple) |
148 | + returns a tuple of (Gtk.DialogResponse, tuple) |
149 | The returnd tuple is in the form of integers for (year,month,day) |
150 | where month is zero indexed (Jaunary is 0, December is 11) |
151 | |
152 | - gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise |
153 | - the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog |
154 | - (gtk.RESPONSE_DELETE_EVENT) |
155 | + Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise |
156 | + the user cancelled (Gtk.ResponseType.CANCEL) or dismissed the dialog |
157 | + (Gtk.ResponseType.DELETE_EVENT) |
158 | |
159 | """ |
160 | dp = DatePrompt(title, text, default_value) |
161 | @@ -201,7 +205,7 @@ |
162 | #Collect a date from the user by using the |
163 | #quickly.prompts.date() helper function |
164 | reponse, val = date("Date prompt title","Date prompt message") |
165 | - if response == gtk.RESPONSE_OK: |
166 | + if response == Gtk.ResponseType.OK: |
167 | my_date = val |
168 | |
169 | Configuring |
170 | @@ -210,10 +214,10 @@ |
171 | dp.content_box.pack_end(my_additional_widget) |
172 | |
173 | #Modify the _calendar member |
174 | - dp._calendar.set_display_options(gtk.CALENDAR_SHOW_DAY_NAMES) |
175 | + dp._calendar.set_display_options(Gtk.CALENDAR_SHOW_DAY_NAMES) |
176 | |
177 | Extending |
178 | - A DatePrompt is a Prompt which is a gtk.Dialog. |
179 | + A DatePrompt is a Prompt which is a Gtk.Dialog. |
180 | |
181 | """ |
182 | |
183 | @@ -226,7 +230,7 @@ |
184 | |
185 | """ |
186 | Prompt.__init__(self, title, text) |
187 | - self._calendar = gtk.Calendar() |
188 | + self._calendar = Gtk.Calendar() |
189 | self._calendar.show() |
190 | self.content_box.pack_end(self._calendar, True, True, 5) |
191 | |
192 | @@ -263,11 +267,11 @@ |
193 | max_value, the highest number accepted by the spinner, |
194 | defaults to 1000000000 |
195 | |
196 | - returns a tuple of (gtk.DialogResponse, integer) |
197 | + returns a tuple of (Gtk.DialogResponse, integer) |
198 | |
199 | - gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise |
200 | - the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog |
201 | - (gtk.RESPONSE_DELETE_EVENT) |
202 | + Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise |
203 | + the user cancelled (Gtk.ResponseType.CANCEL) or dismissed the dialog |
204 | + (Gtk.ResponseType.DELETE_EVENT) |
205 | |
206 | """ |
207 | |
208 | @@ -280,14 +284,14 @@ |
209 | |
210 | class IntegerPrompt(Prompt): |
211 | """A Prompt for collecting an integer number value from user. Uses |
212 | - a gtk.Spinner for data entry. |
213 | + a Gtk.Spinner for data entry. |
214 | |
215 | |
216 | Using |
217 | #Collect an integer value from the user by using the |
218 | #quickly.prompts.integer() helper function |
219 | reponse, val = integer("Integer prompt title","Integer prompt message") |
220 | - if response == gtk.RESPONSE_OK: |
221 | + if response == Gtk.ResponseType.OK: |
222 | my_date = val |
223 | |
224 | Configuring |
225 | @@ -299,7 +303,7 @@ |
226 | dp._spinner.set_value(20) |
227 | |
228 | Extending |
229 | - An IntegerPrompt is a Prompt which is a gtk.Dialog |
230 | + An IntegerPrompt is a Prompt which is a Gtk.Dialog |
231 | |
232 | """ |
233 | |
234 | @@ -311,8 +315,9 @@ |
235 | """ |
236 | |
237 | Prompt.__init__(self, title, text) |
238 | - adj = gtk.Adjustment(default_value,min_value,max_value,step) |
239 | - self._spinner = gtk.SpinButton(adj,1,0) |
240 | + adj = Gtk.Adjustment(default_value,min_value,max_value,step) |
241 | + self._spinner = Gtk.SpinButton() |
242 | + self._spinner.set_adjustment(adj) |
243 | self._spinner.set_activates_default(True) |
244 | self._spinner.show() |
245 | self._spinner.set_numeric(True) |
246 | @@ -344,11 +349,11 @@ |
247 | supports a maximum of 20 decimal places. Values great than 20 will |
248 | be converted to 20, and values less than 0 will be converted to 0 |
249 | |
250 | - returns a tuple of (gtk.DialogResponse, number) |
251 | + returns a tuple of (Gtk.DialogResponse, number) |
252 | |
253 | - gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise |
254 | - the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog |
255 | - (gtk.RESPONSE_DELETE_EVENT) |
256 | + Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise |
257 | + the user cancelled (Gtk.ResponseType.CANCEL) or dismissed the dialog |
258 | + (Gtk.ResponseType.DELETE_EVENT) |
259 | |
260 | """ |
261 | |
262 | @@ -361,14 +366,14 @@ |
263 | |
264 | class DecimalPrompt(Prompt): |
265 | """A Prompt for collecting a decimal number value from user. Uses |
266 | - a gtk.Spinner for data entry. |
267 | + a Gtk.Spinner for data entry. |
268 | |
269 | Using |
270 | #Collect a number from the user by using the |
271 | #quickly.prompts.decimal() helper function |
272 | reponse, val = decimal("Decimal prompt title","Decimal prompt message") |
273 | - if response == gtk.RESPONSE_OK: |
274 | - my_date = val |
275 | + if response == Gtk.ResponseType.OK: |
276 | + my_decimal = val |
277 | |
278 | Configuring |
279 | #Add widgets to the content_box member |
280 | @@ -379,7 +384,7 @@ |
281 | dp._spinner.set_value(20.0) |
282 | |
283 | Extending |
284 | - An DecimalPrompt is a Prompt which is a gtk.Dialog |
285 | + An DecimalPrompt is a Prompt which is a Gtk.Dialog |
286 | |
287 | |
288 | """ |
289 | @@ -406,22 +411,24 @@ |
290 | supports a maximum of 20 decimal places. Values great than 20 will |
291 | be converted to 20, and values less than 0 will be converted to 0 |
292 | |
293 | - returns a tuple of (gtk.DialogResponse, number) |
294 | + returns a tuple of (Gtk.DialogResponse, number) |
295 | |
296 | - gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise |
297 | - the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog |
298 | - (gtk.RESPONSE_DELETE_EVENT) |
299 | + Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise |
300 | + the user cancelled (Gtk.ResponseType.CANCEL) or dismissed the dialog |
301 | + (Gtk.ResponseType.DELETE_EVENT) |
302 | |
303 | """ |
304 | |
305 | Prompt.__init__(self, title, text) |
306 | |
307 | - self._adjustment = gtk.Adjustment(default_value,min_value,max_value,step) |
308 | + self._adjustment = Gtk.Adjustment(default_value,min_value,max_value,step) |
309 | if digits > 20: |
310 | digits = 20 |
311 | if digits < 0: |
312 | digits = 0 |
313 | - self._spinner = gtk.SpinButton(self._adjustment,1,digits) |
314 | + self._spinner = Gtk.SpinButton() |
315 | + self._spinner.set_adjustment(self._adjustment) |
316 | + self._spinner.set_digits(digits) |
317 | self._spinner.set_activates_default(True) |
318 | self._spinner.show() |
319 | self._spinner.set_numeric(True) |
320 | @@ -450,11 +457,11 @@ |
321 | step - set the incriments for each click of the spinner buttons, |
322 | defaults to 1 |
323 | |
324 | - returns a tuple of (gtk.DialogResponse, number) |
325 | + returns a tuple of (Gtk.DialogResponse, number) |
326 | |
327 | - gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise |
328 | - the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog |
329 | - (gtk.RESPONSE_DELETE_EVENT) |
330 | + Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise |
331 | + the user cancelled (Gtk.ResponseType.CANCEL) or dismissed the dialog |
332 | + (Gtk.ResponseType.DELETE_EVENT) |
333 | |
334 | """ |
335 | |
336 | @@ -468,13 +475,13 @@ |
337 | class PricePrompt(DecimalPrompt): |
338 | """A Prompt for collecting a decimal number value from the user, |
339 | formatted with two decimal places appropriate for entering |
340 | - a currence ammount. Uses a gtk.Spinner for data entry. |
341 | + a currence ammount. Uses a Gtk.Spinner for data entry. |
342 | |
343 | Using |
344 | #Collect a number from the user by using the |
345 | #quickly.prompts.price() helper function |
346 | reponse, val = price("Price prompt title","Price prompt message") |
347 | - if response == gtk.RESPONSE_OK: |
348 | + if response == Gtk.ResponseType.OK: |
349 | my_date = val |
350 | |
351 | Configuring |
352 | @@ -486,7 +493,7 @@ |
353 | pp._spinner.set_value(20.00) |
354 | |
355 | Extending |
356 | - An PricePrompt is Decimal Prompt which is a Prompt which is a gtk.Dialog |
357 | + An PricePrompt is Decimal Prompt which is a Prompt which is a Gtk.Dialog |
358 | |
359 | |
360 | """ |
361 | @@ -510,11 +517,11 @@ |
362 | step - set the incriments for each click of the spinner buttons, |
363 | defaults to 1 |
364 | |
365 | - returns a tuple of (gtk.DialogResponse, number) |
366 | + returns a tuple of (Gtk.DialogResponse, number) |
367 | |
368 | - gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise |
369 | - the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog |
370 | - (gtk.RESPONSE_DELETE_EVENT) |
371 | + Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise |
372 | + the user cancelled (Gtk.ResponseType.CANCEL) or dismissed the dialog |
373 | + (Gtk.ResponseType.DELETE_EVENT) |
374 | |
375 | """ |
376 | |
377 | @@ -534,10 +541,10 @@ |
378 | yes - a string that is a verb representing the Yes action |
379 | no - a string that is a verb representing the No action |
380 | |
381 | - returns a gtk.DialogResponse |
382 | - gtk.RESPONSE_YES means the user clicked the "YES" button, otherwise |
383 | - gtk.RESPONSE_NO means the user clicked the "NO" button, otherwise |
384 | - the user dismissed the dialogv(gtk.RESPONSE_DELETE_EVENT) |
385 | + returns a Gtk.DialogResponse |
386 | + Gtk.ResponseType.YES means the user clicked the "YES" button, otherwise |
387 | + Gtk.ResponseType.NO means the user clicked the "NO" button, otherwise |
388 | + the user dismissed the dialogv(Gtk.ResponseType.DELETE_EVENT) |
389 | |
390 | """ |
391 | yn = YesNoPrompt(title,text,yes,no) |
392 | @@ -545,7 +552,7 @@ |
393 | yn.destroy() |
394 | return response |
395 | |
396 | -class YesNoPrompt(gtk.Dialog): |
397 | +class YesNoPrompt(Gtk.Dialog): |
398 | """A prompt to collect a user choice between two options, |
399 | one "yes" and one "no", though typically the button labels |
400 | should be set as verbs. |
401 | @@ -554,7 +561,7 @@ |
402 | #Collect a response from the user using the |
403 | #quickly.prompts.yes_no() helper function |
404 | reponse = decimal(title,message,"Do it", "Don't do it") |
405 | - if response == gtk.RESPONSE_YES: |
406 | + if response == Gtk.ResponseType.YES: |
407 | yes = True |
408 | else: |
409 | yes = False |
410 | @@ -565,11 +572,11 @@ |
411 | dp.content_box.pack_end(my_additional_widget) |
412 | |
413 | #add a widget to the response by creating it and |
414 | - #passing it in with a Gtk.RESPONSE_ID |
415 | + #passing it in with a Gtk.ResponseType.ID |
416 | dp.add_action_widget(new_widget, response_id) |
417 | |
418 | Extending |
419 | - An YesNoPrompt is a gtk.Dialog |
420 | + An YesNoPrompt is a Gtk.Dialog |
421 | |
422 | """ |
423 | |
424 | @@ -585,37 +592,37 @@ |
425 | |
426 | """ |
427 | |
428 | - gtk.Dialog.__init__(self, title, None, gtk.DIALOG_MODAL) |
429 | + Gtk.Dialog.__init__(self, title, None, Gtk.DialogFlags.MODAL) |
430 | |
431 | if no == "": |
432 | - no_button = gtk.Button(stock=gtk.STOCK_NO) |
433 | + no_button = Gtk.Button(stock=Gtk.STOCK_NO) |
434 | else: |
435 | - no_button = gtk.Button(label=no) |
436 | - self.add_action_widget(no_button,gtk.RESPONSE_NO) |
437 | + no_button = Gtk.Button(label=no, use_underline=True) |
438 | + self.add_action_widget(no_button,Gtk.ResponseType.NO) |
439 | no_button.show() |
440 | |
441 | if yes == "": |
442 | - yes_button = gtk.Button(stock=gtk.STOCK_YES) |
443 | + yes_button = Gtk.Button(stock=Gtk.STOCK_YES) |
444 | else: |
445 | - yes_button = gtk.Button(label=yes) |
446 | - self.add_action_widget(yes_button,gtk.RESPONSE_YES) |
447 | + yes_button = Gtk.Button(label=yes, use_underline=True) |
448 | + self.add_action_widget(yes_button,Gtk.ResponseType.YES) |
449 | yes_button.show() |
450 | - yes_button.set_flags(gtk.CAN_DEFAULT) |
451 | - |
452 | - |
453 | - self.set_has_separator(False) |
454 | + yes_button.set_can_default(True) |
455 | + |
456 | + |
457 | + #self.set_has_separator(False) |
458 | content_area = self.get_content_area() |
459 | content_area.set_border_width(5) |
460 | - self.set_default_response(gtk.RESPONSE_YES) |
461 | + self.set_default_response(Gtk.ResponseType.YES) |
462 | |
463 | - self.content_box = gtk.HBox(False, 10) |
464 | - img = gtk.Image() |
465 | - img.set_from_stock(gtk.STOCK_DIALOG_QUESTION,gtk.ICON_SIZE_DIALOG) |
466 | - self.content_box.pack_start(img) |
467 | - label = gtk.Label(text) |
468 | + self.content_box = Gtk.HBox(False, 10) |
469 | + img = Gtk.Image() |
470 | + img.set_from_stock(Gtk.STOCK_DIALOG_QUESTION,Gtk.IconSize.DIALOG) |
471 | + self.content_box.pack_start(img, False, False, 5) |
472 | + label = Gtk.Label(text) |
473 | label.set_line_wrap(True) |
474 | self.content_box.pack_start(label,False, False, 5) |
475 | - content_area.pack_start(self.content_box) |
476 | + content_area.pack_start(self.content_box, False, False, 5) |
477 | self.content_box.show() |
478 | label.show() |
479 | img.show() |
480 | @@ -628,13 +635,13 @@ |
481 | title - a string to be the title of the dialog |
482 | text - a string describing the warning |
483 | |
484 | - returns a gtk.DialogResponse |
485 | - gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise |
486 | - the user dismissed the dialogv(gtk.RESPONSE_DELETE_EVENT) |
487 | + returns a Gtk.DialogResponse |
488 | + Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise |
489 | + the user dismissed the dialogv(Gtk.ResponseType.DELETE_EVENT) |
490 | |
491 | """ |
492 | |
493 | - w = Alert(title,text,gtk.STOCK_DIALOG_WARNING) |
494 | + w = Alert(title,text,Gtk.STOCK_DIALOG_WARNING) |
495 | response = w.run() |
496 | w.destroy() |
497 | return response |
498 | @@ -647,13 +654,13 @@ |
499 | title - a string to be the title of the dialog |
500 | text - a string describing the error |
501 | |
502 | - returns a gtk.DialogResponse |
503 | - gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise |
504 | - the user dismissed the dialogv(gtk.RESPONSE_DELETE_EVENT) |
505 | + returns a Gtk.DialogResponse |
506 | + Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise |
507 | + the user dismissed the dialogv(Gtk.ResponseType.DELETE_EVENT) |
508 | |
509 | """ |
510 | |
511 | - e = Alert(title,text,gtk.STOCK_DIALOG_ERROR) |
512 | + e = Alert(title,text,Gtk.STOCK_DIALOG_ERROR) |
513 | response = e.run() |
514 | e.destroy() |
515 | return response |
516 | @@ -667,18 +674,18 @@ |
517 | title - a string to be the title of the dialog |
518 | text - a string providing the information |
519 | |
520 | - returns a gtk.DialogResponse |
521 | - gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise |
522 | - the user dismissed the dialogv(gtk.RESPONSE_DELETE_EVENT) |
523 | + returns a Gtk.DialogResponse |
524 | + Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise |
525 | + the user dismissed the dialogv(Gtk.ResponseType.DELETE_EVENT) |
526 | |
527 | """ |
528 | |
529 | - i = Alert(title,text,gtk.STOCK_DIALOG_INFO) |
530 | + i = Alert(title,text,Gtk.STOCK_DIALOG_INFO) |
531 | response = i.run() |
532 | i.destroy() |
533 | return response |
534 | |
535 | -class Alert(gtk.Dialog): |
536 | +class Alert(Gtk.Dialog): |
537 | """Displays an icon, a message, and an OK button to users. |
538 | Used by quickly.prompts.info(), quickly.prompts.warning(), |
539 | and quickly.prompts.error(). |
540 | @@ -690,37 +697,37 @@ |
541 | Configuring |
542 | #Add widgets to the content_box member |
543 | alert = Alert(title, text, image) |
544 | - alert.content_box.pack_end(my_additional_widget) |
545 | + alert.content_box.pack_end(my_additional_widget, False, False, 5) |
546 | |
547 | - #change the image by passing in a stock gtk image |
548 | + #change the image by passing in a stock Gtk image |
549 | alert.set_image(stock_image) |
550 | |
551 | Extending |
552 | - An Alert is a gtk.Dialog. |
553 | + An Alert is a Gtk.Dialog. |
554 | |
555 | """ |
556 | |
557 | def __init__(self,title="",text="",image=None): |
558 | - gtk.Dialog.__init__(self, title,None,gtk.DIALOG_MODAL,(gtk.STOCK_OK, gtk.RESPONSE_OK)) |
559 | - self.set_has_separator(False) |
560 | + Gtk.Dialog.__init__(self, title,None,Gtk.DialogFlags.MODAL,(Gtk.STOCK_OK, Gtk.ResponseType.OK)) |
561 | + #self.set_has_separator(False) |
562 | content_area = self.get_content_area() |
563 | content_area.set_border_width(5) |
564 | - self.set_default_response(gtk.RESPONSE_OK) |
565 | + self.set_default_response(Gtk.ResponseType.OK) |
566 | |
567 | - self.content_box = gtk.HBox(False, 10) |
568 | - label = gtk.Label(text) |
569 | + self.content_box = Gtk.HBox(False, 10) |
570 | + label = Gtk.Label(text) |
571 | label.set_line_wrap(True) |
572 | - self._image = gtk.Image() |
573 | - self._image.set_from_stock(image,gtk.ICON_SIZE_DIALOG) |
574 | + self._image = Gtk.Image() |
575 | + self._image.set_from_stock(image,Gtk.IconSize.DIALOG) |
576 | self.content_box.pack_start(self._image, False, False, 5) |
577 | self.content_box.pack_end(label,False, False, 5) |
578 | - content_area.pack_start(self.content_box) |
579 | + content_area.pack_start(self.content_box, False, False, 5) |
580 | self.content_box.show() |
581 | label.show() |
582 | self._image.show() |
583 | |
584 | def set_image(self, image): |
585 | - self._image.set_from_stock(image,gtk.ICON_SIZE_DIALOG) |
586 | + self._image.set_from_stock(image,Gtk.IconSize.DIALOG) |
587 | |
588 | |
589 | def save_image_file(title=_("Choose an Image"),path=None): |
590 | @@ -731,10 +738,10 @@ |
591 | path - a string providing a path to a directory where the |
592 | dialog should start. Defaults to Pictures directory. |
593 | |
594 | - returns a gtk.DialogResponse |
595 | - gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise |
596 | + returns a Gtk.DialogResponse |
597 | + Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise |
598 | the user clicked "Cancel" or the userdismissed the |
599 | - dialogv(gtk.RESPONSE_DELETE_EVENT) |
600 | + dialogv(Gtk.ResponseType.DELETE_EVENT) |
601 | |
602 | """ |
603 | |
604 | @@ -745,7 +752,7 @@ |
605 | return (response, value) |
606 | |
607 | |
608 | -class ImageDialog(gtk.FileChooserDialog): |
609 | +class ImageDialog(Gtk.FileChooserDialog): |
610 | """A base class for OpenImageDialog and SaveImageDialog |
611 | |
612 | Sets up typical mime types and file name patterns suitable |
613 | @@ -761,10 +768,10 @@ |
614 | """Create an ImageDialog. |
615 | |
616 | arguments: |
617 | - action - a file chooser action, either gtk.FILE_CHOOSER_ACTION_SAVE |
618 | - or gtk.FILE_CHOOSER_ACTION_OPEN |
619 | - button - a gtk stock button for the intended action, either |
620 | - gtk.STOCK_SAVE or gtk.STOCK_OPEN |
621 | + action - a file chooser action, either Gtk.FILE_CHOOSER_ACTION_SAVE |
622 | + or Gtk.FILE_CHOOSER_ACTION_OPEN |
623 | + button - a Gtk stock button for the intended action, either |
624 | + Gtk.STOCK_SAVE or Gtk.STOCK_OPEN |
625 | |
626 | keyword arguments: |
627 | title - a title for the dialog, defaults to an empty string |
628 | @@ -773,24 +780,24 @@ |
629 | |
630 | """ |
631 | |
632 | - gtk.FileChooserDialog.__init__(self,title, |
633 | + Gtk.FileChooserDialog.__init__(self,title, |
634 | None, |
635 | action, |
636 | - (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, |
637 | - button, gtk.RESPONSE_OK)) |
638 | + (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, |
639 | + button, Gtk.ResponseType.OK)) |
640 | |
641 | - self.set_default_response(gtk.RESPONSE_OK) |
642 | + self.set_default_response(Gtk.ResponseType.OK) |
643 | |
644 | if path == None: |
645 | - path = glib.get_user_special_dir(glib.USER_DIRECTORY_PICTURES) |
646 | + path = GLib.get_user_special_dir(GLib.USER_DIRECTORY_PICTURES) |
647 | self.set_current_folder(path) |
648 | |
649 | - self._filter = gtk.FileFilter() |
650 | + self._filter = Gtk.FileFilter() |
651 | self._filter.set_name("All files") |
652 | self._filter.add_pattern("*") |
653 | self.add_filter(self._filter) |
654 | |
655 | - self._filter = gtk.FileFilter() |
656 | + self._filter = Gtk.FileFilter() |
657 | self._filter.set_name("Images") |
658 | self._filter.add_mime_type("image/png") |
659 | self._filter.add_mime_type("image/jpeg") |
660 | @@ -811,7 +818,7 @@ |
661 | #Collect a location using the quickly.prompts.save_image_file() |
662 | #helper function |
663 | response, path = save_image_file(title) |
664 | - if response == gtk.RESPONSE_OK: |
665 | + if response == Gtk.ResponseType.OK: |
666 | save_to_path = path |
667 | |
668 | Configuring |
669 | @@ -820,7 +827,7 @@ |
670 | sid._filter.add_pattern("*.svg") |
671 | |
672 | Extending |
673 | - A SaveImageDialog is an ImageDialog which is a gtk.FileChooserDialog |
674 | + A SaveImageDialog is an ImageDialog which is a Gtk.FileChooserDialog |
675 | |
676 | """ |
677 | |
678 | @@ -834,7 +841,7 @@ |
679 | |
680 | """ |
681 | |
682 | - ImageDialog.__init__(self,gtk.FILE_CHOOSER_ACTION_SAVE, gtk.STOCK_SAVE, title,path) |
683 | + ImageDialog.__init__(self,Gtk.FileChooserAction.SAVE, Gtk.STOCK_SAVE, title,path) |
684 | |
685 | class OpenImageDialog(ImageDialog): |
686 | """ |
687 | @@ -844,7 +851,7 @@ |
688 | #Collect a location using the quickly.prompts.open_image_file() |
689 | #helper function |
690 | response, path = open_image_file(title) |
691 | - if response == gtk.RESPONSE_OK: |
692 | + if response == Gtk.ResponseType.OK: |
693 | path_to_image = path |
694 | |
695 | Configuring |
696 | @@ -853,7 +860,7 @@ |
697 | sid._filter.add_pattern("*.svg") |
698 | |
699 | Extending |
700 | - A SaveImageDialog is an ImageDialog which is a gtk.FileChooserDialog |
701 | + A SaveImageDialog is an ImageDialog which is a Gtk.FileChooserDialog |
702 | |
703 | """ |
704 | |
705 | @@ -866,7 +873,7 @@ |
706 | ~/Pictures |
707 | |
708 | """ |
709 | - ImageDialog.__init__(self,gtk.FILE_CHOOSER_ACTION_OPEN, gtk.STOCK_OPEN, title,path) |
710 | + ImageDialog.__init__(self,Gtk.FileChooserAction.OPEN, Gtk.STOCK_OPEN, title,path) |
711 | |
712 | def open_image_file(title=_("Choose an Image"),path=None): |
713 | """open_image_file - prompts the user to choose an image file |
714 | @@ -876,10 +883,10 @@ |
715 | path - a string providing a path to a directory where the |
716 | dialog should start. Defaults to Pictures directory. |
717 | |
718 | - returns a tuple of (gtk.DialogResponse, str) |
719 | - gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise |
720 | - the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog |
721 | - (gtk.RESPONSE_DELETE_EVENT) |
722 | + returns a tuple of (Gtk.DialogResponse, str) |
723 | + Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise |
724 | + the user cancelled (Gtk.ResponseType.CANCEL) or dismissed the dialog |
725 | + (Gtk.ResponseType.DELETE_EVENT) |
726 | The str is the path to the image chosen by the user, if any. |
727 | |
728 | |
729 | @@ -900,10 +907,10 @@ |
730 | dialog should start. |
731 | |
732 | |
733 | - returns a tuple of (gtk.DialogResponse, str) |
734 | - gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise |
735 | - the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog |
736 | - (gtk.RESPONSE_DELETE_EVENT) |
737 | + returns a tuple of (Gtk.DialogResponse, str) |
738 | + Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise |
739 | + the user cancelled (Gtk.ResponseType.CANCEL) or dismissed the dialog |
740 | + (Gtk.ResponseType.DELETE_EVENT) |
741 | The str is the path to the directory chosen by the user, if any. |
742 | |
743 | """ |
744 | @@ -914,7 +921,7 @@ |
745 | dcd.destroy() |
746 | return (response, value) |
747 | |
748 | -class DirectoryChooserDialog(gtk.FileChooserDialog): |
749 | +class DirectoryChooserDialog(Gtk.FileChooserDialog): |
750 | """A Dialog to prompt the user to choose a directory path. |
751 | |
752 | Using |
753 | @@ -922,13 +929,13 @@ |
754 | quickly.prompts.choose_directory(title) |
755 | |
756 | Configuring |
757 | - #A DirectoryChooseDialog is a gtk.FileChooserDialog, so you can |
758 | - #use gtk.FileChooseDialog members |
759 | + #A DirectoryChooseDialog is a Gtk.FileChooserDialog, so you can |
760 | + #use Gtk.FileChooseDialog members |
761 | dcd = DirectoryChooserDialog(title) |
762 | dcd.set_local_only(False) |
763 | |
764 | Extending |
765 | - #A DirectoryChooseDialog is a gtk.FileChooserDialog |
766 | + #A DirectoryChooseDialog is a Gtk.FileChooserDialog |
767 | |
768 | """ |
769 | |
770 | @@ -943,12 +950,12 @@ |
771 | |
772 | """ |
773 | |
774 | - gtk.FileChooserDialog.__init__(self, title, |
775 | + Gtk.FileChooserDialog.__init__(self, title, |
776 | None, |
777 | - gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, |
778 | - (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, |
779 | - gtk.STOCK_OPEN, gtk.RESPONSE_OK)) |
780 | - self.set_default_response(gtk.RESPONSE_OK) |
781 | + Gtk.FileChooserAction.SELECT_FOLDER, |
782 | + (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, |
783 | + Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) |
784 | + self.set_default_response(Gtk.ResponseType.OK) |
785 | if path is not None: |
786 | self.set_current_folder(path) |
787 | |
788 | @@ -962,63 +969,63 @@ |
789 | |
790 | #the rest of values to test for |
791 | response, val = choose_directory("directory choose test") |
792 | - if response == gtk.RESPONSE_OK: |
793 | + if response == Gtk.ResponseType.OK: |
794 | print "response was OK" |
795 | else: |
796 | print "response was not OK" |
797 | - print "selected directory was " + val |
798 | + print "selected directory was " + str(val) |
799 | |
800 | response, val = open_image_file("image open test") |
801 | - if response == gtk.RESPONSE_OK: |
802 | + if response == Gtk.ResponseType.OK: |
803 | print "response was OK" |
804 | else: |
805 | print "response was not OK" |
806 | print "selected locations was " + str(val) |
807 | |
808 | response, val = save_image_file("image save test") |
809 | - if response == gtk.RESPONSE_OK: |
810 | + if response == Gtk.ResponseType.OK: |
811 | print "response was OK" |
812 | else: |
813 | print "response was not OK" |
814 | print "selected locations was " + str(val) |
815 | |
816 | reponse, val = string("String select test","String select test") |
817 | - if response == gtk.RESPONSE_OK: |
818 | + if response == Gtk.ResponseType.OK: |
819 | print "response was OK" |
820 | else: |
821 | print "response was not OK" |
822 | print "string was " + str(val) |
823 | |
824 | reponse, val = date("Date select test","Date select test") |
825 | - if response == gtk.RESPONSE_OK: |
826 | + if response == Gtk.ResponseType.OK: |
827 | print "response was OK" |
828 | else: |
829 | print "response was not OK" |
830 | print "date was " + str(val) |
831 | |
832 | reponse, val = integer("Integer select test","Integer select test",default_value=20) |
833 | - if response == gtk.RESPONSE_OK: |
834 | + if response == Gtk.ResponseType.OK: |
835 | print "response was OK" |
836 | else: |
837 | print "response was not OK" |
838 | print "integer was " + str(val) |
839 | |
840 | - reponse, val = decimal("Price select test","Price select test",default_value=20,digits=5) |
841 | - if response == gtk.RESPONSE_OK: |
842 | + reponse, val = decimal("Decimal select test","Decimal select test",default_value=20,digits=5) |
843 | + if response == Gtk.ResponseType.OK: |
844 | print "response was OK" |
845 | else: |
846 | print "response was not OK" |
847 | print "decimal was " + str(val) |
848 | |
849 | reponse, val = price("Price select test","Price select test",default_value=20) |
850 | - if response == gtk.RESPONSE_OK: |
851 | + if response == Gtk.ResponseType.OK: |
852 | print "response was OK" |
853 | else: |
854 | print "response was not OK" |
855 | print "price was " + str(val) |
856 | |
857 | response = yes_no("Yes/No Test","Yes/No Test", "_Yes Verb","_No Verb") |
858 | - if response == gtk.RESPONSE_YES: |
859 | + if response == Gtk.ResponseType.YES: |
860 | print "response was yes" |
861 | |
862 |
From the tests: __init_ _.py", line 977, in <module>
if I answer "Cancel" on the first "Open" dialog, I get a traceback:
python prompts/__init__.py
response was not OK
Traceback (most recent call last):
File "prompts/
print "selected directory was " + val
TypeError: cannot concatenate 'str' and 'NoneType' objects
All the rest of the tests are passing fine with both "ok" and "cancel".
Some remarks:
- gtk.Dialog. __init_ _(self, title, None, gtk.DIALOG_ MODAL,( gtk.STOCK_ CANCEL, gtk.RESPONSE_ CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK)) has_separator( False) __init_ _(self, title, None, Gtk.DialogFlags .MODAL, (Gtk.STOCK_ CANCEL, Gtk.ResponseTyp e.CANCEL, Gtk.STOCK_OK, Gtk.ResponseTyp e.OK)) has_separator( False) pyshared/ gi/overrides/ Gtk.py
69 - self.set_
70 + Gtk.Dialog.
71 + #self.set_
-> is this wanted that it's commented right now? (it was used before) Same with a lot of other set_has_separator. It seems to be in pygi and is even ued in the Gtk override file: /usr/share/
242 + self._spinner. set_adjustment( adj)
243 + #adj,1,0
-> same comment (you added adj, 1, 0 before)
314 - self._spinner = gtk.SpinButton( self._adjustmen t,1,digits) set_adjustment( self._adjustmen t) set_digits( digits) #,1,digits)
315 + self._spinner = Gtk.SpinButton()
316 + self._spinner.
317 + self._spinner.
-> same :)
451 - yes_button. set_flags( gtk.CAN_ DEFAULT) has_separator( False) set_can_ default( True) has_separator( False)
452 -
453 -
454 - self.set_
455 + yes_button.
456 +
457 +
458 + #self.set_
-> same :)
559 - gtk.Dialog. __init_ _(self, title,None, gtk.DIALOG_ MODAL,( gtk.STOCK_ OK, gtk.RESPONSE_OK)) has_separator( False) __init_ _(self, title,None, Gtk.DialogFlags .MODAL, (Gtk.STOCK_ OK, Gtk.ResponseTyp e.OK)) has_separator( False)
560 - self.set_
561 + Gtk.Dialog.
562 + #self.set_
-> same same same ;)