Example #1
0
    def setPersepolisColorScheme(self, color_scheme):
        self.persepolis_color_scheme = color_scheme
        if color_scheme == 'Persepolis Dark Red':
            persepolis_dark_red = DarkRedPallete()
            self.setPalette(persepolis_dark_red)
            self.setStyleSheet(
                "QMenu::item:selected {background-color : #d64937 ;color : white} QToolTip { color: #ffffff; background-color: #353535; border: 1px solid white; }"
            )
        elif color_scheme == 'Persepolis Dark Blue':
            persepolis_dark_blue = DarkBluePallete()
            self.setPalette(persepolis_dark_blue)
            self.setStyleSheet(
                "QMenu::item:selected { background-color : #2a82da ;color : white } QToolTip { color: #ffffff; background-color: #353535; border: 1px solid white; }"
            )
        elif color_scheme == 'Persepolis ArcDark Red':
            persepolis_arcdark_red = ArcDarkRedPallete()
            self.setPalette(persepolis_arcdark_red)
            self.setStyleSheet(
                "QMenu::item:selected {background-color : #bf474d ; color : white} QToolTip { color: #ffffff; background-color: #353945; border: 1px solid white; } QPushButton {background-color: #353945  } QTabWidget {background-color : #353945;} QMenu {background-color: #353945 }"
            )

        elif color_scheme == 'Persepolis ArcDark Blue':
            persepolis_arcdark_blue = ArcDarkBluePallete()
            self.setPalette(persepolis_arcdark_blue)
            self.setStyleSheet(
                "QMenu::item:selected {background-color : #5294e2 ; color : white } QToolTip { color: #ffffff; background-color: #353945; border: 1px solid white; } QPushButton {background-color: #353945  } QTabWidget {background-color : #353945;} QMenu {background-color: #353945 }"
            )
        elif color_scheme == 'Persepolis Light Red':
            persepolis_light_red = LightRedPallete()
            self.setPalette(persepolis_light_red)
            self.setStyleSheet(
                "QMenu::item:selected {background-color : #d64937 ;color : white} QToolTip { color: #ffffff; background-color: #353535; border: 1px solid white; }"
            )

        elif color_scheme == 'Persepolis Light Blue':
            persepolis_light_blue = LightBluePallete()
            self.setPalette(persepolis_light_blue)
            self.setStyleSheet(
                "QMenu::item:selected { background-color : #2a82da ;color : white } QToolTip { color: #ffffff; background-color: #353535; border: 1px solid white; }"
            )

        elif color_scheme == 'New Dark Style':
            file = QFile(":/dark_style.qss")
            file.open(QFile.ReadOnly | QFile.Text)
            stream = QTextStream(file)
            self.setStyleSheet(stream.readAll())

        elif color_scheme == 'New Light Style':
            file = QFile(":/light_style.qss")
            file.open(QFile.ReadOnly | QFile.Text)
            stream = QTextStream(file)
            self.setStyleSheet(stream.readAll())
Example #2
0
    def __init__(self, parent=None, in_designer=False):
        QWidget.__init__(self, parent=parent)

        self.in_designer = in_designer

        ui = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)),
                          'compoundtoggle.ui')

        # TODO: CAMPid 9549757292917394095482739548437597676742
        if not QFileInfo(ui).isAbsolute():
            ui_file = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)),
                                   ui)
        else:
            ui_file = ui
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(ui_file)
        sio = io.StringIO(ts.readAll())
        self.ui = uic.loadUi(sio, self)

        self.ui.command.in_designer = self.in_designer
        self.ui.status_on.in_designer = self.in_designer
        self.ui.status_off.in_designer = self.in_designer

        if self.in_designer:
            self.ui.status_off.set_value(self.ui.status_off.on_value)
            self.ui.status_on.set_value(self.ui.status_off.on_value)
    def setupInterface(self):
        self.layouts['main'] = QVBoxLayout()

        path = str(getcwd()) + '/views/html/help.html'
        file = QFile(path)
        results = file.open(QFile.ReadOnly | QFile.Text)
        istream = QTextStream(file)

        self.widgets['test'] = QTextEdit()
        self.widgets['test'].setReadOnly(True)
        self.widgets['test'].setHtml(istream.readAll())
        file.close()
        '''
        self.widgets['test'] = QTextEdit("Welcome to our town generator!</br> "
                                        "When you click the 'wizard' tab, ")
        self.widgets['test'].setReadOnly(True)
        self.widgets['wizard'] = QLabel("When you click the 'wizard' tab, "
                                        "you'll see a page that allows seeds "
                                        "for towns to be generated!")
        self.widgets['load'] = QLabel("To load a town, click 'Load' on the "
                                        "right side of the page. ")
        self.widgets['gen'] = QLabel("")
        '''

        self.layouts['main'].addWidget(self.widgets['test'])
        # self.layouts['main'].addWidget(self.widgets['wizard'])
        # self.layouts['main'].addWidget(self.widgets['load'])

        self.set_layout(self.layouts['main'])
Example #4
0
    def getstylesheetfromQss(qss_path):
        file = QFile(qss_path)
        file.open(QFile.ReadOnly)
        ts = QTextStream(file)

        stylesheet = ts.readAll()
        return stylesheet
Example #5
0
    def __init__(self, parent=None, in_designer=False):
        QtWidgets.QWidget.__init__(self, parent=parent)

        self.in_designer = in_designer

        ui = 'variableselection.ui'
        self.file_name = ui
        # TODO: CAMPid 9549757292917394095482739548437597676742
        if not QFileInfo(ui).isAbsolute():
            ui_file = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)),
                                   ui)
        else:
            ui_file = ui
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(ui_file)
        sio = io.StringIO(ts.readAll())
        self.ui = uic.loadUi(sio, self)

        self.ui.load_binary_button.clicked.connect(self.load_binary)
        self.ui.save_selection_button.clicked.connect(self.save_selection)
        self.ui.load_selection_button.clicked.connect(self.load_selection)
        self.ui.update_parameters_button.clicked.connect(
            self.update_parameters)
        self.ui.process_raw_log_button.clicked.connect(self.process_raw_log)
        self.ui.process_raw_log_button.setEnabled(False)

        self.ui.view.tree_view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.ui.view.tree_view.customContextMenuRequested.connect(
            self.context_menu)

        self.progress = None
def test3():
    file = QFile("TopTitleUi.qss")
    file.open(QIODevice.ReadOnly | QIODevice.Text)
    fin = QTextStream(file)
    fin.setCodec("UTF-8")
    print(fin.readAll())
    file.close()
 def readStyleSheet(self):
     if self.appContext is not None:
         fp = self.appContext.get_resource(self.stylesheetPath)
         f = QFile(fp)
         f.open(QFile.ReadOnly | QFile.Text)
         stream = QTextStream(f)
         self.setStyleSheet(stream.readAll())
