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
Related
I am trying to extract labels of widgets of running GTK applications. I tried using GtkParasite but I have no idea how to get it working in my python program.
I want to be able to get the widgets and their labels of a gtk application that is running on my computer. It means that if I run gedit on my system then i want to get the labels of the widgets at run time. I hope this makes sense.
Is there a way to use the C library of GTK to get an instance of a running GTK application?
Thanks in advance.
You probably should use accessibility libraries - those are tools that allow eg. screen readers to read GUI labels for visually impaired users. On Linux, at-spi2 seems to be the de-facto standard.
For Python, take look at at-spi examples:
https://github.com/infapi00/at-spi2-examples
How can I make a PyQt5 application to look like the same when run on Windows, and Linux?
I would prefer the Windows style on both systems.
Thanks
You can call QApplication::setStyle("windows") before creating QApplication object to set a style by name. However, Qt on Linux is usually built without modern Windows styles, so it's possible that the best you will accomplish is the classic (old) Windows style, which is not very attractive. You can also try to use "fusion" style or other values that QStyleFactory::keys() returns.
You can use existing styles mentioned above
or you can specify the styles of your widgets using Stylesheet, which is quite powerful.
I have PyQT v.4.8.8 installed.When I draw layouts and I want to view the code , it comes with error that is unable to launch uic as in snapshot:
I can compile the .ui files manually in cmdLine. But I dont know where to put the code for slot,methods ,signals.
1- Where should I set the settings for finding uic to compile ui? My installation does not have pyuic4.
2 - Where can I define my own slots/methods and functoins signatures ? (receiver object,sender) I can see the Edit signals/slots in edit menu but that only shows standard signals/slots.Doesn't have options to define yours.
As the name says, the Qt designer is for interface design only. You cannot use it to write the code for the actual application logic. For this, you'll need a normal Python editor. The exact details on how to use designer files in Python are explained in PyQt reference guide, Using Qt Designer.
Btw, uic is not for PyQt, but for compiling user interfaces into C++. To compile user interfaces to Python, you need to use pyuic4. This tool cannot be run from the designer, you need to run it manually. But it is recommended to load the user interface dynamically at runtime using the PyQt4.uic modules as explained in the reference guide.
I found this tutorial for PyQt4 explaining how to add your own slots in Qt4.Very informative.
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.
Last time I saw, GUIs in Python were extremely ugly, how's it today?
(saw some beautiful images on google images, but I don't know if are really Python's)
Python 2.7 and 3.0 ships with the themed tk ("ttk") widgets which look much better than previous versions of Tk (though, honestly, any competent GUI developer can make even older Tk look good). Don't let the people who don't know much about Tk sway you from using it, it's still a very viable toolkit for many, many tasks. You won't be creating a Photoshop clone with it, but how many people write those kinds of apps anyway?
I've been using wxPython for the past year and would still choose Tkinter over it for most tasks. Tkinter is much simpler and in many respects more powerful. The only advantage wxWidgets has is that it has more built-in widgets, but I find many of them a bit buggy and hard to use. For most apps that most people will write, Tkinter is still an excellent choice.
Some screenshots of themed widgets are available here:
http://code.google.com/p/python-ttk/wiki/Screenshots
Here's a screenshot of a Tkinter app that uses the themed widgets on the Mac:
http://www.codebykevin.com/phynchronicity-running.png
Tk is sill is the default GUI toolkit for Python, but it has a theme support from Python 2.7/3.1. It is not as ugly as before.
However, you can use some nice alternatives which still look better (IMHO) and have more functionalities :
wxPython : maybe the most used, cross platform and all, your applications will look the same as native.
PyQt or soon PySide : bindings for the Nokia Qt open source framework. There is more than just a GUI toolkit.
PyGTK : bindings for the GTK+ libraries
Here is more info : http://wiki.python.org/moin/GuiProgramming
Python has bindings for Tk, Qt, GTK, wx, and many more. There's no reason it should be any uglier than another language. You're probably thinking of a gui made with Tk, which has a reputation of being ugly. It's not specific to python, but it might be more common because it's very simple and ships with python by default.
See Gui Programming on the python wiki for more info.
I Think the latest Tkinter version offers native look for Macos. WxPython and QT offers native look for macos,windows and linux. GTK is abit ugly and prone to crashes on mac cause of the X11 implentation there.
Of course you could build your own GUI , that something I am trying to do with pygame.Let me clarify , I am not making a GUI library just GUI for my own application. I am making the graphics in the 3d app Blender.
My vote for Generic GUI goes to wxPython, tried it, looks great, easy to use and works like a charm across platforms. You will also find tons of info about it. Integrates well with opengl so if you want to do extreme guis on it , it can do them.