예제 #1
0
    def setAnnotations(self, gds):
        self._annotationsUpdating = True
        self.annotationsTree.clear()

        annotations = defaultdict(set)
        subsetscount = {}
        for desc in gds["subsets"]:
            annotations[desc["type"]].add(desc["description"])
            subsetscount[desc["description"]] = str(len(desc["sample_id"]))

        for type, subsets in annotations.items():
            key = (gds["dataset_id"], type)
            subsetItem = QTreeWidgetItem(self.annotationsTree, [type])
            subsetItem.setFlags(subsetItem.flags() | Qt.ItemIsUserCheckable
                                | Qt.ItemIsTristate)
            subsetItem.setCheckState(
                0, self.gdsSelectionStates.get(key, Qt.Checked))
            subsetItem.key = key
            for subset in subsets:
                key = (gds["dataset_id"], type, subset)
                item = QTreeWidgetItem(
                    subsetItem, [subset, subsetscount.get(subset, "")])
                item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
                item.setCheckState(
                    0, self.gdsSelectionStates.get(key, Qt.Checked))
                item.key = key
        self._annotationsUpdating = False
        self.annotationsTree.expandAll()
        for i in range(self.annotationsTree.columnCount()):
            self.annotationsTree.resizeColumnToContents(i)
 def __add_themen(self):
     self.ui.TREE_THEMEN.headerItem().setText(0, '')
     #TODO: resize column to contents
     #all of these don't work??
     self.ui.TREE_THEMEN.header().resizeSection(0, 250)
     self.ui.TREE_THEMEN.header().setResizeMode(QHeaderView.ResizeToContents);
     self.ui.TREE_THEMEN.header().setStretchLastSection(True);
     themen = self.json_settings.themen()
     for thema_name, thema in themen.iteritems():
         tree_thema = QTreeWidgetItem(self.ui.TREE_THEMEN)
         tree_thema.setText(0, thema_name)
         tree_thema.setData(0, Qt.UserRole, thema)
         tree_thema.setFlags(tree_thema.flags() | Qt.ItemIsUserCheckable)
         if thema_name == 'DKM':
             tree_thema.setCheckState(0, Qt.Checked)
         else:
             tree_thema.setCheckState(0, Qt.Unchecked)
         if not thema.subthemen is None:
             for subthema in thema.subthemen:
                 if VRP_DEBUG is True: QgsMessageLog.logMessage(u'Subthema: {0}'.format(subthema.name), DLG_CAPTION)
                 tree_subthema = QTreeWidgetItem()
                 tree_subthema.setText(0, subthema.name)
                 tree_subthema.setData(0, Qt.UserRole, subthema)
                 tree_subthema.setFlags(tree_subthema.flags() | Qt.ItemIsUserCheckable)
                 tree_subthema.setCheckState(0, Qt.Unchecked)
                 tree_thema.addChild(tree_subthema)
예제 #3
0
    def setAnnotations(self, gds):
        self._annotationsUpdating = True
        self.annotationsTree.clear()

        annotations = defaultdict(set)
        subsetscount = {}
        for desc in gds["subsets"]:
            annotations[desc["type"]].add(desc["description"])
            subsetscount[desc["description"]] = str(len(desc["sample_id"]))

        for type, subsets in annotations.items():
            key = (gds["dataset_id"], type)
            subsetItem = QTreeWidgetItem(self.annotationsTree, [type])
            subsetItem.setFlags(subsetItem.flags() | Qt.ItemIsUserCheckable |
                                Qt.ItemIsTristate)
            subsetItem.setCheckState(
                0, self.gdsSelectionStates.get(key, Qt.Checked)
            )
            subsetItem.key = key
            for subset in subsets:
                key = (gds["dataset_id"], type, subset)
                item = QTreeWidgetItem(
                    subsetItem, [subset, subsetscount.get(subset, "")]
                )
                item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
                item.setCheckState(
                    0, self.gdsSelectionStates.get(key, Qt.Checked)
                )
                item.key = key
        self._annotationsUpdating = False
        self.annotationsTree.expandAll()
        for i in range(self.annotationsTree.columnCount()):
            self.annotationsTree.resizeColumnToContents(i)
 def __add_themen(self):
     self.ui.TREE_THEMEN.headerItem().setText(0, '')
     #TODO: resize column to contents
     #all of these don't work??
     self.ui.TREE_THEMEN.header().resizeSection(0, 250)
     self.ui.TREE_THEMEN.header().setResizeMode(
         QHeaderView.ResizeToContents)
     self.ui.TREE_THEMEN.header().setStretchLastSection(True)
     themen = self.json_settings.themen()
     for thema_name, thema in themen.iteritems():
         tree_thema = QTreeWidgetItem(self.ui.TREE_THEMEN)
         tree_thema.setText(0, thema_name)
         tree_thema.setData(0, Qt.UserRole, thema)
         tree_thema.setFlags(tree_thema.flags() | Qt.ItemIsUserCheckable)
         if thema_name == 'DKM':
             tree_thema.setCheckState(0, Qt.Checked)
         else:
             tree_thema.setCheckState(0, Qt.Unchecked)
         if not thema.subthemen is None:
             for subthema in thema.subthemen:
                 if VRP_DEBUG is True:
                     QgsMessageLog.logMessage(
                         u'Subthema: {0}'.format(subthema.name),
                         DLG_CAPTION)
                 tree_subthema = QTreeWidgetItem()
                 tree_subthema.setText(0, subthema.name)
                 tree_subthema.setData(0, Qt.UserRole, subthema)
                 tree_subthema.setFlags(tree_subthema.flags()
                                        | Qt.ItemIsUserCheckable)
                 tree_subthema.setCheckState(0, Qt.Unchecked)
                 tree_thema.addChild(tree_subthema)
예제 #5
0
    def makeTree(self):
        self.tree.clear()
        arr = Valid().pullData('datas', '', {'pubID': self.titleID})
        self.hold_data = {}
        self.hold_mdata = {}
        self.hold_data_add = {}
        self.hold_data_add_item = {}

        if self.titleSub and self.titleSub > 0:
            if arr and len(arr) > 0:
                for val in arr:
                    ch = Valid().pullData('datas', '', {'subID': val['id']})
                    child = QTreeWidgetItem(self.tree)
                    child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                    child.setText(0, str(val['name']).upper())
                    child.setText(1, str(val['abbrv']).upper())
                    self.hold_data[val['id']] = child
                    self.hold_mdata[val['id']] = child
                    if (val['active'] == 0):
                        child.setCheckState(0, Qt.Checked)
                    else:
                        child.setCheckState(0, Qt.Unchecked)

                    for va in ch:
                        child1 = QTreeWidgetItem(child)
                        child1.setFlags(child1.flags()
                                        | Qt.ItemIsUserCheckable)
                        child1.setText(0, str(va['name']).upper())
                        child1.setText(1, str(va['abbrv']).upper())
                        self.hold_data[va['id']] = child1
                        if (va['active'] == 0):
                            child1.setCheckState(0, Qt.Checked)
                        else:
                            child1.setCheckState(0, Qt.Unchecked)

                    child1 = QTreeWidgetItem(child)
                    child1.setFlags(child1.flags() | Qt.ItemIsUserCheckable)
                    child1.setText(0, 'Add New Item')
                    self.hold_data_add_item[val['id']] = child1
        else:
            if arr and len(arr) > 0:
                for val in arr:
                    child = QTreeWidgetItem(self.tree)
                    child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                    child.setText(0, str(val['name']).upper())
                    child.setText(1, str(val['abbrv']).upper())
                    self.hold_data[val['id']] = child
                    if (val['active'] == 0):
                        child.setCheckState(0, Qt.Checked)
                    else:
                        child.setCheckState(0, Qt.Unchecked)

        child = QTreeWidgetItem(self.tree)
        child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
        child.setText(0, 'Add New')
        self.hold_data_add['addnew'] = child
    def generate_tree_model(self, data_dict):
        """Generate a tree model for specified dictionary

        :param data_dict: A dictionary
        :type data_dict: dict
        :return: list of QTreeWidgetItem
        :rtype list:
        """
        widget_items = []
        font = QFont()
        font.setBold(True)
        for key in data_dict.keys():
            entry = data_dict[key]
            key_item = QTreeWidgetItem()
            key_item.setText(0, str(key))
            key_item.setFont(0, font)
            if isinstance(entry, dict):
                items = self.generate_tree_model(entry)
                key_item.addChildren(items)
            else:
                # value_item = QTreeWidgetItem()
                key_item.setText(1, str(entry))
                key_item.setFlags(key_item.flags() | Qt.ItemIsEditable)
                # key_item.addChild(key_item)
            widget_items.append(key_item)

        return widget_items
 def createActionItem( self, key ):
     """
     Creates a new action item for the inputed key.
     
     :param      key | <str>
     
     :return     <QTreeWidgetItem>
     """
     action = self._actions.get(key)
     if ( not action ):
         text = 'Missing Action: %s' % key
         item = QTreeWidgetItem([text])
         ico = projexui.resources.find('img/log/warning.png')
         item.setIcon(0, QIcon(ico))
     else:
         item = QTreeWidgetItem([str(action.text()).replace('&', '')])
         item.setIcon(0, action.icon())
     
     item.setSizeHint(0, QSize(120, 20))
     item.setData(0, Qt.UserRole, qt.wrapVariant(key))
     
     flags = item.flags()
     flags ^= Qt.ItemIsDropEnabled
     item.setFlags(flags)
     
     return item
예제 #8
0
    def _populate_datasets_tree(self):
        """
        Initialize the tree widget of datasets and volumes.
        """
        self._data_treewidget.clear()

        if self._repos_info is None:
            return

        for dset_uuid, dset_info in sorted(self._repos_info.items()):
            dset_item = QTreeWidgetItem(self._data_treewidget,
                                        QStringList(dset_uuid))
            dset_item.setData(0, Qt.UserRole, (dset_uuid, ""))
            for data_name in dset_info["DataInstances"].keys():
                data_item = QTreeWidgetItem(dset_item, QStringList(data_name))
                data_item.setData(0, Qt.UserRole, (dset_uuid, data_name))
                if self._mode == 'specify_new':
                    # If we're in specify_new mode, only the dataset parent items are selectable.
                    flags = data_item.flags()
                    flags &= ~Qt.ItemIsSelectable
                    flags &= ~Qt.ItemIsEnabled
                    data_item.setFlags(flags)

        # Expand everything
        self._data_treewidget.expandAll()

        # Select the first item by default.
        if self._mode == "select_existing":
            first_item = self._data_treewidget.topLevelItem(0).child(0)
        else:
            first_item = self._data_treewidget.topLevelItem(0)
        self._data_treewidget.setCurrentItem(first_item, 0)
