I've been trying to embed an icon (.ico) into my "compyled" .exe with py2exe.
Py2Exe does have a way to embed an icon:
windows=[{
'script':'MyScript.py',
'icon_resources':[(1,'MyIcon.ico')]
}]
And that's what I am using. The icon shows up fine on Windows XP or lower, but doesn't show at all on Vista. I suppose this is because of the new Vista icon format, which can be in PNG format, up to 256x256 pixels.
So, how can I get py2exe to embed them into my executable, without breaking the icons on Windows XP?
I'm cool with doing it with an external utility rather than py2exe - I've tried this command-line utility to embed it, but it always corrupts my exe and truncates its size for some reason.
Vista uses icons of high resolution 256x256 pixels images, they are stored using PNG-based compression. The problem is if you simply make the icon and save it in standard XP ICO format, the resulting file will be 400Kb on disk. The solution is to compress the images. The compression scheme used is PNG (Portable Network Graphic) because it has a good lossless ratio and supports alpha channel.
And use
png2ico myicon.ico logo16x16.png logo32x32.png logo255x255.png
It creates an ICO file from 1 or more PNG's and handles multiple sizes etc. And I guess XP would have no problem with that.
It seems that the order of icon sizes is the key, as said by Helmut.
To invert the pages (larger ones first) solves the issue on Windows 7 for 'include_resources' (using Py2exe 0.6.9).
I was having problems with embedding the icon resource with py2exe on Windows7 using a .ico file containing a 32x32 pixel image. I was using the same method as the original question.
Once compiled the icon on the exe disappears. On investigation the icon is added at index 0, according to the Resource Hacker tool, but if I use the same tool to replace the icon it is added at index 1. Once at index 1 the icon magically appears in explorer against the exe again.
If desperate, you could use Resource Hacker to amend the exe post-build and it can be scripted via the command line interface but I tried the method explained above and managed to get it to work after reversing the png files like so.
png2ico.exe myico.ico myico248x248.png myico48x48.png myico32x32.png myico16x16.png
By the way by adding multiple icons to the ico file you are then populating the resource at icon index 1 anyway, in this case myico248x248.png.
The link to the Greenfish Iceon Editor Pro is broken.
I scanned the net and found Download IcoFX
Used the IcoFX program on my .exe file and could see that indeed it contained my icon.
Using the menu Image->Create Windows Icons from Image, and then accepting the choices I got a new .ico file that worked on both win7 and win xp.
Before that my single 48x48.ico file just didn't show up as an icon for the program.
Related
Windows 10 has a preview function for TTF fonts.
Does there exist a program that does sorta the same but for TXF fonts?
Or does anyone know of a python function that can load such a font so I can write such a program myself, PILLOW didn't seem to support it.
Note: I tried showtxf.exe, but it show an image in too low resolution cannot really make out how the font looks.
I know I'm a little late. But I found this question AND the solution when searching for the answer to the same question.
txf seems to be a private file format for a bitmapped texture font which was/can be used in the context of GLUT by Marc Kilgard, an OpenGL toolkit in the late nineties.
The sourcecode and makefile are still around, along with a little instruction and a tool to generate(!) txf files from ttf font files. Also included is a txf-file viewer (source) where you are supposed to see all glyphs crammed into one coherent bitmap image, IIRC.
I found the source package at this link:
http://chateau-logic.com/content/ttf-txf-font-conversion
I am using the Python Interactive tab (similar to Jupyter notebooks) in Microsoft Visual Studio Code.
When I plot an image, I am unable to save it directly from the editor. There's no option to save it directly with the mouse, or to save it directly from the interface.
Is there a way to save it from the interface or should I only use matplotlib's savefig method?
In my version (1.47.3) I can double click the image, which opens it in a separate tab for inspection.
One of the buttons in this tab is a save icon, which allows you to save the image in a format that depends on the file ending you choose. I've tried .png, but couldn't find an option to change resolution. .pdf or .svg saves it losslessly as vector graphic.
In the image below you can see what it looks like for me. (on Ubuntu)
Not fully sure if this counts as a full answer here on Stack Overflow. But the answer here is that we don't have a way to do this currently. You can highlight it in the interactive window and Ctrl-C to copy it out, but even that support is rather flakey at this point. If you would like to log this issue this would be the best spot to get it on our radar:
https://github.com/Microsoft/vscode-python/issues
We keep our issues open to the public so you can track when we work on it after it's filed there.
I need to change the colour of files in windows filesystem and create a new column with a little icon in it.
I need to do this on single files on the same directory.
Filenames different colours and icons are informative for me.
Imagine that for a file I can colour it in red and that mean that it's in elaboration, or newly created or currently used by more than three editors and so on.
Icons are little ones, and have a different means and ought to be in a different column.
The OS is Windows, but in a near future I would use MAC and Linux, but for now let's focus on windows OS.
I know. It's hard. Any help will be wellcome.
I have been fooling around with python and Pythonista 2.5 on iOS. I currently am far too inexperienced to create good UIs in scripts and need some help using the designer in Pythonista. I currently wish to add an image asset, yet I am only able to use stock images provided, is there any folder path I can follow to add my images to that list, or is there another simple way of doing it?
Keep in mind I have little experience and thank you for any help!
You can store the images files in any folder. A simple way to copy external images would be to first copy it in clipboard (may be from photos) and then save it as png file by running the following script.
(Custom images are currently not supported in the UI editor, You have to load them via code.
https://forum.omz-software.com/topic/3668/images-in-ui-designer
But you can use the [+] button in the code editor (at the top) to view bundled images/textures. (images in the current directory are also shown.)
https://forum.omz-software.com/topic/3760/itunes-file-sharing )
import clipboard
image = clipboard.get_image()
image.show()
image.save('img1.png')
You can also use dropbox or appex scripts to store images.
Im using python turtle (Tkinter) to draw some lines which I need to export to a .jpg or .png file. To do so, I'm using python's turtle method to export my canvas to a postscript file:
pen.getcanvas().postscript(file="grafica.ps")
Where pen is just a fancy name for my turtle.
I get my .ps file, I convert it and... surprize! The image gets cut.
I tried some modifications like:
pen.getcanvas().postscript(file="grafica.ps", colormode='color', pagewidth=1600, pageheight=1200, width=1600, height=1200)
Since my turtle's window is 800x600 I thought that maybe twice as much space would be enough space to fit all the image but it still gets cut down...
I'm posting some output examples after the convertion, how my turtle's screen looks like when saving it, and how it should look exported.
Window while saving the image:
(Yes, there are sliders for the canvas)
How should it look:
And this is what I get:
I'm wondering how should I call postscript(), any idea?
I don't want to code this again on WxPython or other library :(
thanks!
This is probably a problem with ImageMagick interacting with the bounding box of the EPS file. My typical workflow for .eps files on Windows may be slightly convoluted, but it works. Similar thing should work for Linux. Install GhostScript (you'll have to make sure the GhostScript executables are on your path), then use the ps2pdf utility from the command line with the -dEPSCrop option:
ps2pdf -dEPSCrop input.eps output.pdf.
Then, use ImageMagick to convert the PDF to anything else, e.g. PNG
convert output.pdf output.png
You can control the PNG resolution etc. through ImageMagick. Like I said, convoluted, but it works.