def test2():
    file = QFile("ansi.txt")
    file.open(QIODevice.ReadOnly | QIODevice.Text)
    fin = QTextStream(file)
    fin.setCodec("UTF-8")
    print(fin.readAll())
    file.close()
Example #9
0
    def readTextFromFile(self, fileName=None, encoding=None):
        previousFileName = self._fileName
        if fileName:
            self._fileName = fileName
        openfile = QFile(self._fileName)
        openfile.open(QFile.ReadOnly)
        stream = QTextStream(openfile)

        # Only try to detect encoding if it is not specified
        if encoding is None and globalSettings.detectEncoding:
            encoding = self.detectFileEncoding(fileName)

        encoding = encoding or globalSettings.defaultCodec
        if encoding:
            stream.setCodec(encoding)
            # If encoding is specified or detected, we should save the file with
            # the same encoding
            self.editBox.document().setProperty("encoding", encoding)

        text = stream.readAll()
        openfile.close()

        self.editBox.setPlainText(text)
        self.editBox.document().setModified(False)

        if previousFileName != self._fileName:
            self.updateActiveMarkupClass()
            self.fileNameChanged.emit()
Example #10
0
def load_stylesheet_pyqt5():
    """
    Loads the stylesheet for use in a pyqt5 application.

    :param pyside: True to load the pyside rc file, False to load the PyQt rc file

    :return the stylesheet string
    """
    # Smart import of the rc file
    import theme.pyqt5_style_rc

    # Load the stylesheet content from resources
    from PyQt5.QtCore import QFile, QTextStream

    f = QFile(":qdarkstyle/style.qss")
    if not f.exists():
        _logger().error("Unable to load stylesheet, file not found in "
                        "resources")
        return ""
    else:
        f.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(f)
        stylesheet = ts.readAll()
        if platform.system().lower() == 'darwin':  # see issue #12 on github
            mac_fix = '''
            QDockWidget::title
            {
                background-color: #353434;
                text-align: center;
                height: 12px;
            }
            '''
            stylesheet += mac_fix
        return stylesheet
def dark_stylesheet():

    f = QFile(
        os.path.join(os.path.abspath(os.path.dirname(__file__)),
                     "dark_alt/style.qss"))

    if not f.exists():

        return ""

    else:

        f.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(f)
        stylesheet = ts.readAll()

        if platform.system().lower() == 'darwin':  # see issue #12 on github

            mac_fix = '''
            QDockWidget::title
            {
                background-color: #31363b;
                text-align: center;
                height: 12px;
            }
            '''
            stylesheet += mac_fix

        return stylesheet
Example #12
0
def set_window_style(window):
    """
    :return the stylesheet string
    """
    # Smart import of the rc file

    f = QFile(":dark_style.qss")
    if not f.exists():
        print('Custom stylesheet not present')
        Lumberjack.error("Unable to load stylesheet, file not found in "
                         "resources")
        return ""
    else:
        f.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(f)
        stylesheet = ts.readAll()
        if platform.system().lower() == 'darwin':  # see issue #12 on github
            mac_fix = '''
            QDockWidget::title
            {
                background-color: #31363b;
                text-align: center;
                height: 12px;
            }
            '''
            stylesheet += mac_fix
        window.setWindowIcon(QIcon(':/app_icons/rc/PAT_icon.png'))
        window.setStyleSheet(stylesheet)
Example #13
0
    def __init__(self, parent=None, in_designer=False):

        QWidget.__init__(self, parent=parent)

        self.in_designer = in_designer

        # If true, flips the compound scale on y axis if vertically oriented.
        self.cs_vertically_flipped = False

        ui = self.getPath()

        # TODO: CAMPid 9549757292917394095482739548437597676742
        if not QFileInfo(ui).isAbsolute():
            ui_file = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)),
                                   ui)
        else:
            ui_file = ui
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(ui_file)
        sio = io.StringIO(ts.readAll())
        self.ui = uic.loadUi(sio, self)

        self.ui.command.in_designer = in_designer
        self.ui.echo.in_designer = in_designer
        self.ui.status.in_designer = in_designer
        self.ui.numeric_status.in_designer = in_designer

        self.update_echo_visibility()
Example #14
0
    def __init__(self, parent=None, in_designer=False):
        QtWidgets.QWidget.__init__(self, parent=parent)

        self.in_designer = in_designer

        ui = 'devicetreeview.ui'
        # TODO: CAMPid 9549757292917394095482739548437597676742
        if not QFileInfo(ui).isAbsolute():
            ui_file = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)),
                                   ui)
        else:
            ui_file = ui
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(ui_file)
        sio = io.StringIO(ts.readAll())
        self.ui = uic.loadUi(sio, self)

        self.resize_columns = epyqlib.devicetree.Columns(
            name=True,
            nickname=True,
            bitrate=True,
            transmit=True,
        )

        self.ui.tree_view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.ui.tree_view.customContextMenuRequested.connect(self.context_menu)

        self.model = None
Example #15
0
    def load_stylesheet_pyqt5():

        # Smart import of the rc file
        

        # Load the stylesheet content from resources
        from PyQt5.QtCore import QFile, QTextStream

        f = QFile('./darkStyle/style.qss')
        if not f.exists():
            print('Unable to load stylesheet, file not found in '
                            'resources')
            return ''
        else:
            f.open(QFile.ReadOnly | QFile.Text)
            ts = QTextStream(f)
            stylesheet = ts.readAll()
            if platform.system().lower() == 'darwin':  # see issue #12 on github
                mac_fix = '''
                QDockWidget::title
                {
                    background-color: #31363b;
                    text-align: center;
                    height: 12px;
                }
                '''
                stylesheet += mac_fix
            return stylesheet
Example #16
0
    def __init__(self, parent=None, in_designer=False):
        QWidget.__init__(self, parent=parent)

        self.in_designer = in_designer

        ui = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)),
                          'hmidialog.ui')

        # TODO: CAMPid 9549757292917394095482739548437597676742
        if not QFileInfo(ui).isAbsolute():
            ui_file = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)),
                                   ui)
        else:
            ui_file = ui
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(ui_file)
        sio = io.StringIO(ts.readAll())
        self.ui = uic.loadUi(sio, self)

        self.ok_action = None
        self.cancel_action = None
        self.ui.ok_button.clicked.connect(self.ok)
        self.ui.cancel_button.clicked.connect(self.cancel)

        self.label.setWordWrap(True)