예제 #9
0
    def generate_tree_model(self, data_dict):
        """Generate a tree model for specified dictionary

        :param data_dict: A dictionary
        :type data_dict: dict
        :return: list of QTreeWidgetItem
        :rtype list:
        """
        widget_items = []
        font = QFont()
        font.setBold(True)
        for key in data_dict.keys():
            entry = data_dict[key]
            key_item = QTreeWidgetItem()
            key_item.setText(0, str(key))
            key_item.setFont(0, font)
            if isinstance(entry, dict):
                items = self.generate_tree_model(entry)
                key_item.addChildren(items)
            else:
                # value_item = QTreeWidgetItem()
                key_item.setText(1, str(entry))
                key_item.setFlags(key_item.flags() | Qt.ItemIsEditable)
                # key_item.addChild(key_item)
            widget_items.append(key_item)

        return widget_items
예제 #10
0
    def _populate_repo_tree(self):
        """
        Initialize the tree widget of repos and volumes.
        """
        self._repo_treewidget.clear()
        
        if self._repos_info is None:
            return
        
        for repo_uuid, repo_info in sorted(self._repos_info.items()):
            if repo_info is None:
                continue
            repo_column_dict = collections.defaultdict(str)
            repo_column_dict["Alias"] = repo_info["Alias"]
            repo_column_dict["Details"] = "Created: " + repo_info["Created"]
            repo_column_dict["UUID"] = repo_uuid
            repo_column_values = [repo_column_dict[k] for k in TREEVIEW_COLUMNS]
            repo_item = QTreeWidgetItem( self._repo_treewidget, QStringList( repo_column_values ) )
            repo_item.setData( 0, Qt.UserRole, (repo_uuid, "", "") )
            for data_name, data_info in repo_info["DataInstances"].items():
                data_instance_dict = collections.defaultdict(str)
                data_instance_dict["Alias"] = data_name
                typename = data_info["Base"]["TypeName"]
                data_instance_dict["TypeName"] = typename

                is_voxels = (typename in VOXEL_TYPENAMES)
                if is_voxels:
                    start_coord = data_info["Extended"]["MinPoint"]
                    if start_coord:
                        start_coord = tuple(start_coord)
                    stop_coord = data_info["Extended"]["MaxPoint"]
                    if stop_coord:
                        stop_coord = tuple(x+1 for x in stop_coord)
                    if start_coord and stop_coord:
                        shape = tuple(b - a for a,b in zip(start_coord, stop_coord))
                    else:
                        shape = None
                    data_instance_dict["Details"] = "Size={} | Start={} | Stop={}".format( shape, start_coord, stop_coord )

                data_column_values = [data_instance_dict[k] for k in TREEVIEW_COLUMNS]
                data_item = QTreeWidgetItem( repo_item, data_column_values )
                data_item.setData( 0, Qt.UserRole, (repo_uuid, data_name, typename) )

                # If we're in specify_new mode, only the
                # repo parent items are selectable.
                # Also, non-volume items aren't selectable.
                if self._mode == 'specify_new' or typename not in self._selectable_types:
                    flags = data_item.flags()
                    flags &= ~Qt.ItemIsSelectable
                    flags &= ~Qt.ItemIsEnabled
                    data_item.setFlags( flags )
        
        self._repo_treewidget.collapseAll()
        self._repo_treewidget.setSortingEnabled(True)

        if self._hostname in self._default_nodes:
            self._select_node_uuid(self._default_nodes[self._hostname])

        self._repo_treewidget.resizeColumnToContents(0)
        self._repo_treewidget.setFocus()
예제 #11
0
 def _populate_datasets_tree(self):
     """
     Initialize the tree widget of datasets and volumes.
     """
     self._data_treewidget.clear()
     
     if self._repos_info is None:
         return
     
     for dset_uuid, dset_info in sorted(self._repos_info.items()):
         dset_item = QTreeWidgetItem( self._data_treewidget, QStringList( dset_uuid ) )
         dset_item.setData( 0, Qt.UserRole, (dset_uuid, "") )
         for data_name in dset_info["DataInstances"].keys():
             data_item = QTreeWidgetItem( dset_item, QStringList( data_name ) )
             data_item.setData( 0, Qt.UserRole, (dset_uuid, data_name) )
             if self._mode == 'specify_new':
                 # If we're in specify_new mode, only the dataset parent items are selectable.
                 flags = data_item.flags()
                 flags &= ~Qt.ItemIsSelectable
                 flags &= ~Qt.ItemIsEnabled
                 data_item.setFlags( flags )
     
     # Expand everything
     self._data_treewidget.expandAll()
     
     # Select the first item by default.
     if self._mode == "select_existing":
         first_item = self._data_treewidget.topLevelItem(0).child(0)
     else:
         first_item = self._data_treewidget.topLevelItem(0)            
     self._data_treewidget.setCurrentItem( first_item, 0 )
예제 #12
0
    def loadPagesList(self, checkable=False):
        self.clear()
        for section in self.user_settings['pagesindex'].sections:
            root = QTreeWidgetItem([section.title])
            root.setData(0, Qt.UserRole, QVariant(QString(section.name)))
            root.setData(0, Qt.DecorationRole, QVariant(QIcon(section.icon)))
            self.addTopLevelItem(root)

            for page_id, page in section.pages:
                if not page:
                    page = self.getPage(page_id)
                if page.title:
                    page_title = page.title
                else:
                    page_title = tr('(No name)')
                item = QTreeWidgetItem([page_title])
                item.setData(0, Qt.UserRole ,QVariant(QString(page_id)))
                if checkable:
                    item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
                    item.setCheckState(0, Qt.Unchecked)
                root.addChild(item)
                if page == self.window.current_page:
                    f = QFont()
                    f.setWeight(QFont.Bold)
                    item.setData(0, Qt.FontRole, QVariant(f))
                    self.setCurrentItem(item)

        self.expandAll()
예제 #13
0
    def createActionItem(self, key):
        """
        Creates a new action item for the inputed key.
        
        :param      key | <str>
        
        :return     <QTreeWidgetItem>
        """
        action = self._actions.get(key)
        if (not action):
            text = 'Missing Action: %s' % key
            item = QTreeWidgetItem([text])
            ico = projexui.resources.find('img/log/warning.png')
            item.setIcon(0, QIcon(ico))
        else:
            item = QTreeWidgetItem([str(action.text()).replace('&', '')])
            item.setIcon(0, action.icon())

        item.setSizeHint(0, QSize(120, 20))
        item.setData(0, Qt.UserRole, qt.wrapVariant(key))

        flags = item.flags()
        flags ^= Qt.ItemIsDropEnabled
        item.setFlags(flags)

        return item
예제 #14
0
    def treeAddParticle(self):
        item = QTreeWidgetItem(
                ("0.0", "0.0", "0.0", "AU",
                    "0.0", "0.0", "0.0", "km/s",
                    "0.0", "MSun",
                    "0.0", "km"
                    ))

        item.setFlags(item.flags() | Qt.ItemIsEditable)
        self.ui.particlesTree.addTopLevelItem(item)
예제 #15
0
 def _addRequirements(self):
     for requirement, component, reason, optional in self._requirements:
         item = QTreeWidgetItem()
         item.setCheckState(0, Qt.Checked)
         if not optional:
             item.setFlags(Qt.ItemFlags(int(item.flags()) & ~Qt.ItemIsEnabled))
         item.setText(0, requirement)
         item.setText(1, reason)
         item.setText(2, component)
         item.setData(0, self._REQUIREMENT_ROLE, QVariant(requirement))
         self._reqTable.addTopLevelItem(item)
예제 #16
0
def build_tree_widget_item(parent, name, is_checkable=True):
    child = QTreeWidgetItem(parent)
    if is_checkable:
        child.setFlags(child.flags() | QtCore.Qt.ItemIsUserCheckable
                       | QtCore.Qt.ItemIsTristate)
        child.setCheckState(0, QtCore.Qt.Unchecked)
    else:
        child.setFlags(QtCore.Qt.ItemIsEnabled)
    child.setText(0, name)

    return child
예제 #17
0
 def load_packet(self, num, type):
     if type == self.instrument.RX_PACKET:
         packet = self.instrument.rx_packets[int(num)]
         self.rx_packets_num.setText(num)
         self.rx_packets_name.setText(packet.name)
         for field in packet.fields:
             item = QTreeWidgetItem([field.name, field.type])
             item.setFlags(item.flags() | Qt.ItemIsEditable)
             self.rx_packets_fields.addTopLevelItem(item)
         
     elif type == self.instrument.TX_PACKET:
         packet = self.instrument.tx_packets[int(num)]
         self.tx_packets_num.setText(num)
         self.tx_packets_name.setText(packet.name)
         for field in packet.fields:
             item = QTreeWidgetItem([field.name, field.type])
             item.setFlags(item.flags() | Qt.ItemIsEditable)
             self.tx_packets_fields.addTopLevelItem(item)
         
     else:
         raise WrongPacketTypeError(type)
예제 #18
0
    def __init__(self, parent=None):
        super(OfflineDialog, self).__init__(parent)
        
        self.pagetitle = 'Offline Back Up' 
        stylesheet = Valid().background() + Valid().font()

        
        self.hold_data = {}
        self.tree = QTreeWidget()
        self.tree.setHeaderLabel("Choose Sessions to Back-up")
        self.tree.headerItem().setText(0, 'Name')
        #self.tree.setStyleSheet(treeStyleSheet)
        arr = Db().selectn('session','', 5)
        if arr and len(arr) > 0:
               for val in arr:
                 child = QTreeWidgetItem(self.tree)
                 child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                 child.setText(0, str(val['name']).upper())
                 self.hold_data[val['id']] = child
                 child.setCheckState(0, Qt.Checked)
                
        
        
        self.pb = QPushButton()
        self.pb.setObjectName("Add")
        self.pb.setText("Save")
        
        self.pb1 = QPushButton()
        self.pb1.setObjectName("Cancel")
        self.pb1.setText("Close")
        
        hbo = QHBoxLayout()
        hbo.addWidget(self.pb1)
        hbo.addStretch()
        hbo.addWidget(self.pb)
        
        groupBox2 = QGroupBox('')
        groupBox2.setLayout(hbo)
            
        grid = QGridLayout()
        grid.addWidget(self.tree, 0, 0)
        grid.addWidget(groupBox2, 1, 0)
        
        self.setLayout(grid)
        self.connect(self.pb, SIGNAL("clicked()"), lambda: self.button_click())
        self.connect(self.pb1, SIGNAL("clicked()"), lambda: self.button_close(self))
        
        self.setStyleSheet(stylesheet)
        #self.setWindowIcon(QIcon(self.titleIcon))
        self.setWindowTitle(self.pagetitle)
