Changing GUI library : QT, wxPython... anything else? - python

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.

Related

wxpython GUI testing tool Inquiry

For a couple of days, I was trying to find appropriate GUI test tools for toolkits (wxwidgets). The program that am going to test is written in python.I have tried SQUISH but it did not work when using "Verification Point", meaning that object property values were not appearing in squish. The GUI testing tool doesn't have to be free or open source, as long as it meets the above requirements and that you have "first-hand" experience using the framework. I would really appreciate any guidance.
You are probably looking for tools like these:
http://uiautomationverify.codeplex.com/
https://github.com/ldtp/cobra
http://sikuli.org/
wxPython also comes with wx.UIActionSimulator which you could probably use for automated testing.
The squish framework doesn't work with wxwidgets, to my knowledge. It might work with PyQt though and possibly Tkinter

Is there a tutorial specifically for PyQt5? [closed]

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

QtDesigner or doing all of the Qt boilerplate by hand?

When starting up a new project, as a beginner, which would you use?
For example, in my situation. I'm going to have a program running on an infinite loop, constantly updating values. I need these values to be represented as a bar graph as they're updating. At the same time, the GUI has to be responsive to user feedback as there will be some QObjects that will be used to updated parameters within that infinite loop. So these need to be on separate threads, if I'm not mistaken. Which choice would give the most/least hassle?
If I understood your question correctly, updating the GUI has a little to do with the way you programmed it.
From my experience, it's easier to design a main window (or whatever your top level object is) in Designer, and add some dynamically updated content in a widget(s) created in your code. In most cases, it saves your time spent on digging through QT documentation, and additionally, you are able to visually inspect positioning, aligning etc.
You don't lose anything by using a Designer, every part of the GUI can be modified in your code afterwards, if it needs some custom behavior.
Having said that, without knowing all the details of your project is hard to tell which option (QT or in-code) is faster.
Your right threading is your answer. Use the QT threads they work very well.
Where I work when people start out using QT a lot of them start with designer but eventually end up hand coding it. I think you will end up hand coding it but if you are someone who really likes GUIs you may want to start with Designer. I know that isn't a definitive answer but it really depends.
First of all, the requirements that you've mentioned don't (or shouldn't) have much affect on this decision.
Either way, you're going to have to learn something. You might as well investigate both options, and make the decision yourself. Write a couple of "Hello, World!" apps, then start adding some extra widgets/behavior to see how each approach scales.
Since you asked, I would probably use Qt Designer. But I'm not you, and I'm not working on (nor do I know much of anything about) your project.

questions re: current state of GUI programming with Python

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.

OPENGL User Interface Programming [closed]

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)

Categories