def build_ui(self): """ Build and modify this widget's GUI Returns ------- None """ self.ui = UI_descript.Ui_fgdc_descript() self.ui.setupUi(self) self.setObjectName('fgdc_descript') self.abstract = Abstract() self.ui.verticalLayout.addWidget(self.abstract)
class Descript(WizardWidget): drag_label = "Abstract <abstract>" acceptable_tags = ['abstract'] def build_ui(self): """ Build and modify this widget's GUI Returns ------- None """ self.ui = UI_descript.Ui_fgdc_descript() self.ui.setupUi(self) self.setObjectName('fgdc_descript') self.abstract = Abstract() self.ui.verticalLayout.addWidget(self.abstract) def _to_xml(self): """ encapsulates the QPlainTextEdit text in an element tag Returns ------- abstract element tag in xml tree """ return self.abstract._to_xml() def _from_xml(self, abstract): """ parses the xml code into the relevant abstract elements Parameters ---------- access_constraints - the xml element status and its contents Returns ------- None """ self.abstract._from_xml(abstract)
def build_ui(self): self.ui = self.ui_class() self.ui.setupUi(self) self.setup_dragdrop(self) self.ptcontac = ContactInfoPointOfContact(parent=self) self.taxonomy = Taxonomy(parent=self) self.keywords = Keywords(parent=self) self.accconst = AccessConstraints(parent=self) self.useconst = UseConstraints(parent=self) self.status = Status(parent=self) self.timeperd = Timeperd(parent=self) self.citation = Citation(parent=self) self.datacredit = DataCredit(parent=self) self.abstract = Abstract(parent=self) self.purpose = Purpose(parent=self) self.supplinf = SupplInf(parent=self) self.ui.fgdc_citation.layout().addWidget(self.citation) #bottom to top in layout time_hbox = QHBoxLayout() time_hbox.addWidget(self.status) time_hbox.addWidget(self.timeperd) self.ui.two_column_left.layout().insertLayout(0, time_hbox) self.ui.two_column_left.layout().insertWidget(0, self.datacredit) self.ui.two_column_left.layout().insertWidget(0, self.taxonomy) self.ui.two_column_left.layout().insertWidget(0, self.ptcontac) self.ui.two_column_left.layout().insertWidget(0, self.useconst) self.ui.two_column_left.layout().insertWidget(0, self.accconst) self.ui.two_column_right.layout().insertWidget(0, self.supplinf) self.ui.two_column_right.layout().insertWidget(0, self.keywords) self.ui.two_column_right.layout().insertWidget(0, self.purpose) self.ui.two_column_right.layout().insertWidget(0, self.abstract)
class IdInfo(WizardWidget): drag_label = "Identification Information <idinfo>" # This dictionary provides a mechanism for crosswalking between # gui elements (pyqt widgets) and the xml document xpath_lookup = {'cntper': 'cntinfo/cntperp/cntper', 'cntorg': 'cntinfo/cntperp/cntorg', 'cntpos': 'cntinfo/cntpos',} ui_class = UI_IdInfo.Ui_fgdc_idinfo def __init__(self, root_widget=None): super(self.__class__, self).__init__() self.schema = 'bdp' self.root_widget = root_widget def build_ui(self): self.ui = self.ui_class() self.ui.setupUi(self) self.setup_dragdrop(self) self.ptcontac = ContactInfoPointOfContact(parent=self) self.taxonomy = Taxonomy(parent=self) self.keywords = Keywords(parent=self) self.accconst = AccessConstraints(parent=self) self.useconst = UseConstraints(parent=self) self.status = Status(parent=self) self.timeperd = Timeperd(parent=self) self.citation = Citation(parent=self) self.datacredit = DataCredit(parent=self) self.abstract = Abstract(parent=self) self.purpose = Purpose(parent=self) self.supplinf = SupplInf(parent=self) self.ui.fgdc_citation.layout().addWidget(self.citation) #bottom to top in layout time_hbox = QHBoxLayout() time_hbox.addWidget(self.status) time_hbox.addWidget(self.timeperd) self.ui.two_column_left.layout().insertLayout(0, time_hbox) self.ui.two_column_left.layout().insertWidget(0, self.datacredit) self.ui.two_column_left.layout().insertWidget(0, self.taxonomy) self.ui.two_column_left.layout().insertWidget(0, self.ptcontac) self.ui.two_column_left.layout().insertWidget(0, self.useconst) self.ui.two_column_left.layout().insertWidget(0, self.accconst) self.ui.two_column_right.layout().insertWidget(0, self.supplinf) self.ui.two_column_right.layout().insertWidget(0, self.keywords) self.ui.two_column_right.layout().insertWidget(0, self.purpose) self.ui.two_column_right.layout().insertWidget(0, self.abstract) def dragEnterEvent(self, e): """ Parameters ---------- e : qt event Returns ------- """ print("idinfo drag enter") mime_data = e.mimeData() if e.mimeData().hasFormat('text/plain'): parser = etree.XMLParser(ns_clean=True, recover=True, encoding='utf-8') element = etree.fromstring(mime_data.text(), parser=parser) if element.tag == 'idinfo': e.accept() else: e.ignore() def children(self): return super(IdInfo, self).children() + [self.root_widget.spatial_tab.spdom] def switch_schema(self, schema): self.schema = schema if schema == 'bdp': self.taxonomy.show() else: self.taxonomy.hide() self.citation.switch_schema(self.schema) def _to_xml(self): # add code here to translate the form into xml representation idinfo_node = xml_utils.xml_node('idinfo') citation_node = xml_utils.xml_node('citation', parent_node=idinfo_node) citeinfo_node = self.citation._to_xml() citation_node.append(citeinfo_node) idinfo_node.append(citation_node) descript_node = xml_utils.xml_node('descript', parent_node=idinfo_node) abstract_node = self.abstract._to_xml() descript_node.append(abstract_node) purpose_node = self.purpose._to_xml() descript_node.append(purpose_node) supplinf_node = self.supplinf._to_xml() if supplinf_node.text is not None: descript_node.append(supplinf_node) idinfo_node.append(descript_node) timeperd_node = self.timeperd._to_xml() idinfo_node.append(timeperd_node) status_node = self.status._to_xml() idinfo_node.append(status_node) spdom_node = self.root_widget.spatial_tab.spdom._to_xml() idinfo_node.append(spdom_node) keywords = self.keywords._to_xml() idinfo_node.append(keywords) if self.schema == 'bdp' and self.taxonomy.has_content(): taxonomy = self.taxonomy._to_xml() idinfo_node.append(taxonomy) accconst_node = self.accconst._to_xml() idinfo_node.append(accconst_node) useconst_node = self.useconst._to_xml() idinfo_node.append(useconst_node) datacredit_node = self.datacredit._to_xml() if len(datacredit_node.text): idinfo_node.append(datacredit_node) if self.ptcontac.has_content(): ptcontac = self.ptcontac._to_xml() idinfo_node.append(ptcontac) datacredit_node = self.datacredit._to_xml() if datacredit_node.text: idinfo_node.append(datacredit_node) return idinfo_node def _from_xml(self, xml_idinfo): try: citation = xml_idinfo.xpath('citation')[0] self.citation._from_xml(citation) except IndexError: pass try: abstract = xml_idinfo.xpath('descript/abstract')[0] self.abstract._from_xml(abstract) except IndexError: pass try: purpose = xml_idinfo.xpath('descript/purpose')[0] self.purpose._from_xml(purpose) except IndexError: pass try: supplinf = xml_idinfo.xpath('descript/supplinf')[0] self.supplinf._from_xml(supplinf) except IndexError: pass try: timeperd = xml_idinfo.xpath('timeperd')[0] self.timeperd._from_xml(timeperd) except IndexError: pass try: status = xml_idinfo.xpath('status')[0] self.status._from_xml(status) except IndexError: pass try: spdom = xml_idinfo.xpath('spdom')[0] self.root_widget.spatial_tab.spdom._from_xml(spdom) except IndexError: pass try: keywords = xml_idinfo.xpath('keywords')[0] self.keywords._from_xml(keywords) except IndexError: pass try: taxonomy = xml_idinfo.xpath('taxonomy')[0] self.taxonomy._from_xml(taxonomy) except IndexError: pass try: accconst = xml_idinfo.xpath('accconst')[0] self.accconst._from_xml(accconst) except IndexError: pass try: useconst = xml_idinfo.xpath('useconst')[0] self.useconst._from_xml(useconst) except IndexError: pass try: ptcontac = xml_idinfo.xpath('ptcontac')[0] self.ptcontac._from_xml(ptcontac) except IndexError: pass