예제 #19
0
    def add_item(self, texts, edit_item=False, select_item=False):
        item = QTreeWidgetItem(texts)
        item.setFlags(item.flags() | Qt.ItemIsEditable)

        self.tree_items.addTopLevelItem(item)

        if edit_item:
            self.tree_items.setCurrentItem(item)
            self.tree_items.setFocus()
            self.tree_items.editItem(item)
        elif select_item:
            self.tree_items.setCurrentItem(item)
            self.tree_items.setFocus()

        self.update_ui_state()
예제 #20
0
 def createSeparatorItem( self ):
     """
     Creates a new separator item.
     
     :return     <QTreeWidgetItem>
     """
     item = QTreeWidgetItem(['                                    '])
     font = item.font(0)
     font.setStrikeOut(True)
     item.setFont(0, font)
     item.setData(0, Qt.UserRole, qt.wrapVariant('separator'))
     flags = item.flags()
     flags ^= Qt.ItemIsDropEnabled
     item.setFlags(flags)
     
     return item
예제 #21
0
    def setupDialog(self):
        for particle in self.particles:
            pos = particle.position.number
            vel = particle.velocity.number
            mass = particle.mass.number
            radius = particle.radius.number

            item = QTreeWidgetItem((
                str(pos[0]), str(pos[1]), str(pos[2]), str(particle.position.unit),
                str(vel[0]), str(vel[1]), str(vel[2]), str(particle.velocity.unit),
                str(mass), str(particle.mass.unit),
                str(radius), str(particle.radius.unit)
                ))

            item.setFlags(item.flags() | Qt.ItemIsEditable)
            self.ui.particlesTree.addTopLevelItem(item)
예제 #22
0
    def createSeparatorItem(self):
        """
        Creates a new separator item.
        
        :return     <QTreeWidgetItem>
        """
        item = QTreeWidgetItem(['                                    '])
        font = item.font(0)
        font.setStrikeOut(True)
        item.setFont(0, font)
        item.setData(0, Qt.UserRole, qt.wrapVariant('separator'))
        flags = item.flags()
        flags ^= Qt.ItemIsDropEnabled
        item.setFlags(flags)

        return item
예제 #23
0
	def LoadConfig(self, e):
		" Loads parameter values from EVO file "
		# Get the name of the configuration file (where 'parameter value' pairs are stored)
		CfgFileName = self.NodeValue('ScenarioFileName')
		CfgFileName = QFileDialog.getOpenFileName(None,QString('Choose a configuration file'),
												  QString(CfgFileName), QString('*.evo'))
		if CfgFileName == '':   return False
		Params = EvolParam.Parameters(CfgFileName)
		#for PName in Params.ParamNames():	# processes only numerical parameters
		for PName in Params.Params:	# processes all parameters
			PNode = self.findNode(PName)
			if PNode is not None:
				PNode.setText(1,QString(str(Params.Parameter(PName))))
			elif PName.startswith('S_'):	
				# compatibility with older versions
				self.ScenarioName = PName[2:]
				SNameNode = self.findNode('ScenarioName')
				if SNameNode is not None:
					SNameNode.setText(1,QString(self.ScenarioName))
			else:
				print 'Creating missing node:', PName
				Node = QTreeWidgetItem(None, QStringList(QString(PName)))
				self.addTopLevelItem(Node)
				Node.setText(1,QString(str(Params.Parameter(PName))))
				Node.setFlags(Node.flags()|Qt.ItemIsEditable)
				self.NodeDescriptions[PName] = (1, [PName], PName)				
		# update the configuration file name node (priority over loaded node)
		FNameNode = self.findNode('ScenarioFileName')
		if FNameNode is not None:			
			FNameNode.setText(1,QString(os.path.relpath(str_(CfgFileName))))
		# get new parameter values
		# Special case for scenario name
		if 'ScenarioName' in Params.Params:
			self.ScenarioName = Params.Parameter('ScenarioName')
			SNameNode = self.findNode('ScenarioName')
			if SNameNode is not None:
				SNameNode.setText(1,QString(self.ScenarioName))
		self.highlightRelevantParameters()
		self.changed = False	# all parameters come from file
		return True
예제 #24
0
    def __init__(self, term, parent=None):
        super(TermFeeDialog, self).__init__(parent)
        self.term = term
        terms = self.pullOnes('terms', self.term)
        session = self.pullOnes('session', terms['sessionID'])
        self.termname = str(
            session['name']) + ' ' + terms['name'] + ' Term Report'
        self.pagetitle = self.termname

        #pull all CA
        ko = 0
        feesText = QLabel('Select Fee')
        feesAmountText = QLabel('Amount')
        self.feesPop = QLabel('Total:')
        self.feesAmount = QLineEdit()
        self.feesAmount.setObjectName("schno")
        self.feesAmount.setPlaceholderText("000.00")
        self.feesCombo = QComboBox()
        self.arr = self.pullFees()
        self.hol = {}
        ko = 0
        if self.arr and len(self.arr) > 0:
            for val in self.arr:
                self.feesCombo.addItem(val['name'].upper())
                self.hol[ko] = val['id']
                ko += 1

        self.tree1 = QTreeWidget()
        self.tree1.setHeaderLabel("Choose Class")
        self.cla_arr = {}
        parent1 = QTreeWidgetItem(self.tree1)
        parent1.setText(0, "Select Class")
        parent1.setFlags(parent1.flags() | Qt.ItemIsTristate
                         | Qt.ItemIsUserCheckable)
        arr1 = self.pullClass()
        if arr1 and len(arr1) > 0:
            for val in arr1:
                child = QTreeWidgetItem(parent1)
                child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                child.setText(0, str(val['name']).upper())

                self.cla_arr[val['id']] = child
                if (val['active'] == 0):
                    child.setCheckState(0, Qt.Unchecked)
                else:
                    child.setCheckState(0, Qt.Unchecked)
                ko += 1

        self.tree1.itemClicked.connect(lambda x=7: self.getClass(x))

        self.hw = QFormLayout()
        self.hw.addRow(feesText, self.feesCombo)

        self.hw1 = QFormLayout()
        self.hw1.addRow(feesAmountText, self.feesAmount)

        layout1 = QGridLayout()
        layout1.addLayout(self.hw, 0, 0)
        layout1.addWidget(self.tree1, 1, 0)
        layout1.addLayout(self.hw1, 2, 0)

        layout2 = QGridLayout()
        layout2.addWidget(self.feesPop, 0, 0)

        groupBox1 = QGroupBox('Fees Settings')
        groupBox1.setLayout(layout1)

        self.pb = QPushButton()
        self.pb.setObjectName("Add")
        self.pb.setText("Add Fees")

        self.pb1 = QPushButton()
        self.pb1.setObjectName("Cancel")
        self.pb1.setText("Cancel")

        hbo = QHBoxLayout()
        hbo.addWidget(self.pb1)
        hbo.addStretch()
        hbo.addWidget(self.pb)
        groupBox2 = QGroupBox('')
        groupBox2.setLayout(hbo)

        groupBox3 = QGroupBox('')
        groupBox3.setLayout(layout2)

        grid = QGridLayout()
        grid.addWidget(groupBox1, 0, 0)
        grid.addWidget(groupBox3, 1, 0)
        grid.addWidget(groupBox2, 2, 0)

        self.setLayout(grid)
        self.connect(self.pb, SIGNAL("clicked()"), lambda: self.button_click())
        self.connect(self.pb1, SIGNAL("clicked()"),
                     lambda: self.button_close(self))

        self.setWindowTitle(self.pagetitle)
예제 #25
0
    def makeTree(self):
        self.tree.clear()
        arr = Db().selectn('session', '', 5)
        self.hold_data = {}
        self.hold_mdata = {}
        self.hold_data_add = {}
        self.hold_data_add_item = {}
        current = time.time()

        if self.titleSub and self.titleSub > 0:
            if arr and len(arr) > 0:
                for val in arr:
                    ch = Valid().pullData('terms', '',
                                          {'sessionID': val['id']})
                    child = QTreeWidgetItem(self.tree)
                    child.setIcon(0, QIcon('icons.cfolder.png'))
                    try:
                        ts = int(float(val['start_date']))
                    except:
                        ts = int(current)
                    ts = datetime.utcfromtimestamp(ts).strftime('%d-%m-%Y')

                    try:
                        ts1 = int(float(val['end_date']))
                    except:
                        ts1 = int(current)
                    ts1 = datetime.utcfromtimestamp(ts1).strftime('%d-%m-%Y')

                    child.setText(
                        0,
                        str(val['name']).upper() + " - " + ts + " " + ts1)
                    self.hold_mdata[val['id']] = child

                    for va in ch:
                        child1 = QTreeWidgetItem(child)
                        child1.setFlags(child1.flags()
                                        | Qt.ItemIsUserCheckable)

                        try:
                            ts2 = int(float(va['start_date']))
                        except:
                            ts2 = int(current)
                        ts2 = datetime.utcfromtimestamp(ts2).strftime(
                            '%d-%m-%Y')
                        try:
                            ts3 = int(float(va['end_date']))
                        except:
                            ts3 = int(current)
                        ts3 = datetime.utcfromtimestamp(ts3).strftime(
                            '%d-%m-%Y')

                        child1.setText(
                            0,
                            str(va['name']).upper() + " " + ts2 + " " + ts3)
                        self.hold_data[va['id']] = child1
                        if (va['active'] == 1):
                            child1.setCheckState(0, Qt.Checked)
                        else:
                            child1.setCheckState(0, Qt.Unchecked)

                    child1 = QTreeWidgetItem(child)
                    child1.setFlags(child1.flags() | Qt.ItemIsUserCheckable)
                    child1.setText(0, 'Add New Term')
                    self.hold_data_add_item[val['id']] = child1
        else:
            if arr and len(arr) > 0:
                for val in arr:
                    child = QTreeWidgetItem(self.tree)
                    child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                    child.setText(0, str(val['name']).upper())
                    child.setText(1, str(val['abbrv']).upper())
                    self.hold_data[val['id']] = child
                    if (val['active'] == 0):
                        child.setCheckState(0, Qt.Checked)
                    else:
                        child.setCheckState(0, Qt.Unchecked)

        child = QTreeWidgetItem(self.tree)
        child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
        child.setText(0, 'Add New Session')
        self.hold_data_add['addnew'] = child