Example #17
0
	def readTextFromFile(self, fileName=None, encoding=None):
		previousFileName = self._fileName
		if fileName:
			self._fileName = fileName

		# Only try to detect encoding if it is not specified
		if encoding is None and globalSettings.detectEncoding:
			encoding = self.detectFileEncoding(self._fileName)

		# TODO: why do we open the file twice: for detecting encoding
		# and for actual read? Can we open it just once?
		openfile = QFile(self._fileName)
		openfile.open(QFile.ReadOnly)
		stream = QTextStream(openfile)
		encoding = encoding or globalSettings.defaultCodec
		if encoding:
			stream.setCodec(encoding)
			# If encoding is specified or detected, we should save the file with
			# the same encoding
			self.editBox.document().setProperty("encoding", encoding)

		text = stream.readAll()
		openfile.close()

		if previousFileName != self._fileName:
			self.updateActiveMarkupClass()

		self.editBox.setPlainText(text)
		self.editBox.document().setModified(False)

		cssFileName = self.getBaseName() + '.css'
		self.cssFileExists = QFile.exists(cssFileName)

		if previousFileName != self._fileName:
			self.fileNameChanged.emit()
Example #18
0
    def __init__(self, parent=None, in_designer=False):
        QWidget.__init__(self, parent=parent)

        self.in_designer = in_designer

        ui = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)),
                          'iopoint.ui')

        # TODO: CAMPid 9549757292917394095482739548437597676742
        if not QFileInfo(ui).isAbsolute():
            ui_file = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)),
                                   ui)
        else:
            ui_file = ui
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(ui_file)
        sio = io.StringIO(ts.readAll())
        self.ui = uic.loadUi(sio, self)

        self.ui.status.in_designer = self.in_designer
        self.ui.set.in_designer = self.in_designer
        self.ui.override.in_designer = self.in_designer

        self.update_configuration()
Example #19
0
    def readTextFromFile(self, fileName=None, encoding=None):
        previousFileName = self._fileName
        if fileName:
            self._fileName = fileName

            # Only try to detect encoding if it is not specified
        if encoding is None and globalSettings.detectEncoding:
            encoding = self.detectFileEncoding(self._fileName)

            # TODO: why do we open the file twice: for detecting encoding
            # and for actual read? Can we open it just once?
        openfile = QFile(self._fileName)
        openfile.open(QFile.ReadOnly)
        stream = QTextStream(openfile)
        encoding = encoding or globalSettings.defaultCodec
        if encoding:
            stream.setCodec(encoding)
            # If encoding is specified or detected, we should save the file with
            # the same encoding
            self.editBox.document().setProperty("encoding", encoding)

        text = stream.readAll()
        openfile.close()

        self.editBox.setPlainText(text)
        self.editBox.document().setModified(False)

        if previousFileName != self._fileName:
            self.updateActiveMarkupClass()
            self.fileNameChanged.emit()
Example #20
0
    def __init__(self, parent=None, in_designer=False):
        QWidget.__init__(self, parent=parent)

        self.in_designer = in_designer

        ui = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)),
                          'iogroup.ui')

        # TODO: CAMPid 9549757292917394095482739548437597676742
        if not QFileInfo(ui).isAbsolute():
            ui_file = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)),
                                   ui)
        else:
            ui_file = ui
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(ui_file)
        sio = io.StringIO(ts.readAll())
        self.ui = uic.loadUi(sio, self)

        self._status_frame = ''
        self._status_signal_format = ''
        self._set_frame = ''
        self._set_signal_format = ''
        self._override_frame = ''
        self._override_signal_format = ''

        self._quantity = 0
        self._tx = True

        self.points = []
Example #21
0
    def __init__(self, parent=None, in_designer=False):
        QtWidgets.QWidget.__init__(self, parent=parent)

        self.in_designer = in_designer

        ui = 'listmenuview.ui'
        # TODO: CAMPid 9549757292917394095482739548437597676742
        if not QFileInfo(ui).isAbsolute():
            ui_file = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)),
                                   ui)
        else:
            ui_file = ui
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(ui_file)
        sio = io.StringIO(ts.readAll())
        self.ui = uic.loadUi(sio, self)

        scroll_bar = self.ui.list_view.verticalScrollBar()
        up = functools.partial(scroll_bar.triggerAction,
                               QAbstractSlider.SliderPageStepSub)
        self.ui.up_button.clicked.connect(up)
        down = functools.partial(scroll_bar.triggerAction,
                                 QAbstractSlider.SliderPageStepAdd)
        self.ui.down_button.clicked.connect(down)

        self.ui.list_view.viewport().setAutoFillBackground(False)

        self.ui.list_view.clicked.connect(self.clicked)
Example #22
0
def readTextFile(filePath):
    f = QFile(filePath)
    if not f.open(QIODevice.ReadOnly):
        return False
    ts = QTextStream(f)

    return ts.readAll()
Example #23
0
    def __init__(self, parent=None, in_designer=False, action=None):
        QWidget.__init__(self, parent=parent)

        self.in_designer = in_designer

        ui = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)),
                          'listselect.ui')

        # TODO: CAMPid 9549757292917394095482739548437597676742
        if not QFileInfo(ui).isAbsolute():
            ui_file = os.path.join(
                QFileInfo.absolutePath(QFileInfo(__file__)), ui)
        else:
            ui_file = ui
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(ui_file)
        sio = io.StringIO(ts.readAll())
        self.ui = uic.loadUi(sio, self)

        self.action = action
        self.items = {}
        self.ui.accept_button.clicked.connect(self.accept)
        self.ui.cancel_button.clicked.connect(
            functools.partial(self.exit, value=None))
Example #24
0
    def load_stylesheet(self, f):
        if not f.exists():
            self.logger.error(
                'Unable to load stylesheet, file not found in resources')
            return ''
        else:
            f.open(QFile.ReadOnly | QFile.Text)
            ts = QTextStream(f)
            stylesheet = ts.readAll()
            if platform.system().lower(
            ) == 'darwin':  # see issue #12 on github
                mac_fix = '''
                QDockWidget::title
                {
                    background-color: #31363b;
                    text-align: center;
                    height: 12px;
                }
                '''
                stylesheet += mac_fix
            return stylesheet


# -------------------------------------------------------------------------------------------------------------
# Created by panda on 22/06/2018 - 3:51 AM
# © 2017 - 2018 DAMGteam. All rights reserved
Example #25
0
class Main(QApplication):
    """
    Implementation of the main application class

    """

    def __init__(self):
        """
        Constructor / Instantiate the class

        """
        super().__init__(sys.argv)

        self.f = QFile("source/ui/default_theme.qss")
        self.f.open(QFile.ReadOnly | QFile.Text)
        self.ts = QTextStream(self.f)
        self.qss = self.ts.readAll()

        self.setStyle("Fusion")
        self.setStyleSheet(self.qss)

        SplashView(self)
        self.home = HomeView()
        self.home.showMaximized()

        sys.exit(self.exec_())
