How can I convert canvas content to an image?

from Tkinter import * root = Tk() cv = Canvas(root) cv.create_rectangle(10,10,50,50) cv.pack() root.mainloop() I want to convert canvas content to a bitmap or other image, and then do other operations, such as rotating or scaling the image, or changing its coordinates. Bitmaps can improve efficiency to show if I am no longer drawing. What should … Read more

Why does list.append() return None?

I am trying to calculate a postfix expression using Python, but it did not work. I think this is maybe a Python-related problem. Any suggestions? expression = [12, 23, 3, '*', '+', 4, '-', 86, 2, '/', '+'] def add(a,b): return a + b def multi(a,b): return a* b def sub(a,b): return a – b … Read more

Python regex matching Unicode properties

Perl and some other current regex engines support Unicode properties, such as the category, in a regex. E.g. in Perl you can use p{Ll} to match an arbitrary lower-case letter, or p{Zs} for any space separator. I don’t see support for this in either the 2.x nor 3.x lines of Python (with due regrets). Is anybody aware of a good strategy to get a similar effect? Homegrown solutions are welcome.