예제 #26
0
    def __init__(self, session, students, parent=None):
        super(SubjectClassDialog, self).__init__(parent)

        ko = 0
        self.students = self.pullStudents(students)
        self.session = session[2]
        self.frame1 = QGroupBox('Set Student Subjects')

        hc1_box = QVBoxLayout()
        ses_name = str(session[1]) + ' ' + str(session[3] + ' Term')
        ses = QLabel(ses_name)

        tree = QTreeWidget()
        tree.setHeaderLabel("Students?")
        self.std_arr = {}
        parent = QTreeWidgetItem(tree)
        parent.setText(0, "Selected Students")
        parent.setFlags(parent.flags() | Qt.ItemIsTristate
                        | Qt.ItemIsUserCheckable)
        for student in self.students:
            child = QTreeWidgetItem(parent)
            child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
            child.setText(
                0,
                str(student['surname'] + ' ' + student['firstname'] + ' ' +
                    student['othername']).title())
            self.std_arr[student['id']] = child
            child.setCheckState(0, Qt.Checked)
            ko += 1

        tree1 = QTreeWidget()
        tree1.setHeaderLabel("Subjects?")
        self.sub_arr = {}
        parent1 = QTreeWidgetItem(tree1)
        parent1.setText(0, "Selected Subjects")
        parent1.setFlags(parent.flags() | Qt.ItemIsTristate
                         | Qt.ItemIsUserCheckable)
        arr = self.pullSubject()
        for v in arr:
            child = QTreeWidgetItem(parent1)
            child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
            child.setText(0, str(v['name']).upper())
            self.sub_arr[v['id']] = child
            child.setCheckState(0, Qt.Unchecked)
            ko += 1

        hc1_box.addWidget(ses)
        hc1_box.addWidget(tree)
        hc1_box.addWidget(tree1)

        self.frame1.setLayout(hc1_box)

        self.pb = QPushButton()
        self.pb.setObjectName("setsub")
        self.pb.setText("Set Subject")

        self.pb1 = QPushButton()
        self.pb1.setObjectName("remsub")
        self.pb1.setText("Remove Subject")

        self.pb2 = QPushButton()
        self.pb2.setObjectName("Cancel")
        self.pb2.setText("Cancel")

        but_box = QHBoxLayout()
        but_box.addWidget(self.pb2)
        but_box.addWidget(self.pb1)
        but_box.addWidget(self.pb)

        main_box = QVBoxLayout()
        main_box.addWidget(self.frame1)
        main_box.addLayout(but_box)

        self.setLayout(main_box)
        self.connect(self.pb, SIGNAL("clicked()"), lambda: self.button_click())
        self.connect(self.pb1, SIGNAL("clicked()"),
                     lambda: self.button_remove())
        self.connect(self.pb2, SIGNAL("clicked()"),
                     lambda: self.button_close())
        self.setWindowTitle(self.pagetitle)
예제 #27
0
 def __init__(self, parent = None):
     super(OfflinerDialog, self).__init__(parent)
     
     self.pagetitle = 'Offline Restore' 
     stylesheet = Valid().background() + Valid().font()
     fileName = QFileDialog.getOpenFileName(self, 'Save File as', '', '*.zip')
     achi_zip = zipfile.ZipFile(fileName)
     achi_zip.extractall('_temp')
     achi_zip.close()
     
     re = open('_temp/data.txt', 'r')
     arr_string = {}
     contents = re.readlines()
     for con in contents:    
         r = con.split('=')
         arr_string[r[0].strip()] = r[1]
         
     #print(arr_string)
     list_dt = arr_string['SAVED_DATE']
     damt = datetime.utcfromtimestamp(float(list_dt)).strftime('%d-%m-%Y, %H:%M:%S')
     #dt = 
     self.sessions = ast.literal_eval(arr_string['SAVED_IDS'])
     self.list_data = ast.literal_eval(arr_string['SAVED_TABLES'])
     self.hold_data = {}
     self.tree = QTreeWidget()
     self.tree.setHeaderLabel("Choose Sessions to restore")
     self.tree.headerItem().setText(0, 'Choose Sessions')
     #self.tree.setStyleSheet(treeStyleSheet)
     for t in self.sessions:
         arr = Db().selectn('session', '', 1, {'id':t})
      
         if arr and arr['id'] > 0:
                  child = QTreeWidgetItem(self.tree)
                  child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                  child.setText(0, str(arr['name']).upper())
                  self.hold_data[arr['id']] = child
                  child.setCheckState(0, Qt.Checked)
     
     self.pb = QPushButton()
     self.pb.setObjectName("Add")
     self.pb.setText("Restore")
     
     self.pb1 = QPushButton()
     self.pb1.setObjectName("Cancel")
     self.pb1.setText("Close")
     
     hbo = QHBoxLayout()
     hbo.addWidget(self.pb1)
     hbo.addStretch()
     hbo.addWidget(self.pb)
     
     groupBox2 = QGroupBox('')
     groupBox2.setLayout(hbo)
     
     self.lbl = QLabel('Saved on the '+damt)
     
     grid = QGridLayout()
     grid.addWidget(self.lbl, 0, 0)
     grid.addWidget(self.tree, 1, 0)
     grid.addWidget(groupBox2, 2, 0)
     
     self.setLayout(grid)
     self.connect(self.pb, SIGNAL("clicked()"), lambda: self.button_click())
     self.connect(self.pb1, SIGNAL("clicked()"), lambda: self.button_close(self))
     
     self.setStyleSheet(stylesheet)
     #self.setWindowIcon(QIcon(self.titleIcon))
     self.setWindowTitle(self.pagetitle)
예제 #28
0
    def _populate_repo_tree(self):
        """
        Initialize the tree widget of repos and volumes.
        """
        self._repo_treewidget.clear()

        if self._repos_info is None:
            return

        for repo_uuid, repo_info in sorted(self._repos_info.items()):
            if repo_info is None:
                continue
            repo_column_dict = collections.defaultdict(str)
            repo_column_dict["Alias"] = repo_info["Alias"]
            repo_column_dict["Details"] = "Created: " + repo_info["Created"]
            repo_column_dict["UUID"] = repo_uuid
            repo_column_values = [
                repo_column_dict[k] for k in TREEVIEW_COLUMNS
            ]
            repo_item = QTreeWidgetItem(self._repo_treewidget,
                                        QStringList(repo_column_values))
            repo_item.setData(0, Qt.UserRole, (repo_uuid, "", ""))
            for data_name, data_info in repo_info["DataInstances"].items():
                data_instance_dict = collections.defaultdict(str)
                data_instance_dict["Alias"] = data_name
                typename = data_info["Base"]["TypeName"]
                data_instance_dict["TypeName"] = typename

                is_voxels = (typename in VOXEL_TYPENAMES)
                if is_voxels:
                    start_coord = data_info["Extended"]["MinPoint"]
                    if start_coord:
                        start_coord = tuple(start_coord)
                    stop_coord = data_info["Extended"]["MaxPoint"]
                    if stop_coord:
                        stop_coord = tuple(x + 1 for x in stop_coord)
                    if start_coord and stop_coord:
                        shape = tuple(b - a
                                      for a, b in zip(start_coord, stop_coord))
                    else:
                        shape = None
                    data_instance_dict[
                        "Details"] = "Size={} | Start={} | Stop={}".format(
                            shape, start_coord, stop_coord)

                data_column_values = [
                    data_instance_dict[k] for k in TREEVIEW_COLUMNS
                ]
                data_item = QTreeWidgetItem(repo_item, data_column_values)
                data_item.setData(0, Qt.UserRole,
                                  (repo_uuid, data_name, typename))

                # If we're in specify_new mode, only the
                # repo parent items are selectable.
                # Also, non-volume items aren't selectable.
                if self._mode == 'specify_new' or typename not in self._selectable_types:
                    flags = data_item.flags()
                    flags &= ~Qt.ItemIsSelectable
                    flags &= ~Qt.ItemIsEnabled
                    data_item.setFlags(flags)

        self._repo_treewidget.collapseAll()
        self._repo_treewidget.setSortingEnabled(True)

        if self._hostname in self._default_nodes:
            self._select_node_uuid(self._default_nodes[self._hostname])

        self._repo_treewidget.resizeColumnToContents(0)
        self._repo_treewidget.setFocus()
