Exemplo n.º 1
0
class SettingsWindow(QWidget):
    def __init__(self, mainGui):
        """
        Argument parent powinien być typu MainGui
        """
        super(SettingsWindow, self).__init__(None)
        self.ui = Ui_PeanotesSettings()
        self.ui.setupUi(self)
        self.mainGui = mainGui
        self.setWindowIcon(pea_app().tray_icon)

        self.filters = self.loadData()

        self.ui.filtersList.addItems([k for k in self.filters.keys()])

        self.iter = 1

        self.ui.addButton.clicked.connect(self.addFilter)
        self.ui.removeButton.clicked.connect(self.removeFilter)

        self.ui.saveButton.clicked.connect(self.updateFilter)

        self.ui.colorBox.addItems(STYLES.keys())

        self.ui.filtersList.currentItemChanged.connect(self.handleItemChanged)

    def loadData(self):
        data = collections.OrderedDict()
        try:
            with open(CLIENT_USERDATA_PATH, "rb") as file_:
                data = pickle.load(file_)
            print "DEBUG: loading %s" % data
        except IOError:
            pass
        return data is None and collections.OrderedDict() or data

    def persistData(self, data):
        try:
            with open(CLIENT_USERDATA_PATH, "wb") as file_:
                pickle.dump(data, file_)
            print "DEBUG: persist %s" % data
        except IOError, e:
            print e
Exemplo n.º 2
0
    def __init__(self, mainGui):
        """
        Argument parent powinien być typu MainGui
        """
        super(SettingsWindow, self).__init__(None)
        self.ui = Ui_PeanotesSettings()
        self.ui.setupUi(self)
        self.mainGui = mainGui
        self.setWindowIcon(pea_app().tray_icon)

        self.filters = self.loadData()

        self.ui.filtersList.addItems([k for k in self.filters.keys()])

        self.iter = 1

        self.ui.addButton.clicked.connect(self.addFilter)
        self.ui.removeButton.clicked.connect(self.removeFilter)

        self.ui.saveButton.clicked.connect(self.updateFilter)

        self.ui.colorBox.addItems(STYLES.keys())

        self.ui.filtersList.currentItemChanged.connect(self.handleItemChanged)