def ask(self): while True: cords = input("Shoot!!!: ").split() if len(cords) != 2: raise WrongValueException() x, y = cords if not (x.isdigit()) or not (y.isdigit()): raise WrongValueException() return Dot(int(x), int(y))
def _getValue(self, textbox, mandatory): textbox.setStyleSheet("QLineEdit{background: white}") value = textbox.text().strip() if value == "" and mandatory: textbox.setStyleSheet("QLineEdit{background: yellow}") raise WrongValueException() return value
def clusterDistance(self): try: if self.clusterItem.checkState(0) == Qt.Checked: dist = self.clusterDistanceItem.text(1) else: return 0 except: return 0 try: f = float(dist) return f except: raise WrongValueException()
def value(self): self.setBackgroundColor(0, Qt.white) self.setBackgroundColor(1, Qt.white) try: if isinstance(self._value, bool): return self.checkState(1) == Qt.Checked elif isinstance(self._value, (int, long)): return long(self.text(1)) elif isinstance(self._value, float): return float(self.text(1)) elif isinstance(self._value, tuple): return self.combo.currentText() elif ("\n" in unicode(self._value) or unicode(self._value).upper().startswith("EPSG:")): return self.newValue else: return self.text(1) except: self.setBackgroundColor(0, Qt.yellow) self.setBackgroundColor(1, Qt.yellow) raise WrongValueException()
raise e def getSettings(self): try: title = self._getValue(self.titleBox, True) except WrongValueException, e: self.tabPanel.setCurrentIndex(0) for b in self.themesButtons: if b.isChecked(): themeName = self.themesButtons[b] break logo = self.logoBox.text().strip() if logo and not os.path.exists(logo): self.tabPanel.setCurrentIndex(0) self.logoBox.setStyleSheet("QLineEdit{background: yellow}") raise WrongValueException() self.logoBox.setStyleSheet("QLineEdit{background: white}") parameters = {"Title": title, "Logo": logo, "Theme": themeName} try: for param, item in self.settingsItems.iteritems(): parameters[param] = item.value() except WrongValueException, e: self.tabPanel.setCurrentIndex(5) return parameters def getLayersAndGroups(self): layers = [] groups = {} for i in xrange(self.layersTree.topLevelItemCount()): item = self.layersTree.topLevelItem(i)