def set_theme(app, ui, mode):
    ui.mode = mode
    if mode in ['dark', 'light']:
        file = QFile(":/" + mode + ".qss")
        file.open(QFile.ReadOnly | QFile.Text)
        stream = QTextStream(file)
        app.setStyleSheet(stream.readAll())
Example #27
0
 def insert_html(self, path):
     # f = QFile("./../resource/html/collectMineralsAndGas.html")
     f = QFile(globalInformation.map_name_to_html(path))
     f.open(QFile.ReadOnly | QFile.Text)
     istream = QTextStream(f)
     self.text_edit.setHtml(istream.readAll())
     f.close()
Example #28
0
def main():
    """
    Application entry point
    """
    logging.basicConfig(level=logging.DEBUG)
    # create the application and the main window
    app = QtWidgets.QApplication(sys.argv)
    #app.setStyle(QtWidgets.QStyleFactory.create("fusion"))
    window = QtWidgets.QMainWindow()

    # setup ui
    ui = example.Ui_MainWindow()
    ui.setupUi(window)
    ui.bt_delay_popup.addActions([ui.actionAction, ui.actionAction_C])
    ui.bt_instant_popup.addActions([ui.actionAction, ui.actionAction_C])
    ui.bt_menu_button_popup.addActions([ui.actionAction, ui.actionAction_C])
    window.setWindowTitle("BreezeDark example")

    # tabify dock widgets to show bug #6
    window.tabifyDockWidget(ui.dockWidget1, ui.dockWidget2)

    # setup stylesheet
    file = QFile(":/dark.qss")
    file.open(QFile.ReadOnly | QFile.Text)
    stream = QTextStream(file)
    app.setStyleSheet(stream.readAll())

    # auto quit after 2s when testing on travis-ci
    if "--travis" in sys.argv:
        QtCore.QTimer.singleShot(2000, app.exit)

    # run
    window.show()
    app.exec_()
Example #29
0
    def load(self):
        """Load ?"""
        exception = None
        filehandle = None
        try:
            filehandle =  QFile(self.filename)
            if not filehandle.open( QIODevice.ReadOnly):
                raise IOError(unicode(filehandle.errorString()))
            stream =  QTextStream(filehandle)
            stream.setCodec("UTF-8")
            QApplication.processEvents()
            self.setPlainText(stream.readAll())
            self.document().setModified(False)
            self.setWindowTitle( QFileInfo(self.filename).fileName())
            self.loadHighlighter(self.filename)
            for plugin in filter_plugins_by_capability('afterFileOpen',self.enabled_plugins):
                plugin.do_afterFileOpen(self)

        except (IOError, OSError) as error:
            exception = error
        finally:
            if filehandle is not None:
                filehandle.close()
            if exception is not None:
                raise exception
Example #30
0
 def openFile(self):
     if settings.get("file_dialog_dir"):
         self.curDir = '~/'
     else:
         self.curDir = settings.get("file_dialog_dir")
     fn = QFileDialog.getOpenFileName(self,
             self.tr("Open File..."), self.curDir,
             self.tr("HTML-Files (*.htm *.html);;All Files (*)"))
     QApplication.setOverrideCursor(Qt.WaitCursor)
     if fn:
         self.lastFolder = os.path.dirname(fn)
         if os.path.exists(fn):
             if os.path.isfile(fn):
                 f = QFile(fn)
                 if not f.open(QIODevice.ReadOnly |
                               QIODevice.Text):
                     QtGui.QMessageBox.information(self.parent(),
                     self.tr("Error - Lector"),
                     self.tr("Can't open '%s.'" % fn))
                 else:
                     stream = QTextStream(f)
                     text = stream.readAll()
                     self.setText(text)
             else:
                 QMessageBox.information(self.parent(),
                 self.tr("Error - Lector"),
                 self.tr("'%s' is not a file." % fn))
     QApplication.restoreOverrideCursor()
 def do_snap(self,gfile):
     img = Snapshot.snapshot(width = 200, height = 200).scaled(200,200,Qt.IgnoreAspectRatio, Qt.SmoothTransformation)
     outdata = ""
     outdata = outdata + self.overseek()
     outdata = outdata + "; bigtree thumbnail end\r\n\r\n"
     outdata = outdata + self.material_usage()
     
     fh = QFile(gfile)
     fh.open(QIODevice.ReadOnly)
     stream = QTextStream(fh)
     stream.setCodec(CODEC)
     fg = stream.readAll() + "\r\n"
     if self.extruder_M2O() == True:
         fg = fg.replace("M104 T0",";M104 T0")
         fg = fg.replace("M104 T1",";M104 T1")
         fg = fg.replace("M109 T0",";M109 T0")
         fg = fg.replace("M109 T1",";M109 T1")
     fh.close()
     bigtree3dfile = os.path.splitext(gfile)[0]+"[Bigtree].gcode"
     fh = QFile(bigtree3dfile)
     fh.open(QIODevice.WriteOnly)
     stream = QTextStream(fh)
     stream.setCodec(CODEC)
     stream << outdata
     stream << fg
     fh.close()
     os.remove(gfile)
Example #32
0
def load_stylesheet():
    """
    Load the stylesheet for use in a pyqt5 application.

    :param pyside: True to load the pyside rc file, False to load the PyQt rc file

    :return the stylesheet string
    """
    warnings.warn(
        "load_stylesheet_pyqt5() will be deprecated in version 3,"
        "set QtPy environment variable to specify the Qt binding and "
        "use load_stylesheet()", PendingDeprecationWarning)

    # Smart import of the rc file
    import themes.breezedark.breeze_resources

    # Load the stylesheet content from resources
    from PyQt5.QtCore import QCoreApplication, QFile, QTextStream
    from PyQt5.QtGui import QColor, QPalette

    f = QFile(":/breezedark/style.qss")
    if not f.exists():
        _logger().error("Unable to load stylesheet, file not found in "
                        "resources")
        return ""
    else:
        f.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(f)
        stylesheet = ts.readAll()

        # Apply OS specific patches
        # stylesheet = _apply_stylesheet_patches(stylesheet)
        return stylesheet
