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.
Related
I'm creating a drawing app as one of my first kivy projects as a learning experience, and one of the core features on it is a save_as method where you get to save the image you drew on canvas at a specified filepath as a png. I'm using the FileChooserListView built in kivy to get the specified path the user desires, and there is a button that should save the drawing as a png.
I've been having a really hard issue trying to figure this out and wondering if anyone has an idea how this would be possible. I know there is a export_to_png method built in, but that saves to the current directory of where the coding folder is located.
Any sort of ideas would be awesome, thank you
I know there is a export_to_png method built in, but that saves to the current directory of where the coding folder is located.
It saves to whatever path you give it. If you want to save to a path from the filechooserview, pass that pass as the argument to export_to_png.
New to windows automation - I need to pass around 12000 images through a Windows 10 application the client has specified - downloaded from the Windows store.
I'm a python hobbyist mostly so tried some basic python automation tools I'm familiar with but got stuck v quickly utilising a VM.
Is there a VERY simple method I can use to record some mouse clicks, and then write a "for FILE in LIST: do foo" that will change what file is loaded every iteration?
Sorry if this is super beginner. Tried googling and checking previous answers but got a little (a lot) confused.
How about following code. It will open all JPG files in your image folder one after another.
import os,sys, glob
from PIL import Image
for eachImage in glob.glob("C:\\yourImageFolder\\*.jpg"):
im = Image.open(eachImage)
im.show()
I am trying to build an application that builds tool-strings by selecting and inserting pre-made png that are saved in a folder. The pngs need to be placed onto a canvas and built up one by one by selecting an image from a folder and placing onto the canvas in a grid like format.
I have including an example of the toolstring I am trying to make. Currently this is being built manually in a photo manipulation software but I would like to automate the process in a stand alone python application.
Any pointers in the right direction would be grateful, I'm not sure what to google. (Relevant plugins, tutorials, examples). I have a small amount of experience in python programming.
You will want to look at this Python library, PIL
I wanted to use Python to create animations (video) containing text and simple moving geometric objects (lines, rectangles, circles and so on).
In the book titled "Python 2.6 Graphics Cookbook" I found examples using Tkinter library. First, it looked like what I need. I was able to create simple animation but then I realized that in the end I want to have a file containing my animation (in gif or mp4 format). However, what I have, is an application with GUI running on my computer and showing me my animation.
Is there a simple way to save the animation that I see in my GUI in a file?
There is no simple way.
The question Programmatically generate video or animated GIF in Python? has answers related strictly to creating these files with python (ie: it doesn't mention tkinter).
The question How can I convert canvas content to an image? has answers related to saving the canvas as an image
You might be able to take the best answers from those two questions and combine them into a single program.
I've accomplished this before, but not in a particularly pretty way.
Tl;dr save your canvas as an image at each step of the iteration, use external tools to convert from image to gif
This won't require any external dependencies or new packages except having imagemagick already installed on your machine
Save the image
I assume that you're using a Tkinter canvas object. If you're posting actual images to the tk widgets, it will probably be much easier to save them; the tk canvas doesn't have a built-in save function except as postcript. Postscript might actually be fine for making the animation, but otherwise you can
Concurrently draw in PIL and save the PIL image https://www.daniweb.com/software-development/python/code/216929/saving-a-tkinter-canvas-drawing-python
Take a screenshot at every step, maybe using imagegrab http://effbot.org/imagingbook/imagegrab.htm
Converting the images to to an animation
Once the images are saved, I used imagemagick to dump them into either a gif, or into a mpg. You can run the command right from python using How to run imagemagick in the background from python or something similar. It also means that the process is implictely run on a separate thread, so it won't halt your program while it happens. You can query the file to find out when the process is done.
The command
convert ../location/*.ps -quality 100 ../location/animation.gif
should do the trick.
Quirks:
There are some small details, and the process isn't perfect. Imagemagick reads files in order, so you'll need to save the files so that alphabetical and chronological line up. Beware that the name
name9.ps
Is alphabetically greater than
name10.ps
From imagemagick's point of view.
If you don't have imagemagick, you can download it easily (its a super useful command-line tool to have) on linux and mac, and cygwin comes with it on windows. If you're worried about portability... well... PIL isn't standard either
There is a way of doing that, with the "recording screen method", this was explained in other question: "how can you record your screen in a gif?".
Click the link -->LICEcap : https://github.com/lepht/licecap
They say that it's free software for Mac (OS X) and Windows
You could look at Panda3D, but it could be a little over killed for what you need.
I would say you can use Blender3d too but i'm not really sure of how it works. Someone more experimented then me could tell you more about this.
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.