Displaying a pdf document within a PySide python application - python

I have a python application using PySide, Qt and python. In my application I would like to open and display a pdf document, but have the viewer within the application and not using the default viewer on the operating system.
I have not as of yet been able to find a widget which is capable of doing this or some example code. I have never used these tools before and this is my first Qt & PySide application so I am sure there is a widget which is capable of this but that I am just not aware of it.
I found this post and when I take the sample code I am unable to get any pdf to show and cannot replicate the behaviour of the poster, but I am using python 2.7.3, PySide 1.1.1 so perhaps this is why. The error that I get when trying to run the sample code in the other post is:
QWebInspector: QSettings couldn't read configuration setting [resourceTrackingEnabled].
and the pdfs I would like to render are saved locally, in the same directory as the the python script and not accessible via the web.
Could somebody point me in the direction of some sample code or a Qt widget which I would be able to use to render a pdf?
As an aside, I am not sure that it matters but the pdf will be generated using LaTeX.
Edit --More information--
The program has to run on both Windows and Mac OSX environments but it is just for a personal project which wont be distributed. Using PyQt is not an option as it is not compatible with the python editor that I use and PySide is the requirement. I have read the following link but from what I understood under the Rendering section it said that the 3rd party libraries available worked with C, C++ and Qt not python or PySide but maybe I have misunderstood this?

Related

How to render PDF using poppler in pyqt4 or wxpython?

My goal is to create a pdf viewer that can select a text in the viewer.
is it possible?
i'm only experienced using wxpython for deleveloping gui application. I just heard poppler can support rendering pdf, but i did not found any snippet or example. please help.
If you are looking for how to create a wxPython PDF viewer, I've found a couple of examples. The first one uses Poppler as you mentioned in conjunction with wxPython:
http://code.activestate.com/recipes/577195-wxpython-pdf-viewer-using-poppler/
It's a pretty old example, so I don't know how well it works now. The other one I found uses PyMuPDF and fitz and was published this year (2016):
http://code.activestate.com/recipes/580621-wxpython-pdf-viewer-using-pymupdf-binding-for-fitz/
If you happen to be on Windows, wxPython comes with an ActiveX wrapper around Adobe's reader. You can read more about it here:
https://wxpython.org/Phoenix/docs/html/wx.lib.pdfviewer.viewer.pdfViewer.html

How to display the manual in Gtk?

I'm building a Gtk3 application using Python. I was wondering if there was a standard way for building and displaying inline help (the manual). More specifically:
What text format should I use for storing it (html? XML? other?)
How should I display it? I need to be able to browse the contents, the search for specific terms, to display formatted text with images, and to open the help window at a specific location when the user request online help about a specific part of the user interface.
Finally, in the ideal case, it should be cross-platform (e.g. I plan to port it to Windows)
Didn't know your app needed to be multiplatform. Be careful, because GTK3 on Windows is quite difficult to use for the time being (AFAIK there are no official installer either for GTK3 nor PyGObject on Windows, only community stuff).
On Linux, GNOME uses Yelp to handle documentation, but I don't know if it has been ported to Windows.

console application gui for python

We have console application option in C#, but how do I can make a console GUI in python?
I should note I want to compile and use my program in windows.
Also I want to select Items in Python GUI by Enter button.
If you're using Windows you will ultimately need to integrate with the win32 console API to create a console GUI (aka. a Text UI or TUI). Your options are basically:
Write your TUI using curses or the packages that sit on top of it, like urwid or npyscreen. To do this you either need to install cygwin or PDcurses to make it work.
Write to the win32 API directly using something like pywin32.
Use a package that simplifies the win32 API like effbot's console package.
I found all the above unsatisfactory as I didn't want all the hassle of installing 3rd party binaries for Windows and wanted an API that I could use anywhere (after a simple pip install), so I wrote a cross-platform package (asciimatics) to fix it. This package takes all the hassle away and provides a clean, documented API with a set of widgets for TUI applications.
For example the following is a screenshot of the contacts list sample code referenced in the previous docs link, showing some of the basic text and button widgets.
Take a look at Python's curses library:
http://docs.python.org/howto/curses.html
http://www.dev-explorer.com/articles/python-with-curses
http://docs.python.org/library/curses.html
If you'd like a Python shell, then you might want to look at something like PyFlakes / PyShell or similar.

Python Plugins for QGIS

I am working with python plugins for QGIS . I am done with my one of my .py file using python 2.5 and pyqt4. It is just help file for QGIS, which I changed. I wanted to in-cooperate the same in QGIS. I installed QGIS 1.7.1.
I know it to be done through python plugins. But how to go about it?
where to copy my file, so that it will get open from QGIS?
QGIS already has that page(help file), I need to change it.
help me out.
If you're creating a QGIS plugin in Python, you may want to place it in your .qgis/python/plugins folder. Actually, you should create a subfolder below that. But that's not all, your code has to provide certain functions in order to get hooked up properly into QGIS. http://qgis.org/pyqgis-cookbook/plugins.html#plugins provides detailed information about that. Once your Python plugin is complete and located in the correct location, you'll have to enable it in the QGIS Plugin Manager (choose Plugins/Manage Plugins... from the manu). I'm not sure if your question is about creating QGIS Python Plugins or about replacing QGIS menu items via Python - could you clarify this? Are there any error messages for the things that are not working? Could you post your code (or relevant parts of it) for review (this might speed up the process of finding a solution)?

Python: Desktop UI for my python script

Im new to python and want to create a GUI front-end (desktop, rather than web) for my python script. The script essentially parses XML files and runs various searches over the contents (eg. accepts regex searches from the user, returns results etc).
It works well on the command line but I want to present a more user friendly interface.
There seems to be a lot of options out there - http://docs.python.org/faq/gui.html
Or should I look elsewhere?
Can someone recommend a GUI toolkit for Python?
Cheers.
I recommend using one of Tkinter, wxPython or PyQt. They are all equally suitable for a simple task. My personal favorite is Tkinter because I think it is the simplest way to get started. However, any of those would make a fine choice.
Here is a page on the Python wiki with some fifty options.
PyQt is great, although it's on GPL. There is also PySide alternative on LGPL.
You can also try wxPython or PyGTK if you don't like Qt for some reason. There is also gui library in python standard library called Tkinter, but I haven't used it and don't have any experience with it.

Categories