예제 #29
0
    def __init__(self, term, row, parent=None):
        super(EditReportDialog, self).__init__(parent)

        self.term = term
        self.sid = term
        self.row = row
        terms = self.pullOnes('terms', self.term)
        datas = self.pullOnes('datas', self.row)
        session = self.pullOnes('session', terms['sessionID'])
        self.termname = str(
            session['name']) + ' ' + terms['name'] + ' Term Report'
        self.pagetitle = self.termname
        ko = 0

        #prepare data
        d = datas['description']
        d = d.split(':::')
        _title = d[0]
        _theme = d[1]
        _font = d[2]
        _ass = d[3]
        _gra = d[4]
        _set = d[5]

        _ass_list = _ass.split('::')
        _gra_list = _gra.split('::')
        _set_list = _set.split('::')

        _cla_list = _set.split('::')
        layout1 = QGridLayout()
        Form1 = QFormLayout()
        Form2 = QFormLayout()

        #title
        self.title = QLabel("Report Title")
        self.titleData = QLineEdit()
        self.titleData.setObjectName("name")
        self.titleData.setText(_title)

        tree = QTreeWidget()
        tree.setItemDelegate(Delegate())
        tree.setHeaderLabel("Which grading system will you be using?")

        tree1 = QTreeWidget()
        tree1.setHeaderLabel("Choose Assessments and classes")

        tree2 = QTreeWidget()
        tree2.setHeaderLabel("Report Card Settings")

        self.ass_arr = {}
        parent = QTreeWidgetItem(tree1)
        parent.setText(0, "Select Assessments")
        parent.setFlags(parent.flags() | Qt.ItemIsTristate
                        | Qt.ItemIsUserCheckable)
        arr = self.pullCas()
        if arr and len(arr) > 0:
            for val in arr:
                dt = self.pullOne(val['name'])
                child = QTreeWidgetItem(parent)
                child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                child.setText(0, str(dt['name']).upper())
                self.ass_arr[val['id']] = child
                if str(val['id']) in _ass_list:
                    child.setCheckState(0, Qt.Checked)
                else:
                    child.setCheckState(0, Qt.Unchecked)
                ko += 1

        self.cla_arr = {}
        parent1 = QTreeWidgetItem(tree1)
        parent1.setText(0, "Select Class")
        parent1.setFlags(parent1.flags() | Qt.ItemIsTristate
                         | Qt.ItemIsUserCheckable)
        arr = self.pullClass()
        if arr and len(arr) > 0:
            for val in arr:
                child = QTreeWidgetItem(parent1)
                child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                child.setText(0, str(val['name']).upper())
                self.cla_arr[val['id']] = child
                va = str(val['id'])
                if (va in _cla_list):
                    child.setCheckState(0, Qt.Checked)
                else:
                    child.setCheckState(0, Qt.Unchecked)
                ko += 1

        self.gra_arr = {}
        parent2 = QTreeWidgetItem(tree)
        parent2.setText(0, "Select Grade")
        arr = self.pullGrade()
        if arr and len(arr) > 0:
            for val in arr:
                child = QTreeWidgetItem(parent2)
                child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                child.setText(0, str(val['name']).upper())
                self.gra_arr[val['id']] = child
                if str(val['id']) in _gra_list:
                    child.setCheckState(0, Qt.Checked)
                else:
                    child.setCheckState(0, Qt.Unchecked)
                ko += 1

        self.set_arr = {}
        parent3 = QTreeWidgetItem(tree2)
        parent3.setText(0, "Include ...")
        parent3.setFlags(parent3.flags() | Qt.ItemIsTristate
                         | Qt.ItemIsUserCheckable)
        arr = {
            1: 'School Number',
            2: 'Class Position',
            3: 'Class Unit Position',
            4: 'Total (100%)',
            5: 'Total',
            6: 'Grading',
            7: 'Subject Average',
            8: 'Ranking',
            9: 'Ranking and Student Population',
            10: 'Student Passport',
            11: 'School Logo',
            12: 'School Address',
            13: 'Students Address',
            14: 'Attendance',
            15: 'Fees Owed',
            16: 'Test/Assesments'
        }
        if arr and len(arr) > 0:
            for val in arr:

                child = QTreeWidgetItem(parent3)
                child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                child.setText(0, str(arr[val]).upper())
                self.set_arr[val] = child

                if str(val) in _set_list:

                    child.setCheckState(0, Qt.Checked)
                else:
                    child.setCheckState(0, Qt.Unchecked)

            child1 = QTreeWidgetItem(parent3)
            child1.setFlags(child1.flags() | Qt.ItemIsUserCheckable)
            child1.setText(0, 'AFFECTIVE DOMAIN REPORT')
            self.set_arr['aff'] = child1
            if 'aff' in _set_list:
                child1.setCheckState(0, Qt.Checked)
            else:
                child1.setCheckState(0, Qt.Unchecked)

            child2 = QTreeWidgetItem(child1)
            child2.setFlags(child2.flags() | Qt.ItemIsTristate
                            | Qt.ItemIsUserCheckable)
            child2.setText(0, 'TABLE')
            self.set_arr['afftable'] = child2
            if 'afftable' in _set_list:
                child2.setCheckState(0, Qt.Checked)
            else:
                child2.setCheckState(0, Qt.Unchecked)

            child3 = QTreeWidgetItem(child1)
            child3.setFlags(child3.flags() | Qt.ItemIsUserCheckable)
            child3.setText(0, 'GRAPH')
            self.set_arr['affgraph'] = child3
            if 'affgraph' in _set_list:
                child3.setCheckState(0, Qt.Checked)
            else:
                child3.setCheckState(0, Qt.Unchecked)

            child4 = QTreeWidgetItem(parent3)
            child4.setFlags(child4.flags() | Qt.ItemIsTristate
                            | Qt.ItemIsUserCheckable)
            child4.setText(0, 'PYSCHOMOTOR DOMAIN REPORT')
            self.set_arr['psy'] = child4
            if 'psy' in _set_list:
                child4.setCheckState(0, Qt.Checked)
            else:
                child4.setCheckState(0, Qt.Unchecked)

            child5 = QTreeWidgetItem(child4)
            child5.setFlags(child5.flags() | Qt.ItemIsUserCheckable)
            child5.setText(0, 'TABLE')
            self.set_arr['psytable'] = child5
            if 'psytable' in _set_list:
                child5.setCheckState(0, Qt.Checked)
            else:
                child5.setCheckState(0, Qt.Unchecked)

            child6 = QTreeWidgetItem(child4)
            child6.setFlags(child6.flags() | Qt.ItemIsUserCheckable)
            child6.setText(0, 'GRAPH')
            self.set_arr['psygraph'] = child6
            if 'psygraph' in _set_list:
                child6.setCheckState(0, Qt.Checked)
            else:
                child6.setCheckState(0, Qt.Unchecked)

        tree.expandAll()
        tree1.expandAll()
        tree2.expandAll()
        #tree.show()

        self.l5 = QLabel("Theme Color")
        self.pbc = QPushButton()
        self.pbc.setObjectName("Pickcolor")
        self.pbc.setText("Click to change")

        self.le5 = QLineEdit()
        self.le5.setObjectName("Showcolor")
        self.le5.setText(_theme)
        self.pbc.setStyleSheet("background-color: " + _theme +
                               "; color: white")
        self.connect(self.pbc, SIGNAL("clicked()"),
                     lambda: self.color_picker())

        self.l6 = QLabel("Pick Theme Font")
        self.pbf = QPushButton()
        self.pbf.setObjectName("Pickfont")
        self.pbf.setText(_font)

        self.le6 = QLineEdit()
        self.le6.setObjectName("Showcolor")
        self.le6.setText("#000000")
        self.pbf.setStyleSheet("color: black")
        self.connect(self.pbf, SIGNAL("clicked()"), lambda: self.font_picker())

        self.lv_box = QHBoxLayout()
        self.lv_box.addWidget(self.pbc)
        self.lv_box.addWidget(self.le5)

        self.lv_box1 = QHBoxLayout()
        self.lv_box1.addWidget(self.pbf)
        self.lv_box1.addWidget(self.le6)

        Form1.addRow(self.title, self.titleData)
        Form2.addRow(self.l5, self.lv_box)
        Form2.addRow(self.l6, self.lv_box1)

        Gbo = QGridLayout()
        Gbo.addLayout(Form1, 0, 0, 1, 2)
        Gbo.addWidget(tree, 1, 0)
        Gbo.addWidget(tree1, 1, 1)
        Gbo.addWidget(tree2, 2, 0)
        Gbo.addLayout(Form2, 2, 1)

        groupBox1 = QGroupBox('Academic Report Setup')
        groupBox1.setLayout(Gbo)

        self.pb = QPushButton()
        self.pb.setObjectName("Add")
        self.pb.setText("Add Assessment")

        self.pb1 = QPushButton()
        self.pb1.setObjectName("Cancel")
        self.pb1.setText("Cancel")

        hbo = QHBoxLayout()
        hbo.addWidget(self.pb1)
        hbo.addStretch()
        hbo.addWidget(self.pb)

        groupBox2 = QGroupBox('')
        groupBox2.setLayout(hbo)

        grid = QGridLayout()
        grid.addWidget(groupBox1, 0, 0)
        grid.addWidget(groupBox2, 1, 0)

        self.setLayout(grid)
        self.connect(self.pb, SIGNAL("clicked()"),
                     lambda: self.button_click(self))
        self.connect(self.pb1, SIGNAL("clicked()"),
                     lambda: self.button_close(self))

        self.setWindowTitle(self.pagetitle)