Example #33
0
    def __init__(self, parent=None, in_designer=False):

        QWidget.__init__(self, parent=parent)

        self.in_designer = in_designer

        self.d_vertically_flipped = False

        ui = self.getPath()

        # TODO: CAMPid 9549757292917394095482739548437597676742
        if not QFileInfo(ui).isAbsolute():
            ui_file = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)),
                                   ui)
        else:
            ui_file = ui
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(ui_file)
        sio = io.StringIO(ts.readAll())
        self.ui = uic.loadUi(sio, self)

        self.scale1 = epyqlib.widgets.scale.Scale(self, in_designer)
        self.scale2 = epyqlib.widgets.scale.Scale(self, in_designer)
        # color ranges, scale markers, labels, needle painted.
        self.scale1.scale.m_paintMode = 1
        # needle, cover painted.
        self.scale2.scale.m_paintMode = 3
        # scale2's needle is blue
        self.scale2.scale.isBlue = True
        self.stackedLayout = QStackedLayout()
        self.stackedLayout.addWidget(self.scale2)
        self.stackedLayout.addWidget(self.scale1)
        self.stackedLayout.setStackingMode(1)
        self.ui.glayout.addLayout(self.stackedLayout, 0, 0)
def test1():
    file = QFile("utf8.txt")
    file.open(QIODevice.ReadOnly)
    fin = QTextStream(file)
    fin.setCodec("UTF-8")
    print(fin.readAll())
    file.close()
Example #35
0
    def __init__(self, ui_file, bus, devices=[], parent=None):
        QtWidgets.QMainWindow.__init__(self, parent=parent)

        self.bus = bus

        # TODO: CAMPid 980567566238416124867857834291346779
        ico_file = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)), "icon.ico")
        ico = QtGui.QIcon(ico_file)
        self.setWindowIcon(ico)

        ui = ui_file
        # TODO: CAMPid 9549757292917394095482739548437597676742
        if not QFileInfo(ui).isAbsolute():
            ui_file = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)), ui)
        else:
            ui_file = ui
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(ui_file)
        sio = io.StringIO(ts.readAll())
        self.ui = uic.loadUi(sio, self)

        self.ui.action_About.triggered.connect(self.about)

        device_tree = epyqlib.devicetree.Tree()
        device_tree_model = epyqlib.devicetree.Model(root=device_tree)
        device_tree_model.device_removed.connect(self._remove_device)
        self.ui.device_tree.setModel(device_tree_model)

        self.ui.device_tree.device_selected.connect(self.set_current_device)
Example #36
0
def loadStyle(stylesheet):

    if stylesheet not in StyleSheets.keys():
        raise RuntimeError('Invalid stylesheet (%s)' %stylesheet)

    f = QFile(StyleSheets[stylesheet])
    f.open(QFile.ReadOnly | QFile.Text)
    ts = QTextStream(f)
    return  ts.readAll()
Example #37
0
 def readFile(self, path, coding = "UTF-8"):
     """读取文件"""
     file = QFile(path)
     file.open(QIODevice.ReadOnly | QIODevice.Text)
     fin = QTextStream(file)
     fin.setCodec(coding)
     data = fin.readAll()
     file.close()
     return data
Example #38
0
def ReadTextFile(filePath):

    file = QFile(filePath)
    file.open(QFile.ReadOnly | QFile.Text)
    textStream = QTextStream(file)
    data = textStream.readAll()
    file.close()

    return data
Example #39
0
def ReadResourceTextFile(resFile):

    res = QResource(resFile)
    file = QFile(res.absoluteFilePath())
    file.open(QFile.ReadOnly | QFile.Text)
    textStream = QTextStream(file)
    data = textStream.readAll()
    file.close()

    return data
Example #40
0
 def ouvrirtexte(self):
     filename, _ = QFileDialog.getOpenFileName(self)
     if filename:
         file = QFile(filename)
         if not file.open(QFile.ReadOnly | QFile.Text):
             QMessageBox.critical(self, appname + version + "Open File",
                                  "Reading Error %s:\n%s." % (filename, file.errorString()))
             return
         instr = QTextStream(file)
         self.ui.plainTextEdit.setPlainText(instr.readAll())
Example #41
0
    def updateTextEdit(self):
        mib = self.encodingComboBox.itemData(self.encodingComboBox.currentIndex())
        codec = QTextCodec.codecForMib(mib)

        data = QTextStream(self.encodedData)
        data.setAutoDetectUnicode(False)
        data.setCodec(codec)

        self.decodedStr = data.readAll()
        self.textEdit.setPlainText(self.decodedStr)
Example #42
0
 def loadFile(self):
     fh = QFile(self.filename)
     print("fh is ", fh)
     if not fh.open(QIODevice.ReadOnly):
         raise IOError(str(fh.errorString()))
     stream = QTextStream(fh)
     stream.setCodec("UTF-8")
     # self.setPlainText("Hello World")
     self.preParse = (stream.readAll())  # Here lies the problem how to fix it? PyQt 3.4.2 Works Fine
     print(self.preParse)
     self.parseOutputData(self.preParse)
Example #43
0
    def read(self):
        """ Reads the file and returns the content """

        _file = QFile(self.filename)
        if not _file.open(QIODevice.ReadOnly | QIODevice.Text):
            raise Exception(_file.errorString())

        # Codec
        codec = QTextCodec.codecForLocale()
        stream = QTextStream(_file)
        stream.setCodec(codec)
        return stream.readAll()
Example #44
0
    def setPersepolisColorScheme(self, color_scheme):
        self.persepolis_color_scheme = color_scheme
        if color_scheme == 'Persepolis Old Dark Red':
            persepolis_dark_red = DarkRedPallete()
            self.setPalette(persepolis_dark_red)
            self.setStyleSheet("QMenu::item:selected {background-color : #d64937 ;color : white} QToolTip { color: #ffffff; background-color: #353535; border: 1px solid white; }")
        elif color_scheme == 'Persepolis  Old Dark Blue':
            persepolis_dark_blue = DarkBluePallete()
            self.setPalette(persepolis_dark_blue)
            self.setStyleSheet("QMenu::item:selected { background-color : #2a82da ;color : white } QToolTip { color: #ffffff; background-color: #353535; border: 1px solid white; }")
        elif color_scheme == 'Persepolis ArcDark Red':
            persepolis_arcdark_red = ArcDarkRedPallete()
            self.setPalette(persepolis_arcdark_red)
            self.setStyleSheet("QMenu::item:selected {background-color : #bf474d ; color : white} QToolTip { color: #ffffff; background-color: #353945; border: 1px solid white; } QPushButton {background-color: #353945  } QTabWidget {background-color : #353945;} QMenu {background-color: #353945 }")

        elif color_scheme == 'Persepolis ArcDark Blue':
            persepolis_arcdark_blue = ArcDarkBluePallete()
            self.setPalette(persepolis_arcdark_blue)
            self.setStyleSheet("QMenu::item:selected {background-color : #5294e2 ; color : white } QToolTip { color: #ffffff; background-color: #353945; border: 1px solid white; } QPushButton {background-color: #353945  } QTabWidget {background-color : #353945;} QMenu {background-color: #353945 }")
        elif color_scheme == 'Persepolis Old Light Red':
            persepolis_light_red = LightRedPallete()
            self.setPalette(persepolis_light_red)
            self.setStyleSheet("QMenu::item:selected {background-color : #d64937 ;color : white} QToolTip { color: #ffffff; background-color: #353535; border: 1px solid white; }")

        elif color_scheme == 'Persepolis Old Light Blue':
            persepolis_light_blue = LightBluePallete()
            self.setPalette(persepolis_light_blue)
            self.setStyleSheet("QMenu::item:selected { background-color : #2a82da ;color : white } QToolTip { color: #ffffff; background-color: #353535; border: 1px solid white; }")

        elif color_scheme == 'Persepolis Dark Blue':
            file = QFile(":/dark_style.qss")
            file.open(QFile.ReadOnly | QFile.Text)
            stream = QTextStream(file)
            self.setStyleSheet(stream.readAll())

        elif color_scheme == 'Persepolis Light Blue':
            file = QFile(":/light_style.qss")
            file.open(QFile.ReadOnly | QFile.Text)
            stream = QTextStream(file)
            self.setStyleSheet(stream.readAll())
