Question

I'm looking for GUI feature that will be part of Python desktop application.

The feature is a text tree with drag and drop functionality between individual nodes. Further I'd like to be able to attach a note with longer text to individual nodes in the tree. The note would be switchable to expanded or collapsed state.

It is exactly shown in this NestedSortable JQuery library except of the switchable note.

Could you show me what are the possibilities of contemporary Python GUIs according to this feature? I prefer lightweight GUI with modern look as in the JQuery example.

Which GUI would be the most suitable for this task? Tkinter, wxPython, pyQt, pyGTK or other? Or would you choose some GUI + Javascript libraries? Why would you prefer particular GUI to achieve requested functionality and lightweight modern design?

Était-ce utile?

La solution

pyQT has a good solution for this with its QTreeWidget or a MVC setup. QTreeWidget is simplest:

Here's a small example using PyQt4

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *

class MainWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        self.treewidget = QTreeWidget(self)
        self.treewidget.setHeaderLabels(['a'])
        self.treewidget.setDragEnabled(True)
        self.treewidget.setAcceptDrops(True)
        self.treewidget.setDropIndicatorShown(True)
        self.treewidget.resize(300,300)
        self.titems = []
        for i in xrange(100):
            if not i%10:
                pitem = QTreeWidgetItem(self.treewidget,["Parent %d"%i])
                self.titems.append(pitem)
            else:
                item = QTreeWidgetItem(pitem,["Child of %d"%i])
                self.titems.append(item) 
        self.show()

app = QApplication(sys.argv)
w = MainWindow()
app.exec_()

Autres conseils

Try using etetoolkit. Its much simpler.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top