-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion on how to remove TkImg or improve platform compatibility #22
Comments
When installing directly from git, with the same command as you have used, except for using Python 3.6 instead of Python 3.4 on Ubuntu 17.04 64-bit, I cannot reproduce the issue. Could you provide me with more details about your platform? Then I can spin up a Virtual Machine and try to reproduce the issue in the exact same environment. |
Python 3.4 and Python 3.7 on a 64-bit Ubuntu 14.04.
|
Oops, I clicked the close button accidentally. |
I think I found the problem...
Maybe something's wrong with setup.py? |
Are you sure that this code is ok? https://github.com/RedFantom/ttkthemes/blob/master/setup.py#L23-L35 |
Umm... can you just delete the weird I liked this library when this was a "pip install and use and it works" thing instead of an ugly |
The real issue here is that I need to include a certain set of library files, Thus, I have to include the compiled library files for the platforms they are available for. However, I do not want to include all library files for all platforms in all wheel packages, I only want to include a single set. But because it is not an extension that can be compiled upon building the wheel, I have to include the files in the package manually. What files to select depends on the platform, and then the files can be copied over to the right folder and packaged in the wheel. When using a source distribution, all library files are included still and the code uses path finding to select the correct ones out of the full set during runtime. I don't know why the files don't get copied in your particular case, and I would certainly like to know so I can fix this issue, but I can't reproduce it: It works fine for me when either using sdist or bdist. For now, I cannot delete the weird hack, because I do not know of a better way to implement this. If I could build the If you do know a better way of fixing this instead, I would love to hear it, but for now this is the only solution that I know of that works and allows non-Tk 8.6 platforms to work with PNG-images. |
Maybe it would be best to always include all binaries on all platforms for now? Nobody would notice the bigger download size anyway. I can figure out a better alternative to the Edit: I'm interested in the |
Ummm, did I understand correctly? I think you're saying that tkimg is only needed for Tcl/Tk 8.5 and older. Would it be possible to instead use the built-in png support in Tcl/Tk 8.6 when that's available? I always use Tk 8.6 anyway. |
Sorry for the walls of text :( It's just annoying not to be able to install a library I really want to use. |
Yes, I understand that that is frustrating. I really want to help and fix this, I just don't know how yet. I want to offer everyone on every platform the same experience. Building just an sdist is something I will consider as a last option. The pip check is performed to see if the package is being installed with pip, or whether a 'normal' execution of setup.py is performed. For now, could you run setup.py as: I will spin up a fresh VM with no history of ttkthemes when I am back at my workstation. |
Why would pip need to be treated differently? |
Well, that command was very useful...
|
Well, at least I have a working installation now. I wish pip installing wasn't so broken though. I ran |
If your system does not recognize the It's not necessarily Edit: For now, the packages on |
In that case, why not check for their existance with e.g.
Something too old. I just updated it. |
I can create a pull request that replaces |
Yes, that is okay with me. I will try to get to it as soon as I can, but that can take a few more days. My concern when initialiy building this code, was that when using an existence check, I was not sure how compatible that would be with installing (and thus execution from) wheel packages and source distributions alike. The real underlying issue is that the libraries are already compiled, and that is in no way officially supported by Python packaging. So it will always be a work-around-like situation. |
Automatically closed after merging #23. |
Hi,
Thanks P.S.: Should I open a new issue or will you reopen this one? |
I found out that tkimg isn't installed. The folder |
This really is the gift that keeps on giving. You cannot install Update: I am as of yet unable to reproduce the issue for
I do not think the issue is related to the location where Python was installed (I had it installed in |
Here is the result:
|
If check the provided Update: Oh, and could you make sure that you're not running inside a |
It doesn't exists... |
That is very strange indeed. Did you install Could you install the Windows 64-bit Python 3.6 wheel by downloading the file and then running |
I installed ttkthemes from PyPi using pip. With the wheel it works. I found out, when I'm installing it, that I had two versions of ttkthemes installed, the 2.0.6 and the 2.0.5. First, I uninstalled 2.0.6 and then installed the wheel, that uninstalled 2.0.5. |
So it might have been loading This is clearly a complicated issue. Before I released For future posters: If you have any issues, please post! I want to really make sure that it doesn't just work for me, but for everyone! |
How about just converting all images to gifs and getting rid of tkimg? Then we wouldn't have more "it doesn't work for me" issues, and if anyone happens to be using an OS that is actually unsupported, it would also work for them. Edit: I use gifs with my own tkinter projects just because other image files don't work before Tk 8.6, and not everyone have 8.6 yet. |
@Akuli Converting to GIF can have unintended consequences for some themes because the color space is more limited. It does support transparency though (at least with Tk >8.5, I'm not sure about 8.4). Conversion would be a pretty big undertaking though. Conversion with PIL is not sufficient, because transparency conversion does not work quite correctly: Conversion with It would also mean that introducing new themes would be more complicated as well. I was hoping to port over a few more Gtk-themes like I did with Considering everything, I will not convert the PNG-based themes to GIF-only images just yet. I first want to see if more people continue having issues. In the meantime, I will look into the possibility of having the package support an option for installing Edit: And as a side-note: I have been using PNG-images and other formats in other projects for a long time using the from PIL.ImageTk import PhotoImage
from PIL import Image
image = Image.open("some_image.png")
photo = PhotoImage(image) # Pass this to the image kwarg of Tkinter widgets |
Have you checked PIL's source to see how it passes the image data to tk? |
PIL is an extensive C-library for Python, and checking how it passes its image data to Tk would involve basically writing something similar to the I've been looking into the possibility of building a second library that can load |
Maybe it wouldn't be too bad to write a working png to gif converter in plain Tcl? If you're lazy, just take some conversion code written for another language and convert that to Tcl. |
Tcl is an interpreted language, like Python, and I won't pretend to be good at it. Conversion during run-time would cost an enormous amount of time (relatively speaking) at library object creation, and that would most definitely be more than what removing Plain Tcl would be too slow to do run-time conversion. There is no PIL library in Tcl, so conversion would have to be done by reading in the binary data of the files, then somehow manipulating that (which means studying how PNG and GIF-formats work in the first place) and then saving the manipulated file. That does not make sense. Once you know how to read the PNG image, it would be more efficient to simply pass that on. Now the worst part is that passing on that data has to be done in C. Tcl supports custom image formats with its C-library, and surprise: That's exactly what Even conversion before start-up using Python would be too slow. The From all this I conclude that there are three options:
So, I really appreciate the input, I do, but currently I just don't see any other feasible option. At least not one that is both relatively fast and will not take months with the amount of time I currently spend on this library. |
Theme images are very small. For example, if you have a 1500x1500 pixel photo, it has 10000 times more pixels than a 15x15 icon typically found in a theme. I don't think that speed would be a big issue with small pictures, even in plain Tcl. A 15x15 icon has 225 pixels, and a loop that runs 225 iterations per image doesn't sound too bad to me.
I can look into this if you decide that this might be useful. I also know a few friends who might find this a nice challenge. Also, like you said, someone has done this before, so we could find someone else's code that does this and make a Tcl version of it.
Tk images can take raw gif data directly, and there's no need to save it to a temporary file. It looks roughly like
Maybe we could convert the images when they are actaully needed (i.e. when changing a theme) instead of on startup? What do you think? |
Hmmm, I think I'm really overcomplicating things... If you look at e.g. |
Yes, Tkinter can indeed take Converting the images when they are actually needed would require dynamically loading the themes when they are needed, and that complicates things in the current Tcl file-structure. It might also increase Tcl overhead, but actually knowing for sure requires profiling. If the work is already done to convert the PNG images to GIF format (of which I doubt whether it's a good idea, see my first paragraph) then doing that would be relatively easy. When I integrated TkImg I attempted to separate the files from each other, but then I got weird crashes of Tkinter (the kind that I had when the |
Ok, one more idea... how about just always including all tkimg files for all platforms, not just the target platform? Nobody would notice the bigger size of the package anyway, and we would stop getting "this didn't install correctly to me" problems. |
Everything considered I think that providing an option upon installation for using the PNG-based themes and using the GIF-themes by default would not require a huge amount of work while offering the most flexibility in terms of supporting platforms, porting over themes and providing a simple interface. I just really dislike the idea of copying Windows- and macOS-library files onto Linux machines (or any other combination) just because setting up the already compiled library files is difficult. They would literally be a waste of space. Also, when packaging with PyInstaller, that additional size is most definitely noticeable. |
How about checking if Tk 8.6 or newer is installed in I don't really like the idea of copying macOS files to Linux machines, but I really don't like random "it doesn't work for me" bug reports. #32 seems like a lot of work. Are you sure there's no better option? |
#32 might be a lot of work, but it not the most work out of the alternatives, and it does satisfy everything on what I would want from a solution:
Currently, platforms that do not support PNG only have the option of installing So far, no one has indicated a reproducable problem that exists for the latest version, neither here nor on StackOverflow, so I am treating the current version as good until I have seen otherwise. Executing checks in Building a single source distribution that can perform the checks would be okay, but then the files to be copied would have to be dynamically set. That might be a neat solution, but depending on the implementation it might be more fragile than the current set-up... |
Does the issue with Pyinstaller happen also with cx_freeze? It raises me the same error. UPDATE: I think I've found a fix. See PR below! |
@maicol07 , could you please elaborate on the issue you are experiencing? Because this thread is not specifically about issues with PyInstaller. In fact, I use this library with PyInstaller and it works quite fine... If you have an issue with PyInstaller specifically, could you open a new issue so it can get the attention it deserves? This issue has transformed into a discussion instead. |
@maicol07 While this thread is related to platform issues, I would like to keep the actual, concrete issues in the current version with the path-finding and the discussion on how to improve the path-finding in future versions separate. This looks like a new issue indeed. Could you open a new issue, particularly so you can elaborate on why PR #33 implements a fix for the issue you are experiencing? |
With the merging of #38, this discussion has come to an end. Most Python installations will now use the PNG-based themes by default, and those that do not always have GIF-counterparts available to them. Using PNG-based themes is still possible for those platforms by manually installing Thank you @Akuli for providing your input and pushing this issue and @maicol07 for reporting your issues. |
This is a "continuation" of #17. I just installed from github...
...and I still get the same error:
The text was updated successfully, but these errors were encountered: