How to apply theme to PyGTK Application - python

Is it possible to apply this GTK+ theme in my PyGTK application?
Can I apply the theme programatically? Ie, to apply the theme do I use a PyGTK function or do I have to find where PyGTK is installed on my machine(Inside Python2.7) and change the arrow .pngs, and the scrollbar .pngs and etc.?
Note I only have PyGTK installed I dont have GTK+ installed, do I need that? Will the theme linked above work for PyGTK or only for GTK+?
Can you provide advice on how I can apply this theme to my PyGTK application?

If you download the first package from your link, the one that's labelled "(GTK & Metacity themes)" you should get a tar.gz archive. Unpack the archive into some folder like /home/jake/.themes.
Then in your pygtk code, before you initialize your widgets(I would do it right after you import pygtk and gtk in your code), add this line:
gtk.rc_parse('/home/jake/.themes/Elegant Brit/gtk-2.0/gtkrc')
That gtkrc file in that directory contains the information used to tell gtk how to draw the widgets for that theme.
Hope that helps.
Note: Theme choices should be left up to the user and it is generally frowned upon to change/modify the current user's theme when developing an application using gtk.

Related

Displaying a pdf document within a PySide python application

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?

Change Design of the buttons

I'm developing a program in python with a gui in pyqt4.
Now i have some porblem with the design of my buttons.
They have some style like windows 98 and i don't like that.
I have change my theme of my raspberry but nothing changed in my python application.
The theme changed my raspberry but not my application.
I use LXDE on my raspberry.
Do have anybody some solution?
Thanks,
You can change style of the Qt Application using one of the built in styles from Qt, for example you can use:
app.setStyle('plastique')
There are QWindowsStyle, QPlastiqueStyle, QCleanlooksStyle, QGtkStyle, QMotifStyle, QCDEStyle...
or you can use QSS (Qt Style Sheets) to theme your application, docs are here: http://qt-project.org/doc/qt-4.8/stylesheet.html

Equivalent of pyrcc4 on KDE

Am working on a pyqt app, done the ui via qt-designer 4.8.1, and generated the corresponding py file using pykdeuic4 (available on OpenSuse 12.2), but can't find an equivalent for pyrcc4 to hadle the *.qrc files.
what's the equivalent tool/command?
Edit:
Most of the documentation on using QtDesigner with PyQt, indicates using pyuic4 / pyuic (which on my platform is pykdeuic4), but as for the other tool pyrcc4 / pyrcc, I can't find an equivalent.
Am wondering, where can I even get the original tool from (pyrcc4)?
There is no PyKDE-specific tool that corresponds with pyrrc4. The KDE python bindings are built on top of PyQt, so you can just use pyrrc4 itself.
PyKDE only needs a specialized tool (pykdeuic4) for compiling ui files, because obviously KDE has lots of widgets that PyQt doesn't know about.
For OpenSuse, I believe the package that contains pyrrc is python-qt4-utils.
NB: The PyKDE project is moribund: see here for details.
Well, turns out all I needed was to install the extra package python-qt4-utils ontop of the existing python-qt4. Now, I have the sought after utilities in place.

Python - Best GUI library for the job?

I've been using WxPython and I've tried Tk, but it seems that, while both are good and I'll likely use them for other projects, neither of those appear to be capable of accomplishing the things that I want for my current project (which is fine, they're good at what they do).
Basically what I'm looking for is something that will allow me to make rich graphical GUIs. My specific goal is a window that will draw bitmap buttons, resize the parent window automatically to fit them, and possibly animate the resize with a slide effect and have the buttons fade in. Also being able to have my own window border style instead of the inbuilt one is important to me.
This particular project will be Windows only, so non-portable libraries are fine in this case, though portable ones would be great too.
If I missed how this can be done in either WxPython or Tk, I'm all ears.
PySide: http://www.pyside.org/
The PySide project provides
LGPL-licensed Python bindings for the
Qt cross-platform application and UI
framework. PySide Qt bindings allow
both free open source and proprietary
software development and ultimately
aim to support all of the platforms as
Qt itself.
The Windows version of PySide is quite new and may be considered as a beta version. PySide is API compatible with PyQt.
How about PyQt?
http://www.riverbankcomputing.co.uk/software/pyqt/intro
Just sharing my opinion: Kivy.
Innovative open-source library. Supports both 2.x and 3.x versions of Python.
Kivy - Open source Python library for rapid development of applications
that make use of innovative user interfaces, such as multi-touch apps.
Kivy is based on OpenGL ES 2 and includes native multi-touch for each platform and Android/iOS. It’s an event-driven framework based around a main loop, and is thus also suitable for game development.
Try Pyglet. Its a library for python that makes using OpenGL very easy. You can draw pretty good 2d interfaces using Quads.
I can't tell you what is best because that is subjective but I can give you another option: PyGTK
PyGTK lets you to easily create programs with a graphical user interface using the Python programming language. The underlying GTK+ library provides all kind of visual elements and utilities for it and, if needed, you can develop full featured applications for the GNOME Desktop.
PyGTK applications are truly multiplatform and they're able to run, unmodified, on Linux, Windows, MacOS X and other platforms.

Am I supposed to use PyQT4 for programming cross-platform software in Python?

So a user suggested getting PyQT.
A quick Google gave me this: Link
Is this GUI Library for pay?
If my development environment is Ubuntu Linux, what should I download on that site. I have no idea.
Please provide links if the site I provided is not correct to what I need. Thank you.
You may want to look at PySide which is sponsored by Nokia, who own QT. It's also LGPL, which is a bit better of a license than the PyQT bindings. It's also a bit more pythonic in how it works. Unfortunately, it's new, so there isn't as much documentation. On their download page you can find information about a PPA for Ubuntu which will make it so your bindings automatically stay up to date.
If you want to run PyQT then just use APT and install python-qt3 or python-qt4.
I will answer the question you have stated in title
"Am I supposed to use PyQT4 for programming cross-platform software in Python?"
No.
You can use wxPython (http://www.wxpython.org/), it is a quite decent GUI toolkit base on wxWdigets and many commercial applications are written in wxPython e.g. www.mockupscreens.com
wxpython works on Mac/linux/Windows, has a very good support for custom widgets and provides a native looks on each platform, though you are free to design you own widgets/skins.
PyQT is comparable or may be in some cases better but costly for non GPL applications(http://qt.nokia.com/products/licensing), but wxPython is free as free beer (http://en.wikipedia.org/wiki/WxPython#License).
PyQT is released under multiple licenses: http://www.riverbankcomputing.co.uk/software/pyqt/license
You only need to pay if you don't want to release your product under the GPL.
PyQT isn't the only option for cross platform GUI in Python. There are many others too: http://wiki.python.org/moin/GuiProgramming
Near the top of the page you will find:
Source Packages
This is the latest stable version of PyQt4.
PyQt-x11-gpl-4.6.2.tar.gz Linux, UNIX source
PyQt-win-gpl-4.6.2.zip Windows source
PyQt-mac-gpl-4.6.2.tar.gz MacOS/X source
For Ubuntu, choose the first one.
You should try pyQt and wxPython both, but You will know which one better when you release your program to public.
you can install wxpython with synaptic easily.
and here is helloworld for wxpython
import wx
app = wx.App()
frame = wx.Frame(None, wx.ID_ANY, "Hello World")
frame.Show(True)
app.MainLoop()
Just my 2 cents, Sorry, If you dont like to use it.
In Ubuntu Linux, for PyQT try the package python-qt4.
An alternative is wxpython, and in Ubuntu the package is python-wxgtk2.8.
Another possibility to consider, that is considered an integral part of the Python distribution, is Tkinter, a Python interface to the Tk GUI toolkit. Tkinter is not necessarily considered as "good looking" as wxPython or PyQT, but it is definitely cross-platform, and has the blessing of being part of the Python distribution.
For cross-platform qt is the best option. GTK doesn't look well on windows, wxwidget/wxpython is ok but not so powerful and tkinter is too ugly/basic. Besides, qt4 is LGPL so you can link with it even if your application is not GPL.

Categories