On 01/27/2013 03:24 PM, Christian Mallwitz wrote:

Where in C you would have something along the lines of:

  switch (event->keyval) {
    case GDK_Left: ...
    case GDK_BackSpace: ...
    ...
}

What is your preferred code style to handle that in Python? How about
more than one keyval triggering the same action?

If it's a small number of cases, just use if/elif. (With "or" for the multiple value case.)

If it's a large number of cases, you can use a dict, with functions or methods as the values.

--
David Ripton    drip...@ripton.net
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to