def render_bytes(self, svg_bytes: bytes): s = self.scene() s.clear() self.__svg_items = [] self.resetTransform() self.__svg_renderer.load(QByteArray(svg_bytes)) import xml.etree.ElementTree as ET g = "{http://www.w3.org/2000/svg}g" xml = svg_bytes.decode('utf-8') # logger.debug(xml) for i in ET.fromstring(xml).findall(f"./{g}/{g}"): if i.attrib['class'] == 'edge': item = SvgItem(i.attrib['id'], self.__svg_renderer) else: node_name = next( (c.text for c in i if c.tag == '{http://www.w3.org/2000/svg}title'), None) if node_name: # logger.debug(f"Adding clickable item for {node_name}") item = ClickableSvgItem(i.attrib['id'], self.__svg_renderer, self.signal, node_name) else: # logger.debug(f"Adding standard item for {i.attrib['id']}") item = SvgItem(i.attrib['id'], self.__svg_renderer) item.setFlags(QGraphicsItem.ItemClipsToShape) item.setCacheMode(QGraphicsItem.NoCache) item.setZValue(1) s.addItem(item) rect: QRectF = s.itemsBoundingRect() rect.adjust(-10, -10, 10, 10) s.setSceneRect(rect)
def _read_output(self, error=False): """ Read otuput from QProcess. Parameters ---------- error: bool, optional Process QProcess output or error channels. Default is False. """ if error: self.process.setReadChannel(QProcess.StandardError) else: self.process.setReadChannel(QProcess.StandardOutput) qba = QByteArray() while self.process.bytesAvailable(): if error: qba += self.process.readAllStandardError() else: qba += self.process.readAllStandardOutput() text = to_text_string(qba.data(), encoding='utf-8') if error: self.error_output += text else: self.output += text
def send_ctrl_to_process(self, letter): char = chr("abcdefghijklmnopqrstuvwxyz".index(letter) + 1) byte_array = QByteArray() byte_array.append(char) self.process.write(byte_array) self.process.waitForBytesWritten(-1) self.shell.write(LOCALE_CODEC.toUnicode(byte_array), flush=True)
def base64_from_icon_obj(self, icon_obj, width, height): """Convert icon object to base64 encoding.""" image = QImage(icon_obj.pixmap(width, height).toImage()) byte_array = QByteArray() buffer = QBuffer(byte_array) image.save(buffer, "PNG") return byte_array.toBase64().data().decode()
def mouseMoveEvent(self, event): if (self._clickPos is None or (event.pos() - self._clickPos).manhattanLength() < QApplication.startDragDistance()): return # _log.debug("Drag move") # render before detachment otherwise it might look ugly pixmap = QPixmap(self.size()) self.render(pixmap) self.setVisible(False) if len(self._dock.parentContainer.flatDockList) == 1: self._dock.parentContainer.setVisible(False) # Build drag object event.accept() drag = QDrag(self) mimeData = QMimeData() encodedData = QByteArray(pickle.dumps(self._dock.uid)) mimeData.setData(MIME_TYPE, encodedData) drag.setMimeData(mimeData) drag.setPixmap(pixmap) action = drag.exec_(Qt.MoveAction) _log.debug("After drag. Action: {}".format(action)) if Qt.IgnoreAction == action: _log.debug("D'n'D canceled") self.setVisible(True) self._dock.parentContainer.setVisible(True)
def QImage_to_compressed_bytes(qimage, format): """ Compress QImage or QPixmap into bytes corresponding to a image file format (BMP,PNG,JPG) To reconstruct the QImage or QPixamp : image = QImage.fromData(data) image = QImage() ; image.loadFromData(data) image = QPixmap(); image.loadFromData(data) The QImage.format will be preserved when loading only if in format in : Format_Mono Format_Indexed8 Format_RGB32 Format_ARGB32 Format_Grayscale8 """ # https://stackoverflow.com/questions/24965646/convert-pyqt4-qtgui-qimage-object-to-base64-png-data # https://stackoverflow.com/questions/57404778/how-to-convert-a-qpixmaps-image-into-a-bytes qbytearray = QByteArray() qbuffer = QBuffer(qbytearray) qbuffer.open(QIODevice.WriteOnly) ok = qimage.save(qbuffer, format) assert ok return qbytearray.data() # fait une copie ?
def _create_window(self): """Create a QMainWindow instance containing this plugin.""" self._undocked_window = window = PluginWindow(self) window.setAttribute(Qt.WA_DeleteOnClose) icon = self.get_plugin_icon() if is_text_string(icon): icon = self.get_icon(icon) window.setWindowIcon(icon) window.setWindowTitle(self.get_plugin_title()) window.setCentralWidget(self) window.resize(self.size()) # Restore window geometry geometry = self.get_option('window_geometry', default='') if geometry: try: window.restoreGeometry(QByteArray().fromHex( str(geometry).encode('utf-8'))) except Exception: pass self.refresh_plugin() self.set_ancestor(window) self.dockwidget.setFloating(False) self.dockwidget.setVisible(False) window.show()
def dropEvent(self, event: QDropEvent): mimedata = event.mimeData() data = QByteArray(mimedata.data("application/x_nodepath.list")) stream = QDataStream(data, QIODevice.ReadOnly) while not stream.atEnd(): path = stream.readQString() self.parent().add_plot(path) event.acceptProposedAction()
def __init__(self, parent=None): super(Downloader, self).__init__(parent) self.manager = QNetworkAccessManager() self.url = 'http://localhost:9998/jpg/image.jpg' self.request = QNetworkRequest() self.request.setUrl(QUrl(self.url)) self.buffer = QByteArray() self.reply = None
def __init__(self, parent=None, standalone=False): super(Camera, self).__init__(parent) # This prevents doing unneeded initialization # when QtDesginer loads the plugin. if parent is None and not standalone: return if not multimedia_available: return self.ui = uic.loadUi(os.path.join(WIDGET_PATH, "camera.ui"), self) self.camera = None self.imageCapture = None self.mediaRecorder = None self.isCapturingImage = False self.applicationExiting = False self.imageSettings = QImageEncoderSettings() self.audioSettings = QAudioEncoderSettings() self.videoSettings = QVideoEncoderSettings() self.videoContainerFormat = '' camera_device = QByteArray() videoDevicesGroup = QActionGroup(self) videoDevicesGroup.setExclusive(True) if not QCamera.availableDevices(): self.ui.devicesCombo.addItem("No Device") else: for deviceName in QCamera.availableDevices(): description = QCamera.deviceDescription(deviceName) self.ui.devicesCombo.addItem(description) videoDeviceAction = QAction(description, videoDevicesGroup) videoDeviceAction.setCheckable(True) videoDeviceAction.setData(deviceName) if camera_device.isEmpty(): cameraDevice = deviceName videoDeviceAction.setChecked(True) self.ui.devicesCombo.addAction(videoDeviceAction) videoDevicesGroup.triggered.connect(self.updateCameraDevice) self.ui.captureWidget.currentChanged.connect(self.updateCaptureMode) self.ui.devicesCombo.currentIndexChanged.connect(self.get_device_action) self.ui.lockButton.hide() if not IN_DESIGNER: # Start camera 2s after the UI has loaded QTimer.singleShot(2000, lambda: self.setCamera(camera_device))
def mimeData(self, indexes): self.indexes = [ index.internalPointer() for index in indexes if index.column() == 0 ] mimedata = QMimeData() mimedata.setData('application/x-qabstractitemmodeldatalist', QByteArray()) # run virtual function self.dragStartEvent(self.indexes) return mimedata
def paintEvent(self, event): """Handle appearence of the widget on state updates.""" self.style().unpolish(self) self.style().polish(self) option = QStyleOption() option.initFrom(self) h = option.rect.height() w = option.rect.width() if self.m_shape in (self.ShapeMap.Triangle, self.ShapeMap.Round): aspect = (4 / 3.0) if self.m_shape == self.ShapeMap.Triangle else 2.0 ah = w / aspect aw = w if ah > h: ah = h aw = h * aspect x = abs(aw - w) / 2.0 y = abs(ah - h) / 2.0 bounds = QRectF(x, y, aw, ah) else: size = min(w, h) x = abs(size - w) / 2.0 y = abs(size - h) / 2.0 bounds = QRectF(x, y, size, size) painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing, True) ind = self.m_state % len(self.m_stateColors) dark_r, dark_g, dark_b = self.getRGBfromQColor(self.m_stateColors[ind]) if not self.isEnabled(): dark_r, dark_g, dark_b = self.getRGBfromQColor(self.m_dsblColor) sel1_r, sel1_g, sel1_b = self.getRGBfromQColor(self.SelColor) sel2_r, sel2_g, sel2_b = self.getRGBfromQColor(self.SelColor) opc = '1.000' if not self.isSelected(): sel1_r, sel1_g, sel1_b = self.getRGBfromQColor(self.NotSelColor1) sel2_r, sel2_g, sel2_b = self.getRGBfromQColor(self.NotSelColor2) opc = '0.145' dark_str = "rgb(%d,%d,%d)" % (dark_r, dark_g, dark_b) light_str = "rgb(%d,%d,%d)" % self.adjust(dark_r, dark_g, dark_b) sel1_str = "rgb(%d,%d,%d)" % (sel1_r, sel1_g, sel1_b) sel2_str = "rgb(%d,%d,%d)" % (sel2_r, sel2_g, sel2_b) shape_bytes = bytes( self.shapesdict[self.m_shape] % (sel1_str, opc, sel2_str, dark_str, light_str), 'utf-8') self.renderer.load(QByteArray(shape_bytes)) self.renderer.render(painter, bounds)
def set_window_settings(self, hexstate, window_size, prefs_dialog_size, pos, is_maximized, is_fullscreen): """ Set window settings Symetric to the 'get_window_settings' accessor. """ main = self.main main.setUpdatesEnabled(False) self.prefs_dialog_size = QSize(prefs_dialog_size[0], prefs_dialog_size[1]) # width,height main.set_prefs_size(self.prefs_dialog_size) self.window_size = QSize(window_size[0], window_size[1]) # width, height self.window_position = QPoint(pos[0], pos[1]) # x,y main.setWindowState(Qt.WindowNoState) main.resize(self.window_size) main.move(self.window_position) # Window layout if hexstate: hexstate_valid = self.main.restoreState( QByteArray().fromHex(str(hexstate).encode('utf-8')), version=WINDOW_STATE_VERSION ) # Check layout validity. Spyder 4 and below use the version 0 # state (default), whereas Spyder 5 will use version 1 state. # For more info see the version argument for # QMainWindow.restoreState: # https://doc.qt.io/qt-5/qmainwindow.html#restoreState if not hexstate_valid: self.main.setUpdatesEnabled(True) self.setup_layout(default=True) return # Workaround for spyder-ide/spyder#880. # QDockWidget objects are not painted if restored as floating # windows, so we must dock them before showing the mainwindow. for widget in self.children(): if isinstance(widget, QDockWidget) and widget.isFloating(): self.floating_dockwidgets.append(widget) widget.setFloating(False) # Is fullscreen? if is_fullscreen: self.main.setWindowState(Qt.WindowFullScreen) # Is maximized? if is_fullscreen: self._maximized_flag = is_maximized elif is_maximized: self.main.setWindowState(Qt.WindowMaximized) self.main.setUpdatesEnabled(True)
def colorize_svg( src: Union[str, Path, IO[bytes]], dst: Union[None, str, Path, BinaryIO]=None, *, selected: bool=False, app: Optional[QApplication]=None, ) -> bytes: """Inject colors into a breeze-style SVG. :param src: A file object or path to read SVG data from. :param dst: A file object or path to write SVG data to. :param selected: Use selection colors? :param app: Currently running QApplication. Uses QApplication.instance() by default. :return: Returns the SVG as binary data. """ if app is None: app = QApplication.instance() sheet = get_sheet(selected, app) if hasattr(src, 'read'): raw = src.read() else: path = Path(src) with gzip.open(str(path)) if path.suffix == '.svgz' else path.open('rb') as f: raw = f.read() processed = QByteArray() reader = QXmlStreamReader(raw) writer = QXmlStreamWriter(processed) while not reader.atEnd(): if ( reader.readNext() == QXmlStreamReader.StartElement and reader.qualifiedName() == 'style' and reader.attributes().value('id') == 'current-color-scheme' ): writer.writeStartElement('style') writer.writeAttributes(reader.attributes()) writer.writeCharacters(sheet) writer.writeEndElement() while reader.tokenType() != QXmlStreamReader.EndElement: reader.readNext() elif reader.tokenType() != QXmlStreamReader.Invalid: writer.writeCurrentToken(reader) processed = bytes(processed) if hasattr(dst, 'write'): dst.write(processed) elif dst is not None: with Path(dst).open('wb'): dst.write(processed) return processed
def add_widget_totree(self, pixmap_items): for item in pixmap_items: widget = QtWidgets.QWidget() vLayout = QtWidgets.QVBoxLayout() label1D = QtWidgets.QLabel() bytes = QByteArray(item['node']._v_attrs['pixmap1D']) im1 = QtGui.QImage.fromData(bytes) a = QtGui.QPixmap.fromImage(im1) label1D.setPixmap(a) label2D = QtWidgets.QLabel() bytes = QByteArray(item['node']._v_attrs['pixmap2D']) im2 = QtGui.QImage.fromData(bytes) b = QtGui.QPixmap.fromImage(im2) label2D.setPixmap(b) vLayout.addWidget(label1D) vLayout.addwidget(label2D) widget.setLayout(vLayout) self.ui.h5file_tree.ui.Tree.setItemWidget(item['item'], 1, widget)
def test_read_standard_output(mocker): """Test that .read_standard_output() stores the output.""" before = 'before\n' output = 'Αθήνα\n' # check that we can handle non-ascii mock_read = mocker.Mock(return_value=QByteArray(output.encode())) mock_process = mocker.Mock(spec=QProcess, readAllStandardOutput=mock_read) server = ServerProcess(mock_process, '', output=before) serverManager = ServerManager() serverManager.servers = [server] serverManager.read_server_output(server) mock_read.assert_called_once() assert server.output == before + output
def read_output(self, error=False): if error: self.process.setReadChannel(QProcess.StandardError) else: self.process.setReadChannel(QProcess.StandardOutput) qba = QByteArray() while self.process.bytesAvailable(): if error: qba += self.process.readAllStandardError() else: qba += self.process.readAllStandardOutput() text = to_text_string(locale_codec.toUnicode(qba.data())) if error: self.error_output += text else: self.output += text
def read_output(self, error=False): if error: self.process.setReadChannel(QProcess.StandardError) else: self.process.setReadChannel(QProcess.StandardOutput) qba = QByteArray() while self.process.bytesAvailable(): if error: qba += self.process.readAllStandardError() else: qba += self.process.readAllStandardOutput() text = str(qba.data(), 'utf-8') if error: self.error_output += text else: self.output += text
def set_window_settings(self, hexstate, window_size, prefs_dialog_size, pos, is_maximized, is_fullscreen): """ Set window settings Symetric to the 'get_window_settings' accessor. """ main = self.main main.setUpdatesEnabled(False) self.prefs_dialog_size = QSize(prefs_dialog_size[0], prefs_dialog_size[1]) # width,height main.set_prefs_size(self.prefs_dialog_size) self.window_size = QSize(window_size[0], window_size[1]) # width, height self.window_position = QPoint(pos[0], pos[1]) # x,y main.setWindowState(Qt.WindowNoState) main.resize(self.window_size) main.move(self.window_position) # Window layout if hexstate: hexstate_valid = self.main.restoreState( QByteArray().fromHex(str(hexstate).encode('utf-8')), version=WINDOW_STATE_VERSION ) # Check layout validity. Spyder 4 and below use the version 0 # state (default), whereas Spyder 5 will use version 1 state. # For more info see the version argument for # QMainWindow.restoreState: # https://doc.qt.io/qt-5/qmainwindow.html#restoreState if not hexstate_valid: self.main.setUpdatesEnabled(True) self.setup_layout(default=True) return # Is fullscreen? if is_fullscreen: self.main.setWindowState(Qt.WindowFullScreen) # Is maximized? if is_fullscreen: self._maximized_flag = is_maximized elif is_maximized: self.main.setWindowState(Qt.WindowMaximized) self.main.setUpdatesEnabled(True)
def load_font(self, prefix, ttf_filename, charmap_filename, directory=None): """Loads a font file and the associated charmap If `directory` is None, the files will be looked up in ./fonts/ Arguments --------- prefix: str prefix string to be used when accessing a given font set ttf_filename: str ttf font filename charmap_filename: str charmap filename directory: str or None, optional directory for font and charmap files """ def hook(obj): result = {} for key in obj: result[key] = unichr(int(obj[key], 16)) return result if directory is None: directory = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'fonts') with open(os.path.join(directory, ttf_filename), 'rb') as f: font_data = QByteArray(f.read()) with open(os.path.join(directory, charmap_filename), 'r') as codes: self.charmap[prefix] = json.load(codes, object_hook=hook) id_ = QFontDatabase.addApplicationFontFromData(font_data) loadedFontFamilies = QFontDatabase.applicationFontFamilies(id_) if (loadedFontFamilies): self.fontname[prefix] = loadedFontFamilies[0] else: print('Font is empty')
def _read_output(self, error=False): process = self._process if error: process.setReadChannel(QProcess.StandardError) else: process.setReadChannel(QProcess.StandardOutput) qba = QByteArray() while process.bytesAvailable(): if error: qba += process.readAllStandardError() else: qba += process.readAllStandardOutput() text = str(qba.data(), "utf-8") if error: self.error_output += text else: self.output += text self.update_actions()
def setValue(self, dic): if 'data' in dic: if not isinstance(dic['data'], QtGui.QPixmap): self.data = QByteArray(dic['data']) im = QtGui.QImage.fromData(self.data) a = QtGui.QPixmap.fromImage(im) else: a = dic['data'] else: a = dic['pixmap'] if 'path' in dic: self.path = dic['path'] else: self.path = '' if 'info' in dic: info = dic['info'] else: info = '' self.label.setPixmap(a) self.checkbox.setChecked(dic['checked']) self.info.setText(info)
def paintEvent(self, event): """Treat appearence changes based on connection state and value.""" self.style().unpolish(self) self.style().polish(self) if not self.isEnabled(): state = 'Disconnected' elif self._bit_val == self._on: state = 'On' elif self._bit_val == self._off: state = 'Off' else: state = 'Disconnected' if self.shape == 0: shape_dict = PyDMStateButton.squaredbuttonstatesdict elif self.shape == 1: shape_dict = PyDMStateButton.roundedbuttonstatesdict option = QStyleOption() option.initFrom(self) h = option.rect.height() w = option.rect.width() aspect = 2.0 ah = w/aspect aw = w if ah > h: ah = h aw = h*aspect x = abs(aw-w)/2.0 y = abs(ah-h)/2.0 bounds = QRectF(x, y, aw, ah) painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing, True) shape_str = shape_dict[state] buttonstate_bytearray = bytes(shape_str, 'utf-8') self.renderer.load(QByteArray(buttonstate_bytearray)) self.renderer.render(painter, bounds)
def create_window(self): """ Create a QMainWindow instance containing this widget. """ logger.debug("Undocking plugin") # Widgets self.windowwidget = window = SpyderWindowWidget(self) # If the close corner button is used self.windowwidget.sig_closed.connect(self.close_window) # Wigdet setup window.setAttribute(Qt.WA_DeleteOnClose) window.setCentralWidget(self) window.setWindowIcon(self.get_icon()) window.setWindowTitle(self.get_title()) window.resize(self.size()) # Restore window geometry geometry = self.get_conf('window_geometry', default='') if geometry: try: window.restoreGeometry( QByteArray().fromHex(str(geometry).encode('utf-8')) ) except Exception: pass # Dock widget setup if self.dockwidget: self.dockwidget.setFloating(False) self.dockwidget.setVisible(False) self.set_ancestor(window) self._update_actions() window.show()
def save_state(self, version: int = 0) -> QByteArray: ''' Saves the current state of the dockmanger and all its dock widgets into the returned QByteArray. See also `config_flags`, which allow for auto-formatting and compression of the resulting XML file. Parameters ---------- version : int Returns ------- value : QByteArray ''' xmldata = QByteArray() stream = QXmlStreamWriter(xmldata) stream.setAutoFormatting( DockFlags.xml_auto_formatting in self._mgr.config_flags) stream.writeStartDocument() stream.writeStartElement("QtAdvancedDockingSystem") stream.writeAttribute("Version", str(version)) stream.writeAttribute("Containers", str(len(self._mgr.containers))) for container in self._mgr.containers: if isinstance(container, DockManager): DockContainerWidget.save_state(container, stream) else: container.save_state(stream) stream.writeEndElement() stream.writeEndDocument() return (qCompress(xmldata, 9) if DockFlags.xml_compression in self._mgr.config_flags and qCompress is not None else xmldata)
def __init__(self, xml: Union[str, bytes]) -> None: if isinstance(xml, str): xml = xml.encode('utf-8') self.data = QByteArray(xml) super().__init__()
def load_font(self, prefix, ttf_filename, charmap_filename, directory=None): """Loads a font file and the associated charmap. If ``directory`` is None, the files will be looked for in ``./fonts/``. Parameters ---------- prefix: str Prefix string to be used when accessing a given font set ttf_filename: str Ttf font filename charmap_filename: str Charmap filename directory: str or None, optional Directory for font and charmap files """ def hook(obj): result = {} for key in obj: try: result[key] = chr(int(obj[key], 16)) except ValueError: if int(obj[key], 16) > 0xffff: # ignoring unsupported code in Python 2.7 32bit Windows # ValueError: chr() arg not in range(0x10000) warnings.warn("Your Python version doesn't support " "character {0}:{1}".format( key, obj[key])) else: raise FontError(u'Failed to load character ' '{0}:{1}'.format(key, obj[key])) return result if directory is None: directory = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'fonts') # Load font if QApplication.instance() is not None: with open(os.path.join(directory, ttf_filename), 'rb') as font_data: id_ = QFontDatabase.addApplicationFontFromData( QByteArray(font_data.read())) font_data.close() loadedFontFamilies = QFontDatabase.applicationFontFamilies(id_) if loadedFontFamilies: self.fontname[prefix] = loadedFontFamilies[0] else: raise FontError(u"Font at '{0}' appears to be empty. " "If you are on Windows 10, please read " "https://support.microsoft.com/" "en-us/kb/3053676 " "to know how to prevent Windows from blocking " "the fonts that come with QtAwesome.".format( os.path.join(directory, ttf_filename))) with open(os.path.join(directory, charmap_filename), 'r') as codes: self.charmap[prefix] = json.load(codes, object_hook=hook) # Verify that vendorized fonts are not corrupt if not SYSTEM_FONTS: ttf_hash = MD5_HASHES.get(ttf_filename, None) if ttf_hash is not None: hasher = hashlib.md5() with open(os.path.join(directory, ttf_filename), 'rb') as f: content = f.read() hasher.update(content) ttf_calculated_hash_code = hasher.hexdigest() if ttf_calculated_hash_code != ttf_hash: raise FontError(u"Font is corrupt at: '{0}'".format( os.path.join(directory, ttf_filename)))
def load_font(self, prefix, ttf_filename, charmap_filename, directory=None): """Loads a font file and the associated charmap. If ``directory`` is None, the files will be looked for in the qtawesome ``fonts`` directory. Parameters ---------- prefix: str Prefix string to be used when accessing a given font set ttf_filename: str Ttf font filename charmap_filename: str Charmap filename directory: str or None, optional Directory path for font and charmap files """ def hook(obj): result = {} for key in obj: try: result[key] = chr(int(obj[key], 16)) except ValueError: if int(obj[key], 16) > 0xffff: # ignoring unsupported code in Python 2.7 32bit Windows # ValueError: chr() arg not in range(0x10000) pass else: raise FontError(u'Failed to load character ' '{0}:{1}'.format(key, obj[key])) return result if directory is None: directory = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'fonts') # Load font if QApplication.instance() is not None: with open(os.path.join(directory, ttf_filename), 'rb') as font_data: id_ = QFontDatabase.addApplicationFontFromData( QByteArray(font_data.read())) font_data.close() loadedFontFamilies = QFontDatabase.applicationFontFamilies(id_) if loadedFontFamilies: self.fontids[prefix] = id_ self.fontname[prefix] = loadedFontFamilies[0] else: raise FontError(u"Font at '{0}' appears to be empty. " "If you are on Windows 10, please read " "https://support.microsoft.com/" "en-us/kb/3053676 " "to know how to prevent Windows from blocking " "the fonts that come with QtAwesome.".format( os.path.join(directory, ttf_filename))) with open(os.path.join(directory, charmap_filename), 'r') as codes: self.charmap[prefix] = json.load(codes, object_hook=hook)
def get_stderr(self): self.process.setReadChannel(QProcess.StandardError) qba = QByteArray() while self.process.bytesAvailable(): qba += self.process.readAllStandardError() return self.transcode(qba)