Example #45
0
    def loadFile(self, fileName):
        file = QFile(fileName)
        if not file.open(QFile.ReadOnly | QFile.Text):
            QMessageBox.warning(self, "Application",
                    "Cannot read file %s:\n%s." % (fileName, file.errorString()))
            return

        inf = QTextStream(file)
        QApplication.setOverrideCursor(Qt.WaitCursor)
        self.textEdit.setPlainText(inf.readAll())
        QApplication.restoreOverrideCursor()

        self.setCurrentFile(fileName)
        self.statusBar().showMessage("File loaded", 2000)
Example #46
0
	def readTextFromFile(self, encoding=None):
		openfile = QFile(self.fileName)
		openfile.open(QFile.ReadOnly)
		stream = QTextStream(openfile)
		encoding = encoding or globalSettings.defaultCodec
		if encoding:
			stream.setCodec(encoding)
		text = stream.readAll()
		openfile.close()
		markupClass = get_markup_for_file_name(self.fileName, return_class=True)
		self.setMarkupClass(markupClass)
		modified = bool(encoding) and (self.editBox.toPlainText() != text)
		self.editBox.setPlainText(text)
		self.editBox.document().setModified(modified)
Example #47
0
    def __init__(self, subtitle, encoding="UTF-8"):
        super().__init__()

        subtitlefile = QFile(subtitle)

        if not subtitlefile.open(QIODevice.ReadOnly | QIODevice.Text):
            return

        text = QTextStream(subtitlefile)
        text.setCodec(encoding)

        subtitletext = text.readAll()

        # ('sıra', 'saat', 'dakika', 'saniye', 'milisaniye', 'saat', 'dakika', 'saniye', 'milisaniye', 'birincisatır', 'ikincisatır')
        compile = re.compile(r"(\d.*)\n(\d{2}):(\d{2}):(\d{2}),(\d{3}) --> (\d{2}):(\d{2}):(\d{2}),(\d{3})\n(\W.*|\w.*)\n(\w*|\W*|\w.*|\W.*)\n")
        self.sublist = compile.findall(subtitletext)
Example #48
0
def get_style(style_sheet):
    try:
        mod = importlib.import_module("." + style_sheet, __name__)
        hasattr(mod, "qt_resource_name")
        f = QFile(":/%s/style.qss" % style_sheet)                                
        f.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(f)
        stylesheet = ts.readAll()    
    except ImportError as e:
        print "Style sheet not available. Use available_styles() to check for valid styles"
        return u""
    except Exception as e:
        print "Style sheet available, but an error occured..."
        traceback.print_exc()
        return u""
        
    return stylesheet
Example #49
0
    def loadFile(self, fileName):
        file = QFile(fileName)
        if not file.open(QFile.ReadOnly | QFile.Text):
            QMessageBox.warning(self, "MDI",
                    "Cannot read file %s:\n%s." % (fileName, file.errorString()))
            return False

        instr = QTextStream(file)
        QApplication.setOverrideCursor(Qt.WaitCursor)
        self.setPlainText(instr.readAll())
        QApplication.restoreOverrideCursor()

        self.setCurrentFile(fileName)

        self.document().contentsChanged.connect(self.documentWasModified)

        return True
Example #50
0
    def load(self):  # Windows crash buty why
        exception = None
        fh = None

        print("Hello Load Text File")
        # Looks like there's bug in windows
        try:
            fh = QFile(self.filename)
            print("fh is ", fh)
            if not fh.open(QIODevice.ReadOnly):
                raise IOError(str(fh.errorString()))
            stream = QTextStream(fh)
            stream.setCodec("UTF-8")
            # self.setPlainText("Hello World")
            self.setPlainText(stream.readAll())  # Here lies the problem how to fix it? PyQt 3.4.2 Works Fine
            self.document().setModified(False)
        except EnvironmentError as e:
            exception = e
Example #51
0
def main():
    """
    Application entry point
    """
    logging.basicConfig(level=logging.DEBUG)
    # create the application and the main window
    app = QtWidgets.QApplication(sys.argv)
    #app.setStyle(QtWidgets.QStyleFactory.create("fusion"))
    window = QtWidgets.QMainWindow()

    # setup ui
    ui = example.Ui_MainWindow()
    ui.setupUi(window)
    ui.bt_delay_popup.addActions([
        ui.actionAction,
        ui.actionAction_C
    ])
    ui.bt_instant_popup.addActions([
        ui.actionAction,
        ui.actionAction_C
    ])
    ui.bt_menu_button_popup.addActions([
        ui.actionAction,
        ui.actionAction_C
    ])
    window.setWindowTitle("BreezeDark example")

    # tabify dock widgets to show bug #6
    window.tabifyDockWidget(ui.dockWidget1, ui.dockWidget2)

    # setup stylesheet
    file = QFile(":/dark.qss")
    file.open(QFile.ReadOnly | QFile.Text)
    stream = QTextStream(file)
    app.setStyleSheet(stream.readAll())

    # auto quit after 2s when testing on travis-ci
    if "--travis" in sys.argv:
        QtCore.QTimer.singleShot(2000, app.exit)

    # run
    window.show()
    app.exec_()
Example #52
0
	def readTextFromFile(self, fileName=None, encoding=None):
		previousFileName = self._fileName
		if fileName:
			self._fileName = fileName
		openfile = QFile(self._fileName)
		openfile.open(QFile.ReadOnly)
		stream = QTextStream(openfile)
		encoding = encoding or globalSettings.defaultCodec
		if encoding:
			stream.setCodec(encoding)
		text = stream.readAll()
		openfile.close()

		modified = bool(encoding) and (self.editBox.toPlainText() != text)
		self.editBox.setPlainText(text)
		self.editBox.document().setModified(modified)

		if previousFileName != self._fileName:
			self.updateActiveMarkupClass()
			self.fileNameChanged.emit()
