I really like SVG, it's very nice to draw with it. So far i've made static images using Inkscape. I'd like to make them interactive though.
I did some trials, following tutorials like this one. But i can see a SVG and interact with it in my web browser only. I'd like to make such things in a window on the desktop.
There are drawing kits like Cairo or OpenGL, but then i have to draw from code. It seems a more clever thing to use SVG (which was drawn using Inkscape).
What does it require to view interactive/animated SVG in a plain desktop window/canvas? I've seen some modules to convert SVG to Cairo: but is there a direct SVG intepreter for Linux?
The problem is that the effects require javascript and cascading style-sheets, which basically means complete web rendering engine. So the easiest way is to use one, either webkit or gecko (webkit has probably better support for SVG these days, plus I can't find package of gecko right now).
Related
I'm wondering if it's possible to play an animated gif using Python. I'd just like to display a set of them and iterate at a certain interval. I'm wondering what the best route to take to open them in python. Is it possible to open with Preview (I'm using a Mac) or perhaps a web browser package?
You can do this using Tkinter library in python. You can even add buttons, labels etc..
More Information:
https://docs.python.org/2/library/tkinter.html#a-simple-hello-world-program
http://effbot.org/tkinterbook/photoimage.htm
I am looking to make a GUI in python but currently do not have much experience. The GUI must have a few key features, namely a slider bar to control audio, and a few basic menu buttons. I realize essentially all GUI development tools could handle these simple features, but I am also interested in some custom content as well. The basic look of the GUI I am looking to create is shown here:
In the image, the slider volume bar, "button1," "button2," the colored circles, and any slice of the circle (one highlighted section is shown) needs to be clickable and interactive. Moreover, the small colored circles must be able to dynamically revolve around the edge of the circle and remain clickable at all times. I have not used any GUI development tools yet, but have looked into pyGTK, pyQT, wxWidgets, and Kivy. Can anyone who has used these tools recommend which would be best suited? As far as shapes of buttons, am I restricted?
You can use pyopengl, pygame , pygtk .
I have one example how to show this images if you want take a look at :
http://free-tutorials.org software free section is decor.tgz example.
In my opinion you can use pyOpenGL is very portable to another language like C,C++ and also you can make it to Linux , Windows , Android.
I'm developing a CMS like application where the user should be able to create the menu the way he wants. Ideally, each menu object wouldn't be a text with a background but rather an image of the text. I envision this in either of these 2 ways:
a) By rendering a font in a/several image file/s with every letter and a script that given a word would give me either the sequence of images to string together or a single image file with the combination of all letters. I understand this could be done manually, but I feel there's probably a library to help with this.
b) With some kind of imaging library that would be able to render text with several blending effects such as gradient color, shadows, glow, etc. While I believe this one's a bit harder, maybe there's something that suits this need.
Any tips on any library that does this or anything similar?
Thanks in advance!
Bruno
We are using Imagemagick.
http://www.imagemagick.org/Usage/text/#attributes
This will render a simple button with text:
convert -background white -fill dodgerblue -font Candice -strokewidth 2 -stroke blue -undercolor lightblue -size 165x70 -gravity center label:Anthony label_color.gif
Wrapping this into a Python module is straight forward.
Although nowadays I'd settle to go with web fonts and CSS,a couple of years ago I faced this problem, and put together a small project that would generate text-within a templated image on the file, according to passed URL parameters.
The project is still publicized here: https://bitbucket.org/jsbueno/dynabutton -- it is made to work as a CGI script, but could be easily adapted to work with a more eficient server (I'd recomend some security tunning as well, if you are putting it online). You can also use it to generate all your images with a server side script, and just put the resulting image files online.
(it does use PIL underneath)
Ah yes, it can do shadow, and glow with proper parameters, can use any server-installed font, and will use an image template for providing the background, so you can apply any effect manually. (the included temlates, though, are quite amateurish)
Check out pycairo, bindings for the cairo rendering package. It can render text as well as graphics.
Well, with modern CSS techniques, the issue of nonmatching client-side fonts is less of a problem these days. Still there's demand for text-to-image tools.
PIL is often given as the answer to this question, but personally, I would give a good, hard look at pythonmagick as well. Pick the one that works best for you.
Actually the pygtk also has a pango renderer, as well.
I need a tile/sprite editor kind of like Pixen, but I couldn't find one for Windows so I thought it might be a good exercise for me to try and put one together. I use Python, so are there any libraries out there that are suited to the task of putting together a simple tile/sprite editor?
You just need a gui toolkit (gtk, qt, wx) a image library (PIL) and 500 hours of free time ...
Have you looked at the Python Imaging Library (PIL)?
So, the fact is that creating a complex app with a nice UI takes time - I am just expanding a little bit on the answer by THC4k.
PIL, at least PIL alone is useless for this: it does have some functions to manipulate images, but the complicate task here is creating and tunning your desired UI.
That's where the widgets toolkits come in: You would have to pick a toolkit platform that can offer you buttons, images, load and save the image files, maybe some specialzed widgets you can use to create your color swatches, etc.
both GTK+ and QT4.5 have a liberal license, are very complete and very unpythonic on their use :-(
(While you are at it, when using these libraries and toolkits our app can easily be multiplatform: you don't have to make it windows specific, it is equally easy to create an app that will run on Windows, Linux and Mac using python and either GTK+ or Qt4)
One thing I would suggest is for you to learn to proper use GIMP: it is an Image editor, and certainly it will lack a lot of tools you are needing for sprites: but you can expand it's capabilities with Python plug-ins. On the other hand GIMP does have thousands of features that you'd no longer will need to create for your stand-alone app. (think on layer support, color filters, image rotation etc...)
Check around on how to install GIMP with Python support on Windows, then spend some hours learning the app, with some book-like text around preferably so you can find the hidden features.
Ah, ok, finally:
If you want a very simple thing, just for the taste of "i did it" - you can use Pygame: You have to do all the drawing on the window, including text - but have straighter access to pixels, colors, mouse clicks and coordinates than with GTK+ or Qt, in a sense it would be a lot less of overhead for you to learn in terms of API's and internal working.
You could try PyGame but, seriously, you couldn't find a freeware graphics editor for Windows??!!
EDIT: In the past I've used Aha-Soft's IconXP for pixel work, but it costs USD 30 and doesn't offer all of the Pixen features that I guess you'll want.
I am making a Python gui project that needs to duplicate the look of a Windows gui environment (ie Explorer). I have my own custom icons to draw but they should be selectable by the same methods as usual; click, ctrl-click, drag box etc. Are any of the gui toolkits going to help with this or will I have to implement it all myself. If there aren't any tools to help with this advice would be greatly appreciated.
edit I am not trying to recreate explorer, that would be madness. I simply want to be able to take icons and lay them out in a scrollable window. Any number of them may be selected at once. It would be great if there was something that could select/deselect them in the same (appearing at least) way that Windows does. Then all I would need is a list of all the selected icons.
Python has extensions for accessing the Win32 API, but good luck trying to re-write explorer in that by yourself. Your best bet is to use a toolkit like Qt, but you'll still have to write the vast majority of the application from scratch.
Is there any way you can re-use explorer itself in your project?
Updated for edited question:
GTK+ has an icon grid widget that you could use. See a reference for PyGTK+: gtk.IconView
In wxPython there's a plethora of ready-made list and tree controls (CustomTreeCtrl, TreeListCtrl, and others), a mixture of which you can use to create a simple explorer in minutes. The wxPython demo even has a few relevant examples (see the demo of MVCTree).
I'll assume you're serious and suggest that you check out the many wonderful GUI libraries available for Python.