[21:04:23] <speckle> Hello, does anyone know how to specify a palette when converting an array of 8-bit image data from Numpy to Pillow using PIL.Image.fromarray? Documentation is unclear about this
[21:08:38] <wiredfool> I think you need to putpalette
[21:10:59] <wiredfool> The documentation needs a going over, especially for things that aren't totally obvious from the code
[21:19:32] <speckle> I'm also unable to find the "TkImage" module to convert PIL images to Tk photos - I've tried various permutations but no luck
[21:19:50] <speckle> I'm unsure whether that's a tkinter module or a PIL module, though
[21:20:12] <wiredfool> I'm not really familiar with that part of the code
[21:20:35] <speckle> it seems like most of the tutorials are for Python 2, and the reorganization of the modules caused it to be buried somewhere for Python 3, and I have no idea where to look.. maybe I'll grep the source code, or maybe it's a separate package entirely. Hmm..
[21:25:21] <wiredfool> which is in the root directory
[21:39:31] <speckle> Maybe the bindings are missing :(
[21:40:54] <speckle> Either they are missing or Pillow is not installed properly on my system - even the import in the test script fails
[21:43:45] <speckle> Yeah, ImageTk.py is strangely missing from /usr/lib/python3/dist-packages/PIL/. Very odd
[21:49:05] <speckle> Okay, I got it by uninstalling my distro's package of Pillow, and reinstalling it from pip3. It seems very strange for distro package maintainers to silently leave out a file like that :(
[22:04:49] <wiredfool> I wonder if it's a split package
[22:06:55] <speckle> Could be - the version string says "python3-imaging 1.1.7+2.0.0-1ubuntu1"
[22:08:25] <wiredfool> the one they have is an old release
[22:09:23] <wiredfool> Thing is, on those two, if you're doing any dev, the pillow package compiles and installs so easily that it's almost not worth the maintainer's packages
[22:10:19] <speckle> Hmm, it looks like that ImageTk file existed since the 90s, though. Maybe it was a bug from an early edition of the version 2 branch, though, while you guys were in the middle of some transition or something
[22:11:12] <wiredfool> there's a lot of conditional compilation depending on libraries that are installed, so I'm guessing that it's a packaging/dependency thing.
[22:11:44] <wiredfool> I'd guess that they wouldn't want to pull in all of tk for pillow, and yet, if they build against tk, it's going to be broken on machines where it's not installed
[22:11:52] <speckle> Well, it's more about keeping one's system consistent than ease of installation, since going half-and-half on Pypi and the package manager can cause some issues. Maybe I just need a separate change root for development packages, and then distribute all dependencies together with my software
[22:12:08] <wiredfool> so, they may want a python-pil-tk package, or something
[22:12:22] <speckle> Hmm, I thought Tk was automatically installed...
[22:12:41] <wiredfool> I don't think it's on my servers
[22:19:55] <speckle> Now "fromarray" it giving me the error message "Cannot handle this data type" - I wonder which data types it *can* handle :P I just passed it a 2d numpy array of integers ranging from 0 to 255
[22:22:39] <wiredfool> There are a set of numpy types, I think if you tag them uint8 it will work.
[22:37:23] <speckle> I think I figured out the root cause of all these issues - I had the Tcl and Tk runtimes for 8.5 installed, but not the development libraries
[22:37:39] <speckle> somehow, that allowed Python to use it in a partially functional way
[22:38:04] <wiredfool> yeah, there's some wierdness there with tk
[22:38:16] <wiredfool> at least, I have a vague memory of it.
[22:39:27] <wiredfool> if you understand enough about tk to code up some basic tests I'd really appreciate getting them into the test suite
[22:39:29] <speckle> partially my fault for not installing the development libraries for everything I was using
[22:39:43] <wiredfool> then at least ther'd be examples and a known working state at one point in time
[22:51:17] <speckle> Hooray, I can finally draw a shape in numpy and pass it to Tkinter through PIL :) It still doesn't work with Xubuntu's default Pillow installation, though - I still need to get it from pip3
[22:52:13] <speckle> I'm not sure how we'd write tests for GUIs, though - it's difficult to automate that without an advanced framework
[22:58:17] <wiredfool> well, if we make an image, pass that into a tkimage, then somehow check a few of the values
[22:58:31] <wiredfool> or if there are conversions both ways, we could try round tripping it.
[23:02:21] <speckle> Ah, yeah. We'd still have a lot to test without actually testing the visual GUI - either way, it would be an improvement