예제 #30
0
	def load(self):
		" Loads parameter definitions and documentation from xml file "

		# First, retrieve parameter definitions from XML file
		NodeDescriptionList = []
		try:
			Parameters = xml.dom.minidom.parse(self.TreeFileName).getElementsByTagName('Parameter')
		except (ExpatError, IOError):
			print 'No xml description found in %s' % self.TreeFileName
			return
		for P in Parameters:
			Name = P.getElementsByTagName('Name')[0].childNodes[0].data
			if P.getAttribute('Scenario'):
				# this parameter is stored as belonging to a scenario
				self.ParamScenario[str(Name)] = str(P.getAttribute('Scenario'))
			Description = Value = ''
			# Retrieve parameter description
			DescriptionNodes = P.getElementsByTagName('Description')
			if DescriptionNodes != [] and DescriptionNodes[0].parentNode == P:
				InfoNodes = DescriptionNodes[0].getElementsByTagName('info')
				if InfoNodes:
					Description = InfoNodes[0].childNodes[0].data
			# Retrieve parameter value
			ValueNodes = P.getElementsByTagName('Value')
			if ValueNodes != [] and ValueNodes[0].parentNode == P:
				Value = ValueNodes[0].childNodes[0].data
			# Store parameter in NodeDescriptionList
			if P.parentNode.tagName == 'Config':
				# root parameter node
				NodeDescriptionList.append((Name, 1, [Name], Description, Value))
			else:
				Parent = P.parentNode.getElementsByTagName('Name')[0].childNodes[0].data
				NodeDescriptionList.append((Name, 2, [Parent, Name], Description, Value))

		self.NodeDescriptions = dict(map(lambda x: (x[0],x[1:-1]), NodeDescriptionList))

		# Building the tree
		for NodeDescription in NodeDescriptionList:
			NodeName = NodeDescription[0]
			NodeValue = NodeDescription[4]
			if NodeDescription[1] <= 1:
				# root node
				Node = QTreeWidgetItem(None, QStringList(QString(NodeName)))
				self.addTopLevelItem(Node)
				Node.setText(1, QString(NodeValue))
				Node.setFlags(Node.flags()|Qt.ItemIsEditable)
			else:
				ParentName = NodeDescription[2][-2]
				Parent = self.findNode(ParentName)
				if Parent is not None:
					if EvolParam.isInZ(NodeName): # compatibility with the old system
						Parent.setText(1,QString(NodeName))
					else:
						Node = QTreeWidgetItem(QStringList(QString(NodeName)))
						Parent.addChild(Node)
						Node.setText(1, QString(NodeValue))				
						Node.setFlags(Node.flags()|Qt.ItemIsEditable)
				else:
					print 'error: missing parent', ParentName, 'for', NodeDescription[0]
		
		# Checking Evolife Path
		ApplicationPathNode = self.findNode('ApplicationDir')
		self.ApplicationPath = self.NodeValue('ApplicationDir')
		if not self.ApplicationPath or not os.path.exists(self.ApplicationPath):
			# rescue attempt
			self.ApplicationPath = None
			for R in os.walk(os.path.abspath('.')[0:os.path.abspath('.').find('Evo')]):
				if os.path.exists(os.path.join(R[0],'Evolife','__init__.py')):
					self.ApplicationPath = os.path.join(R[0],'Evolife')
					break
			if ApplicationPathNode and self.ApplicationPath:
				# ApplicationPathNode.setText(1,QString(self.ApplicationPath))
				ApplicationPathNode.setText(1,QString(os.path.relpath(self.ApplicationPath)))
			else:	self.ApplicationPath = '.'
		self.ScenarioName = str(self.NodeValue('ScenarioName'))
		if self.NodeValue('RunConfigFile'):
			self.RunCfgFileName = self.NodeValue('RunConfigFile')
		if self.NodeValue('Icon'):
			self.parent.setWindowIcon(QIcon(os.path.join(self.ApplicationPath,self.NodeValue('Icon'))))
		self.highlightRelevantParameters()
예제 #31
0
 def _add_code_pep8(self):
     item = QTreeWidgetItem()
     item.setFlags(item.flags() | Qt.ItemIsEditable)
     self._listIgnoreViolations.addTopLevelItem(item)
     self._listIgnoreViolations.setCurrentItem(item)
     self._listIgnoreViolations.editItem(item, 0)
예제 #32
0
 def actionAdd(self, checked=False, prop_name='', prop_val=''):
     item = QTreeWidgetItem(self.extCfgEdit, [prop_name, prop_val])
     item.setFlags(item.flags() | Qt.ItemIsEditable)
예제 #33
0
파일: mainWindow.py 프로젝트: pgollor/pyGUI
	def __loadModules(self):
		# init variables
		loadOrder = ["hidden", "setting", "application"]

		currentDir = os.path.abspath(os.curdir)
		modulesPath = currentDir + "/" + self.__v_modulePath
		content = os.listdir(modulesPath)
		content.sort()
		modules = []
		moduleNames = []
		
		# clear gui list
		self.__p_selectModule.treeWidgetModules.reset()
		itemList = {"hidden": [], "setting": [], "application": []}

		# search for modules in module order
		index = 0
		for moduleClassType in loadOrder:
			# find modules
			for name in content:
				# only direcotries without .* and ..
				if (not os.path.isdir(modulesPath + name) or re.match("^\.", name)):
					continue
				# end if
				
				# don't load modules twice
				if (name in moduleNames):
					continue
				# end if

				m = re.match("^(\d+)(.*)$", name)
				suffix = ""
				if (m):
					suffix = m.group(1)
					name = m.group(2)
				# end if

				# change into module directory
				moduleDir = modulesPath + suffix + name
				os.chdir(moduleDir)

				# import module
				fullpath_to_py = moduleDir + "/" + name + ".py"
				if not os.path.isfile(fullpath_to_py):
					continue
				# end if
				
				modHandle = imp.load_source(name, fullpath_to_py)

				# switch back to main directory
				os.chdir(currentDir)

				# auf klasse pruefen
				if (moduleClassType + "ModuleClass" in dir(modHandle)):
					moduleNames.append(suffix+name)
					
					# search for dependencies
					dependencies = ""
					dependenciyList = list()
					if ("dependencies" in dir(modHandle)):
						dependenciyList = modHandle.dependencies
						for d in modHandle.dependencies:
							dependencies += d + ", "
						# end for
						
						dependencies = dependencies[0:len(dependencies) - 2]
					# end if
					item = QTreeWidgetItem([name, dependencies])
					item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
					
					path = modulesPath + suffix + name
					path = re.sub(r'[\\/]+', '/', path)
					module = {"name" : name, "modHandle" : modHandle, "handle" : False, "suffix" : suffix, "path" : path, "dependencies": dependenciyList}
					
					# don't load unused modules
					if (name not in self.__l_usedModules):
						item.setCheckState(0, Qt.Unchecked)
						module["modHandle"] = False
						delete(modHandle)
					else:
						item.setCheckState(0, Qt.Checked)
					# end fi
					
					modules.append(module)

					itemList[moduleClassType].append(item)

					continue
				else:
					delete(modHandle)
				# end if
			# end for
			
			# add items to tree widget
			item = self.__p_selectModule.treeWidgetModules.topLevelItem(index)
			item.addChildren(itemList[moduleClassType])
			
			index += 1
		# end for - search for modules in module order
		
		# init modules
		for module in modules:
			if (module["modHandle"] == False):
				continue
			# end if
			#module["handle"] = module["modHandle"].module(None, module["name"])
			module["handle"] = module["modHandle"].module(self, module["name"])
			
			#self.__p_logger.debug("load module " + module["name"])
		# end for - init modules


		# set static functions
		abstractModuleClass.d_modules = dict()
		abstractModuleClass.p_progressBar = self.progressBarGlobal
		abstractModuleClass.p_progressBarThread = self.__p_progressBarThread


		# open modules and load GUI
		firstDockWidget = None
		for module in modules:
			moduleName = module['name']
			moduleHand = module['handle']
			
			try:
				# Wichtig: Damit auch bei nicht geladenen Modulen die dependencies ueberprueft werden koennen.
				abstractModuleClass.d_modules[moduleName] = module
				
				# if module not used
				if (module["modHandle"] == False):
					continue
				# end if
				
				moduleDir = modulesPath + module["suffix"] + moduleName
	
				# find *.py files in the specific modules directory
				os.chdir(moduleDir)
				content = os.listdir(moduleDir)
				includes = dict()
				for filename in content:
					if (os.path.isfile(moduleDir + "/" + filename)):
						if (re.match(".*\.py$", filename) and not (moduleName + ".py") == filename ):
							name = filename[0:-3]
							includes[name] = imp.load_source(name, moduleDir + "/" + filename)
						# end if
					# end if
				# end for
				os.chdir(currentDir)

				# set module settings
				moduleHand.setModulePath(self.__v_modulePath + module["suffix"] + moduleName, os.path.abspath(os.curdir))
				moduleHand.setIncludes(includes)
	
				# check for module type
				moduleClassType = moduleHand.getClassType()

				# module type specific init
				if (moduleClassType != 'hidden'):
					# load [moduleName].ui
					self.__p_logger.setLevel(logging.WARN)
					uic.loadUi(moduleDir + "/" +moduleName + ".ui", moduleHand)
					self.__p_logger.setLevel(abstractModuleClass.loglevel)

					# load module settings
					moduleHand.initPreSettings()
					moduleHand.handleSettings()
					moduleHand.loadSettings()
				# end if

				# join in specific modules folder for initModule
				os.chdir(moduleDir)
				moduleHand.initModule()
				os.chdir(currentDir)
	
				# add module widget to GUI
				if (moduleClassType != 'hidden'):
					iconPath = False
					icon = None
					
					# get icon path
					iconPath = moduleHand.getIconPath()
					
					# try to load icon
					if (iconPath != False):
						icon = QIcon(iconPath)
					# end if
					
					displayName = moduleHand.getDisplayName()
					
					# init menu button
					button = moduleHand.getMenuButton()
					button.setText(displayName)
					
					# dock widget for current module
					# ... create
					dockWidget = mainWindowDockWidget(displayName, self)
					
					# ... set object name and title
					dockWidget.setObjectName(displayName)
					dockWidget.setWindowTitle(displayName)
					
					# ... add module as widget
					dockWidget.setWidget(moduleHand)
					
					# ... add dock widget to main window
					self.addDockWidget(Qt.LeftDockWidgetArea, dockWidget)
					
					# ... hide dock widget
					dockWidget.setVisible(False)
					
					# tabify all dock widgets
					if (firstDockWidget == None):
						firstDockWidget = dockWidget
					else:
						self.tabifyDockWidget(firstDockWidget, dockWidget)
					# end if
					
					# ... Set window icon.
					dockWidget.setWindowIcon(moduleHand.getMenuButton().icon())
					
					# ... Connect signal for checking and unchecking menu button on visibility change.
					#     If module is tabbed then set active module as current module.
					dockWidget.visibilityChanged[bool].connect(partial(self.__onModuleVisibilityChanged, dockWidget))


					# add button for application module and action for setting module					
					if (moduleClassType == 'application'):
						# get menu button
						button = moduleHand.getMenuButton()
						
						# set icon for menu button
						if (icon != None):
							button.setIcon(icon)
						# end if
						
						# add menu button to tool bar
						self.toolBar.addWidget(button)
						
						# connect signal from application menu button
						button.clicked[QObject].connect(self.__onModuleButtonClicked)
					else:
						# get action
						action = dockWidget.toggleViewAction()
						
						# set icon
						if (icon != None):
							action.setIcon(icon)
						# end if
						
						# add action to settings menu
						self.menuModuleSettings.addAction(action)
					# end if
				else:
					moduleHand.setParent(None)
				# end if
			except Exception as e:
				msg = "Error in module " + moduleName
				self.__p_logger.critical(msg)
				print(msg)
				raise e
			# end try
		# end for


		# init gui
		for module in modules:
			if (module["modHandle"] == False):
				continue
			# end if
			
			self.__v_moduleCounter += 1
			
			moduleDir = modulesPath + module["suffix"] + module["name"]
			moduleClassType = module["handle"].getClassType()
			
			if (moduleClassType != "hidden"):
				os.chdir(moduleDir)

				try:
					module["handle"].initGUI()
				except Exception as e:
					msg = "Fehler in Module " + module["name"]
					self.__p_logger.critical(msg)
					print(msg)
					raise e
				# end try

				os.chdir(currentDir)
			# end if
		# end for
		
		usedModules = self.__l_usedModules.copy()
		# remove not known used modules
		for moduleName in usedModules:
			if (moduleName not in abstractModuleClass.d_modules):
				self.__l_usedModules.remove(moduleName)
				
				continue
