Reputation: 44345
When I use pylab and python under Linux to draw and show an image, like in the following example:
img = pylab.imread(filename)
pylab.imshow(img)
pylab.show()
pylab.draw()
When I do so, a new window pops up with the image.
My question: How can I influence the position and the size?
Upvotes: 0
Views: 272
Reputation: 365807
The whole point of pylab
's Image stuff is that you get a np.array
of pixel data.
So, you can just do this:
img = pylab.imread(filename)
img = img * myTransformationMatrix
pylab.imshow(img)
If that immediately tells you what you need to know, great. If you don't understand what matrix multiplication has to do with rotating, translating, and scaling images, pylab
is probably not the image library you want to use. Just use PIL.
If you're trying to manipulate the windows, rather than the images, pylab
is really not meant for that.
You probably want to use TkInter
, the windowing library that comes built-in with Python. It's can be ugly, clunky, and slow, and some advanced uses are either impossible or require you to write Tcl code instead of Python… but for simple stuff, it's not going to be a step down from pylab
. In fact, it's what pylab
uses under the covers.
If you start to hit the limits of TkInter
, it's time to look at an external windowing library. You can go with a full GUI framework like Gtk+, Qt, or wx. The Python bindings to the three aren't that different; the important difference is that in the slightly different models of how GUIs work, so read about them and pick the model you like best. Alternatively, you can use something like pygame
, which does very bare-bones windowing (the kind of thing games would need, rather than, say, word processors).
Upvotes: 1