Wednesday, December 30, 2009

More Quidget One-Liners: Yes/No, Warnings, Info, Errors

Last night I spent some time working on bug #500911, adding some more useful functions to the quidgets.prompts namespace.

quidgets.prompts.yes_no() works like this:
  response = quidgets.prompts.yes_no("I need some info","Do you want to give me a yes or no?")
if response == gtk.RESPONSE_YES:
print "they said yes"
elif response == gtk.RESPONSE_NO:
print "they said no"
print "they dismissed the dialog"
This is a little different than the other functions in the namespace in that in that the responses are gtk.RESPONSE_YES or gtk.RESPONSE_NO, rather than gtk.RESPONSE_OK, or gtk.RESPONSE_CANCEL. Of course, there is no "value", as you are just looking for a yes or no from the user.

Warning, Error, and Info are similar, but you don't even check the return value, as you are not seeking any feedback. You just supply a title and some text that you are trying to tell the user.

quidgets.prompts.warning("Title goes here","Warning")
quidgets.prompts.error("Title goes here","Error")"Title goes here","Info")
I hope that folks find this useful, and that it saves writing lots of lines of code. I've pushed the branch, and should get it into my PPA in the next few days.

About Quidgets
Quickly + Widgets = Quidgets
There is a Launchpad Project for Quidgets
The most up to date changes are in the Quidgets Trunk Branch


  1. Quidgets is starting to look a lot like zenity, which is great. Perhaps you could look at the ones zenity offers for ideas on things people use often.

    Thanks for your awesome work,

  2. added bug 501804

  3. Yay that solves my blog post from a week ago thanks rick :D

  4. Don't use Yes/No - that is a bad, bad Windows paradigm. Use VERBS on buttons instead of asking Yes/No questions.

  5. I agree with Rich. "Close without saving", "Continue editing" and "Save as" are much better buttons then Yes/No/Cancel.

  6. Perhaps adding a default minium width will improve the layout of the smaller dialogs. The examples look to me a little squashed.

  7. Nice, though I don't really see how this is useful given that gtk.MessageDialog does the same and is already quite simple.

    I also agreed with Rich and flimm in that Yes/No dialogues really suck. Further, I believe dialogues should be avoided whenever possible (by using morphing windows, embeded messages like gedit/Firefox do, etc.), but I suppose those one-liners are intended for people writing little scripts for personal usage, so this isn't really applicable anyway.

    By the way Rick, please poke me when you're on IRC, I'd like to talk to you about something else related to Quidgets :).