예제 #34
0
 def _load_command_values(self, command, values_widget):
     for field, value in zip(command.fields, command.values):
         item = QTreeWidgetItem([field.name, str(value)])
         if field.name != Field.EMPTY_FIELD:
             item.setFlags(item.flags() | Qt.ItemIsEditable)
         values_widget.addTopLevelItem(item)
예제 #35
0
 def actionAdd(self, checked=False, prop_name='', prop_val=''):
     item = QTreeWidgetItem(self.extCfgEdit, [prop_name, prop_val])
     item.setFlags(item.flags()|Qt.ItemIsEditable)
예제 #36
0
    def __init__(self, term, parent=None):
        super(SubjectCaDialog, self).__init__(parent)
        self.setMinimumHeight(280)
        ko = 0
        self.subjects = self.pullSubjects()
        self.term = term
        self.cas = self.pullCas(self.term)
        g = Db()
        hc1_box = QVBoxLayout()
        self.subject_hold = {}
        self.ca_hold = {}
        self.tree1 = QTreeWidget()
        self.tree1.setMinimumHeight(280)
        self.tree1.setHeaderLabel("Select Subject and CA to Display")
        self.hold_checkbox = []
        parent1 = QTreeWidgetItem(self.tree1)
        parent1.setText(0, "Select")
        parent1.setFlags(parent1.flags() | Qt.ItemIsTristate
                         | Qt.ItemIsUserCheckable)
        for subject in self.subjects:
            num = subject['id']
            child = QTreeWidgetItem(parent1)
            child.setFlags(child.flags() | Qt.ItemIsTristate
                           | Qt.ItemIsUserCheckable)
            child.setText(0, str(subject['name']).upper())
            child.setCheckState(0, Qt.Checked)
            for ca in self.cas:
                dt = g.selectn('datas', '', 1, {'id': ca['name']})
                child2 = QTreeWidgetItem(child)
                child2.setFlags(child2.flags() | Qt.ItemIsTristate
                                | Qt.ItemIsUserCheckable)
                child2.setText(0, str(dt['name']).upper())
                child2.setCheckState(0, Qt.Checked)
                self.hold_checkbox.append(child2)
                self.subject_hold[child2] = num
                self.ca_hold[child2] = ca['id']
                ko += 1

            hc1_box.addWidget(self.tree1)

            ko += 1

        self.pb = QPushButton()
        self.pb.setObjectName("MakeEntries")
        self.pb.setText("Edit View")

        self.pb1 = QPushButton()
        self.pb1.setObjectName("View Report")
        self.pb1.setText("Report View")

        self.pb2 = QPushButton()
        self.pb2.setObjectName("Cancel")
        self.pb2.setText("Cancel")

        but_box = QHBoxLayout()
        but_box.addWidget(self.pb2)
        but_box.addWidget(self.pb1)
        but_box.addWidget(self.pb)

        main_box = QVBoxLayout()
        main_box.addLayout(hc1_box)
        main_box.addLayout(but_box)

        self.setLayout(main_box)
        self.connect(self.pb, SIGNAL("clicked()"),
                     lambda: self.button_click(0))
        self.connect(self.pb1, SIGNAL("clicked()"),
                     lambda: self.button_click(1))
        self.connect(self.pb2, SIGNAL("clicked()"),
                     lambda: self.button_close())
        self.setWindowTitle(self.pagetitle)
    def __init__(self, student, term, parent=None):
        super(FormClassSubject, self).__init__(parent)
        self.student = student
        self.term = term

        self.db_class = 'student_class' + str(self.term)
        self.db_subject = 'student_subject' + str(self.term)

        student = self.pullData('students', 1, {'id': self.student})
        term = self.pullData('terms', 1, {'id': self.term})
        session = self.pullData('session', 1, {'id': term['sessionID']})
        subjects = self.pullData('datas', '', {'pubID': 3})
        student_class = self.pullData(self.db_class, 1,
                                      {'studentID': self.student})
        student_subject = self.pullData(self.db_subject, '',
                                        {'studentID': self.student})

        subjects_arr = self.convert_arr(student_subject)
        self.session = str(
            str(session['name']) + " " + str(term['name'] + " Term")).title()
        self.fullname = str(
            str(student['surname']) + " " + str(student['firstname'])).title()

        fullnameLbl = QLabel(self.fullname)
        fullnameLbl.setFont(QFont("Candara", 14, QFont.Bold))
        termLbl = QLabel(self.session)
        termLbl.setFont(QFont("Candara", 12, QFont.Bold))
        classLbl = QLabel('Select Class')
        self.classCombo = QComboBox()
        pullClass = self.pullData('datas', '', {'pubID': 1})
        self.class_arr = {}
        ko = 0
        for r in pullClass:
            pullClassUnit = self.pullData('datas', '', {'subID': r['id']})
            for f in pullClassUnit:
                self.classCombo.addItem(
                    str(r['abbrv']).upper() + " " + str(f['abbrv']).upper())
                self.class_arr[ko] = f['id']
                ko += 1

        tree = QTreeWidget()
        tree.setHeaderLabel("Select Subjects")
        self.sub_arr = {}
        parent = QTreeWidgetItem(tree)
        parent.setText(0, "Subjects")
        parent.setFlags(parent.flags() | Qt.ItemIsTristate
                        | Qt.ItemIsUserCheckable)
        if subjects and len(subjects) > 0:
            for val in subjects:
                child = QTreeWidgetItem(parent)
                child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                child.setText(0, str(val['name']).upper())
                self.sub_arr[val['id']] = child
                if int(val['id']) in subjects_arr:
                    child.setCheckState(0, Qt.Checked)
                else:
                    child.setCheckState(0, Qt.Unchecked)
                ko += 1

        tree1 = QTreeWidget()
        tree1.setHeaderLabel("Remove Subjects")
        self.sub1_arr = {}
        parent1 = QTreeWidgetItem(tree1)
        parent1.setText(0, "Subjects")
        parent1.setFlags(parent1.flags() | Qt.ItemIsTristate
                         | Qt.ItemIsUserCheckable)

        if student_subject and len(student_subject) > 0:
            for val in student_subject:
                st_nam = self.pullData('datas', 1, {'id': val['subjectID']})
                child = QTreeWidgetItem(parent1)
                child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                child.setText(0, str(st_nam['name']).upper())
                self.sub1_arr[st_nam['id']] = child
                child.setCheckState(0, Qt.Checked)
                ko += 1

        h_box = QHBoxLayout()
        h_box.addWidget(classLbl)
        h_box.addWidget(self.classCombo)

        self.pb = QPushButton()
        self.pb.setObjectName("close")
        self.pb.setText("Close")

        self.pb1 = QPushButton()
        self.pb1.setObjectName("Submit")
        self.pb1.setText("Submit")

        self.connect(self.pb1, SIGNAL("clicked()"),
                     lambda: self.button_click())
        self.connect(self.pb, SIGNAL("clicked()"), lambda: self.button_close())

        h_box1 = QHBoxLayout()
        h_box1.addWidget(self.pb)
        h_box1.addWidget(self.pb1)

        self.v_box = QVBoxLayout()
        self.v_box.addWidget(fullnameLbl)
        self.v_box.addWidget(termLbl)
        self.v_box.addLayout(h_box)
        self.v_box.addWidget(tree)
        self.v_box.addWidget(tree1)
        self.v_box.addLayout(h_box1)

        if student_class and student_class['classID'] > 0:
            stID = self.class_arr.keys()[self.class_arr.values().index(
                student_class['classID'])]
            self.classCombo.setCurrentIndex(stID)

        self.setLayout(self.v_box)
        self.setWindowTitle("Class")
 def _add_code_pep8(self):
     item = QTreeWidgetItem()
     item.setFlags(item.flags() | Qt.ItemIsEditable)
     self._listIgnoreViolations.addTopLevelItem(item)
     self._listIgnoreViolations.setCurrentItem(item)
     self._listIgnoreViolations.editItem(item, 0)
예제 #39
0
    def __init__(self, session, students, parent=None):
        super(ChangeClassDialog, self).__init__(parent)

        ko = 0
        self.students = self.pullStudents(students)
        self.session = session[2]
        self.claszs = self.pullClass(1)

        self.d_displayData = QComboBox()
        for k in self.claszs:
            act = str(self.claszs[k]) + ' '
            for k in self.claszs:
                arr = self.pullClass(k)
                for dd in arr:
                    self.d_displayData.addItem(str(act + arr[dd]).upper(), dd)

        self.frame1 = QGroupBox('Students')
        self.frame2 = QGroupBox('New Class')

        hc1_box = QVBoxLayout()

        tree = QTreeWidget()
        tree.setHeaderLabel("Students?")
        self.std_arr = {}
        parent = QTreeWidgetItem(tree)
        parent.setText(0, "Selected Students")
        parent.setFlags(parent.flags() | Qt.ItemIsTristate
                        | Qt.ItemIsUserCheckable)
        for student in self.students:
            child = QTreeWidgetItem(parent)
            child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
            child.setText(
                0,
                str(student['surname'] + ' ' + student['firstname'] + ' ' +
                    student['othername']).title())
            self.std_arr[student['id']] = child
            child.setCheckState(0, Qt.Checked)
            ko += 1

        hc1_box.addWidget(tree)

        self.li1 = []
        self.li1ID = []

        exp = QLabel('Select Class')
        ses_name = str(session[1]) + ' ' + str(session[3])
        ses = QLabel(ses_name)

        v_box = QHBoxLayout()
        v_box.addWidget(exp)
        v_box.addStretch()
        v_box.addWidget(self.d_displayData)

        hv_box = QVBoxLayout()
        hv_box.addWidget(ses)
        hv_box.addStretch()
        hv_box.addLayout(v_box)

        self.frame1.setLayout(hc1_box)
        #frame1.setFrameShape(QFrame.StyledPanel)
        self.frame2.setLayout(hv_box)
        #frame2.setFrameShape(QFrame.StyledPanel)

        h_box = QVBoxLayout()
        h_box.addWidget(self.frame2)
        h_box.addWidget(self.frame1)

        self.pb = QPushButton()
        self.pb.setObjectName("setclass")
        self.pb.setText("Set Class")

        self.pb1 = QPushButton()
        self.pb1.setObjectName("remclass")
        self.pb1.setText("Remove from Class")

        self.pb2 = QPushButton()
        self.pb2.setObjectName("Cancel")
        self.pb2.setText("Cancel")

        but_box = QHBoxLayout()
        but_box.addWidget(self.pb2)
        but_box.addWidget(self.pb1)
        but_box.addWidget(self.pb)

        main_box = QVBoxLayout()
        main_box.addLayout(h_box)
        main_box.addLayout(but_box)

        self.setLayout(main_box)
        self.connect(self.pb, SIGNAL("clicked()"), lambda: self.button_click())
        self.connect(self.pb1, SIGNAL("clicked()"),
                     lambda: self.button_remove())
        self.connect(self.pb2, SIGNAL("clicked()"),
                     lambda: self.button_close())
        self.setWindowTitle(self.pagetitle)
