Example #1
0
class LoadThings(QUndoCommand):
    def __init__(self, widget, thing):
        super(LoadThings, self).__init__()
        self.widget = widget

        self.createdThing = thing
        self.item = QTreeWidgetItem()
        self.item.setText(0, thing.name)

        typeName = type(thing).__name__
        for i in range(self.widget.ui.treeWidget.topLevelItemCount()):
            group = self.widget.ui.treeWidget.topLevelItem(i)
            if group.text(0) == typeName:
                self.group = group
                break
        else: # group not found
            self.group = QTreeWidgetItem()
            self.group.setText(0, typeName)

    def redo(self):
        if self.widget.ui.treeWidget.indexOfTopLevelItem(self.group) == -1:
            self.widget.ui.treeWidget.addTopLevelItem(self.group)
        self.group.addChild(self.item)
        self.group.setExpanded(True)
        self.widget.ui.treeWidget.setCurrentItem(self.item)

    def undo(self):
        self.group.takeChild(self.group.childCount()-1)
        if self.group.childCount() == 0:
            parentIndex = self.widget.ui.treeWidget.indexOfTopLevelItem(self.group)
            self.widget.ui.treeWidget.takeTopLevelItem(parentIndex)
    def buildEdgeList(self):
        ''' populate the ui tree with the edges that can be extended'''
        self.edgeList = []

        treeExists = False
        if self.edges_TW.topLevelItem(0):
            treeExists = True
            parentItem = self.edges_TW.topLevelItem(0)
        else:
            self.edges_TW.clear()
            parentItem = QTreeWidgetItem()
            faceName = self.face_LE.text()
            parentItem.setText(0, faceName)
            self.edges_TW.addTopLevelItem(parentItem)
            self.edges_TW.expandItem(parentItem)

            if not treeExists:
                for edgeNum in self.helperFace.ExtendableEdges:
                    ###### populate the edge tree ######
                    edgeItem = QTreeWidgetItem()
                    edgeItem.setText(0, str("Edge" + str(edgeNum)))
                    checked = QtCore.Qt.Unchecked
                    if edgeNum in self.helperFace.CheckedEdges:
                        checked = QtCore.Qt.Checked
                    edgeItem.setCheckState(0, checked)
                    parentItem.addChild(edgeItem)

        self.loadTools()
    def _init_widgets(self):

        self.clear()

        if self._simgr is None:
            return

        for stash_name, stash in self._simgr.stashes.iteritems():

            if not stash and stash_name not in ('active', 'deadended',
                                                'avoided'):
                continue

            item = QTreeWidgetItem(self,
                                   ["%s (%d)" % (stash_name, len(stash))])

            for state in stash:
                subitem = QTreeWidgetItem(item, [str(state)])
                item.addChild(subitem)

            self.addTopLevelItem(item)

        # errored states
        if self._simgr.errored:
            item = QTreeWidgetItem(
                self, ["%s (%d)" % ('errored', len(self._simgr.errored))])
            for state in self._simgr.errored:
                subitem = QTreeWidgetItem(item, [str(state)])
                item.addChild(subitem)

            self.addTopLevelItem(item)
Example #4
0
 def fill_item(self, item, value):  #recursively fills the tree
     item.setExpanded(True)
     for key, val in sorted(value.iteritems()):  #tilts
         child = QTreeWidgetItem()
         child.setText(0, unicode(key))
         child.setFlags(Qt.ItemIsEnabled)
         item.addChild(child)
         for keykey in sorted(val.keys()):  #imgIDs
             childchild = QTreeWidgetItem()
             child.addChild(childchild)
             childchild.setText(0, str(keykey))
             child.setExpanded(True)
             childchild.setExpanded(True)
 def renderCorpEvent(self, corporateEventPositionDictAsset):
     self.clearTables()
     self.treeCorporateEvent.setColumnCount(3)
     self.treeCorporateEvent.setHeaderLabels(self.columnListCorporateEvent)
     for key, cep in corporateEventPositionDictAsset.items():
         l1 = QTreeWidgetItem(
             [key, str(cep.accGrossAmount),
              str(cep.accNetAmount)])
         for ce in cep.corporateEventList:
             l1_child = QTreeWidgetItem([
                 None,
                 str(ce.grossAmount),
                 str(ce.netAmount),
                 str(ce.paymentDate)
             ])
             l1.addChild(l1_child)
             self.treeCorporateEvent.addTopLevelItem(l1)
    def _init_widgets(self):

        self.clear()

        if self._pathgroup is None:
            return

        for stash_name, stash in self._pathgroup.stashes.iteritems():

            if not stash and stash_name not in ('active', 'deadended', 'avoided'):
                continue

            item = QTreeWidgetItem(self, [ "%s (%d)" % (stash_name, len(stash)) ])

            for path in stash:
                subitem = QTreeWidgetItem(item, [ str(path) ])
                item.addChild(subitem)

            self.addTopLevelItem(item)
