I'm having a set of Python scripts that process the photos. What I would like is to be able to create some kind of flash-presentation out of those images.
Is there any package or 'framework' that would help to do this?
I don't know of any Python-specific solutions but there are multiple tools to handle this:
You can create a flash file with dummy pictures which you then replace using mtasc, swfmill, SWF Tools or similar. This way means lots of trouble but allows you to create a dynamic flash file.
If you don't need dynamic content, though, you're better off creating a video with ffmpeg. It can create videos out of multiple images, so if you're somehow able to render the frames you want in the presentation, you could use ffmpeg to make a video out of it.
If you only want charts, use SWF Charts.
You could use external languages that have a library for creating flash files.
And finally there was another script language that could be compiled into several other languages, where swf waas one of the targets, but I can't remember its name right now.
You should generate a formated list with the data to your photos, path and what else you need in your presentation.
That data you load into a SWF, where your presentation happens.
Like that you can let python do what it does and flash what flash does best.
You might find allready made solutions for flash galleries / slideshows. http://airtightinteractive.com/simpleviewer/ is a famous one. You can load your custom xml in it.
Check out Ming, it seems to have Python bindings.
Ming is powerful but you might not find it pythonic to work with.
I prefer Haxe for Flash work. (It's the successor of MTASC)
Related
I have a requirement involving making a large pptx file with loads of charts, images and tables dynamic. This pptx has default styles. Is there any library or method to make a template so that I can insert the dynamic parts. Like docxtpl library allows us to input a dict and generate a docx file.
Thanks.
You can try the following python modules:
https://pypi.org/project/template-pptx-jinja/
https://pypi.org/project/pptx-template-simple/
https://pypi.org/project/python-pptx-templater/
With the first one, the example they show, it works fine, but im having trouble applying it in another custom ppt.. keep getting "Unepexpected end of template".
The third one didint work for me though, maybe you have more luck.. and now i will try the second one.
I'm not sure I understand your problem...
python-pptx (a tag you've used) is the fundamental programmable way to build a presentation - whether from a "template presentation or not.)
I hope nobody will mind me advertising my md2pptx open source project for taking Markdown and images and making a presentation.
However, I think md2pptx doesn't help you unless you have a way of turning graphs into eg PNG files - and I suspect that's not what you want.
I'm looking to store some individual settings to each user's computer. Things like preferences and a license key. From what I know, saving to the registry could be one possibility. However, that won't work on Mac.
One of the easy but not so proper techniques are just saving it to a settings.txt file and reading that on load.
Is there a proper way to save this kind of data? I'm hoping to use my wx app on Windows and Mac.
There is no proper way. Use whatever works best for your particular scenario. Some common ways for storing user data include:
Text files (e.g. Windows INI, cfg files)
binary files (sometimes compressed)
Windows registry
system environment variables
online profiles
There's nothing wrong with using text files. A lot of proper applications uses them exactly for the reason that they are easy to implement, and additionally human readable. The only thing you need to worry about is to make sure you have some form of error handling in place, in case the user decides to replace you config file content with some rubbish.
Take a look at Data Persistence on python docs. One option a you said could be persist them to a simple text file. Or you can save your data using some serialization format as pickle (see previous link) or json but it will be pretty ineficient if you have several keys and values or it will be too complex.
Also, you could save user preferences in an .ini file using python's ConfigParser module as show in this SO answer.
Finally, you can use a database like sqlite3 which is simpler to handle from your code in order to save and retrieve preferences.
I want to automatically generate booking confirmation PDF files in Python. Most of the content will be static (i.e. logos, booking terms, phone numbers), with a few dynamic bits (dates, costs, etc).
From the user side, the simplest way to do this would be to start with a PDF file with the static content, and then using python to just add the dynamic parts. Is this a simple process?
From doing a bit of search, it seems that I can use reportlab for creating content and pyPdf for merging PDF's together. Is this the best approach? Or is there a really funky way that I haven't come across yet?
Thanks!
From the user side, the simplest way to do this would be to start with a PDF file with the static content, and then using python to just add the dynamic parts. Is this a simple process?
Unfortunately no. There are several tools that are good at producing PDFs from scratch (most commonly for Python, ReportLab), but they don't generally load existing PDFs. You would have to include generating code for any boilerplate text, lines, blocks, shapes and images, rather than this being freely editable by the user.
On the other side there's pyPdf which can load PDFs, collate the pages, and extract some of the information, but can't really add new content. You can ‘merge’ pages into one, but you'd still have to create the extra information overlay as a page in ReportLab first.
Look into docutils and reSTructuredText. You could quickly write out your PDF document in reST and then compile the PDF using rst2pdf.py
I've used this, it creates very beautiful documents and the markup is extensible! Later you could take the same code and run it into rst2html to create a website out if it!
Take a look here:
http://docutils.sourceforge.net/docs/user/rst/quickref.html
http://code.google.com/p/rst2pdf/
Good luck
You could generate a document through, for example, TeX, or OpenOffice, or whatever gives you the most comfortable bindings and then print the document with a pdf printer.
This allows you not to have to figure out where to put fields precisely or figure out what to do if your content overflows the space allocated for it.
I'm creating a "slideshow room" web page. The user will upload a PowerPoint file that my server will use to generate a set of .jpg image files representing the slides to present in a custom "gallery viewer".
I'm an experienced Python developer but I cannot find anything useful.
How can I do that?
Off the top of my head, the way I'd do it:
Use OpenOffice.org to convert the .ppt file into a PDF. (OO.o has a very rich Java API. Rich and bloody difficult to use, mind, but once you figure out how to get it to do the task you need, you're all set. Dunno if you can do anything useful with it via Python; not my language.)
Use ImageMagick to convert the PDF into .jpg files. (Though I've been told converting the PDF into a PS file before turning it into images gives better results.) (IM's command line interface is damn near a language unto itself -- though again, once you figure out how to get it to do what you want, you're all set.)
Dunno if that's the most efficient/reliable way to do it. But fundamentally, I'd be on Google trolling for open-source third party tools that do all the dirty work for me.
Apache POI and Jython. POI, even has an ImageExtractor class, but having just glanced at the Javadocs, I suspect it is incomplete.
Are you doing this on Windows? If so win32 com:
import win32com.client
Application = win32com.client.Dispatch("PowerPoint.Application")
Application.Visible = True
Presentation = Application.Presentations.Open(pathToPPT)
Presentation.Slides[1].Export("C:/path/to/jpg.jpg", "JPG", 800, 600);
etc...
On an Ubuntu server, I want to create pdfs which include other static pdfs. I have tried using ReportLab with pyPdf. Ideally I would use ReportLab to do the whole thing, but in order to import the pdfs requires their PageCatcher which has a large recurring fee.
So I use pyPdf to merge a page created with ReportLab and my other pdfs. The problem is that even though this looks fine in Acrobat and Foxit, part of one of the pages prints garbled on a Xerox 7400 color printer. I can't figure out the issue, but would be willing to buy a more integrated solution if it existed and was reasonably priced. I thought PDF Creator Pilot was it until I saw that it was Windows only.
So is there a reasonably priced ($1K or less) solution or a different suggestion?
I have had a lot of success with the Java library iText. They have a great library of samples for pretty much anything you could think of doing with PDF files. This example is for concatenating PDF files and sounds like it would do what you need: http://itextpdf.com/examples/index.php?page=example&id=123. There is also PDFBox which is another great Java based PDF manipulation library.
I realize that you are looking for a Python based solution but there may not be many other options. If you are using the Jython interpreter instead of CPython, integrating in iText should be trivial. If not, then you could consider calling out to it as a separate process. I realize that may not be idea for your situation but I figured I would mention it as an option.
Another non-Python answer. If you are just merging pages, then pdftk does that well (along with a lot of other things).