Example #53
0
def main():
    parser = get_parser()
    args = parser.parse_args()
    app = QApplication([])
    app.setWindowIcon(QIcon(QPixmap(":/logo_small")))
    app.setOrganizationName('Hardcoded Software')
    app.setApplicationName('moneyGuru')
    settings = QSettings()
    if args.debug:
        LOGGING_LEVEL = logging.DEBUG
    else:
        LOGGING_LEVEL = logging.DEBUG if adjust_after_deserialization(settings.value('DebugMode')) else logging.WARNING
    setupQtLogging(level=LOGGING_LEVEL, log_to_stdout=args.log_to_stdout)
    logging.debug('started in debug mode')
    if ISLINUX:
        stylesheetFile = QFile(':/stylesheet_lnx')
    else:
        stylesheetFile = QFile(':/stylesheet_win')
    stylesheetFile.open(QFile.ReadOnly)
    textStream = QTextStream(stylesheetFile)
    style = textStream.readAll()
    stylesheetFile.close()
    app.setStyleSheet(style)
    lang = settings.value('Language')
    locale_folder = op.join(BASE_PATH, 'locale')
    hscommon.trans.install_gettext_trans_under_qt(locale_folder, lang)
    # Many strings are translated at import time, so this is why we only import after the translator
    # has been installed
    from qt.app import MoneyGuru
    app.setApplicationVersion(MoneyGuru.VERSION)
    mgapp = MoneyGuru(filepath=args.filepath)
    install_excepthook('https://github.com/hsoft/moneyguru/issues')
    exec_result = app.exec_()
    del mgapp
    # Since PyQt 4.7.2, I had crashes on exit, and from reading the mailing list, it seems to be
    # caused by some weird crap about C++ instance being deleted with python instance still living.
    # The worst part is that Phil seems to say this is expected behavior. So, whatever, this
    # gc.collect() below is required to avoid a crash.
    gc.collect()
    return exec_result
Example #54
0
	def openFileMain(self, encoding=None):
		openfile = QFile(self.currentTab.fileName)
		openfile.open(QIODevice.ReadOnly)
		stream = QTextStream(openfile)
		if encoding:
			stream.setCodec(encoding)
		elif globalSettings.defaultCodec:
			stream.setCodec(globalSettings.defaultCodec)
		text = stream.readAll()
		openfile.close()
		markupClass = markups.get_markup_for_file_name(
			self.currentTab.fileName, return_class=True)
		self.currentTab.highlighter.docType = (markupClass.name if markupClass else '')
		self.currentTab.markup = self.getMarkup()
		if self.defaultMarkup:
			self.currentTab.highlighter.docType = self.defaultMarkup.name
		editBox = self.currentTab.editBox
		modified = bool(encoding) and (editBox.toPlainText() != text)
		editBox.setPlainText(text)
		self.setCurrentFile()
		editBox.document().setModified(modified)
		self.setWindowModified(modified)
Example #55
0
def main():
    # Initialise.

    defaultContext = "@default"
    fetchedTor = MetaTranslator()
    codecForTr = ''
    codecForSource = ''
    tsFileNames = []
    uiFileNames = []

    verbose = False
    noObsolete = False
    metSomething = False
    numFiles = 0
    standardSyntax = True
    metTsFlag = False
    tr_func = None
    translate_func = None

    # Parse the command line.

    for arg in sys.argv[1:]:
        if arg == "-ts":
            standardSyntax = False

    argc = len(sys.argv)
    i = 1

    while i < argc:
        arg = sys.argv[i]
        i += 1

        if arg == "-help":
            printUsage()
            sys.exit(0)

        if arg == "-version":
            sys.stderr.write("pylupdate5 v%s\n" % PYQT_VERSION_STR)
            sys.exit(0)

        if arg == "-noobsolete":
            noObsolete = True
            continue

        if arg == "-verbose":
            verbose = True
            continue

        if arg == "-ts":
            metTsFlag = True
            continue

        if arg == "-tr-function":
            if i >= argc:
                sys.stderr.write(
                        "pylupdate5 error: missing -tr-function name\n")
                sys.exit(2)

            tr_func = sys.argv[i]
            i += 1
            continue

        if arg == "-translate-function":
            if i >= argc:
                sys.stderr.write(
                        "pylupdate5 error: missing -translate-function name\n")
                sys.exit(2)

            translate_func = sys.argv[i]
            i += 1
            continue

        numFiles += 1

        fullText = ""

        if not metTsFlag:
            f = QFile(arg)

            if not f.open(QIODevice.ReadOnly):
                sys.stderr.write(
                        "pylupdate5 error: Cannot open file '%s'\n" % arg)
                sys.exit(1)

            t = QTextStream(f)
            fullText = t.readAll()
            f.close()

        if standardSyntax:
            oldDir = QDir.currentPath()
            QDir.setCurrent(QFileInfo(arg).path())

            fetchedTor = MetaTranslator()
            codecForTr = ''
            codecForSource = ''
            tsFileNames = []
            uiFileNames = []

            for key, value in proFileTagMap(fullText).items():
                for t in value.split(' '):
                    if key == "SOURCES":
                        fetchtr_py(QDir.current().absoluteFilePath(t),
                                fetchedTor, defaultContext, True,
                                codecForSource, tr_func, translate_func)
                        metSomething = True

                    elif key == "TRANSLATIONS":
                        tsFileNames.append(QDir.current().absoluteFilePath(t))
                        metSomething = True

                    elif key in ("CODEC", "DEFAULTCODEC", "CODECFORTR"):
                        codecForTr = t
                        fetchedTor.setCodec(codecForTr)

                    elif key == "CODECFORSRC":
                        codecForSource = t

                    elif key == "FORMS":
                        fetchtr_ui(QDir.current().absoluteFilePath(t),
                                fetchedTor, defaultContext, True)

            updateTsFiles(fetchedTor, tsFileNames, codecForTr, noObsolete,
                    verbose)

            if not metSomething:
                sys.stderr.write(
                        "pylupdate5 warning: File '%s' does not look like a "
                        "project file\n" % arg)
            elif len(tsFileNames) == 0:
                sys.stderr.write(
                        "pylupdate5 warning: Met no 'TRANSLATIONS' entry in "
                        "project file '%s'\n" % arg)

            QDir.setCurrent(oldDir)
        else:
            if metTsFlag:
                if arg.lower().endswith(".ts"):
                    fi = QFileInfo(arg)

                    if not fi.exists() or fi.isWritable():
                        tsFileNames.append(arg)
                    else:
                        sys.stderr.write(
                                "pylupdate5 warning: For some reason, I "
                                "cannot save '%s'\n" % arg)
                else:
                    sys.stderr.write(
                            "pylupdate5 error: File '%s' lacks .ts extension\n" % arg)
            else:
                fi = QFileInfo(arg)

                if fi.suffix() in ("py", "pyw"):
                    fetchtr_py(fi.absoluteFilePath(), fetchedTor,
                            defaultContext, True, codecForSource, tr_func,
                            translate_func)
                else:
                    fetchtr_ui(fi.absoluteFilePath(), fetchedTor,
                            defaultContext, True)

    if not standardSyntax:
        updateTsFiles(fetchedTor, tsFileNames, codecForTr, noObsolete, verbose)

    if numFiles == 0:
        printUsage()
        sys.exit(1)