예제 #40
0
    def __init__(self, term, parent=None):
        super(FeeDialog, self).__init__(parent)
        
        self.term = term
        self.sid = term
        terms = self.pullOnes('terms', self.term)
        session = self.pullOnes('session', terms['sessionID'])
        self.termname = str(session['name'])+' '+terms['name']+' Term Report'
        self.pagetitle = self.termname 
        ko = 0
        
        
        Form1 = QFormLayout()
        Form2 = QFormLayout()
        
        #title
        self.title = QLabel("Set Fees")
        self.titleData = QComboBox()
        self.titleData.setObjectName("name")
        #self.titleData.setPlaceHolderText("e.g. 2019 FIRST TERM RESULT")
        
        tree = QTreeWidget()
        tree.setItemDelegate(Delegate())
        tree.setHeaderLabel("Which grading system will you be using?")
        
        tree1 = QTreeWidget()
        tree1.setHeaderLabel("Choose Assessments and Classes")
        
        tree2 = QTreeWidget()
        tree2.setHeaderLabel("Report Card Settings")
        
        self.ass_arr = {}
        parent = QTreeWidgetItem(tree1)
        parent.setText(0, "Select Assessments")
        parent.setFlags(parent.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable)
        arr = self.pullCas()
        if arr and len(arr) > 0:
            for val in arr:
                dt = self.pullOne(val['name'])
                child = QTreeWidgetItem(parent)
                child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                child.setText(0, str(dt['name']).upper())
                self.ass_arr[val['name']] = child
                if (val['active'] == 0):
                    child.setCheckState(0, Qt.Unchecked)
                else:
                    child.setCheckState(0, Qt.Unchecked)
                ko += 1
        
        self.cla_arr ={}
        parent1 = QTreeWidgetItem(tree1)
        parent1.setText(0, "Select Class")
        parent1.setFlags(parent1.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable)
        arr = self.pullClass()
        if arr and len(arr) > 0:
            for val in arr:
                child = QTreeWidgetItem(parent1)
                child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                child.setText(0, str(val['name']).upper())
                self.cla_arr[val['id']] = child
                if (val['active'] == 0):
                    child.setCheckState(0, Qt.Unchecked)
                else:
                    child.setCheckState(0, Qt.Unchecked)
                ko += 1

        self.gra_arr = {}
        parent2 = QTreeWidgetItem(tree)
        parent2.setText(0, "Select Grade")
        arr = self.pullGrade()
        if arr and len(arr) > 0:
            for val in arr:
                child = QTreeWidgetItem(parent2)
                child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                child.setText(0, str(val['name']).upper())
                self.gra_arr[val['id']] = child
                if (val['active'] == 0):
                    child.setCheckState(0, Qt.Unchecked)
                else:
                    child.setCheckState(0, Qt.Unchecked)
                ko += 1
                
        self.set_arr= {}
        parent3 = QTreeWidgetItem(tree2)
        parent3.setText(0, "Include ...")
        parent3.setFlags(parent3.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable)
        arr ={
                1:'School Number',
                2:'Class Position',
                3:'Class Unit Position',
                4:'Total (100%)',
                5:'Total',
                6:'Grading',
                7:'Subject Average',
                8:'Ranking',
                9:'Ranking and Student Population',
                10:'Student Passport',
                11:'School Logo',
                12:'School Address',
                13:'Students Address',
                14:'Attendance',
                15:'Fees Owed',
                16:'Test/Assesments'
            }
        if arr and len(arr) > 0:
            for val in arr:
                child = QTreeWidgetItem(parent3)
                child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                child.setText(0, str(arr[val]).upper())
                self.set_arr[val] = child
                child.setCheckState(0, Qt.Unchecked)
            
            child1 = QTreeWidgetItem(parent3)
            child1.setFlags(child1.flags() | Qt.ItemIsUserCheckable)
            child1.setText(0, 'AFFECTIVE DOMAIN REPORT')
            self.set_arr['aff'] = child1
            child1.setCheckState(0, Qt.Unchecked)
            
            child2 = QTreeWidgetItem(child1)
            child2.setFlags(child2.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable)
            child2.setText(0, 'TABLE')
            self.set_arr['afftable'] = child2
            child2.setCheckState(0, Qt.Unchecked)
            
            child3 = QTreeWidgetItem(child1)
            child3.setFlags(child3.flags() | Qt.ItemIsUserCheckable)
            child3.setText(0, 'GRAPH')
            self.set_arr['affgraph'] = child3
            child3.setCheckState(0, Qt.Unchecked)
            
            child4 = QTreeWidgetItem(parent3)
            child4.setFlags(child4.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable)
            child4.setText(0, 'PYSCHOMOTOR DOMAIN REPORT')
            self.set_arr['psy'] = child4
            child4.setCheckState(0, Qt.Unchecked)
            
            child5 = QTreeWidgetItem(child4)
            child5.setFlags(child5.flags() | Qt.ItemIsUserCheckable)
            child5.setText(0, 'TABLE')
            self.set_arr['psytable'] = child5
            child5.setCheckState(0, Qt.Unchecked)
            
            child6 = QTreeWidgetItem(child4)
            child6.setFlags(child6.flags() | Qt.ItemIsUserCheckable)
            child6.setText(0, 'GRAPH')
            self.set_arr['psygraph'] = child6
            child6.setCheckState(0, Qt.Unchecked)

        tree.expandAll()
        tree1.expandAll()
        tree2.expandAll()
        #tree.show()
     
        self.l5 = QLabel("Theme Color")
        self.pbc = QPushButton()
        self.pbc.setObjectName("Pickcolor")
        self.pbc.setText("Click to change")
        
        self.le5 = QLineEdit()
        self.le5.setObjectName("Showcolor")
        self.le5.setText("#000000")
        self.pbc.setStyleSheet("background-color: black; color: white")
        self.connect(self.pbc, SIGNAL("clicked()"), lambda: self.color_picker())
        
        self.l6 = QLabel("Pick Theme Font")
        self.pbf = QPushButton()
        self.pbf.setObjectName("Pickfont")
        self.pbf.setText("Click to Change")
        
        self.le6 = QLineEdit()
        self.le6.setObjectName("Showcolor")
        self.le6.setText("#000000")
        self.pbf.setStyleSheet("background-color: black; color: white")
        self.connect(self.pbf, SIGNAL("clicked()"), lambda: self.font_picker())
        
        self.lv_box = QHBoxLayout()
        self.lv_box.addWidget(self.pbc)
        self.lv_box.addWidget(self.le5)
        
        self.lv_box1 = QHBoxLayout()
        self.lv_box1.addWidget(self.pbf)
        self.lv_box1.addWidget(self.le6)
        
        Form1.addRow(self.title, self.titleData)
        Form2.addRow(self.l5, self.lv_box)
        Form2.addRow(self.l6, self.lv_box1)
        
        Gbo = QGridLayout()
        Gbo.addLayout(Form1, 0, 0, 1, 2)
        Gbo.addWidget(tree, 1, 0)
        Gbo.addWidget(tree1, 1, 1)
        Gbo.addWidget(tree2, 2, 0)
        Gbo.addLayout(Form2, 2, 1)
        
        groupBox1 = QGroupBox('Academic Report Setup')
        groupBox1.setLayout(Gbo)
        
        self.pb = QPushButton()
        self.pb.setObjectName("Add")
        self.pb.setText("Save")
        
        
        self.pb1 = QPushButton()
        self.pb1.setObjectName("Cancel")
        self.pb1.setText("Cancel")
        
        self.pb2 = QPushButton()
        self.pb2.setObjectName("Save")
        self.pb2.setText("Save and Keep Template")
        
        self.lTemplate = QLineEdit() 
        self.lTemplate.setPlaceholderText('Template Name')
        
        self.rTemplate = QLabel() 
        self.rTemplate.setText('')
        
        hbo = QHBoxLayout()
        hbo.addWidget(self.pb1)
        hbo.addStretch()
        hbo.addWidget(self.lTemplate)
        hbo.addWidget(self.pb2)
        hbo.addWidget(self.rTemplate)
        hbo.addStretch()
        hbo.addWidget(self.pb)
        
        groupBox2 = QGroupBox('')
        groupBox2.setLayout(hbo)
            
        grid = QGridLayout()
        grid.addWidget(groupBox1, 0, 0)
        grid.addWidget(groupBox2, 1, 0)
        
        self.setLayout(grid)
        self.connect(self.pb, SIGNAL("clicked()"), lambda: self.button_click(self))
        self.connect(self.pb2, SIGNAL("clicked()"), lambda: self.button_template(self))
        self.connect(self.pb1, SIGNAL("clicked()"), lambda: self.button_close(self))
       
        self.setWindowTitle(self.pagetitle)
예제 #41
0
 def on_tx_packets_add_field_clicked(self):
     item = QTreeWidgetItem([Field.EMPTY_FIELD, "uint8"])
     item.setFlags(item.flags() | Qt.ItemIsEditable)
     self.tx_packets_fields.addTopLevelItem(item)