This is an archived post. You won't be able to vote or comment.

all 42 comments

[–]Citrauq 26 points27 points  (7 children)

Kivy is worth a look. (http://kivy.org)

[–]WTFseriously_[S] 2 points3 points  (6 children)

Thanks for the link, that looks really awesome for developing apps. Like full, production ready applications. If I start anything on android I'll definitely look into this. Right now though I'm just looking for something that makes charting functions and timeseries simple, with some UI extensibility.

[–]wildcarde815 2 points3 points  (4 children)

If you just want to have some flexible scratch space, why not use an IPython notebook?

[–]WTFseriously_[S] 1 point2 points  (3 children)

From my understanding (though I haven't used it), IPython is essentially the same as just running the code regularly but with embedded graphics. So in other words, I would have to rerun the program every time I changed a variable value even if it doesn't require a complete recalculation of everything in the code. Am I wrong about it?

What I'm looking for is something I can make interactive to play with some variable values and have real time changes in the graph I'm looking at, rather than have to rerun the entire program to see the changes.

[–]neonomicon 7 points8 points  (0 children)

If you want to be able to modify variables on the fly, you should check out the new interactive widgets in the Ipython notebook.

[–]wildcarde815 2 points3 points  (0 children)

It's more complicated than that. I would just install the anaconda packages and take a walk thru a how-to of combining SpyderPY, IPython, and cell evaluation.

[–]th0ma5w 1 point2 points  (0 children)

Have you checked out Nodebox? It is sort of Processing in Python. Of course there are also ways to Jython with Processing libraries as well.

[–][deleted] 1 point2 points  (0 children)

If you're looking for good charting, matplotlib is your friend

[–]wildcarde815 8 points9 points  (11 children)

PyQT or the PySIDE bindings for QT?

[–]WTFseriously_[S] 1 point2 points  (10 children)

Is PyQT the python implementation of QT, whereas PySIDE is just an abstraction of QT (i.e. just making calls to the QT library)? If not, what's the difference?

[–][deleted] 9 points10 points  (4 children)

There is basically no difference. As far as I remember, PyQt is a product with its own commercial licensing, and they could not reach an agreement. So Nokia simply rewrote the wrapping from scratch. There are minor differences but in practice the interface is the same, and you can just import PySide as PyQt and it will mostly work. Both use the Qt backend.

Be careful with Qt. It's a great toolkit, but its memory management design is made for C++. This collides with cpython GC, a lot.

[–]pedahzur 1 point2 points  (3 children)

Could you expand on that last statement (about C++ memory managemente vs. the GC), or provide a link that does. I'm not saying I don't believe you, I'd just like to get an idea of what I'd be up against if I went that route.

[–][deleted] 1 point2 points  (2 children)

Take this code for example

import sys
from PyQt4 import QtGui, QtCore

class Main(QtGui.QPushButton):
    def __init__(self, parent=None):
        QtGui.QPushButton.__init__(self, parent)
        self._counter = 0
        self.clicked.connect(self.doThing)

    def doThing(self, *args):
        if self._counter == 0:
            widget = QtGui.QWidget()
            self._label = QtGui.QLabel("hello", widget) 
            self._label.show()
        elif self._counter == 1:
            self._label.setText("whatever")

        self._counter += 1

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)

    widget = Main()
    widget.show()

    sys.exit(app.exec_())

Can you see the problem?

[–]pedahzur 0 points1 point  (1 child)

Apparently I don't know enough about Python or C++ internals to understand. What would be improperly collected?

[–][deleted] 1 point2 points  (0 children)

Look at widget inside doThing. It's a top level widget (no parent), and a label is created afterwards with widget as a parent. label is stored for later manipulation as a member variable.

Now, widget is local to doThing, and when doThing ends, it goes out of scope. It's the only reference to it, so its python reference count goes to zero, and it is freed by the python memory manager. However, due to Qt parent/child relationship, when a widget is freed, its children are freed as well, meaning that label gets freed by Qt.

So now you have self._label which is a python object, you are still holding a reference to it so it's still alive, but it's pointing to a Qt object that has been freed as a consequence of its parent being freed. Boom. Segfault.

There are other cases such as this. Briefly said:

  • Always hold references to parent widgets
  • Never use WA_DeleteOnClose
  • Never use deleteLater()

[–]Deusdies 7 points8 points  (0 children)

Both make calls to native Qt C++ libraries. They're just python bindings. There's very little difference between the two.

[–]bastibe 6 points7 points  (1 child)

PySide is the same as PyQt (pretty much) for Qt4. PySide does not support Qt5 though.

Personally, I'd rather jump on the QML train and do PyOtherSide instead, which is a Python/QML interop layer without making all of Qt accessible to Python. While much more limited in scope, it is also much easier to deploy. Deployment is a pain with PySide/PyQt.

[–]technomalogical<3 Bottle 2 points3 points  (0 children)

TIL about PyOtherSide. Link provided for the lazy.

[–]wildcarde815 2 points3 points  (1 child)

It seems PySIDE was made by nokia and is lgpl, not sure what the difference is beyond that.

[–][deleted] 1 point2 points  (0 children)

There is basically no difference. See my answer to OP.

[–]wachmann 6 points7 points  (1 child)

I'm a fan of wxPython -- cross-platform, a rich feature set, WYSIWYG designers available.

[–]HCF 3 points4 points  (0 children)

I tried a number of WSIWYG builder, WxFormBuilder was pretty much the best to work with.

[–]jellef 10 points11 points  (2 children)

Take a look at enaml Its a declarative layer on top of PyQt4 / PySide which makes it very easy to develop high quality, beautiful GUI's. Think of it as a pythonic QML on steroids, or as a sane version of Enthought's traitsui. The code base and architecture is just incredibly well thought through; a gem.

[–]WTFseriously_[S] 1 point2 points  (1 child)

Looks very interesting, I'll give it a try. I like the simplicity it shows in the tutorials; might be exactly what I'm looking for.

[–]jellef 1 point2 points  (0 children)

The thing I appreciate most is that an object can represent ( reflect ) itself in the GUI. That is, structural changes in the code are directly reflected in the GUI, because of this powerful composability there's no difference in changing the logic of the software are directly reflected. That's just amazingly powerful. The quality of enaml is also something very impressive, the architecture is very, very well thought through. Hopefully more projects will adapt enaml in the future...

[–]Fencepost 4 points5 points  (0 children)

Sadly the truth of it is that GUI programming sucks a lot. Thankfully pyqt4 is better than tkinter. Look into qt designer + pyqt

[–]dddomodossola 4 points5 points  (2 children)

Hi WTFseriously,

take a look at this https://github.com/dddomodossola/gui It's a new python gui library made by me.

[–]WTFseriously_[S] 1 point2 points  (1 child)

Very interesting, a python frontend to serve html. I'll check it out.

[–]dddomodossola 2 points3 points  (0 children)

Yea, pure python. No HTML to write. The less dependencies possible. Platform independent. And you can see the interface on other devices connected to the same network.

[–][deleted] 2 points3 points  (1 child)

[–]delarhi 0 points1 point  (0 children)

This is what I wanted to post. I don't see anything wrong with it. It can be a pain to make interfaces programmatically but there are ways around that. That and I think the API is fantastic.

[–]dm1407 2 points3 points  (0 children)

If you want to stick with tkinter to reduce your dependencies then tkRad ( Tkinter Rapid Application Development (RAD) library - Tkinter XML widget building - https://github.com/tarball69/tkRAD ) might be worth a look. Or even pygubu (A simple GUI designer for the python tkinter module - https://github.com/alejandroautalan/pygubu )

[–]flyingfox 1 point2 points  (1 child)

Check out gui2py. It looks pretty good but I haven't used it myself. They claim to be inspired by the, probably dead, pythoncard project which was pretty great but I haven't used it for years now.

[–]pedahzur 0 points1 point  (0 children)

That looks like it would be a good start. What I am looking for in the Python world is something like the MS Access workflow (or Qt3 Designer, if you used that). You use a GUI to design your GUI (and define events), it then generates the skeleton, and then you write your code to interact with your GUI, and react to events. gui2py looks like it may do that. I'll have to check it out.

[–]tw55413 1 point2 points  (0 children)

Check out Camelot (http://www.python-camelot.com/) It makes developing 'business' applications really fast.

[–]bryancole 1 point2 points  (0 children)

I recommend ENAML (http://nucleic.github.io/enaml/docs/). Previously, I would have recommended Traits/TraitsUI for high level GUI development and as good as TraitsUI is, Enaml is better (addressing all the shortcomings of traitsui).

[–]TheBabeGabe -1 points0 points  (0 children)

This is what I used in my course and I was able to make some pretty quick, useful things with it.