Example #56
0
class LogsReadThread(QThread):
    MAX_INITIAL_SIZE = 2*1024*1024 # 2Mb

    updateLogs = pyqtSignal()

    def __init__(self, parent):
        QThread.__init__(self, parent)

        self.fCloseNow   = False
        self.fPurgeLogs  = False
        self.fRealParent = parent

        # -------------------------------------------------------------
        # Take some values from Logs Window

        self.LOG_FILE_JACK   = LogsW.LOG_FILE_JACK
        self.LOG_FILE_A2J    = LogsW.LOG_FILE_A2J
        self.LOG_FILE_LASH   = LogsW.LOG_FILE_LASH
        self.LOG_FILE_LADISH = LogsW.LOG_FILE_LADISH

        # -------------------------------------------------------------
        # Init logs

        if self.LOG_FILE_JACK is not None:
            self.fLogFileJACK = QFile(self.LOG_FILE_JACK)
            self.fLogFileJACK.open(QIODevice.ReadOnly)
            self.fLogStreamJACK = QTextStream(self.fLogFileJACK)
            self.fLogStreamJACK.setCodec("UTF-8")

            if self.fLogFileJACK.size() > self.MAX_INITIAL_SIZE:
                self.fLogStreamJACK.seek(self.fLogFileJACK.size() - self.MAX_INITIAL_SIZE)

        if self.LOG_FILE_A2J is not None:
            self.fLogFileA2J = QFile(self.LOG_FILE_A2J)
            self.fLogFileA2J.open(QIODevice.ReadOnly)
            self.fLogStreamA2J = QTextStream(self.fLogFileA2J)
            self.fLogStreamA2J.setCodec("UTF-8")

            if self.fLogFileA2J.size() > self.MAX_INITIAL_SIZE:
                self.fLogStreamA2J.seek(self.fLogFileA2J.size() - self.MAX_INITIAL_SIZE)

        if self.LOG_FILE_LASH is not None:
            self.fLogFileLASH = QFile(self.LOG_FILE_LASH)
            self.fLogFileLASH.open(QIODevice.ReadOnly)
            self.fLogStreamLASH = QTextStream(self.fLogFileLASH)
            self.fLogStreamLASH.setCodec("UTF-8")

            if self.fLogFileLASH.size() > self.MAX_INITIAL_SIZE:
                self.fLogStreamLASH.seek(self.fLogFileLASH.size() - self.MAX_INITIAL_SIZE)

        if self.LOG_FILE_LADISH is not None:
            self.fLogFileLADISH = QFile(self.LOG_FILE_LADISH)
            self.fLogFileLADISH.open(QIODevice.ReadOnly)
            self.fLogStreamLADISH = QTextStream(self.fLogFileLADISH)
            self.fLogStreamLADISH.setCodec("UTF-8")

            if self.fLogFileLADISH.size() > self.MAX_INITIAL_SIZE:
                self.fLogStreamLADISH.seek(self.fLogFileLADISH.size() - self.MAX_INITIAL_SIZE)

    def closeNow(self):
        self.fCloseNow = True

    def purgeLogs(self):
        self.fPurgeLogs = True

    def run(self):
        # -------------------------------------------------------------
        # Read logs and set text in main thread

        while not self.fCloseNow:
            if self.fPurgeLogs:
                if self.LOG_FILE_JACK:
                    self.fLogStreamJACK.flush()
                    self.fLogFileJACK.close()
                    self.fLogFileJACK.open(QIODevice.WriteOnly)
                    self.fLogFileJACK.close()
                    self.fLogFileJACK.open(QIODevice.ReadOnly)

                if self.LOG_FILE_A2J:
                    self.fLogStreamA2J.flush()
                    self.fLogFileA2J.close()
                    self.fLogFileA2J.open(QIODevice.WriteOnly)
                    self.fLogFileA2J.close()
                    self.fLogFileA2J.open(QIODevice.ReadOnly)

                if self.LOG_FILE_LASH:
                    self.fLogStreamLASH.flush()
                    self.fLogFileLASH.close()
                    self.fLogFileLASH.open(QIODevice.WriteOnly)
                    self.fLogFileLASH.close()
                    self.fLogFileLASH.open(QIODevice.ReadOnly)

                if self.LOG_FILE_LADISH:
                    self.fLogStreamLADISH.flush()
                    self.fLogFileLADISH.close()
                    self.fLogFileLADISH.open(QIODevice.WriteOnly)
                    self.fLogFileLADISH.close()
                    self.fLogFileLADISH.open(QIODevice.ReadOnly)

                self.fPurgeLogs = False

            else:
                if self.LOG_FILE_JACK:
                    textJACK = fixLogText(self.fLogStreamJACK.readAll()).strip()
                else:
                    textJACK = ""

                if self.LOG_FILE_A2J:
                    textA2J = fixLogText(self.fLogStreamA2J.readAll()).strip()
                else:
                    textA2J = ""

                if self.LOG_FILE_LASH:
                    textLASH = fixLogText(self.fLogStreamLASH.readAll()).strip()
                else:
                    textLASH = ""

                if self.LOG_FILE_LADISH:
                    textLADISH = fixLogText(self.fLogStreamLADISH.readAll()).strip()
                else:
                    textLADISH = ""

                self.fRealParent.setLogsText(textJACK, textA2J, textLASH, textLADISH)
                self.updateLogs.emit()

            if not self.fCloseNow:
                self.sleep(1)

        # -------------------------------------------------------------
        # Close logs before closing thread

        if self.LOG_FILE_JACK:
            self.fLogFileJACK.close()

        if self.LOG_FILE_A2J:
            self.fLogFileA2J.close()

        if self.LOG_FILE_LASH:
            self.fLogFileLASH.close()

        if self.LOG_FILE_LADISH:
            self.fLogFileLADISH.close()