def setupUi(self, MainWindow): self.actionWizard = QAction(self) icon = QIcon() icon.addPixmap(QPixmap(QString.fromUtf8(":/wizard")), QIcon.Normal, QIcon.Off) self.actionWizard.setIcon(icon) self.actionWizard.setObjectName(QString.fromUtf8("actionWizard")) Ui_MainWindow.setupUi(self, MainWindow) self.menuFile.insertAction(self.actionOpen_evidence, self.actionWizard) self.retranslateUi(MainWindow) if REPORT_EDITOR: self.actionReport = QAction(self) icon = QIcon() icon.addPixmap(QPixmap(QString.fromUtf8(":report")), QIcon.Normal, QIcon.Off) self.actionReport.setIcon(icon) self.actionReport.setObjectName(QString.fromUtf8("actionReport")) self.menuReport = QMenu(self.menubar) self.menuReport.setObjectName(QString.fromUtf8("menuReport")) self.menuReport.addAction(self.actionReport) self.actionReport.setText( QApplication.translate("MainWindow", "Report", None, QApplication.UnicodeUTF8)) self.actionReport.setToolTip( QApplication.translate("MainWindow", "Open the report editor", None, QApplication.UnicodeUTF8)) try: self.menuReport.setTitle( QApplication.translate("MainWindow", "Report", None, QApplication.UnicodeUTF8)) except AttributeError: pass
def __init__(self, text, parent = None): super(ReportWindow, self).__init__(parent, layoutCls = QGridLayout) self.setWindowTitle("Fehler!") self.infoLabel = QLabel(self) self.infoLabel.setText("Ein Fehler ist aufegtretten. Bitte senden Sie den unteren Text an <a href=\"mailto:[email protected]\">[email protected]</a>!") self.infoLabel.setTextFormat(Qt.RichText) self.infoLabel.setTextInteractionFlags(Qt.TextBrowserInteraction) self.infoLabel.setOpenExternalLinks(True) self.text = text self.textArea = QTextEdit(self) self.textArea.setPlainText(text) self.textArea.setReadOnly(True) self.okBtn = QPushButton(QString.fromUtf8("Meldung schließen"), self) self.okBtn.clicked.connect(self.close) self.copyBtn = QPushButton(QString.fromUtf8("Text kopieren"), self) self.copyBtn.clicked.connect(self.copy) self.myLayout.addWidget(self.infoLabel, 0,0,1,2) self.myLayout.addWidget(self.textArea, 1,0,1,2) self.myLayout.addWidget(self.copyBtn, 2,0,1,1) self.myLayout.addWidget(self.okBtn, 2,1,1,1)
def setItemText(self, item, vval): if vval == None: item.setText(1, str("None")) elif vval.type() == typeId.DateTime: dateTime = vval.value() if dateTime: item.setText(1, str(dateTime)) elif vval.type() in [ typeId.Int16, typeId.UInt16, typeId.Int32, typeId.UInt32, typeId.Int64, typeId.UInt64 ]: item.setText(1, vval.toString() + " - " + vval.toHexString()) elif vval.type() in [typeId.Char, typeId.String, typeId.CArray]: val = vval.toString() item.setText(1, QString.fromUtf8(val)) elif vval.type() == typeId.Node: label = QLabel('<a href="' + QString.fromUtf8(vval.value().path()) + '" style="color: blue">' + QString.fromUtf8(vval.value().absolute()) + ' </a>') label.connect(label, SIGNAL("linkActivated(QString)"), self.gotolink) self.setItemWidget(item, 1, label) elif vval.type() == typeId.Path: item.setText(1, QString.fromUtf8(vval.value().path)) else: item.setText(1, str(vval.value()))
def fillBase(self, node): fsobj = node.fsobj() fsobjname = "" if fsobj != None: fsobjname = fsobj.name itemName = QTreeWidgetItem(self) itemName.setText(0, self.nameText) itemName.setText(1, QString.fromUtf8(node.name())) if isinstance(node, VLink): linkPath = QTreeWidgetItem(self) linkPath.setText(0, self.linkPath) label = QLabel('<a href="' + QString.fromUtf8(node.linkPath()) + '" style="color: blue">' + QString.fromUtf8(node.linkAbsolute()) + ' </a>') label.connect(label, SIGNAL("linkActivated(QString)"), self.gotolink) self.setItemWidget(linkPath, 1, label) itemName = QTreeWidgetItem(self) itemName.setText(0, self.nodeTypeText) typestr = "" if node.isFile(): typestr += self.fileText if node.hasChildren(): typestr += self.modAppliedText self.fillCompatModule(node) if node.hasChildren(): self.fillChildren(node) if node.isDir(): typestr += self.folderText if not node.hasChildren(): typestr += self.emptyText if node.isDeleted(): typestr += self.deletedText itemName.setText(1, typestr) itemModule = QTreeWidgetItem(self) itemModule.setText(0, self.generateText) itemModule.setText(1, str(fsobjname)) itemSize = QTreeWidgetItem(self) itemSize.setText(0, self.sizeText) itemSize.setText(1, str(node.size())) tags = node.tags() if len(tags): itemTags = QTreeWidgetItem(self) itemTags.setText(0, "tags") tags = node.tags() for tag in tags: itemTag = QTreeWidgetItem(itemTags) color = tag.color() itemTag.setBackground( 0, QBrush(QColor(color.r, color.g, color.b))) itemTag.setForeground(0, QBrush(QColor(255, 255, 255))) itemTag.setText(0, QString.fromUtf8(tag.name())) self.expandItem(itemTags)
def browse(self): title = "Load " + str(self.ckey) if not self.nodetype: if self.inputcombo and self.inputcombo.currentIndex() == 0: if isinstance(self.container, QListWidget): sFileName = QFileDialog.getOpenFileNames(self.parent, title, addLocalPathButton.lastPath) if len(sFileName) > 0: self.setLastPath(sFileName[0]) for name in sFileName: item = QListWidgetItem(name, self.container) elif isinstance(self.container, QLineEdit): sFileName = QFileDialog.getOpenFileName(self.parent, title, addLocalPathButton.lastPath) self.setLastPath(sFileName) self.container.clear() self.container.insert(sFileName) elif isinstance(self.container, QComboBox): sFileName = QFileDialog.getOpenFileName(self.parent, title, addLocalPathButton.lastPath) self.setLastPath(sFileName) self.container.insertItem(0, sFileName) self.container.setCurrentIndex(0) else: return -1 else: sFileName = QFileDialog.getExistingDirectory(self.parent, title, addLocalPathButton.lastPath, QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks) self.setLastPath(sFileName) if isinstance(self.container, QListWidget): if sFileName: item = QListWidgetItem(sFileName, self.container) elif isinstance(self.container, QComboBox): self.container.insertItem(0, sFileName) self.container.setCurrentIndex(0) else: self.container.insert(sFileName) self.manager.emit(SIGNAL("managerChanged")) else: BrowseVFSDialog = DialogNodeBrowser(self) if isinstance(self.container, QListWidget) or isinstance(self.container, QComboBox): iReturn = BrowseVFSDialog.exec_() if iReturn : nodes = BrowseVFSDialog.getSelectedNodes() index = 0 if len(nodes): for node in nodes: self.container.insertItem(index, QString.fromUtf8(node.absolute())) index += 1 if isinstance(self.container, QListWidget): self.container.setCurrentItem(self.container.item(0)) else: self.container.setCurrentIndex(0) else: iReturn = BrowseVFSDialog.exec_() if iReturn : node = BrowseVFSDialog.getSelectedNode() print node if node: self.container.clear() self.container.insert(QString.fromUtf8(node.absolute())) BrowseVFSDialog.browser.__del__()
def data(self, role): if role == Qt.DisplayRole: if self.nodesCount : return QString.fromUtf8(self.__tag.name() + ' (' + str(self.nodesCount) + ')') else: return QString.fromUtf8(self.__tag.name()) elif role == Qt.BackgroundRole: color = self.__tag.color() return QColor(color.r, color.g, color.b) return QListWidgetItem.data(self, role)
def setLink(self, node, width=-1): if node is None: return if isinstance(node, VLink): self.__node = node.linkNode() else: self.__node = node elided_text = QFontMetrics(self.font()).elidedText(QString.fromUtf8(self.__node.absolute()), Qt.ElideLeft, self.width()) self.setText('<a href="' + QString.fromUtf8(self.__node.path()) + '" style="color: blue">'+ elided_text +' </a>') self.setToolTip(QString.fromUtf8(self.__node.absolute()))
def addSingleNode(self, key, predefs, selectednodes, editable=False, config=None): if config: predefs.push_front(config[0]) if not self.overwriteKeys(key) and type(key).__name__ == 'str': vbox = QVBoxLayout() layout = QHBoxLayout() nodecontainer = NodeComboItem(self) self.connect(nodecontainer, SIGNAL("editTextChanged(QString)"), self.argumentChanged) self.connect(nodecontainer, SIGNAL("currentIndexChanged(QString)"), self.argumentChanged) nodecontainer.setEditable(editable) if len(predefs) > 0: if config: for value in predefs: node = value.value() name = QString.fromUtf8(node.absolute()) nodecontainer.addSingleItem(name, node.uid()) else: category = self.tr("Predefined parameters") nodecontainer.addParentItem(category) for value in predefs: node = value.value() name = QString.fromUtf8(node.absolute()) nodecontainer.addChildItem(name, node.uid()) if len(selectednodes) == 1: node = selectednodes[0] name = QString.fromUtf8(node.absolute()) nodecontainer.addSingleItem(name, node.uid()) elif len(selectednodes) > 0: category = self.tr("Selected nodes") nodecontainer.addParentItem(category) for node in selectednodes: name = QString.fromUtf8(node.absolute()) nodecontainer.addChildItem(name, node.uid()) browse = NodeSelectionButton(self, key, nodecontainer) layout.addWidget(nodecontainer, 2) layout.addWidget(browse, 0) vbox.addLayout(layout) if not self.displaykey: self.layout.addRow(vbox) else: self.layout.addRow(key, vbox) self.widgets[key] = nodecontainer return 1 else: return -1
def populateList(self): dicts = self.manager.dictionnaries() currow = 0 for _dict in dicts.iterkeys(): self.dicos.setRowCount(currow + 1) item = QTableWidgetItem(QString.fromUtf8(dicts[_dict].fileName())) item.setFlags(Qt.ItemIsUserCheckable|Qt.ItemIsEnabled|Qt.ItemIsSelectable) item.setCheckState(Qt.Unchecked) self.dicos.setItem(currow, 0, item) name = QTableWidgetItem(QString.fromUtf8(_dict)) name.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable) self.dicos.setItem(currow, 1, name) currow += 1
def start_cap(self): global SCREEN_CAP if SCREEN_CAP == False: self.ui.getCapBtn.setText(QString.fromUtf8("停止截图")) #self.connect(self.cap_thread, SIGNAL("save_capture()"), self.save_capture) self.cap_thread.start() logging.info('start capturing screen') SCREEN_CAP = True else: self.ui.getCapBtn.setText(QString.fromUtf8("开始截图")) self.cap_thread.terminate() logging.info('stop capturing screen') SCREEN_CAP = False
def imageClassify(gui, image, classPath, savePath, minArea): r, c, d = np.shape(image) #odczyt z pliku; criteria: r g b h s v veg ent num_lines = sum(1 for line in open(classPath)) if num_lines < 3: QMessageBox.warning(gui, QString.fromUtf8('Błąd'), QString.fromUtf8('Za mało danych w pliku klas!'), 'Ok') return 0 cls = np.loadtxt(classPath, delimiter=' ', dtype=str, skiprows=1) criteria = open(classPath).readline().rstrip() criteria = criteria.split() param = cls[:, 1:len(criteria) + 1].astype(float) imMaxMin = np.zeros((2, len(criteria))) for i in range(len(criteria)): imMaxMin[0, i] = np.amin(cls[:, len(criteria) + 1 + i * 2].astype(float)) imMaxMin[1, i] = np.amax(cls[:, len(criteria) + 2 + i * 2].astype(float)) param[:, i] = standarize(param[:, i], imMaxMin[0, i], imMaxMin[1, i]) names = list(set(cls[:, 0])) n, x = np.shape(cls) m = len(names) nrcls = np.zeros(n) for i in range(n): for j in range(m): if cls[i, 0] == names[j]: nrcls[i] = j break #dzielenie zdj i klasyfikacja clsImage = np.zeros((r, c)) for i in range(0, r, 1000): for j in range(0, c, 1000): nr = i + 1010 nc = j + 1010 if nr > r: nr = r if nc > c: nc = c imCrop = image[i:nr, j:nc, :] clsImage[i:nr, j:nc] = minDistClassify(imCrop, nrcls, param, criteria, imMaxMin) for i in range(0, m): clsImage2 = np.zeros((r, c)) clsImage2[clsImage == i] = 1 print np.sum(clsImage2), names[i] saveRaster(clsImage, savePath, names, minArea)
def createItem(self, current_path, module, key): p = current_path[:] p.append(unicode(key.name)) item = regItem(QString.fromUtf8(key.name), proc=module,path=p) item.setChildren(len(key.subkeys)) item.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled) return item
def setSnapshotTabWindow(self, eventNames, eventTs, eventIds): tabWidget = None isNew = True for i in range(len(eventIds)): if self.tabWindowDict.has_key(eventIds[i]): tabWidget = self.tabWindowDict[eventIds[i]] else: tabWidget = QTableWidget() self.tabWindowDict[eventIds[i]] = tabWidget QObject.connect(tabWidget, SIGNAL(_fromUtf8("cellDoubleClicked (int,int)")), self.__showArrayData) data = self.retrieveMasarData(eventid=eventIds[i]) if data: if isNew: for j in range(self.snapshotTabWidget.count(), 0, -1): self.snapshotTabWidget.removeTab(j) self.pv4cDict.clear() self.data4eid.clear() self.arrayData.clear() isNew = False tabWidget.clear() self.setSnapshotTable(data, tabWidget, eventIds[i]) tabWidget.resizeColumnsToContents() ts = eventTs[i].split('.')[0] label = QString.fromUtf8((eventNames[i]+': ' + ts)) self.snapshotTabWidget.addTab(tabWidget, label) self.snapshotTabWidget.setTabText(i+1, label) self.pv4cDict[str(eventIds[i])] = data['PV Name'] self.data4eid[str(eventIds[i])] = data self.snapshotTabWidget.setCurrentIndex(1)
def listToString(l): """ Translates an Erlang string (a list of character codes) to a QString. """ if not isinstance(l, list): raise TypeError(str(l) + " is not a list.") return QString.fromUtf8(''.join([chr(c) for c in l]))
def __init__(self): global loggedHours global pickedDateTime QtGui.QWidget.__init__(self); pickedDateTime = datetime.now(pytz.utc) pickedDateTime = pickedDateTime.replace(hour=8); grid = QtGui.QGridLayout(); self.setLayout(grid); self.calendar = QtGui.QCalendarWidget(self); self.calendar.setFirstDayOfWeek(1); self.calendar.setGridVisible(1); self.calendar.clicked.connect(self.pickedDate); self.textBox = QtGui.QTextBrowser(self); if pickedDateTime.date() in loggedHours: for loggedItem in loggedHours[pickedDateTime.date()]: self.textBox.append(QString.fromUtf8(loggedItem[0][0]) + ' ------>' + QString.fromUtf8(loggedItem[1][0])); self.buttonBox = QtGui.QDialogButtonBox(self); self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok|QtGui.QDialogButtonBox.Cancel) self.buttonBox.accepted.connect(self.logIssue); self.buttonBox.rejected.connect(self.close); grid.addWidget(self.calendar); grid.addWidget(self.textBox, 0, 1); grid.setColumnMinimumWidth(1, 300); grid.addWidget(self.buttonBox);
def updateWeather(self): ''' This function is called by a QTimer with 5 min. interval, Updates the weather-icon and the temperature ''' location_ID = global_vars.configuration.get("GENERAL").get( "weather_locationid") try: if location_ID is None: raise ValueError("Weather location not set." ) #return if no location ID can be loaded... temp_condition = weather.get_weather_from_weather_com(location_ID) self.lbl_weather_icon.setPicturePath( os.path.join(self.cwd, "res/weather/icon", temp_condition['current_conditions']['icon'], "static")) self.lbl_temperature.setText( temp_condition['current_conditions']['temperature'] + QString.fromUtf8("°C")) self.lbl_weather_icon.setVisible(True) self.lbl_temperature.setVisible(True) except Exception as e: # this is dangerous, because the weather API is sametimes a little bit instable logger.exception("Could not get weather for location %s", location_ID) self.lbl_weather_icon.setVisible(False) self.lbl_temperature.setVisible(False)
def value(self, value): if isinstance(self.field, (list, dict)) \ and type(self.field) != type(value): raise ValueError('Field.value: type of a value ' 'should be the same as the type of the field.') if self.option.is_poly and self.field is None: self.field = [] if isinstance(self.field, list): while len(self.field) < len(value): self._add_instance() while len(self.field) > len(value): self._del_instance() if not self.field and self.value_required: self._add_instance() else: for instance, inst_value in zip(self.field, value): for name, subvalue in inst_value.items(): instance[name].value = subvalue elif isinstance(self.field, dict): for name, subvalue in value.items(): self.field[name].value = subvalue elif isinstance(self.field, QWidget): if isinstance(self.field, PolyLineEdit): self.field.setText(value) elif isinstance(self.field, QLineEdit): self.field.setText(QString.fromUtf8(value)) elif isinstance(self.field, QDoubleSpinBox) \ or isinstance(self.field, QSpinBox): self.field.setValue(value) elif isinstance(self.field, QCheckBox): self.field.setChecked(value)
def __init__(self, parent=None): QDialog.__init__(self, parent) self.setupUi(self) logoPixmap = QtGui.QPixmap(QString.fromUtf8('images/confirm.png')) logoScaledPixmap = logoPixmap.scaled(self.lblImage.size(), QtCore.Qt.KeepAspectRatio) self.lblImage.setPixmap(logoScaledPixmap)
def createItem(self, current_path, module, key): p = current_path[:] p.append(unicode(key.name)) item = regItem(QString.fromUtf8(key.name), proc=module, path=p) item.setChildren(len(key.subkeys)) item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) return item
def fillBase(self, node): fsobj = node.fsobj() fsobjname = "" if fsobj != None: fsobjname = fsobj.name itemName = QTreeWidgetItem(self) itemName.setText(0, self.nameText) itemName.setText(1, QString.fromUtf8(node.name())) itemName = QTreeWidgetItem(self) itemName.setText(0, self.nodeTypeText) typestr = "" if node.isFile(): typestr += self.fileText if node.hasChildren(): typestr += self.modAppliedText self.fillCompatModule(node) if node.hasChildren(): self.fillChildren(node) if node.isDir(): typestr += self.folderText if not node.hasChildren(): typestr += self.emptyText if node.isDeleted(): typestr += self.deletedText itemName.setText(1, typestr) itemModule = QTreeWidgetItem(self) itemModule.setText(0, self.generateText) itemModule.setText(1, str(fsobjname)) itemSize = QTreeWidgetItem(self) itemSize.setText(0, self.sizeText) itemSize.setText(1, str(node.size()))
def __init__(self): global issues QtGui.QWidget.__init__(self); grid = QtGui.QGridLayout(); self.combo = QtGui.QComboBox(); for issue in issues: self.combo.addItem(QString.fromUtf8(issue.fields.summary)); self.combo.currentIndexChanged.connect(self.setPicked) self.pickedIssue = issues[0] self.buttonBox = QtGui.QDialogButtonBox(self); self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok|QtGui.QDialogButtonBox.Cancel) self.buttonBox.accepted.connect(self.logWorkOnJira); self.buttonBox.rejected.connect(self.close); self.textBox = QtGui.QTextEdit(); self.textBox.setText(QString('7')); grid.addWidget(self.combo); grid.addWidget(self.textBox, 0, 1); grid.addWidget(self.buttonBox); self.setLayout(grid);
def addNodeList(self, key, predefs, selectednodes): if not self.overwriteKeys(key) and type(key).__name__ == 'str': layout = QVBoxLayout() nodeList = NodeListItem() nodeList.setDragDropMode(QAbstractItemView.InternalMove) if len(predefs) > 0: if not self.checkUnifiedTypes(predefs): return -1 for predef in predefs: nodeList.addSingleItem(str(predef), predef.value().uid()) if selectednodes and len(selectednodes) > 0: for node in selectednodes: name = QString.fromUtf8(node.absolute()) nodeList.addSingleItem(name, node.uid()) hbox = QHBoxLayout() buttonbox = QDialogButtonBox() add = NodeSelectionButton(self, key, nodeList) buttonbox.addButton(add, QDialogButtonBox.ActionRole) rm = rmLocalPathButton(self, nodeList) buttonbox.addButton(rm, QDialogButtonBox.ActionRole) self.connect(add, SIGNAL("clicked()"), self.argumentChanged) self.connect(rm, SIGNAL("clicked()"), self.argumentChanged) hbox.addWidget(buttonbox, 3, Qt.AlignLeft) layout.addLayout(hbox, 0) layout.addWidget(nodeList, 2) if not self.displaykey: self.layout.addRow(layout) else: self.layout.addRow(key, layout) self.widgets[key] = nodeList return 1 else: return -1
def addDockWidgets(self, widget, internalName, master=True): if widget is None: return if self.last_state is not None: self.maximizeDockwidget() if widget.windowTitle() != "": wname = widget.windowTitle() else: wname = widget.name new_master = self.getMasterDockWidget() if new_master != None: self.master = new_master dockwidget = self.createDockWidget(widget, wname) docIndex, docTitle = self.getWidgetName(wname) dockwidget.setWindowTitle(QString.fromUtf8(docTitle)) self.connect(dockwidget, SIGNAL("resizeEvent"), widget.resize) self.addDockWidget(self.masterArea, dockwidget) if master: self.tabifyDockWidget(self.master, dockwidget) else: self.tabifyDockWidget(self.second, dockwidget) if docIndex: self.dockWidget[internalName + str(docIndex)] = dockwidget else: self.dockWidget[internalName] = dockwidget self.refreshTabifiedDockWidgets()
def __init__(self, parent, root): QTreeWidgetItem.__init__(self, parent) self.moduleApplyed = {} self.root = root self.processCount = 0 self.processedCount = 0 self.processusItem = None self.setText(0, QString.fromUtf8(self.root.absolute()))
def openFolder(self): newFolder = str(QFileDialog.getExistingDirectory(parent=self, caption=QString.fromUtf8("Ordner auswählen"), directory = self.currentFolder)) if not newFolder: print "HIER: ", newFolder return self._openTextField.setText(newFolder) self.listFolderFiles(newFolder) self.currentFolder = newFolder
def aboutinfo(self): about = QtGui.QMessageBox.information( self, 'About', QString.fromUtf8("\tV201612\t\n" "\t增加截图功能\t\n" "\tMade by Luke\t\n" "\tGood Luck!!!\t"))
def setupUi(self, nodeActions): self.actionScan = QAction(self) icon = QIcon() icon.addPixmap(QPixmap(QString.fromUtf8(":/scan")), QIcon.Normal, QIcon.On) self.actionScan.setIcon(icon) self.actionScan.setObjectName(QString.fromUtf8("actionScan")) self.actionReport_node = QAction(self) icon = QIcon() icon.addPixmap(QPixmap(QString.fromUtf8(":/report")), QIcon.Normal, QIcon.On) self.actionReport_node.setIcon(icon) self.actionReport_node.setObjectName( QString.fromUtf8("actionReport_Node")) Ui_nodeActions.setupUi(self, nodeActions)
def __init__(self, parent = None, *args): super(ViewTab, self).__init__(parent, *args) self._lineEdit = QLineEdit(self) self._acceptBtn = QPushButton(QString.fromUtf8("Öffnen"), self) self._acceptBtn.clicked.connect(self.click) self.myLayout.addRow("Name der Datenbank:", self._lineEdit) self.myLayout.addRow(self._acceptBtn)
def setItemText(self, item, vval): if vval == None: item.setText(1, str("None")) elif vval.type() == typeId.VTime: vtime = vval.value() if vtime: item.setText(1, str(vtime.get_time())) elif vval.type() in [typeId.Int16, typeId.UInt16, typeId.Int32, typeId.UInt32, typeId.Int64, typeId.UInt64]: item.setText(1, vval.toString() + " - " + vval.toHexString()) elif vval.type() in [typeId.Char, typeId.String, typeId.CArray]: val = vval.toString() item.setText(1, QString.fromUtf8(val)) elif vval.type() == typeId.Node: item.setText(1, QString.fromUtf8(vval.value().absolute())) elif vval.type() == typeId.Path: item.setText(1, QString.fromUtf8(vval.value().path)) else: item.setText(1, str(vval.value()))
def getWindowRegion(self): logging.info('Finding bid window...') global BID_REGION while True: #region = pyautogui.locateOnScreen(self.imPath('top.png')) region = pyautogui.locateOnScreen(r'resource\title.png') if region is not None: BID_REGION = (region[0], region[1], 380, 436) logging.info('BID window region found: %s' % (BID_REGION, )) self.ui.winStatLabel.setText(QString.fromUtf8("已找到窗口")) break #self.ui.winStatLabel.setText("searching....") sys.stdout.write(".") sys.stdout.flush() time.sleep(1) self.ui.winStatLabel.setText(QString.fromUtf8("搜索中..."))
def __init__(self, parent, page): QTreeWidgetItem.__init__(self, parent) self.__page = page self.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsSelectable | Qt.ItemIsEnabled) self.setText(0, QString.fromUtf8(self.__page.title())) if self.__page.selected(): self.setCheckState(0, Qt.Checked) else: self.setCheckState(0, Qt.Unchecked)
def load_ui(cls, ui_file, widget): npaths = len(cls._ui_path) for i, path in enumerate(cls._ui_path): try: filepath = os.path.join(path, ui_file) uic.loadUi(QString.fromUtf8(filepath), widget) break except (OSError, IOError): if i == npaths-1: raise OSError('Error: unable to locate %s.' % ui_file)
def load_ui(cls, ui_file, widget): npaths = len(cls._ui_path) for i, path in enumerate(cls._ui_path): try: filepath = os.path.join(path, ui_file) uic.loadUi(QString.fromUtf8(filepath), widget) break except (OSError, IOError): if i == npaths - 1: raise OSError('Error: unable to locate %s.' % ui_file)
def _init(self): self._init_role_list() # Ugly Hack : our window manager is not graying out the button when an app closes itself down and the appropriate # callback (_set_stop_app_button) is fired. It does otherwise though so it looks like the window manager # is getting confused when the original program doesn't have the focus. # # Taking control of it ourselves works... self._widget_app_list.stop_app_btn.setStyleSheet(QString.fromUtf8("QPushButton:disabled { color: gray }")) self._widget_role_list.show() self.initialised = True
def __init__(self, args, parent = None): QObject.__init__(self, parent) # variable declarations self.m_loadStatus = self.m_state = QString() self.m_var = self.m_paperSize = self.m_loadScript_cache = {} self.m_verbose = args.verbose self.m_page = WebPage(self) self.m_clipRect = QRect() # setup the values from args self.m_script = QString.fromUtf8(args.script.read()) self.m_scriptFile = args.script.name self.m_args = args.script_args self.m_upload_file = args.upload_file autoLoadImages = False if args.load_images == 'no' else True pluginsEnabled = True if args.load_plugins == 'yes' else False args.script.close() palette = self.m_page.palette() palette.setBrush(QPalette.Base, Qt.transparent) self.m_page.setPalette(palette) if not args.proxy: QNetworkProxyFactory.setUseSystemConfiguration(True) else: proxy = QNetworkProxy(QNetworkProxy.HttpProxy, args.proxy[0], int(args.proxy[1])) QNetworkProxy.setApplicationProxy(proxy) self.m_page.settings().setAttribute(QWebSettings.AutoLoadImages, autoLoadImages) self.m_page.settings().setAttribute(QWebSettings.PluginsEnabled, pluginsEnabled) self.m_page.settings().setAttribute(QWebSettings.FrameFlatteningEnabled, True) self.m_page.settings().setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True) self.m_page.settings().setAttribute(QWebSettings.LocalStorageEnabled, True) self.m_page.settings().setLocalStoragePath(QDesktopServices.storageLocation(QDesktopServices.DataLocation)) self.m_page.settings().setOfflineStoragePath(QDesktopServices.storageLocation(QDesktopServices.DataLocation)) # Ensure we have a document.body. self.m_page.mainFrame().setHtml('<html><body></body></html>') self.m_page.mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff) self.m_page.mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff) # if our script was called in a different directory, change to it # to make any dealings with files be relative to the scripts directory if os.path.dirname(self.m_scriptFile): os.chdir(os.path.dirname(self.m_scriptFile)) if self.m_verbose: m_netAccessMan = NetworkAccessManager(args.disk_cache, self) self.m_page.setNetworkAccessManager(m_netAccessMan) # inject our properties and slots into javascript self.connect(self.m_page.mainFrame(), SIGNAL('javaScriptWindowObjectCleared()'), self.inject) self.connect(self.m_page, SIGNAL('loadFinished(bool)'), self.finish)
def __init__(self): QCompleter.__init__(self) self.vfs = vfs() self.__model = CompleterModel() self.currentNode = self.vfs.getnode("/") self.currentPath = self.currentNode self.setCompletionPrefix(QString.fromUtf8(self.currentNode.absolute())) self.__model.setRootPath(self.currentNode) self.__model.setCurrentPath("/") self.setModel(self.__model) QObject.connect(self, SIGNAL("activated(const QString &)"), self.updatePath)
def addNode(self): self.container = NodeComboItem() self.container.setReadOnly(False) for value in self.predefs: if self.typeid == typeId.Node: node = value.value() name = QString.fromUtf8(node.absolute()) self.container.addSingleItem(name, node.uid()) browse = NodeSelectionButton(self, key, self.container) self.headerlayout.addWidget(self.container, 2) self.headerlayout.addWidget(browse, 0)
def setItemText(self, item, vval): if vval == None: item.setText(1, str("None")) elif vval.type() == typeId.VTime: vtime = vval.value() if vtime: item.setText(1, str(vtime.get_time())) elif vval.type() in [typeId.Int16, typeId.UInt16, typeId.Int32, typeId.UInt32, typeId.Int64, typeId.UInt64]: item.setText(1, vval.toString() + " - " + vval.toHexString()) elif vval.type() in [typeId.Char, typeId.String, typeId.CArray]: val = vval.toString() item.setText(1, QString.fromUtf8(val)) elif vval.type() == typeId.Node: label = QLabel('<a href="' + QString.fromUtf8(vval.value().path()) + '" style="color: blue">'+ QString.fromUtf8(vval.value().absolute()) + ' </a>') label.connect(label, SIGNAL("linkActivated(QString)"), self.gotolink) self.setItemWidget(item, 1, label) elif vval.type() == typeId.Path: item.setText(1, QString.fromUtf8(vval.value().path)) else: item.setText(1, str(vval.value()))
def selectDico(self): dialog = DicoDialog(self) r = dialog.exec_() if r > 0: self.dicos = dialog.manager.selectedDicoNames() if self.dicos != None: label = str() for dico in self.dicos: label += dico self.dicoPath.clear() self.dicoPath.insert(QString.fromUtf8(label))
def __init__(self, parent = None): QObject.__init__(self, parent) self.m_webPage = QWebPage(self) converter = QFile(':/resources/coffee-script.js') converter.open(QFile.ReadOnly) script = QString.fromUtf8(converter.readAll()) converter.close() self.m_webPage.mainFrame().evaluateJavaScript(script) self.m_webPage.mainFrame().addToJavaScriptWindowObject('converter', self)
def pickedDate(self, qdate): global loggedHours global pickedDateTime pyDate = qdate.toPyDate(); pickedDateTime = datetime.combine(pyDate, datetime.min.time()); pickedDateTime = pickedDateTime.replace(hour=8, tzinfo=pytz.utc); self.textBox.setText(''); if pyDate in loggedHours: for loggedItem in loggedHours[pyDate]: self.textBox.append(QString.fromUtf8(loggedItem[0][0]) + ' ------>' + QString.fromUtf8(loggedItem[1][0]))
def __init__(self, parent=None): QDialog.__init__(self, parent) self.setupUi(self) self.conf.read("settings.ini") self.tickLabelTimerTrigger.connect(self.handletickLabelTimerTrigger) self.tickLabelTimer = threading.Timer(0.5, self.calltickLabelTimerTrigger) self.tickLabelTimer.start() logoPixmap = QtGui.QPixmap(QString.fromUtf8('images/db-connection.jpg')) logoScaledPixmap = logoPixmap.scaled(self.lblDBLogo.size(), QtCore.Qt.KeepAspectRatio) self.lblDBLogo.setPixmap(logoScaledPixmap)
def askUser(self, req_str_in, path_in, pid_in, addr_in, dport_in, sport_in): print "In askUser" #Convert all incoming QString into normal python strings req_str = str(req_str_in) path = unicode(QString.fromUtf8(path_in)) pid = str(pid_in) addr = str(addr_in) dport = str(dport_in) sport = str(sport_in) if (req_str == 'REQUEST_OUT'): dialog = dialogOut rport = sport lport = dport elif (req_str == 'REQUEST_IN'): dialog = dialogOut rport = dport lport = sport name = string.rsplit(path, "/", 1) dialog.path = path dialog.pid = pid dialog.label_name.setText(name[1]) dialog.label_ip.setText(addr) dialog.label_domain.setText("Looking up DNS...") fullpath = QTableWidgetItem(unicode(QString.fromUtf8(path))) dialog.tableWidget_details.setItem(0, 1, fullpath) pid_item = QTableWidgetItem(pid) dialog.tableWidget_details.setItem(1, 1, pid_item) remoteip = QTableWidgetItem(addr) dialog.tableWidget_details.setItem(2, 1, remoteip) dns = QTableWidgetItem("Looking up DNS...") dialog.tableWidget_details.setItem(3, 1, dns) rport_item = QTableWidgetItem(rport) dialog.tableWidget_details.setItem(4, 1, rport_item) lport_item = QTableWidgetItem(lport) dialog.tableWidget_details.setItem(5, 1, lport_item) QHostInfo.lookupHost(addr, dialog.dnsLookupFinished) #we don't want the user to accidentally trigger ALLOW dialog.pushButton_deny.setFocus() dialog.show()
def update(self): model = QStandardItemModel() model.setHorizontalHeaderItem(0, QStandardItem(i18n.get('account'))) model.setHorizontalHeaderItem(1, QStandardItem(i18n.get('message'))) self.list_.setModel(model) now = int(time.time()) interval = self.base.core.get_queue_interval() * 60 if self.last_timestamp: est_time = ((self.last_timestamp + interval) - now) / 60 else: est_time = 0 row = 0 for status in self.base.core.list_statuses_queue(): username = get_username_from(status.account_id) protocol_image = "%s.png" % get_protocol_from(status.account_id) item = QStandardItem(QString.fromUtf8(username)) item.setIcon(QIcon(self.base.load_image(protocol_image, True))) model.setItem(row, 0, item) model.setItem(row, 1, QStandardItem(QString.fromUtf8(status.text))) row += 1 humanized_interval = self.base.humanize_time_intervals( self.base.core.get_queue_interval()) humanized_est_time = self.base.humanize_time_intervals(est_time) warning = i18n.get('messages_will_be_send') % humanized_interval next_message = ' '.join( [i18n.get('next_message_should_be_posted_in'), humanized_est_time]) self.caption.setText(warning) if row == 0: self.estimated_time.setText('') else: self.estimated_time.setText(next_message) self.list_.horizontalHeader().setResizeMode(1, QHeaderView.Stretch) self.list_.resizeColumnsToContents() self.__enable()
def addDictionnary(self): fn = QFileDialog.getOpenFileName(self, self.tr("Select your dictionnary"), os.path.expanduser('~')) if fn != "": ufn = str(unicode(fn).encode('utf-8')) dicname = self.autoDicName(ufn) if dicname != None: currow = self.dicos.rowCount() self.dicos.setRowCount(currow + 1) item = QTableWidgetItem(QString.fromUtf8(ufn)) item.setFlags(Qt.ItemIsUserCheckable|Qt.ItemIsEnabled|Qt.ItemIsSelectable) item.setCheckState(Qt.Unchecked) self.dicos.setItem(currow, 0, item) name = QTableWidgetItem(QString.fromUtf8(dicname)) name.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable) self.dicos.setItem(currow, 1, name) dict_ = FileDictionnary(ufn) dict_.thisown = False try: self.manager.add(dicname, dict_) except RuntimeError: print "Error adding new dictionnary"
def __init__(self, parent, categoryName): QTreeWidgetItem.__init__(self, parent) self.__pageItems = [] self.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsSelectable | Qt.ItemIsEnabled) self.__category = ReportManager().category(categoryName) self.setText(0, QString.fromUtf8(self.__category.name())) self.refreshPage() if self.__category.selected(): self.setCheckState(0, Qt.Checked) else: self.setCheckState(0, Qt.Unchecked)
def __init__(self, obj, parent = None): QWidget.__init__(self, parent) browseText = QTextEdit() browseText.setReadOnly(True) examples = QString.fromUtf8(EXAMPLES) browseText.setText(examples) form = QGridLayout() form.addWidget(browseText,0,0) self.setLayout(form)
def askUser(self, req_str_in, path_in, pid_in, addr_in, dport_in, sport_in): print "In askUser" #Convert all incoming QString into normal python strings req_str = str(req_str_in) path = unicode(QString.fromUtf8(path_in)) pid = str(pid_in) addr = str(addr_in) dport = str(dport_in) sport = str(sport_in) if (req_str == 'REQUEST_OUT'): dialog = dialogOut rport = sport lport = dport elif (req_str == 'REQUEST_IN'): dialog = dialogOut rport = dport lport = sport name = string.rsplit(path,"/",1) dialog.path = path dialog.pid = pid dialog.label_name.setText(name[1]) dialog.label_ip.setText(addr) dialog.label_domain.setText("Looking up DNS...") fullpath = QTableWidgetItem(unicode(QString.fromUtf8(path))) dialog.tableWidget_details.setItem(0,1,fullpath) pid_item = QTableWidgetItem(pid) dialog.tableWidget_details.setItem(1,1,pid_item) remoteip = QTableWidgetItem(addr) dialog.tableWidget_details.setItem(2,1,remoteip) dns = QTableWidgetItem("Looking up DNS...") dialog.tableWidget_details.setItem(3,1,dns) rport_item = QTableWidgetItem(rport) dialog.tableWidget_details.setItem(4,1,rport_item) lport_item = QTableWidgetItem(lport) dialog.tableWidget_details.setItem(5,1,lport_item) QHostInfo.lookupHost(addr, dialog.dnsLookupFinished) #we don't want the user to accidentally trigger ALLOW dialog.pushButton_deny.setFocus() dialog.show()
def __init__(self, parent = None): super(SearchWidget, self).__init__(parent) self.myLayout = QHBoxLayout(self) self.button = QPushButton("Suchen", parent = self) self.resetBtn = QPushButton(QString.fromUtf8("Zurücksetzen"), parent = self) self.lineedit = QLineEdit(parent = self) self.setLayout(self.myLayout) self.layout().addWidget(self.lineedit) self.layout().addWidget(self.button) self.layout().addWidget(self.resetBtn) self.button.clicked.connect(self.searchemited) self.resetBtn.clicked.connect(self.reset)
def update(self): model = QStandardItemModel() model.setHorizontalHeaderItem(0, QStandardItem(i18n.get('account'))) model.setHorizontalHeaderItem(1, QStandardItem(i18n.get('message'))) self.list_.setModel(model) now = int(time.time()) interval = self.base.core.get_queue_interval() * 60 if self.last_timestamp: est_time = ((self.last_timestamp + interval) - now) / 60 else: est_time = 0 row = 0 for status in self.base.core.list_statuses_queue(): username = get_username_from(status.account_id) protocol_image = "%s.png" % get_protocol_from(status.account_id) item = QStandardItem(QString.fromUtf8(username)) item.setIcon(QIcon(self.base.load_image(protocol_image, True))) model.setItem(row, 0, item) model.setItem(row, 1, QStandardItem(QString.fromUtf8(status.text))) row += 1 humanized_interval = self.base.humanize_time_intervals(self.base.core.get_queue_interval()) humanized_est_time = self.base.humanize_time_intervals(est_time) warning = i18n.get('messages_will_be_send') % humanized_interval next_message = ' '.join([i18n.get('next_message_should_be_posted_in'), humanized_est_time]) self.caption.setText(warning) if row == 0: self.estimated_time.setText('') else: self.estimated_time.setText(next_message) self.list_.horizontalHeader().setResizeMode(1, QHeaderView.Stretch) self.list_.resizeColumnsToContents() self.__enable()
def loadScript(self, script): if script in self.m_loadScript_cache: self.m_page.mainFrame().evaluateJavaScript(self.m_loadScript_cache[script]) return True scriptFile = QString(script) try: script = open(script) script = QString.fromUtf8(script.read()) except IOError: return False if script.startsWith('#!'): script.prepend('//') if scriptFile.endsWith('.coffee'): coffee = CSConverter(self) script = QString.fromUtf8(coffee.convert(script)) self.m_loadScript_cache[scriptFile] = script self.m_page.mainFrame().evaluateJavaScript(script) return True
def _customize_field(self, option, field, label): #set style-sheets and fonts if option.name == 'sequence': font = QFont() font.setFamily('Monospace') field.setFont(font) #connect signals to slots elif option.name == 'config': field.textChanged.connect(self._load_config) elif option.name == 'working_directory': field.setText(QString.fromUtf8(os.path.abspath(self._cwdir))) field.editingFinished.connect(self._check_cwdir_field) elif option.name == 'template_files': field.textChanged.connect(self._del_seq_db_if_changed)
def __readFromStdout(self): """ Private slot to handle the readyReadStandardOutput signal of the process. """ if self.proc is None: return self.proc.setReadChannel(QProcess.StandardOutput) while self.proc and self.proc.canReadLine(): ba = self.proc.readLine() if ba.isNull(): return str = QString() s = QString(str.fromUtf8(ba.data()))[:-1] self.logText.append(s)