Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed last year.
Improve this question
I'm developing a graphical application to present data (not a game but a real workhorse app). It needs to be cross platform, so I have chosen:
python
openGL (I need 3D, blending, textures etc)
pyopengl
wx/pywx - windowing, dialogs etc.
The last component - WX - raises the question. I can put together a very nice looking app (the prototypes look slick) - but when I need to interact with the user to ask questions, get input, I have to use WX. It makes the app look inconsistent to have traditional UI with traditional dialogs and combos and text entry on top of a full screen 3D app with blending, smooth motion, textures etc.
Has anyone developed a GUI using OpenGL and python? Can you share with me the toolkits and/or tricks you used? I need combos, text entry, buttons, radios, option buttons, tree view.
There are some toolkits out there, but they are either incomplete or old and unmaintained. A great example is pyUI (http://pyui.sourceforge.net/) - looks slick but untouched for years.
This is not an answer, more of a plea: Please don't do that.
Your reimplemented widgets will lack all sorts of functionality that users will miss. Will your text-entry boxes support drag'n'drop? Copy/paste? Right-to-left scripts? Drag-select? Double-click-select? Will all these mechanisms follow the native conventions of each platform you support?
With Wx your widgets might look inconsistant with the app, but at least they'll look consistant with the OS which is just as important. And more importantly, they'll do what users expect.
(edit) Three posts, and -3 points? Screw this den of karma-whores. Original poster: I have implemented a basic set of widgets in OpenGL (for a game UI) and it was an endless nightmare of a job.
In the latest releases of QT you can draw widgets into your OpenGL context, if you really would like to do something like that. Otherwise there is CEGui that is used in some game engines.
Implementing GUI Widgets yourself unless you want to edify yourself is a waste of your time, unless you would be satisfied with the most rudimentary of looks and functionality.
Python + Qt + OpenGL -
I surely believe any application can be written faster and better using python.
QT4 is cross-platform, beautifull, implements everything you need from widgets (acessibility, etc...), and...it integrates with OpenGL. That means, you can simply have a widget that is a viewport to openGL stuff you render in your code.
Another 3D capable solution that would cover most things, but not so nioce on user interface is to extend Blender3D with a python script. It has the 3d capabilities and rendering , you script it in python all of the same, and it would be cross platform - and you get higher level tools for woriking with the 3D things than openGL alone.
There are obvious drawbacks, mainly from the UI standpoint when compared with PyQT but it could be done.
You might want to look at Clutter, it looks pretty cool. I haven't used it yet but I intend to in an upcoming personal project.
Try Qt instead of wx.
QT is cross platform, and you can style things alot using CSS. It's extremely well documented and has excellent python bindings. In point of fact, I use the C++ documentation and not the PyQT documentation.
Both wx and QT do an excellent job of creating an application that matches the OS look and feel.
It is also possible to implment all the widgets yourself directly in openg, this slashdot post lists some of the sets available
http://ask.slashdot.org/askslashdot/02/12/24/1813219.shtml?tid=156
fox is probably the most developed but looks like windows on all platforms.
Blender is the only app I know of with a GUI written fully in OpenGL...
the only problem is it's in C++.
I'm a Python developer as well, but I'm just getting into using OGL
I honestly don't think there are any toolkits to develop a GUI in OGL...
the Blender developers are giving me runaround documentation instead of direct help...
but I'll let you know what I figure out ;)
EDIT:
here's a bit of documentation on PyOpenGL's functions:
http://pyopengl.sourceforge.net/documentation/manual/reference-GLUT.html
"cegui" is a good choise there is also a gui editor called "ceed" to generate the layout xml files. cegui also has python bindings and its well documented and used in many game engines
my friend.
I believe I have found your answer ;)
http://glinter.sourceforge.net/
I havn't yet tried it, but it seems quite promising.
(I'll edit this if it doesn't work)
EDIT:
eh...
it uses Tk, PMW, and WX...
(not quite what I want)
you can give the CVS download a try...
(there's no released packages, but the CVS runs)
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I am looking for a PyQt5 tutorial. It is rather complicated to start GUI development with Python for the first time without a tutorial.
I only found some PyQt4 tutorials so far, and since something changed from Qt4 to Qt5, for example the fact SIGNAL and SLOT are no more supported in Qt5, it would be nice to have specific tutorials for PyQt5.
Can someone please provide a tutorial on how to start GUI development with PyQt5?
As my travels into the depths of PyQt5 continue, so shall I continue to update this answer with some of the shinier treasures I find.
That being said, I am now taking a "rough draft" stab at a quick intro to PyQt5. I will also provide links to helpful resources. I am new to this framework as well, and I will elaborate on what I believe to be a good strategy for using it, as I figure that strategy out. There are likely other good strategies, so if anyone has anything to add, then please leave a comment. This is very much a work in progress.
Strategy
I've learned much from the example code as suggested in the other answer, but something the examples don't help with is PyQt5's deep magic. Frameworks with a lot of magic in them (PyQt5, Django, SQLAlchemy, ...) are great because an enormous amount of drudgery is abstracted away from you. On the flip side, it is not always clear what the hell is going on, or what you're supposed to do about it.
Luckily, it seems we have options:
QtDesigner: For those days when your keyboard catches fire, there's a rockin' GUI-Builder called in the installation package. When you see the code this produces (perhaps only in the community version?), you'll see why this may not be the panacea it seems.
QML: Another candidate for panacea: declarative GUI building from formatted JSON. Yum.
Qt Quick: The framework for QML. By this point, it may seem tantalizingly easy, but don't get sucked in by this stuff just yet. It always seems to come down to learning it by hand.
The Model-View Framework(1): Model-View (not MVC) separates the code that deals with presentation/interaction from the code that manages the data, with the aim of providing modularity.
Coding in PyQt5 is greatly simplified by using the set of classes that implement the Model-View design pattern. Model-View is an evolution of Model-View-Controller (MVC), in which the Controller has been reunited with the View. They seem like strange bedfellows, but, most of the program's logic is dealing with either the user, or data: it seems to make a certain sense, at least at a stratospheric level.
From a bird's eye:
Architecture(s)
Model-View-Controller
This widely-used design pattern separates the application into 3 layers:
Model ~> Encapsulates the data. Notifies View and Controller of any changes to the underlying data. This causes updates to the display of output or available commands, respectively.
View ~> Displays the relevant output from the Model to the user.
Controller ~> Encapsulates user interaction, and notifies the Model and View of relevant events.
Model-View
The Graphics View Framework(1) ~> Represent everything (including embedded QWidgets, etc) inside a QGraphicsScene as a QGraphicsItem (or derivative thereof), including proxy classes for embedding widgets. The items are supposedly highly optimized, and integrating OpenGL support is a one-liner, which is nice.
This design pattern puts the Controller inside the View. This way, the view is capable of handling the entirety of the user's interaction. In concrete terms, these are the Signals and Slots mechanisms.
User Interaction Management
Callbacks
Signals and Slots
..... ** I'm sorry, but I must sign off now. I'll be back to continue to add to this. **
Practical Example(s)
Like, for instance, you can take a tree view from the itemviews/editabletreemodel example, then swap in a file system model (QFileSystemModel) from the itemviews/dirview example and you've got a full (working) view of your directory tree. Pretty snazzy.
So, you would take the code from the editabletreemodel example:
headers = ("Title", "Description")
file = QFile(':/default.txt')
file.open(QIODevice.ReadOnly)
model = TreeModel(headers, file.readAll())
file.close()
self.view.setModel(model)
...and swap in the model from dirview:
model = QFileSystemModel()
model.setRootPath('')
self.view.setModel(model)
...and it just works. Amazing.
The next step (in my case) (*I think) is implementing a custom model which I will then use several views concurrently, but I don't know if that kinda thing fits your use case.
Resources
Here are some gems I found on my travels. Hopefully they help you on yours.
This is a tutorial on Model-View for Qt5.(1) It is a very detailed document from the official Qt5 docs. A good deal of useful documentation can be found at the Qt5 site. Keep in mind, it's for Qt5 (the C++ library), but the difference is trivial to read through (and the PyQt5 official docs point there anyway).
This PDF contains a quick high-level to PyQt4's Model-View framework. Note that is it for PyQt4 (not PyQt5), but it is actually for Python (as opposed to C++), and I found it very quickly taught me a lot.
I am just starting to play with the Graphics View, and am finding this tutorial on the Graphics View Framework very helpful. This is the same View that is used in the qtdemo example code to generate some slick effects. I'll be updating this in a bit.
This is a complete list of all of the Qt5 Modules.
This is a complete list of all of the Qt5 Classes.
This is a complete list of all functions in the Qt5 API.
As katsh pointed out in another answer's comments, here is a link to the example code for PyQt5.2.1 on GitHub
Additionally, a copy of the example code comes packaged with your distribution and can be found at:
%PYTHON_HOME%\Lib\site-packages\PyQt5\examples
If you're using PyDev (Eclipse), you can run examples by simply right-clicking an example's main module file in PyDev Package Explorer or Navigator =:> Run As =:> Python Run
The best one, in my (not so) humble opinion, is:
%PYTHON_HOME%\Lib\site-packages\PyQt5\examples\qtdemo\qtdemo.py
Among my current projects, I'm in the process of reverse engineering this example. If you check it out, you'll see why. To be continued.. ;)
Enjoy!
Been looking for PyQt5 tutorials for some time? Look no further! You won't find many around the internet.
Not really tutorials, but pretty self-explanatory basic scripts under the following path:
/python/lib/site-packages/PyQt5/examples
you will find about 100 examples in 30 folders ranging from beginner to advanced, covering basic windows, menus, tabs, layouts, network, OpenGL, etc.
Have a look at http://www.thehackeruniversity.com/2014/01/23/pyqt5-beginner-tutorial/ This is a newbie friendly tutorial
Actually working on a project in python with PyQT, we choose to create widgets that were "unpleasant" or that didn't have a good enough behaviour.
So, we finally found that QToolbox, QDate and some others had a behaviour non acceptable for the project, so we had to adapt these.
We had also to create a complete new widget : A scheduler.
As we were creating these, it has been decided that it took too much time. So we were asked to think about other libraries.
I actually found a project of a scheduler in wxPython, that actually looks like what we want ( but we believe that we'll have to adapt it a lot ). Here it is : http://code.google.com/p/wxscheduler/
So, I ask everyone that have some more experience than me in GUI programming in python : Do we need to start again the project in anything other than PyQT? I know the question is weird, but what you need to know is :
The project has now been going on for 2 months
I know only PyQT, and started working in python 2 month ago
We are currently 3 in the project, and we currently know only PyQT
We have currently managed a lot of the PyQT widgets, and were starting to code these new widgets.
Please help us =)
Thanks
Edit : I should have add that the project is opensource and multi-platform
Feel free to look at other libraries if you like. Robin Dunn, the creator of wxPython, recently started working on PySide and he found it somewhat similar to wx, so you might find that wxPython will fit your brain fairly well too. I certainly think wx's class names are more intuitive than PyQt's. The only way to know for certain is to actually experiment a little and see if it works. I will say that the wxPython community is one of the best Python communities I've dealt with over the years.
One possibility would be to use an HTML scheduler control via QtWebKit. If your UI can accommodate a QWebView in the place where you'd otherwise have a custom scheduler widget, there are probably a number of excellent scheduler widgets (implemented as jQuery plugins, etc.) you could choose from.
we choose to create widgets that were "unpleasant" or that didn't have
a good enough behaviour.
Why don't you create "pleasant" widgets ?
so we had to adapt these.
Yes. It is the solution.
it has been decided that it took too much time
Don't you think it would take much more time if you change the whole GUI API ?
As for i know, there is not such native Scheduler in any Python GUI library, especially one you could use with Qt. I don't think it would be so long to recreate one, unless you have very specific needs, that would confirm you wouldn't find a such existing thing in an existing library.
Concerning wxScheduler, i guess you can have a look to the code, even it uses wxWidget and you're working with Qt, to get an idea how to do it.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I have an application whose GUI is to be remade for ergonomic reasons.
It was written in PyGTK and I am wondering if I should switch to PyQt to ease future developments or not.
This application has a mostly classical UI with buttons, toolbars, dialogs etc. but also has some specific requirements : I will certainly need to create a custom widget based on treeview/tableview (to make a spreadsheet-like widget) and this application has a lot of worker threads which update the GUI.
I am seeking advice on these two points :
As regards the creation custom widgets, does PyQt provide better mechanisms than PyGTK, especially to slightly modify existing widgets.
I had problems with (even when properly using threads_init() and threads_enter()) the updating of the GUI by worker threads while using PyGTK. Is PyQt any better on that point ?
I like GTK+ best, since (at least to me) it looks nicer. PyQt and variants (e.g. PySide), however, do have an immensely large set of extras, including a WebKit engine, an XML parser, SQL support, and more.
If you just want looks, I'd say GTK+/PyGObject. If you are plannning on using anything PyQt has, use PyQt.
As a side note, if you stick with GTK+, I'd advise you to upgrade to PyGObject and GTK+ 3.0, since PyGtk+ is no longer maintained.
I can't compare, because I don't use GTK, but I'd suggest Qt.
Qt definitely has "treeview/tableview" you're talking about and you can make the "cells" your custom widgets (I'm just studying this topic right now). Qt was made with a lot of thought about threads, so worker threads can use the signal/slot mechanism with ease. And yes, you can modify the existing widgets by applying stylesheets or subclassing.
Now about PyQt, I wouldn't recommend it because of licensing issues. PySide seems like a better Qt→Python binding to me: it can be used in commercial applications freely and has a few tiny advantages in the API (but otherwise it's fully compatible with PyQt).
Qt is cross-platform and deployment of PySide applications is very easy with cx_Freeze; users of your application won't have to install anything at all.
I also have no experience with GTK, but can offer some answers nevertheless:
Qt is designed from the ground up to be object-oriented; almost everything in it has excellent support for subclassing. PyQt likewise.
Qt explicitly does NOT support modification of the GUI by any threads other than the main GUI thread. You're likely to cause crashes this way. As BlaXpirit mentioned, though, there are a variety of very easy inter-thread communication mechanisms such as signal passing.
Definitely PyQt... There are a lot of advanced applications using it... Personally, I'm using KDE, so, even my system's GUI uses Qt! I'm also creating a spreadsheet application and I find that it's far easier that what I thought at first... But, BiaXpirit is also right: except if you're developing an open-source app, maybe you should use PySide or something else...
I also never used PyGTK but I think the two features of Qt that are exceptionally good are: model/view programming and signal/slots. If you need that kind of stuff I would say that it's worth at least reading the docs about them and compare the two toolkits with that respect.
The designer is such a time saver also. The promotion feature---you can your custom widgets in the designer replacing it visually with something similar, e.g you have implemented a custom tree view with your functions--- is just very convenient. You can use the designer to display a regular tree view but when you export it uses your custom class.
The docs are superb.
Edit: You can use Qt docs directly. I've been programming in python using PySide and there are only a few instances I actually needed specific documentation. Although it exists.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I'm downloading Python 3.1.1 and that comes with the IDLE correct?
I'm also downloading QT for Windows which I'm told is a good GUI framework to work with Python.
What projects should I try to make in order to grasp some of the goodies Python brings to the table?
Thanks a bunch SO.
I highly recommend
http://www.diveintopython3.net
It assumes you already understand programming, and walks you through examples that demonstrate the unique abilities of Python.
Do the next project you intended to program with your prefered language with Python.
If you are new to python, why not start with some simpler command line projects? I know you said you are not new to development, but maybe you should spend some time with the core python stuff before tacking on a GUI framework. Just a suggestion.
Also, I would point out that Python 3+ code looks a bit different than a lot of the python 2.x code samples you will see around the internet. I have found Python 3 to be not the best in terms of backward compatibility. You might want to start out with a 2.x version of Python to get the most out of the plethora of Python tutorials on the internet, then move to Python 3 if you need it.
Write a simple Text Editor.
That was one of the projects i started when i first learned python. It gets you used to the GUI framework, file IO, many types, OOP, lots... It's something that you can grow over time as your confidence builds and it's cross platform so it's handy.
If python is your first dynamic lanugage you might want to play with some of it's dynamic aspects.
For example, using the getattr and setattr methods on objects, you could write a class that provides a fluent way of accessing elements from an XML document. Rather calling methods on an object with parameters like 'xml.getnode("a").getnode("b")' you could dynamically lookup the nodes as attributes and allow 'xml.a.b' instead. I thought this was very cool having come from static languages.
Note that this won't neccessarily give you a great feel for python in general (although you'll pick up the language as you go) but it will give you a taste of what is possible in dynamic languages.
PythonChallenge
Code Golf
Google Code Jam
These are good ways to practice learning Python.
Might I also suggest that you consider using a different IDE.
If you are interested in GUI programming, I would suggest looking into wxPython, PyWin32, easyGUI, TkInter (which is bundled with the Python distribution)
Python Challenge This is fun and interesting to learn Python programming.
While it is a matter of personal preference, I certainly wouldn't want to play around with a GUI framework when starting out -- I would want to get a feel for the language first by playing around with smaller snippets, such as those suggested on Code Golf. While getting your code to fit into the smallest number of bytes perhaps isn't the best way to learn good design, I think it's a good way to learn parts of the language. Certainly, just doing the tasks without necessarily trying to compact them down excessively could be helpful.
A project I wish someone would write: a friendly GUI that wraps around the scanner library and the PDF library, and lets the user easily scan and file documents.
It would have a toolbar with big buttons: "scan letter", "scan brochure", "scan photo". These would respectively choose high-resolution black-and-white, medium-resolution color, and high-resolution color.
The user would plop down the document and hit one of those buttons. Python would wake up the scanner and have it scan, and then would use Python Image Library or something to auto-detect the size of the actual scanned document and auto-crop down to minimal size.
For "scan photo" you would get a JPEG. For the others, you would get a PDF. And it would have an option where you could scan several pages and then select the scanned pages, and say "group" and it would make a single PDF out of them.
Other useful toolbar buttons would be: "Copy Letter", "Copy Brochure", "Copy Photo". These would scan and then immediately print on an appropriate output device (or just on the default output device for your first version).
If you want to go crazy, you could add an OCR function to try to recover searchable text from the scanned images, and put that in the PDF as tags or something.
Someday I will write this if nobody else does...
I recently did some work modifying a Python gui app that was using wxPython widgets. I've experimented with Python in fits and starts over last six or seven years, but this was the first time I did any work with a gui. I was pretty disappointed at what seems to be the current state of gui programming with Python. I like the Python language itself a lot, it's a fun change from the Delphi/ObjectPascal programming I'm used to, definitely a big productivity increase for general purpose programming tasks. I'd like to move to Python for everything.
But wxPython is a huge step backwards from something like Delphi's VCL or .NET's WinForms. While Python itself offers nice productivity gains from generally programming a higher level of abstraction, wxPython is used at a way lower level of abstraction than the VCL. For example, I wasted a lot fo time trying to get a wxPython list object to behave the way I wanted it to. Just to add sortable columns involved several code-intensive steps, one to create and maintain a shadow-data-structure that provided the actual sort order, another to make it possible to show graphic-sort-direction-triangles in the column header, and there were a couple more I don't remember. All of these error prone steps could be accomplished simply by setting a property value using my Delphi grid component.
My conclusion: while Python provides big productivity gains by raising level of abstraction for a lot of general purpose coding, wxPython is several levels of abstraction lower than the gui tools available for Delphi. Net result: gui programming with Delphi is way faster than gui programming with Python, and the resulting ui with Delphi is still more polished and full-featured. It doesn't seem to me like it's exaggerating to say that Delphi gui programming was more advanced back in 1995 than python gui programming with wxPython is in 2009.
I did some investigating of other python gui frameworks and it didn't look like any were substantially better than wxPython. I also did some minimal investigation of gui formbuilders for wxPython, which would have made things a little bit better. But by most reports those solutions are buggy and even a great formbuilder wouldn't address my main complaints about wxPython, which are simply that it has fewer features and generally requires you to do gui programming at a much lower level of abstraction than I'm used to with Delphi's VCL. Some quick investigating into suggested python gui-dev solutions ( http://wiki.python.org/moin/GuiProgramming ) is honestly somewhat depressing for someone used to Delphi or .NET.
Finally, I've got a couple of questions.
First, am I missing something? Is there some gui-development solution for Python that can compare with VCL or WinForms programming? I don't necessarily care if it doesn't quite measure up to Delphi's VCL. I'm just looking for something that's in the same league.
Second, could IronPython be the direction to go? I've mostly tried to avoid drinking the .NET koolaid, but maybe IronPython gives me a reason to finally give in. Even then, does IronPython fully integrate with WinForms, or would I need to have the forms themselves be backed by c# or vb.net? It looks to me like that definitely is the case with SharpDevelop and MonoDevelop (i.e, IronPython can't be used to do design-time gui building). Does VS.NET fully integrate IronPython with gui-building?
It really seems to me like Python could "take over the world" in a way similar to the way that Visual Basic did back in the early 1990's, if some wonderful new gui-building solution came out for Python. Only this time with Python we'd have a whole new paradigm of fast, cross platform, and open source gui programming. Wouldn't corporations eat that up? Yeah, I know, web apps are the main focus of things these days, so a great Python-gui solution wouldn't create same revolution that VB once did. But I don't see gui programming disappearing and I'd like a nice modern, open source, high level solution.
seems your complains are about wxPython, not about Python itself. try pyQt (or is it qtPython?)
but, both wxPython and pyQt are just Python bindings to a C / C++ (respectively) library, it's just as (conceptually) low level as the originals.
but, Qt is far superior to wx
PyQt is a binding to Qt SDK from Nokia, and PyQt itself is delivered by a company called RiverBank.
If licence is not important for you you can use PyQt under GPL or you 'll pay some money for commercial licence.
PyQt is binding Qt 4.4 right now.
Qt is not just GUI, it's a complete C/C++ SDK that help with networking, xml, media, db and other stuff, and PyQt transfer all this to python.
With PyQt you'll use Qt Designer and you 'll transfer the .ui file to .py file by a simple command line.
You 'll find many resources on the web about PyQt and good support from different communities, and even published books on PyQt.
Many suggestions consider that RiverBank has no choice but to release the next version which 'll depend on Qt 4.5 under LGPL, we are waiting :).
Another solution is Jython with Java Swing, very easy and elegant to write (specially under JDK 6), but not enough resources on internet.
You may want to look at Jython (Python on the Java VM). It is very similar to Iron Python, and you can fore go the .Net koolaid.
dabo puts wxPython programming at a higher level like what you're looking for.
You're probably going to have to use the .net or java pythons, but check this out first and see if it meets your requirements:
Kiwi
Short answer: Don't try Tkinter - it's got all the problems described above.
Long answer: Tkinter is not useful for large programs. Handling the various pieces with it somehow invariably degenerates to juggling (which never happens otherwise) and the resulting output doesn't look native or particularly polished.
You are right, wxPython can definetely be improved. But i think Robin Dunn has done a great job so far, and still is.
Especially the wxPython community is open to improvements, like recent inclusion of the widgets by Andrea, so like many community projects pick the one you like most, and improve it while using it.
We've been quite happy using Python.Net to build our UIs in WinForms and using CPython for Presenter, Model. IronPython is also a good tool if you want to do python on Windows.
There is Wax, whose purpose was to create a more pythonic interface to wxWidgets, but it seems its development has stalled.