Example #7
0
    def _populateTree(self):
        self.pushupsListWidget.clear()
        self.pushupsListWidget.setColumnCount(4)
        self.pushupsListWidget.setHeaderLabels([
            "Date", "TotalPushups", "Series", "Repetitions",
            "Average Heart Rate"
        ])
        self.pushupsListWidget.setSortingEnabled(True)
        self.pushupsListWidget.setColumnWidth(0, 180)
        self.pushupsListWidget.setColumnWidth(4, 150)

        pushupDict = self._getPushupDictionary()

        for it, dayOfExercise in enumerate(sorted(pushupDict.keys())):

            dateItem = QTreeWidgetItem()

            dayLabel = dayOfExercise.strftime("%Y/%m/%d")

            dateItem.setText(0, "\n" + dayLabel + "\nDay : " + str(it))

            self.pushupsListWidget.addTopLevelItem(dateItem)

            totalPushups = 0
            for pushup in pushupDict[dayOfExercise]:
                pushupItem = QTreeWidgetItem()

                pushupItem.setText(2, "#" + str(pushup._series))
                pushupItem.setText(3, str(pushup._repetitions))
                pushupItem.setText(4, str(pushup._averageHeartRate))
                pushupItem.setData(0, Qt.UserRole, pushup)

                totalPushups = totalPushups + pushup._repetitions

                dateItem.addChild(pushupItem)

            dateItem.setText(1, str(totalPushups))
Example #8
0
 def _populateTree(self):
     self.pushupsListWidget.clear()
     self.pushupsListWidget.setColumnCount(4)
     self.pushupsListWidget.setHeaderLabels(["Date", "TotalPushups", 
                                             "Series", "Repetitions",
                                             "Average Heart Rate"])
     self.pushupsListWidget.setSortingEnabled(True)
     self.pushupsListWidget.setColumnWidth(0, 180)
     self.pushupsListWidget.setColumnWidth(4, 150)
     
     pushupDict = self._getPushupDictionary()
     
     for it, dayOfExercise in enumerate(sorted(pushupDict.keys())):                  
          
         dateItem = QTreeWidgetItem()
         
         dayLabel = dayOfExercise.strftime("%Y/%m/%d")
         
         dateItem.setText(0, "\n" + dayLabel + "\nDay : " + str(it))
         
         self.pushupsListWidget.addTopLevelItem(dateItem)
         
         totalPushups = 0
         for pushup in pushupDict[dayOfExercise]:
             pushupItem = QTreeWidgetItem()
             
             pushupItem.setText(2, "#" + str(pushup._series))
             pushupItem.setText(3, str(pushup._repetitions))
             pushupItem.setText(4, str(pushup._averageHeartRate))
             pushupItem.setData(0, Qt.UserRole, pushup)
             
             totalPushups = totalPushups + pushup._repetitions 
             
             dateItem.addChild(pushupItem)  
         
         dateItem.setText(1, str(totalPushups))
Example #9
0
from PySide.QtGui import QApplication, QTreeWidgetItem, QWidget, QTreeWidget

if __name__ == '__main__':
    app = 0
    if QApplication.instance():
        app = QApplication.instance()
    else:
        app = QApplication(sys.argv)

    l1 = QTreeWidgetItem(["ALFA", "100"])
    l2 = QTreeWidgetItem(["GRUMA", "200"])

    for i in range(3):
        l1_child = QTreeWidgetItem([None, str(i * 10), "Child C" + str(i)])
        l1.addChild(l1_child)

    for j in range(2):
        l2_child = QTreeWidgetItem([None, str(j * 20), "Child CC" + str(j)])
        l2.addChild(l2_child)

    w = QWidget()
    w.resize(510, 210)

    tw = QTreeWidget(w)
    tw.resize(500, 200)
    tw.setColumnCount(3)
    tw.setHeaderLabels(["Asset", "Gross Amount", "Payment Date"])
    tw.addTopLevelItem(l1)
    tw.addTopLevelItem(l2)
Example #10
0
from PySide.QtGui import QApplication, QTreeWidgetItem, QWidget, QTreeWidget

from engine.engine import Engine
from core.cache import Singleton, MainCache
mainCache = Singleton(MainCache)

if __name__ == '__main__':
    app = 0
    if QApplication.instance():
        app = QApplication.instance()
    else:
        app = QApplication(sys.argv)
    w = QWidget()
    w.resize(510, 210)
    tw = QTreeWidget(w)
    tw.resize(500, 200)
    tw.setColumnCount(3)
    tw.setHeaderLabels(["Asset", "Gross Amount", "Net Amount", "Payment Date"])
    mainCache = Singleton(MainCache)
    mainCache.refreshReferenceData()
    Engine.buildCorporateEventPosition()
    
    for key, cep in mainCache.corporateEventPositionDictAsset.items():
        l1 = QTreeWidgetItem([key, str(cep.accGrossAmount), str(cep.accNetAmount)])
        for ce in cep.corporateEventList:
            l1_child = QTreeWidgetItem([None, str(ce.grossAmount), str(ce.netAmount),str(ce.paymentDate)])
            l1.addChild(l1_child)
        tw.addTopLevelItem(l1)

    w.show()
    sys.exit(app.exec_())