예제 #1
0
    def open_file(self):
        """
        This function is tied to a "Open File" Button and what it
        does is open the xml file the user chooses and parses it.
        It then enables some other buttons,loads information to
        text fields add information from the xml file to comboboxes
        and basically allows the user to see what matters and what
        he might want to change or delete in this XML file that
        will ultimately be used as a mod in the game 'Software Inc
        '"""

        try:
            with open(self.file_name) as f:
                parser = etree.XMLParser(remove_blank_text=True)
                self.tree = etree.parse(f, parser)
            self.features = self.tree.find('Features')
            list_of_things_to_enable = [
                self.addFeatureBttn, self.funcName, self.confirmButton,
                self.CATEGORIESCHECKBOX
            ]
            self.enable_multiple_objects(list_of_things_to_enable, True)
            self.populate_software_type_fields()
            self.add_features_to_combobox()
            self.add_categories_to_combobox()

            self.statusBar().showMessage('File Opened', 1500)
        except:
            if self.file_name == '':
                pass
            else:
                em.showUnexpectedError(self)
예제 #2
0
    def save(self, tree):
        """ This function saves the file to current directory."""
        try:
            with open(self.file_name, 'wb+') as f:
                tree.write(f, pretty_print=True)
            self.statusBar().showMessage('Saved', 1500)

        except:
            if self.file_name == '':
                em.showSaveError(self)
            else:
                em.showUnexpectedError(self)
예제 #3
0
    def delete_dependency(self, number_Of_Dependencies, dependency_name):
        """ This function deletes a dependency from dependencies and
			from the dependency combobox."""
        try:
            index = self.get_dependency_index(dependency_name)
            self.dependencies.remove(self.dependencies[index])
            combobox_index = self.dependencyComboBox.currentIndex()
            self.dependencyComboBox.removeItem(combobox_index)
        except:
            if self.dependencyComboBox.count() == 0:
                self.statusBar().showMessage('There are no dependencies to delete', 1500)
            else:
                em.showUnexpectedError(self)