Ejemplo n.º 1
0
 def __init__(self, parent=None, dat=None):
     """
     Node view/edit dock widget constructor
     """
     super(helpBrowserDock, self).__init__(parent=parent)
     self.setupUi(self)
     self.dat = dat
     self.mw = parent
     self.aboutButton.clicked.connect(self.showAbout.emit)
     self.contentsButton.clicked.connect(self.showContents)
     self.textBrowser = QWebView(self.tabWidget.widget(0))
     self.webviewLayout.addWidget(self.textBrowser)
     self.backButton.clicked.connect(self.textBrowser.back)
     self.forwardButton.clicked.connect(self.textBrowser.forward)
     self.helpPath = os.path.join(helpPath(), 'html')
     self.showContents()
     self.execButton.clicked.connect(self.runDebugCode)
     self.stopButton.clicked.connect(self.setStopTrue)
     self.loadButton.clicked.connect(self.loadDbgCode)
     self.saveButton.clicked.connect(self.saveDbgCode)
     self.ccButton.clicked.connect(self.clearCode)
     self.crButton.clicked.connect(self.clearRes)
     self.clearLogButton.clicked.connect(self.clearLogView)
     self.synhi = PythonHighlighter(self.pycodeEdit.document())
     self.stop = False
     self.timer = None
Ejemplo n.º 2
0
 def displayHelp(self):
     global web
     web = QWebView()
     file_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "Html/main_help.html"))
     local_url = QUrl.fromLocalFile(file_path)
     web.load(local_url)
     web.show()
Ejemplo n.º 3
0
 def __init__(self, url):
     super(Crawler, self).__init__(sys.argv)
     self.url = url
     self.web_view = QWebView()
     self.web_page = WebPage()
     self.web_view.loadFinished.connect(self.loadFinished)
     self.web_view.setPage(self.web_page)
     self.web_page.load(QUrl(self.url))
Ejemplo n.º 4
0
    def load(self):
        view = QWebView()
        view.load(QUrl("https://codechalleng.es"))
        view.showMaximized()
        vbox = QVBoxLayout()
        vbox.addWidget(view)

        self.setLayout(vbox)
 def update_map(self):
     self.journey_map = QWebView()
     self.journey_map.settings().setAttribute(
         QWebEngineSettings.JavascriptEnabled, True)
     self.journey_map.load(
         QUrl.fromLocalFile(
             QDir.current().absoluteFilePath('legend2.html')))
     self.tabs_widget.tab2.layout.addWidget(self.journey_map)
Ejemplo n.º 6
0
    def __init__(self, title, url, width, height, resizable, fullscreen,
                 min_size, confirm_quit, background_color, debug,
                 webview_ready):
        super(BrowserView, self).__init__()
        BrowserView.instance = self
        self.is_fullscreen = False
        self.confirm_quit = confirm_quit

        self._file_name_semaphor = threading.Semaphore(0)
        self._current_url_semaphore = threading.Semaphore()
        self._evaluate_js_semaphor = threading.Semaphore(0)

        self._evaluate_js_result = None
        self._current_url = None
        self._file_name = None

        self.resize(width, height)
        self.title = title
        self.setWindowTitle(title)

        # Set window background color
        self.background_color = QColor()
        self.background_color.setNamedColor(background_color)
        palette = self.palette()
        palette.setColor(self.backgroundRole(), self.background_color)
        self.setPalette(palette)

        if not resizable:
            self.setFixedSize(width, height)

        self.setMinimumSize(min_size[0], min_size[1])

        self.view = QWebView(self)
        self.view.setContextMenuPolicy(
            QtCore.Qt.NoContextMenu)  # disable right click context menu

        if url is not None:
            self.view.setUrl(QtCore.QUrl(url))

        self.setCentralWidget(self.view)

        self.load_url_trigger.connect(self.on_load_url)
        self.html_trigger.connect(self.on_load_html)
        self.dialog_trigger.connect(self.on_file_dialog)
        self.destroy_trigger.connect(self.on_destroy_window)
        self.fullscreen_trigger.connect(self.on_fullscreen)
        self.current_url_trigger.connect(self.on_current_url)
        self.evaluate_js_trigger.connect(self.on_evaluate_js)

        if fullscreen:
            self.toggle_fullscreen()

        self.move(QApplication.desktop().availableGeometry().center() -
                  self.rect().center())
        self.activateWindow()
        self.raise_()
        webview_ready.set()
        BrowserView.running = True
Ejemplo n.º 7
0
 def __init__(self):
     super().__init__()
     self.setSceneRect(0, 0, 1000, 800)
     web = QWebView()
     web.load(QtCore.QUrl("http://www.enib.fr"))
     #        web.load(QtCore.QUrl("https://pythonspot.com/pyqt5-browser/"))
     self.proxy = WebProxy()
     self.proxy.setWidget(web)
     self.addItem(self.proxy)
Ejemplo n.º 8
0
def addDocWidgets(obj):
    doc_master_tab = QWidget()
    doc_master = QVBoxLayout()
    doc_master_tab.setLayout(doc_master)

    obj.doc_view = QWebView()
    doc_master.addWidget(obj.doc_view)
    obj.doc_view.sizeHint = lambda: pg.QtCore.QSize(100, 100)

    obj.tab_widget.addTab(doc_master_tab, 'Documentation')
Ejemplo n.º 9
0
    def showDocumentation(self):
        if self._documentation is None:
            doc = QWebView(self)
            doc.load(QUrl("doc/html/index.html"))
            self._documentation = QDockWidget("Documentation", self)
            self._documentation.setWidget(doc)
            self._documentation.closeEvent = lambda _: self.hide_documentation(
            )

        self.addDockWidget(Qt.LeftDockWidgetArea, self._documentation)
Ejemplo n.º 10
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # 设置窗口标题
        self.setWindowTitle('My Browser')
        # 设置窗口图标
        self.setWindowIcon(QIcon('icons/penguin.png'))
        # 设置窗口大小900*600
        self.resize(1280, 600)
        self.show()

        # 设置浏览器
        self.browser = QWebView()
        url = 'http://my.jjwxc.net'
        # 指定打开界面的 URL
        self.browser.setUrl(QUrl(url))
        # 添加浏览器到窗口中
        self.setCentralWidget(self.browser)

        # 使用QToolBar创建导航栏,并使用QAction创建按钮
        # 添加导航栏
        navigation_bar = QToolBar('Navigation')
        # 设定图标的大小
        navigation_bar.setIconSize(QSize(16, 16))
        # 添加导航栏到窗口中
        self.addToolBar(navigation_bar)

        # QAction类提供了抽象的用户界面action,这些action可以被放置在窗口部件中
        # 添加前进、后退、停止加载和刷新的按钮
        back_button = QAction(QIcon('icons/back.png'), 'Back', self)
        next_button = QAction(QIcon('icons/next.png'), 'Forward', self)
        stop_button = QAction(QIcon('icons/cross.png'), 'stop', self)
        reload_button = QAction(QIcon('icons/renew.png'), 'reload', self)

        back_button.triggered.connect(self.browser.back)
        next_button.triggered.connect(self.browser.forward)
        stop_button.triggered.connect(self.browser.stop)
        reload_button.triggered.connect(self.browser.reload)

        # 将按钮添加到导航栏上
        navigation_bar.addAction(back_button)
        navigation_bar.addAction(next_button)
        navigation_bar.addAction(stop_button)
        navigation_bar.addAction(reload_button)

        # 添加URL地址栏
        self.urlbar = QLineEdit()
        # 让地址栏能响应回车按键信号
        self.urlbar.returnPressed.connect(self.navigate_to_url)

        navigation_bar.addSeparator()
        navigation_bar.addWidget(self.urlbar)

        # 让浏览器相应url地址的变化
        self.browser.urlChanged.connect(self.renew_urlbar)
Ejemplo n.º 11
0
    def __init__(self):
        super().__init__()

        left_box_1 = oasysgui.widgetBox(self.controlArea,
                                        "X0h Request Form",
                                        addSpace=True,
                                        orientation="vertical",
                                        width=610,
                                        height=640)

        html = self.clear_input_form(
            HttpManager.send_xray_server_direct_request(
                "/cgi/www_form.exe?template=X0h_form.htm"))

        self.x0h_input = QWebView(left_box_1)
        self.x0h_input.setHtml(html)

        left_box_1.layout().addWidget(self.x0h_input)

        self.x0h_input.setFixedHeight(540)
        self.x0h_input.setFixedWidth(590)

        button = gui.button(self.controlArea,
                            self,
                            "Get X0h!",
                            callback=self.submit)
        button.setFixedHeight(30)

        gui.rubber(self.controlArea)

        self.tabs = []
        self.tabs_widget = oasysgui.tabWidget(self.mainArea)
        self.initializeTabs()

        self.x0h_output = QWebView(self.tabs[0])

        self.tabs[0].layout().addWidget(self.x0h_output)

        self.x0h_output.setFixedHeight(630)
        self.x0h_output.setFixedWidth(740)
Ejemplo n.º 12
0
    def __setupUI(self):
        # add WebView widget
        self.web = QWebView()
        self.web.setUrl(QUrl(THEORY))
        self.ui.gridLayout_5.addWidget(self.web)

        # add setting widget
        self.Form = QtWidgets.QWidget()
        self.settings_ui = setting_ui()
        self.settings_ui.setupUi(self.Form)
        self.ui.gridLayout_5.addWidget(self.Form)

        self.Form.close()

        # add result widget
        self.Result = QtWidgets.QWidget()
        self.result_ui = result_ui()
        self.result_ui.setupUi(self.Result)
        self.ui.resultGridLayout.addWidget(self.Result)
        self.Result.close()

        # action menu clicked
        self.ui.actionSave_Result.triggered.connect(self.save_result)
        self.ui.actionOpenProject.triggered.connect(self.load_result)
        self.ui.actionNew.triggered.connect(self.new)
        self.ui.actionExit.triggered.connect(self.exit)

        self.ui.theoryButton.setEnabled(False)
        self.ui.theoryCombobox.setEnabled(False)
        self.ui.tempCombobox.setCurrentIndex(2)
        self.ui.theoryButton.clicked.connect(self.__theory_button_checked)
        self.ui.settingsButton.clicked.connect(self.__settings_button_checked)
        self.ui.measurmentButton.clicked.connect(
            self.__measurment_buttton_checked)
        self.ui.theoryCombobox.currentTextChanged.connect(self.__theory_chose)
        self.ui.tempCombobox.currentTextChanged.connect(self.__fullfill_table)

        self.settings_ui.calculateButton.clicked.connect(
            self.__collect_data_to_process)
        self.settings_ui.calculateButton.setEnabled(False)
        self.settings_ui.calculateButton.setStyleSheet(
            "color: rgb(255, 0, 0);")
        self.settings_ui.addliquidButton.clicked.connect(
            self.__add_liquid_button_clicked)

        self.result_ui.resultTable.setColumnCount(4)
        self.result_ui.resultTable.setHorizontalHeaderLabels(
            HORIZONTAL_HEADER_RESULT)
        self.result_ui.resultTable.setRowCount(5)
Ejemplo n.º 13
0
    def __init__(self):
        """
            Create main window with browser and a button
        """
        super(BrowserWidget, self).__init__()

        self.layout = QtWidgets.QHBoxLayout()
        self.setLayout(self.layout)

        self.webview = QWebView()
        self.layout.addWidget(self.webview)

        self.webview.urlChanged.connect(self.url_changed)

        self.set_form_handler(self._default_form_handler)
Ejemplo n.º 14
0
    def __init__(self, rast):
        self.rast = rast
        QMainWindow.__init__(self)
        self.setMinimumSize(800, 900)
        self.setMaximumSize(800, 900)
        self.webView = QWebView()
        self.setCentralWidget(self.webView)
        self.setWindowTitle("Mesaj Önizleme")
        self.setWindowIcon(QIcon(Icons["Standart"]))

        if (os.path.isfile("C:/WhatsMessageSender/WhatsAppGui/index_" +
                           str(self.rast) + ".html")):
            self.webView.load(
                QUrl.fromLocalFile("C:/WhatsMessageSender/WhatsAppGui/index_" +
                                   str(self.rast) + ".html"))
        else:
            self.webView.load(
                QUrl.fromLocalFile(os.getcwd() + "/WhatsAppGui/index_" +
                                   str(self.rast) + ".html"))
Ejemplo n.º 15
0
    def __init__(self, title, url, width, height, icon, resizable, fullscreen,
                 min_size):
        super(BrowserView, self).__init__()
        BrowserView.instance = self
        self.is_fullscreen = False

        self._file_name_semaphor = threading.Semaphore(0)
        self._current_url_semaphore = threading.Semaphore()

        self.resize(width, height)
        self.setWindowTitle(title)

        if not resizable:
            self.setFixedSize(width, height)

        self.setMinimumSize(min_size[0], min_size[1])

        #self.view = QWebView(self)
        self.view = QWebView(self)
        self.view.setContextMenuPolicy(
            Qt.NoContextMenu)  # disable right click context menu
        if icon is not None:
            self.setWindowIcon(QIcon(icon))
        if url is not None:
            self.view.setUrl(QUrl(url))

        self.setCentralWidget(self.view)
        self.load_url_trigger.connect(self._handle_load_url)
        self.html_trigger.connect(self._handle_load_html)
        #self.dialog_trigger.connect(self._handle_file_dialog)
        self.destroy_trigger.connect(self._handle_destroy_window)
        self.fullscreen_trigger.connect(self._handle_fullscreen)
        #self.current_url_trigger.connect(self._handle_current_url)

        if fullscreen:
            self.toggle_fullscreen()

        self.move(QApplication.desktop().availableGeometry().center() -
                  self.rect().center())
        self.activateWindow()
        self.raise_()
Ejemplo n.º 16
0
    def init_ui(self):
        self.statusBar().showMessage('Ready')
        self.setGeometry(640, 480, 640, 480)
        self.setWindowTitle('Vim screenshot')
        widget = QWidget()
        main_layout = QVBoxLayout()
        widget.setLayout(main_layout)
        self.setCentralWidget(widget)

        label_str = str(self._argv)
        label_str = "Label"
        label = QLabel(label_str)
        main_layout.addWidget(label)

        self.web_view = QWebView()
        self.update_html()
        main_layout.addWidget(self.web_view)

        spacer = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Expanding)
        main_layout.addItem(spacer)

        styles = self.get_styles()
        self.color_cbox = QComboBox()
        for style in styles:
            self.color_cbox.addItem(style)
        main_layout.addWidget(self.color_cbox)
        self.color_cbox.currentTextChanged.connect(self.style_changed)

        self.capture_btn = QPushButton("Take Screenshot")
        self.capture_btn.clicked.connect(self.on_capture_clicked)
        main_layout.addWidget(self.capture_btn)

        self.copy_cc_btn = QPushButton("Copy to clipboard")
        self.copy_cc_btn.clicked.connect(self.on_copy_to_clipboard)
        main_layout.addWidget(self.copy_cc_btn)

        self.setLayout(main_layout)
        self.show()
Ejemplo n.º 17
0
    def __init__(self, makura_reader):
        super().__init__()
        self.logger = logging.getLogger(__name__)
        self.logger.info("Creating application instance.")

        # Setup layout
        self.view = QWebView()
        layout = QVBoxLayout()
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.view)
        self.setLayout(layout)

        # Setup bridge to JS
        self.channel = QWebChannel()
        self.channel.registerObject("wrapper", self)
        self.page = self.view.page()
        self.page.setWebChannel(self.channel)

        self.makura_reader = makura_reader
        self.makura_reader.new_page_callback = self.reload_book_page
        self.tokens = None
        self.page_vocabulary = []
        self.translation_toggled = False
Ejemplo n.º 18
0
    def __init__(self):
        sys.excepthook = self.excepthook
        INIPATH = None
        usage = "usage: %prog [options] myfile.ui"
        parser = OptionParser(usage=usage)
        parser.disable_interspersed_args()
        parser.add_options(options)
        # remove [-ini filepath] that linuxcnc adds if being launched as a screen
        # keep a reference of that path
        for i in range(len(sys.argv)):
            if sys.argv[i] == '-ini':
                # delete -ini
                del sys.argv[i]
                # pop out the ini path
                INIPATH = sys.argv.pop(i)
                break

        (opts, args) = parser.parse_args()

        if sys.version_info.major > 2:
            # so web engine can load local images
            sys.argv.append("--disable-web-security")

        # initialize QApp so we can pop up dialogs now.
        self.app = QtWidgets.QApplication(sys.argv)

        # we import here so that the QApp is initialized before
        # the Notify library is loaded because it uses DBusQtMainLoop
        # DBusQtMainLoop must be initialized after to work properly
        from qtvcp import qt_makepins, qt_makegui

        # ToDo: pass specific log levels as an argument, or use an INI setting
        if opts.debug:
            # Log level defaults to INFO, so set lower if in debug mode
            logger.setGlobalLevel(logger.DEBUG)
        if opts.verbose:
            # Log level defaults to INFO, so set lowest if in verbose mode
            logger.setGlobalLevel(logger.VERBOSE)

        # a specific path has been set to load from or...
        # no path set but -ini is present: default qtvcp screen...or
        # oops error
        if args:
            basepath = args[0]
        elif INIPATH:
            basepath = "qt_cnc"
        else:
            PATH.set_paths()

        # set paths using basename
        PATH.set_paths(basepath, bool(INIPATH))

        # keep track of python version during this transition
        if sys.version_info.major > 2:
            ver = 'Python 3'
        else:
            ver = 'Python 2'

        #################
        # Screen specific
        #################
        if INIPATH:
            LOG.info(
                'green<Building A Linuxcnc Main Screen with {}>'.format(ver))
            import linuxcnc
            # internationalization and localization
            import locale, gettext
            # pull info from the INI file
            self.inifile = linuxcnc.ini(INIPATH)
            self.inipath = INIPATH
            # screens require more path info
            PATH.add_screen_paths()

            # International translation
            locale.setlocale(locale.LC_ALL, '')
            locale.bindtextdomain(PATH.DOMAIN, PATH.LOCALEDIR)
            gettext.install(PATH.DOMAIN, localedir=PATH.LOCALEDIR)
            gettext.bindtextdomain(PATH.DOMAIN, PATH.LOCALEDIR)

            # if no handler file specified, use stock test one
            if not opts.usermod:
                LOG.info('No handler file specified on command line')
                target = os.path.join(PATH.CONFIGPATH,
                                      '%s_handler.py' % PATH.BASENAME)
                source = os.path.join(PATH.SCREENDIR,
                                      'tester/tester_handler.py')
                if PATH.HANDLER is None:
                    message = ("""
Qtvcp encountered an error; No handler file was found.
Would you like to copy a basic handler file into your config folder?
This handler file will allow display of your screen and basic keyboard jogging.

The new handlerfile's path will be:
%s

Pressing cancel will close linuxcnc.""" % target)
                    rtn = QtWidgets.QMessageBox.critical(
                        None, "QTVCP Error", message, QtWidgets.QMessageBox.Ok
                        | QtWidgets.QMessageBox.Cancel)
                    if rtn == QtWidgets.QMessageBox.Ok:
                        try:
                            shutil.copy(source, target)
                        except IOError as e:
                            LOG.critical("Unable to copy handler file. %s" % e)
                            sys.exit(0)
                        except:
                            LOG.critical(
                                "Unexpected error copying handler file:",
                                sys.exc_info())
                            sys.exit(0)
                        opts.usermod = PATH.HANDLER = target
                    else:
                        LOG.critical(
                            'No handler file found or specified. User requested stopping'
                        )
                else:
                    opts.usermod = PATH.HANDLER

            # specify the HAL component name if missing
            if opts.component is None:
                LOG.info(
                    'No HAL component base name specified on command line using: {}'
                    .format(PATH.BASENAME))
                opts.component = PATH.BASENAME

        #################
        # VCP specific
        #################
        else:
            LOG.info('green<Building A VCP Panel with {}>'.format(ver))
            # if no handler file specified, use stock test one
            if not opts.usermod:
                LOG.info('No handler file specified - using {}'.format(
                    PATH.HANDLER))
                opts.usermod = PATH.HANDLER

            # specify the HAL component name if missing
            if opts.component is None:
                LOG.info(
                    'No HAL component base name specified - using: {}'.format(
                        PATH.BASENAME))
                opts.component = PATH.BASENAME

        ##############
        # Build ui
        ##############

        #if there was no component name specified use the xml file name
        if opts.component is None:
            opts.component = PATH.BASENAME

        # initialize HAL
        try:
            self.halcomp = hal.component(opts.component)
            self.hal = QComponent(self.halcomp)
        except:
            LOG.critical(
                "Asking for a HAL component using a name that already exists?")
            raise Exception(
                '"Asking for a HAL component using a name that already exists?'
            )

        # initialize the window
        window = qt_makegui.VCPWindow(self.hal, PATH)

        if opts.useropts:
            window.USEROPTIONS_ = opts.useropts
        else:
            window.USEROPTIONS_ = None

        # load optional user handler file
        if opts.usermod:
            LOG.debug('Loading the handler file')
            window.load_extension(opts.usermod)
            try:
                window.web_view = QWebView()
            except:
                window.web_view = None
            # do any class patching now
            if "class_patch__" in dir(window.handler_instance):
                window.handler_instance.class_patch__()
            # add filter to catch keyboard events
            LOG.debug('Adding the key events filter')
            myFilter = qt_makegui.MyEventFilter(window)
            self.app.installEventFilter(myFilter)

        # actually build the widgets
        window.instance()

        # make QT widget HAL pins
        self.panel = qt_makepins.QTPanel(self.hal, PATH, window, opts.debug)

        # call handler file's initialized function
        if opts.usermod:
            if "initialized__" in dir(window.handler_instance):
                LOG.debug(
                    '''Calling the handler file's initialized__ function''')
                window.handler_instance.initialized__()
        # All Widgets should be added now - synch them to linuxcnc
        STATUS.forced_update()

        # call a HAL file after widgets built
        if opts.halfile:
            if opts.halfile[-4:] == ".tcl":
                cmd = ["haltcl", opts.halfile]
            else:
                cmd = ["halcmd", "-f", opts.halfile]
            res = subprocess.call(cmd, stdout=sys.stdout, stderr=sys.stderr)
            if res:
                print >> sys.stderr, "'%s' exited with %d" % (' '.join(cmd),
                                                              res)
                self.shutdown()

        # User components are set up so report that we are ready
        LOG.debug('Set HAL ready')
        self.halcomp.ready()

        # embed us into an X11 window (such as AXIS)
        if opts.parent:
            window = xembed.reparent_qt_to_x11(window, opts.parent)
            forward = os.environ.get('AXIS_FORWARD_EVENTS_TO', None)
            LOG.critical('Forwarding events to AXIS is not well tested yet')
            if forward:
                xembed.XEmbedFowarding(window, forward)

        # push the window id for embedment into an external program
        if opts.push_XID:
            wid = int(window.winId())
            print >> sys.stdout, wid
            sys.stdout.flush()

        # for window resize and or position options
        if "+" in opts.geometry:
            LOG.debug('-g option: moving window')
            try:
                j = opts.geometry.partition("+")
                pos = j[2].partition("+")
                window.move(int(pos[0]), int(pos[2]))
            except Exception as e:
                LOG.critical("With -g window position data:\n {}".format(e))
                parser.print_help()
                self.shutdown()
        if "x" in opts.geometry:
            LOG.debug('-g option: resizing')
            try:
                if "+" in opts.geometry:
                    j = opts.geometry.partition("+")
                    t = j[0].partition("x")
                else:
                    t = opts.geometry.partition("x")
                window.resize(int(t[0]), int(t[2]))
            except Exception as e:
                LOG.critical("With -g window resize data:\n {}".format(e))
                parser.print_help()
                self.shutdown()

        # always on top
        if opts.always_top:
            window.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)

        # theme (styles in QT speak) specify a qss file
        if opts.theme:
            window.apply_styles(opts.theme)
        # appy qss file or default theme
        else:
            window.apply_styles()

        # title
        if INIPATH:
            title = 'QTvcp-Screen-%s' % opts.component
        else:
            title = 'QTvcp-Panel-%s' % opts.component
        window.setWindowTitle(title)

        LOG.debug('Show window')
        # maximize
        if opts.maximum:
            window.showMaximized()
        # fullscreen
        elif opts.fullscreen:
            window.showFullScreen()
        else:
            self.panel.set_preference_geometry()
        window.show()
        if INIPATH:
            self.postgui()

        # catch control c and terminate signals
        signal.signal(signal.SIGTERM, self.shutdown)
        signal.signal(signal.SIGINT, self.shutdown)

        if opts.usermod and "before_loop__" in dir(window.handler_instance):
            LOG.debug('''Calling the handler file's before_loop__ function''')
            window.handler_instance.before_loop__()

        LOG.info('Preference path: {}'.format(PATH.PREFS_FILENAME))
        # start loop
        self.app.exec_()

        # now shut it all down
        self.shutdown()
Ejemplo n.º 19
0
    def open_webbrowser(self):

        self.web = QWebView()
        self.web.load(QUrl("https://www.pocketape.com"))
        self.web.show()
Ejemplo n.º 20
0
    def initUI(self):
        ## Information Labels:
        infoLabel1 = QLabel()  ## NAME
        infoLabel1.setText(con[self.conNum - 1][0][0]["name"].upper())
        infoLabel1.setFont(QFont(fonts[1], rPix(25), weight=75))

        infoLabel2 = QLabel()
        infoLabel2.setText(con[self.conNum - 1][1][0]["name"].upper())
        infoLabel2.setFont(QFont(fonts[1], rPix(25), weight=75))

        infoLabel3 = QLabel()  ## SECTION
        if con[self.conNum - 1][0][1]["section"] == con[self.conNum -
                                                        1][1][1]["section"]:
            infoLabel3.setText(
                str(con[self.conNum - 1][2]["grade"]) + " - " +
                con[self.conNum - 1][0][1]["section"])
        else:
            infoLabel3.setText(
                str(con[self.conNum - 1][2]["grade"]) + " - " +
                con[self.conNum - 1][0][1]["section"] + " & " +
                con[self.conNum - 1][1][1]["section"])
        infoLabel3.setFont(QFont(fonts[0], rPix(15), weight=75))

        infoLabelLayout = [QHBoxLayout(),
                           QHBoxLayout(),
                           QHBoxLayout()
                           ]  ## Centralize Using Horizontal Box Layout
        for i in infoLabelLayout:
            i.setContentsMargins(0, 0, 0, 0)
            i.setSpacing(0)
        infoLabelLayout[0].addStretch()
        infoLabelLayout[0].addWidget(infoLabel1)
        infoLabelLayout[0].addStretch()
        infoLabelLayout[1].addStretch()

        infoLabelLayout[1].addWidget(infoLabel2)
        infoLabelLayout[1].addStretch()

        infoLabelLayout[2].addStretch()
        infoLabelLayout[2].addWidget(infoLabel3)
        infoLabelLayout[2].addStretch()

        ## Information Layout:
        infoLayout = QVBoxLayout()
        infoLayout.setSpacing(10)
        for i in infoLabelLayout:
            infoLayout.addLayout(i)
        ## Information Frame:
        infoFrame = QFrame()
        infoFrame.setFixedSize(rPix(780), rPix(205))
        infoFrame.setObjectName("infoFrame")
        infoFrame.setStyleSheet(
            ".QFrame#infoFrame{border-bottom:2px #A9A9A9;background:" +
            self.ui[(self.conNum - 1) % 4] + ";border-radius : 5px}")
        infoFrame.setLayout(infoLayout)

        ## Score Sheet Webview:
        if "-nosheet" in sys.argv:
            self.sheet = QFrame()
            self.sheet.setFixedSize(rPix(760), rPix(630))
        else:
            self.sheet = QWebView()
            self.sheet.loadFinished.connect(self.pageLoaded)
            _path = QUrl.fromLocalFile(currentDir() + "/resources/sheet.html")
            self.sheet.load(_path)

        ## Navigation Buttons
        resetButton = ImageButton("resources/img/buttons/reset",
                                  rPix(30),
                                  rPix(30),
                                  toggle=False,
                                  tooltip="<b>Reset Scores</b>")

        saveButton = ImageButton("resources/img/buttons/save",
                                 rPix(30),
                                 rPix(30),
                                 toggle=False,
                                 tooltip="<b>Save Scores</b>")

        if "-nosheet" not in sys.argv:
            resetButton.clicked.connect(self.resetScores)
            saveButton.clicked.connect(self.saveScores)

        ## Sheet Navigation Layout:
        sheetNavigationLayout = QHBoxLayout()
        sheetNavigationLayout.addStretch()
        sheetNavigationLayout.addWidget(resetButton)
        sheetNavigationLayout.addWidget(saveButton)

        ## Layout of Sheet Frame:
        sheetLayout = QVBoxLayout()
        sheetLayout.setContentsMargins(rPix(15), rPix(10), rPix(10), rPix(10))
        sheetLayout.setSpacing(rPix(5))
        sheetLayout.addWidget(self.sheet)
        sheetLayout.addLayout(sheetNavigationLayout)

        ## Sheet Frame:
        sheetFrame = QFrame()
        sheetFrame.setFixedSize(rPix(780), rPix(650))
        sheetFrame.setObjectName("sheetFrame")
        sheetFrame.setStyleSheet(
            ".QFrame#sheetFrame{border-bottom:2px #A9A9A9;background:" +
            self.ui[(self.conNum - 1) % 4] + ";border-radius : 5px}")
        sheetFrame.setLayout(sheetLayout)

        ## Left Placeholder Layout:
        leftLayout = QVBoxLayout()
        leftLayout.setContentsMargins(0, 0, 0, 0)
        leftLayout.setSpacing(10)
        leftLayout.addWidget(infoFrame)
        leftLayout.addWidget(sheetFrame)

        ## Previous Image Button:
        prevImage = ImageButton("resources/img/buttons/prevImg",
                                rPix(100),
                                rPix(845),
                                toggle=False,
                                tooltip="<b>Previous Image</b>")
        prevImage.clicked.connect(self.prevImageEvt)

        ## Next Image Button:
        nextImage = ImageButton("resources/img/buttons/nextImg",
                                rPix(100),
                                rPix(845),
                                toggle=False,
                                tooltip="<b>Next Image</b>")
        nextImage.clicked.connect(self.nextImageEvt)
        ##Con Num Label:
        conNumLabel = QLabel(str(self.conNum))
        conNumLabel.setFont(QFont(fonts[0], rPix(30)))

        ##Con Num Layout:
        conNumLabelLayout = QHBoxLayout()
        conNumLabelLayout.setContentsMargins(0, 0, 0, 0)
        conNumLabelLayout.setSpacing(0)
        conNumLabelLayout.addStretch()
        conNumLabelLayout.addWidget(conNumLabel)
        conNumLabelLayout.addStretch()

        ## Label for info
        self.infoconLabel = QLabel("NO IMAGE LOADED")
        self.infoconLabel.setFont(QFont(fonts[1], rPix(10)))

        ##Con Num Layout:
        infoconLabelLayout = QHBoxLayout()
        infoconLabelLayout.setContentsMargins(0, 0, 0, 0)
        infoconLabelLayout.setSpacing(0)
        infoconLabelLayout.addStretch()
        infoconLabelLayout.addWidget(self.infoconLabel)
        infoconLabelLayout.addStretch()

        ##Vertical Layout for conNum and Info
        vertConInfoLayout = QVBoxLayout()
        vertConInfoLayout.setContentsMargins(0, 0, 0, 0)
        vertConInfoLayout.setSpacing(rPix(20))
        vertConInfoLayout.addStretch()
        vertConInfoLayout.addLayout(conNumLabelLayout)
        vertConInfoLayout.addLayout(infoconLabelLayout)
        vertConInfoLayout.addStretch()

        ## Image Info Frame:
        infoFrame = ImageFrame()
        _infoPixmap = QPixmap("resources/img/infoFrame.png")
        infoFrame.setPixmap(
            _infoPixmap.scaled(rPix(560), rPix(120), Qt.KeepAspectRatio))
        infoFrame.setLayout(vertConInfoLayout)

        ## Image Info Filler:
        infoFiller = QLabel()
        infoFiller.setFixedSize(rPix(560), rPix(727))

        ## Image Info Layout:
        infoLayout = QVBoxLayout()
        infoLayout.addWidget(infoFiller)
        infoLayout.addWidget(infoFrame)
        infoLayout.setContentsMargins(0, 0, 0, 0)
        infoLayout.setSpacing(0)

        ## Image Navigation/Info Layout:
        navigLayout = QHBoxLayout()
        navigLayout.addWidget(prevImage)
        navigLayout.addLayout(infoLayout)
        navigLayout.addWidget(nextImage)
        navigLayout.setContentsMargins(0, 0, 0, 0)
        navigLayout.setSpacing(0)

        ## Image Navigation/Info Frame:
        navigFrame = QFrame()
        navigFrame.setObjectName("noframe")
        navigFrame.setStyleSheet(styles["noframe"])
        navigFrame.setLayout(navigLayout)

        ## Image Frame:
        self.imageFrame = ImageFrame(fade=True)
        try:  ##Checks if Pixmap is available, then sets it
            self.imageFrame.setPixmap(self.pixmaps[str(
                self.conNum)][self.imgNum])
            self.infoconLabel.setText(order[self.imgNum])
        except:
            pass
        self.imageFrame.setFixedSize(rPix(760), rPix(845))

        #self.imageFrame.setLayout(navigLayout)
        ## Image Stacked Layout:
        imageStacked = QStackedLayout()
        imageStacked.setStackingMode(QStackedLayout.StackAll)
        imageStacked.setContentsMargins(0, 0, 0, 0)
        imageStacked.setSpacing(0)
        imageStacked.insertWidget(0, self.imageFrame)
        imageStacked.insertWidget(1, navigFrame)

        ## Image Placeholder Layout:
        imagePlaceholderLayout = QHBoxLayout()
        imagePlaceholderLayout.setContentsMargins(rPix(15), rPix(10), rPix(10),
                                                  rPix(10))
        imagePlaceholderLayout.setSpacing(0)
        imagePlaceholderLayout.addLayout(imageStacked)

        ## Image Placeholder Frame
        imagePlaceholderFrame = QFrame()
        imagePlaceholderFrame.setObjectName("imageplaceholder")
        imagePlaceholderFrame.setStyleSheet(
            ".QFrame#imageplaceholder{border-bottom:2px #A9A9A9;background:" +
            self.ui[(self.conNum - 1) % 4] + ";border-radius : 5px}")
        imagePlaceholderFrame.setFixedSize(rPix(780), rPix(865))
        imagePlaceholderFrame.setLayout(imagePlaceholderLayout)

        ## Main Layout:
        mainLayout = QHBoxLayout()
        mainLayout.setContentsMargins(rPix(10), rPix(10), rPix(10), rPix(10))
        mainLayout.setSpacing(10)

        ## Dynamic Layouting (based on Contestant Number)
        if self.conNum <= (tconNum / 2):
            mainLayout.addLayout(leftLayout)
            mainLayout.addWidget(imagePlaceholderFrame)
        else:
            mainLayout.addWidget(imagePlaceholderFrame)
            mainLayout.addLayout(leftLayout)

        ## Background Frame:
        mainFrame = ImageFrame()
        mainFrame.setPixmap(self.bg)
        mainFrame.setLayout(mainLayout)

        ## Placeholder Layout:
        placeholderLayout = QHBoxLayout()
        placeholderLayout.setContentsMargins(0, 0, 0, 0)
        placeholderLayout.setSpacing(0)
        placeholderLayout.addWidget(mainFrame)

        self.setLayout(placeholderLayout)
Ejemplo n.º 21
0
    def __init__(self):
        super().__init__()

        left_box_1 = oasysgui.widgetBox(self.controlArea,
                                        "X0h Request Form",
                                        addSpace=True,
                                        orientation="vertical",
                                        width=400,
                                        height=630)

        left_box_2 = oasysgui.widgetBox(left_box_1,
                                        "X-rays",
                                        addSpace=True,
                                        orientation="horizontal",
                                        width=380,
                                        height=110)

        left_box_2_1 = oasysgui.widgetBox(left_box_2,
                                          "",
                                          addSpace=True,
                                          orientation="vertical",
                                          width=150,
                                          height=110)

        gui.radioButtons(
            left_box_2_1,
            self,
            "xway", ["Wavelength (Å)", "Energy (keV)", "Characteristic line"],
            callback=self.set_xway)

        self.box_wave = oasysgui.widgetBox(left_box_2,
                                           "",
                                           addSpace=True,
                                           orientation="vertical",
                                           width=190)
        gui.separator(self.box_wave, height=10)
        gui.lineEdit(self.box_wave,
                     self,
                     "wave",
                     label="",
                     labelWidth=0,
                     addSpace=False,
                     valueType=float,
                     orientation="horizontal")

        self.box_line = oasysgui.widgetBox(left_box_2,
                                           "",
                                           addSpace=True,
                                           orientation="horizontal",
                                           width=190,
                                           height=110)
        gui.separator(self.box_line, height=120)
        XRayServerGui.combobox_text(self.box_line,
                                    self,
                                    "line",
                                    label="",
                                    labelWidth=0,
                                    items=self.get_lines(),
                                    sendSelectedValue=True,
                                    orientation="horizontal",
                                    selectedValue=self.line)

        button = gui.button(self.box_line, self, "?", callback=self.help_lines)
        button.setFixedWidth(15)

        self.set_xway()

        left_box_3 = oasysgui.widgetBox(left_box_1,
                                        "Target",
                                        addSpace=True,
                                        orientation="horizontal",
                                        width=380,
                                        height=140)

        left_box_3_1 = oasysgui.widgetBox(left_box_3,
                                          "",
                                          addSpace=True,
                                          orientation="vertical",
                                          width=125,
                                          height=110)

        gui.radioButtons(left_box_3_1,
                         self,
                         "coway",
                         ["Crystal", "Other Material", "Chemical Formula"],
                         callback=self.set_coway)

        self.box_crystal = oasysgui.widgetBox(left_box_3,
                                              "",
                                              addSpace=True,
                                              orientation="horizontal",
                                              width=210)
        XRayServerGui.combobox_text(self.box_crystal,
                                    self,
                                    "code",
                                    label="",
                                    labelWidth=0,
                                    items=self.get_crystals(),
                                    sendSelectedValue=True,
                                    orientation="horizontal",
                                    selectedValue=self.code)

        button = gui.button(self.box_crystal,
                            self,
                            "?",
                            callback=self.help_crystals)
        button.setFixedWidth(15)

        self.box_other = oasysgui.widgetBox(left_box_3,
                                            "",
                                            addSpace=True,
                                            orientation="horizontal",
                                            width=210)
        gui.separator(self.box_other, height=75)
        XRayServerGui.combobox_text(self.box_other,
                                    self,
                                    "amor",
                                    label="",
                                    labelWidth=0,
                                    items=self.get_others(),
                                    sendSelectedValue=True,
                                    orientation="horizontal",
                                    selectedValue=self.amor)

        button = gui.button(self.box_other,
                            self,
                            "?",
                            callback=self.help_others)
        button.setFixedWidth(15)

        self.box_chemical = oasysgui.widgetBox(left_box_3,
                                               "",
                                               addSpace=True,
                                               orientation="vertical",
                                               width=210,
                                               height=140)
        gui.separator(self.box_chemical, height=50)

        gui.lineEdit(self.box_chemical,
                     self,
                     "chem",
                     label=" ",
                     labelWidth=1,
                     addSpace=False,
                     valueType=str,
                     orientation="horizontal",
                     callback=self.set_rho)
        gui.lineEdit(self.box_chemical,
                     self,
                     "rho",
                     label=u"\u03C1" + " (g/cm3)",
                     labelWidth=60,
                     addSpace=False,
                     valueType=float,
                     orientation="horizontal")

        self.set_coway()

        left_box_4 = oasysgui.widgetBox(left_box_1,
                                        "Reflection",
                                        addSpace=True,
                                        orientation="horizontal",
                                        width=380,
                                        height=60)

        gui.lineEdit(left_box_4,
                     self,
                     "i1",
                     label="Miller indices",
                     labelWidth=200,
                     addSpace=False,
                     valueType=int,
                     orientation="horizontal")
        gui.lineEdit(left_box_4,
                     self,
                     "i2",
                     label=" ",
                     labelWidth=1,
                     addSpace=False,
                     valueType=int,
                     orientation="horizontal")
        gui.lineEdit(left_box_4,
                     self,
                     "i3",
                     label=" ",
                     labelWidth=1,
                     addSpace=False,
                     valueType=int,
                     orientation="horizontal")

        left_box_5 = oasysgui.widgetBox(
            left_box_1,
            "Database Options for dispersion corrections df1, df2",
            addSpace=True,
            orientation="vertical",
            width=380,
            height=185)

        gui.radioButtons(left_box_5, self, "df1df2", [
            "Auto (Henke at low energy, X0h at mid, Brennan-Cowan\nat high)",
            "Use X0h data (5-25 keV or 0.5-2.5 A), recommended for\nBragg diffraction",
            "Use Henke data (0.01-30 keV or 0.4-1200 A),\nrecommended for soft x-rays",
            "Use Brennan-Cowan data (0.03-700 keV or 0.02-400 A)",
            "Compare results for all of the above sources"
        ])

        left_box_6 = oasysgui.widgetBox(left_box_1,
                                        "Output Options",
                                        addSpace=True,
                                        orientation="vertical",
                                        width=380,
                                        height=50)

        gui.checkBox(left_box_6,
                     self,
                     "detail",
                     "Print atomic coordinates",
                     labelWidth=250)

        button = gui.button(self.controlArea,
                            self,
                            "Get X0h!",
                            callback=self.submit)
        button.setFixedHeight(30)

        gui.rubber(self.controlArea)

        self.tabs = []
        self.tabs_widget = oasysgui.tabWidget(self.mainArea)
        self.initializeTabs()

        self.x0h_output = QWebView(self.tabs[0])

        self.tabs[0].layout().addWidget(self.x0h_output)

        self.x0h_output.setFixedHeight(640)
        self.x0h_output.setFixedWidth(740)
Ejemplo n.º 22
0
from PyQt5.QtOpenGL import QGLWidget
import plots

html = '''<html>
<head>
    <title>Plotly Example</title>
    <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
    <body>
    %(plot_content)s
    </body>
</html>'''

if __name__ == '__main__':

    app = QApplication(sys.argv)


    w = QWebView()
    w.resize(800, 600)
    w.setWindowTitle('Simple Plot')

    # QWebSettings.globalSettings().setAttribute(QWebSettings.AcceleratedCompositingEnabled, True)
    # QWebSettings.globalSettings().setAttribute(QWebSettings.WebGLEnabled, True)

    plot_content = plots.plot3d()
    w.setHtml(html%{'plot_content':plot_content})
    w.show()

    sys.exit(app.exec_())
Ejemplo n.º 23
0
    def setupUi(self, helpDialog):
        helpDialog.setObjectName("helpDialog")
        helpDialog.resize(1184, 958)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/images/images/gromoteurGmini.png"),
                       QtGui.QIcon.Normal, QtGui.QIcon.Off)
        helpDialog.setWindowIcon(icon)
        helpDialog.setSizeGripEnabled(True)
        self.gridLayout_3 = QtWidgets.QGridLayout(helpDialog)
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.tabWidget = QtWidgets.QTabWidget(helpDialog)
        self.tabWidget.setMaximumSize(QtCore.QSize(16777215, 555555))
        self.tabWidget.setTabPosition(QtWidgets.QTabWidget.West)
        self.tabWidget.setObjectName("tabWidget")
        self.tab_3 = QtWidgets.QWidget()
        self.tab_3.setObjectName("tab_3")
        self.gridLayout_4 = QtWidgets.QGridLayout(self.tab_3)
        self.gridLayout_4.setObjectName("gridLayout_4")
        self.helpWebView = QWebView(self.tab_3)
        self.helpWebView.setProperty("url",
                                     QtCore.QUrl("http://gromoteur.ilpga.fr"))
        self.helpWebView.setObjectName("helpWebView")
        self.gridLayout_4.addWidget(self.helpWebView, 0, 0, 1, 1)
        self.tabWidget.addTab(self.tab_3, "")
        self.aboutTab = QtWidgets.QWidget()
        self.aboutTab.setObjectName("aboutTab")
        self.gridLayout = QtWidgets.QGridLayout(self.aboutTab)
        self.gridLayout.setObjectName("gridLayout")
        self.about = QtWidgets.QTextBrowser(self.aboutTab)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.about.sizePolicy().hasHeightForWidth())
        self.about.setSizePolicy(sizePolicy)
        self.about.setMaximumSize(QtCore.QSize(16777215, 55555))
        self.about.setOpenExternalLinks(True)
        self.about.setObjectName("about")
        self.gridLayout.addWidget(self.about, 0, 0, 1, 1)
        self.tabWidget.addTab(self.aboutTab, "")
        self.gnutab = QtWidgets.QWidget()
        self.gnutab.setObjectName("gnutab")
        self.gridLayout_2 = QtWidgets.QGridLayout(self.gnutab)
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.gnulicence = QtWidgets.QTextBrowser(self.gnutab)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.gnulicence.sizePolicy().hasHeightForWidth())
        self.gnulicence.setSizePolicy(sizePolicy)
        self.gnulicence.setMaximumSize(QtCore.QSize(16777215, 55555))
        self.gnulicence.setObjectName("gnulicence")
        self.gridLayout_2.addWidget(self.gnulicence, 0, 0, 1, 1)
        self.tabWidget.addTab(self.gnutab, "")
        self.gridLayout_3.addWidget(self.tabWidget, 0, 0, 1, 1)
        self.buttonBox = QtWidgets.QDialogButtonBox(helpDialog)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.gridLayout_3.addWidget(self.buttonBox, 1, 0, 1, 1)

        self.retranslateUi(helpDialog)
        self.tabWidget.setCurrentIndex(0)
        self.buttonBox.accepted.connect(helpDialog.accept)
        self.buttonBox.rejected.connect(helpDialog.reject)
        QtCore.QMetaObject.connectSlotsByName(helpDialog)
Ejemplo n.º 24
0
    def setupUi(self, FieldSelector):
        FieldSelector.setObjectName("FieldSelector")
        FieldSelector.resize(964, 923)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/images/images/selector.png"),
                       QtGui.QIcon.Normal, QtGui.QIcon.Off)
        FieldSelector.setWindowIcon(icon)
        FieldSelector.setSizeGripEnabled(True)
        FieldSelector.setModal(True)
        self.gridLayout_2 = QtWidgets.QGridLayout(FieldSelector)
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.webView = QWebView(FieldSelector)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.webView.sizePolicy().hasHeightForWidth())
        self.webView.setSizePolicy(sizePolicy)
        self.webView.setMouseTracking(True)
        self.webView.setUrl(QtCore.QUrl("about:blank"))
        self.webView.setObjectName("webView")
        self.gridLayout_2.addWidget(self.webView, 1, 0, 1, 2)
        self.textualFrame = QtWidgets.QFrame(FieldSelector)
        self.textualFrame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.textualFrame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.textualFrame.setObjectName("textualFrame")
        self.gridLayout_5 = QtWidgets.QGridLayout(self.textualFrame)
        self.gridLayout_5.setObjectName("gridLayout_5")
        self.label_4 = QtWidgets.QLabel(self.textualFrame)
        self.label_4.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.label_4.setFrameShadow(QtWidgets.QFrame.Plain)
        self.label_4.setLineWidth(0)
        self.label_4.setAlignment(QtCore.Qt.AlignRight
                                  | QtCore.Qt.AlignTrailing
                                  | QtCore.Qt.AlignVCenter)
        self.label_4.setObjectName("label_4")
        self.gridLayout_5.addWidget(self.label_4, 0, 0, 1, 1)
        self.textualComboBox = QtWidgets.QComboBox(self.textualFrame)
        self.textualComboBox.setEnabled(True)
        sizePolicy = QtWidgets.QSizePolicy(
            QtWidgets.QSizePolicy.MinimumExpanding,
            QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.textualComboBox.sizePolicy().hasHeightForWidth())
        self.textualComboBox.setSizePolicy(sizePolicy)
        self.textualComboBox.setEditable(False)
        self.textualComboBox.setDuplicatesEnabled(False)
        self.textualComboBox.setObjectName("textualComboBox")
        self.gridLayout_5.addWidget(self.textualComboBox, 0, 1, 1, 1)
        self.label_3 = QtWidgets.QLabel(self.textualFrame)
        self.label_3.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.label_3.setFrameShadow(QtWidgets.QFrame.Raised)
        self.label_3.setAlignment(QtCore.Qt.AlignRight
                                  | QtCore.Qt.AlignTrailing
                                  | QtCore.Qt.AlignVCenter)
        self.label_3.setObjectName("label_3")
        self.gridLayout_5.addWidget(self.label_3, 1, 0, 1, 1)
        self.textcolComboBox = QtWidgets.QComboBox(self.textualFrame)
        self.textcolComboBox.setEnabled(True)
        sizePolicy = QtWidgets.QSizePolicy(
            QtWidgets.QSizePolicy.MinimumExpanding,
            QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.textcolComboBox.sizePolicy().hasHeightForWidth())
        self.textcolComboBox.setSizePolicy(sizePolicy)
        self.textcolComboBox.setEditable(True)
        self.textcolComboBox.setObjectName("textcolComboBox")
        self.gridLayout_5.addWidget(self.textcolComboBox, 1, 1, 1, 1)
        self.gridLayout_2.addWidget(self.textualFrame, 4, 0, 1, 1)
        self.url = QtWidgets.QLineEdit(FieldSelector)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                           QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.url.sizePolicy().hasHeightForWidth())
        self.url.setSizePolicy(sizePolicy)
        self.url.setReadOnly(True)
        self.url.setObjectName("url")
        self.gridLayout_2.addWidget(self.url, 0, 0, 1, 2)
        self.gridLayout = QtWidgets.QGridLayout()
        self.gridLayout.setObjectName("gridLayout")
        self.tagCheckBox = QtWidgets.QCheckBox(FieldSelector)
        self.tagCheckBox.setEnabled(False)
        font = QtGui.QFont()
        font.setPointSize(9)
        self.tagCheckBox.setFont(font)
        self.tagCheckBox.setChecked(True)
        self.tagCheckBox.setObjectName("tagCheckBox")
        self.gridLayout.addWidget(self.tagCheckBox, 4, 1, 1, 1)
        self.idCheckBox = QtWidgets.QCheckBox(FieldSelector)
        self.idCheckBox.setEnabled(False)
        font = QtGui.QFont()
        font.setPointSize(9)
        self.idCheckBox.setFont(font)
        self.idCheckBox.setChecked(True)
        self.idCheckBox.setObjectName("idCheckBox")
        self.gridLayout.addWidget(self.idCheckBox, 4, 2, 1, 1)
        self.classCheckBox = QtWidgets.QCheckBox(FieldSelector)
        self.classCheckBox.setEnabled(False)
        font = QtGui.QFont()
        font.setPointSize(9)
        self.classCheckBox.setFont(font)
        self.classCheckBox.setChecked(True)
        self.classCheckBox.setObjectName("classCheckBox")
        self.gridLayout.addWidget(self.classCheckBox, 4, 3, 1, 1)
        self.numElecomboBox = QtWidgets.QComboBox(FieldSelector)
        self.numElecomboBox.setEnabled(False)
        self.numElecomboBox.setObjectName("numElecomboBox")
        self.numElecomboBox.addItem("")
        self.gridLayout.addWidget(self.numElecomboBox, 4, 5, 1, 1)
        self.backButton = QtWidgets.QPushButton(FieldSelector)
        self.backButton.setMaximumSize(QtCore.QSize(100, 16777215))
        self.backButton.setAutoDefault(False)
        self.backButton.setDefault(False)
        self.backButton.setObjectName("backButton")
        self.gridLayout.addWidget(self.backButton, 4, 6, 1, 1)
        self.nextButton = QtWidgets.QPushButton(FieldSelector)
        self.nextButton.setEnabled(True)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                           QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.nextButton.sizePolicy().hasHeightForWidth())
        self.nextButton.setSizePolicy(sizePolicy)
        self.nextButton.setMaximumSize(QtCore.QSize(100, 16777215))
        self.nextButton.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.nextButton.setCheckable(False)
        self.nextButton.setChecked(False)
        self.nextButton.setAutoDefault(False)
        self.nextButton.setFlat(False)
        self.nextButton.setObjectName("nextButton")
        self.gridLayout.addWidget(self.nextButton, 4, 7, 1, 1)
        self.additionTagLineEdit = QtWidgets.QLineEdit(FieldSelector)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                           QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.additionTagLineEdit.sizePolicy().hasHeightForWidth())
        self.additionTagLineEdit.setSizePolicy(sizePolicy)
        self.additionTagLineEdit.setObjectName("additionTagLineEdit")
        self.gridLayout.addWidget(self.additionTagLineEdit, 4, 4, 1, 1)
        self.gridLayout_2.addLayout(self.gridLayout, 2, 0, 1, 2)
        self.sourceText = QtWidgets.QPlainTextEdit(FieldSelector)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.sourceText.sizePolicy().hasHeightForWidth())
        self.sourceText.setSizePolicy(sizePolicy)
        self.sourceText.setObjectName("sourceText")
        self.gridLayout_2.addWidget(self.sourceText, 3, 0, 1, 2)
        self.gridLayout_3 = QtWidgets.QGridLayout()
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.state = QtWidgets.QLabel(FieldSelector)
        self.state.setText("")
        self.state.setObjectName("state")
        self.gridLayout_3.addWidget(self.state, 0, 0, 1, 1)
        self.warnLabel = QtWidgets.QLabel(FieldSelector)
        self.warnLabel.setMinimumSize(QtCore.QSize(0, 20))
        self.warnLabel.setText("")
        self.warnLabel.setObjectName("warnLabel")
        self.gridLayout_3.addWidget(self.warnLabel, 1, 0, 1, 1)
        self.progressBar = QtWidgets.QProgressBar(FieldSelector)
        self.progressBar.setMaximumSize(QtCore.QSize(16777215, 30))
        font = QtGui.QFont()
        font.setPointSize(11)
        self.progressBar.setFont(font)
        self.progressBar.setProperty("value", 0)
        self.progressBar.setObjectName("progressBar")
        self.gridLayout_3.addWidget(self.progressBar, 2, 0, 1, 1)
        self.gridLayout_2.addLayout(self.gridLayout_3, 5, 0, 1, 2)
        self.extractFrame = QtWidgets.QFrame(FieldSelector)
        self.extractFrame.setEnabled(False)
        self.extractFrame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.extractFrame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.extractFrame.setObjectName("extractFrame")
        self.gridLayout_7 = QtWidgets.QGridLayout(self.extractFrame)
        self.gridLayout_7.setObjectName("gridLayout_7")
        self.widget = QtWidgets.QWidget(self.extractFrame)
        self.widget.setObjectName("widget")
        self.gridLayout_4 = QtWidgets.QGridLayout(self.widget)
        self.gridLayout_4.setObjectName("gridLayout_4")
        self.textExtraction = QtWidgets.QRadioButton(self.widget)
        self.textExtraction.setEnabled(False)
        self.textExtraction.setChecked(True)
        self.textExtraction.setObjectName("textExtraction")
        self.gridLayout_4.addWidget(self.textExtraction, 0, 0, 1, 1)
        self.sourceExtraction = QtWidgets.QRadioButton(self.widget)
        self.sourceExtraction.setObjectName("sourceExtraction")
        self.gridLayout_4.addWidget(self.sourceExtraction, 1, 0, 1, 1)
        self.gridLayout_7.addWidget(self.widget, 0, 0, 1, 1)
        self.widget_2 = QtWidgets.QWidget(self.extractFrame)
        self.widget_2.setObjectName("widget_2")
        self.gridLayout_6 = QtWidgets.QGridLayout(self.widget_2)
        self.gridLayout_6.setObjectName("gridLayout_6")
        self.selectedExtraction = QtWidgets.QRadioButton(self.widget_2)
        self.selectedExtraction.setChecked(True)
        self.selectedExtraction.setObjectName("selectedExtraction")
        self.gridLayout_6.addWidget(self.selectedExtraction, 0, 0, 1, 1)
        self.inverseExtraction = QtWidgets.QRadioButton(self.widget_2)
        self.inverseExtraction.setObjectName("inverseExtraction")
        self.gridLayout_6.addWidget(self.inverseExtraction, 1, 0, 1, 1)
        self.gridLayout_7.addWidget(self.widget_2, 0, 1, 1, 1)
        self.newcolumnButton = QtWidgets.QPushButton(self.extractFrame)
        self.newcolumnButton.setEnabled(False)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                           QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.newcolumnButton.sizePolicy().hasHeightForWidth())
        self.newcolumnButton.setSizePolicy(sizePolicy)
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(":/images/images/newColumn.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.newcolumnButton.setIcon(icon1)
        self.newcolumnButton.setIconSize(QtCore.QSize(36, 36))
        self.newcolumnButton.setAutoDefault(True)
        self.newcolumnButton.setFlat(False)
        self.newcolumnButton.setObjectName("newcolumnButton")
        self.gridLayout_7.addWidget(self.newcolumnButton, 0, 2, 1, 1)
        self.gridLayout_2.addWidget(self.extractFrame, 4, 1, 1, 1)
        self.sourceText.raise_()
        self.textualFrame.raise_()
        self.url.raise_()
        self.webView.raise_()
        self.extractFrame.raise_()
        self.label_4.setBuddy(self.textualComboBox)
        self.label_3.setBuddy(self.textcolComboBox)

        self.retranslateUi(FieldSelector)
        QtCore.QMetaObject.connectSlotsByName(FieldSelector)
Ejemplo n.º 25
0
    def __init__(self,
                 splash,
                 nexicoBase,
                 config,
                 selectionName="standard",
                 parent=None):
        """
		Constructor	
		"""
        QMainWindow.__init__(self)
        self.setupUi(self)
        qfdb = QFontDatabase()
        fi = qfdb.addApplicationFont(":fonts/resources/FreeSans.otf")

        try:
            self.font = qfdb.font(
                qfdb.applicationFontFamilies(fi)[0], "Light", False)
        except:
            self.font = None

        self.config = config
        self.nbBestKids = int(self.config["configuration"]["nbBestKids"])
        self.currentSection = None
        self.selectedWord = ""
        self.selectedTokeni = None
        self.sectList = []
        self.base = nexicoBase
        self.wordTableWidget.setHorizontalHeaderLabels(
            [self.tr("word"), self.tr("frequency")])
        self.autoSelect = 0

        false_positives = set(["aliases", "undefined"])
        self.encodings = set(
            name
            for imp, name, ispkg in pkgutil.iter_modules(encodings.__path__)
            if not ispkg)
        self.encodings.difference_update(false_positives)
        self.encodings = sorted(self.encodings)

        self.statusbar.showMessage(self.tr("Welcome!"), 20000)
        self.fileNameEdit.setText(selectionName)
        self.pb = QtWidgets.QProgressBar(self.statusBar())
        self.statusBar().addPermanentWidget(self.pb)
        self.pb.hide()
        self.splash = splash
        self.selecting = False
        self.graphicsView.setRenderHints(
            QtGui.QPainter.Antialiasing
            or QtGui.QPainter.SmoothPixmapTransform)
        self.ngra = self.ngraDial.sliderPosition()
        self.renoword = re.compile("\W+$", re.U + re.I + re.M)

        self.webView = QWebView()
        self.collocations = Collocations(self)

        #self.gridLayout_3.addWidget(self.graphcanvas, 0, 0, 1, 1)
        self.gridLayout_3.addWidget(self.webView, 0, 0, 1, 1)

        # start with collocation open?
        #openwithcolloc=int(self.config["configuration"]["openwithcolloc"]) # False
        openwithcolloc = False
        self.actionCollocations.setChecked(openwithcolloc)
        self.on_actionCollocations_toggled(openwithcolloc)
        #self.graphButton.setChecked(True)

        #self.specos=None # dict of collocations for current word

        # TODO: solve the memory problem of qsplitter:
        #self.hsplitter=QSplitter(1, self.centralwidget)  # 2=vertical orientation
        #self.centralGridLayout.addWidget(self.hsplitter,  0, 1)
        #self.vspgridLayout = QtGui.QGridLayout(self.hsplitter)
        #self.vspgridLayout.setSpacing(0)
        #self.hsplitter.setHandleWidth(8)
        #self.vspgridLayout.setContentsMargins(2, 0, 2, 0)
        #self.vspgridLayout.addWidget(self.westwidget, 0, 0)
        #self.vspgridLayout.addWidget(self.eastwidget)

        self.load()
        self.filter.textChanged.connect(self.filterChanged)
        self.colfilter.textChanged.connect(self.colfilterChanged)

        self.recenter = RecenterClass()
Ejemplo n.º 26
0
    def __init__(self, uid, title, url, width, height, resizable, fullscreen,
                 min_size, confirm_quit, background_color, debug, js_api,
                 webview_ready):
        super(BrowserView, self).__init__()
        BrowserView.instances[uid] = self
        self.uid = uid

        self.js_bridge = BrowserView.JSBridge()
        self.js_bridge.api = js_api
        self.js_bridge.parent_uid = self.uid

        self.is_fullscreen = False
        self.confirm_quit = confirm_quit

        self._file_name_semaphore = Semaphore(0)
        self._current_url_semaphore = Semaphore(0)

        self.load_event = Event()

        self._js_results = {}
        self._current_url = None
        self._file_name = None

        self.resize(width, height)
        self.title = title
        self.setWindowTitle(title)

        # Set window background color
        self.background_color = QColor()
        self.background_color.setNamedColor(background_color)
        palette = self.palette()
        palette.setColor(self.backgroundRole(), self.background_color)
        self.setPalette(palette)

        if not resizable:
            self.setFixedSize(width, height)

        self.setMinimumSize(min_size[0], min_size[1])

        self.view = QWebView(self)

        if url is not None:
            self.view.setUrl(QtCore.QUrl(url))
        else:
            self.load_event.set()

        self.setCentralWidget(self.view)

        self.create_window_trigger.connect(BrowserView.on_create_window)
        self.load_url_trigger.connect(self.on_load_url)
        self.html_trigger.connect(self.on_load_html)
        self.dialog_trigger.connect(self.on_file_dialog)
        self.destroy_trigger.connect(self.on_destroy_window)
        self.fullscreen_trigger.connect(self.on_fullscreen)
        self.current_url_trigger.connect(self.on_current_url)
        self.evaluate_js_trigger.connect(self.on_evaluate_js)
        self.set_title_trigger.connect(self.on_set_title)

        if _qt_version >= [5, 5]:
            self.channel = QWebChannel(self.view.page())
            self.view.page().setWebChannel(self.channel)

        self.view.page().loadFinished.connect(self.on_load_finished)

        if fullscreen:
            self.toggle_fullscreen()

        self.view.setContextMenuPolicy(
            QtCore.Qt.NoContextMenu)  # disable right click context menu

        self.move(QApplication.desktop().availableGeometry().center() -
                  self.rect().center())
        self.activateWindow()
        self.raise_()
        webview_ready.set()
Ejemplo n.º 27
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1189, 574)
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(46, 52, 54))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush)
        brush = QtGui.QBrush(QtGui.QColor(69, 78, 81))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Light, brush)
        brush = QtGui.QBrush(QtGui.QColor(57, 65, 67))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Midlight, brush)
        brush = QtGui.QBrush(QtGui.QColor(23, 26, 27))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Dark, brush)
        brush = QtGui.QBrush(QtGui.QColor(30, 34, 36))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Mid, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.BrightText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(46, 52, 54))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Shadow, brush)
        brush = QtGui.QBrush(QtGui.QColor(23, 26, 27))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.AlternateBase,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 220))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipBase,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(46, 52, 54))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush)
        brush = QtGui.QBrush(QtGui.QColor(69, 78, 81))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Light, brush)
        brush = QtGui.QBrush(QtGui.QColor(57, 65, 67))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Midlight,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(23, 26, 27))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Dark, brush)
        brush = QtGui.QBrush(QtGui.QColor(30, 34, 36))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Mid, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.BrightText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(46, 52, 54))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Shadow, brush)
        brush = QtGui.QBrush(QtGui.QColor(23, 26, 27))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.AlternateBase,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 220))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipBase,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(23, 26, 27))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(46, 52, 54))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush)
        brush = QtGui.QBrush(QtGui.QColor(69, 78, 81))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Light, brush)
        brush = QtGui.QBrush(QtGui.QColor(57, 65, 67))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Midlight,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(23, 26, 27))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Dark, brush)
        brush = QtGui.QBrush(QtGui.QColor(30, 34, 36))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Mid, brush)
        brush = QtGui.QBrush(QtGui.QColor(23, 26, 27))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.BrightText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(23, 26, 27))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(46, 52, 54))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(46, 52, 54))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Shadow, brush)
        brush = QtGui.QBrush(QtGui.QColor(46, 52, 54))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 220))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipBase,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipText,
                         brush)
        MainWindow.setPalette(palette)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/resources/app.png"),
                       QtGui.QIcon.Normal, QtGui.QIcon.Off)
        MainWindow.setWindowIcon(icon)
        MainWindow.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setSizeConstraint(
            QtWidgets.QLayout.SetDefaultConstraint)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setSizeConstraint(
            QtWidgets.QLayout.SetDefaultConstraint)
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.fileNameLabel = QtWidgets.QLabel(self.centralwidget)
        self.fileNameLabel.setObjectName("fileNameLabel")
        self.horizontalLayout_3.addWidget(self.fileNameLabel)
        self.fileNameTextBox = QtWidgets.QLineEdit(self.centralwidget)
        self.fileNameTextBox.setReadOnly(True)
        self.fileNameTextBox.setObjectName("fileNameTextBox")
        self.horizontalLayout_3.addWidget(self.fileNameTextBox)
        self.openFileBtn = QtWidgets.QToolButton(self.centralwidget)
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(":/resources/open.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.openFileBtn.setIcon(icon1)
        self.openFileBtn.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
        self.openFileBtn.setObjectName("openFileBtn")
        self.horizontalLayout_3.addWidget(self.openFileBtn)
        self.verticalLayout.addLayout(self.horizontalLayout_3)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.previousBtn = QtWidgets.QPushButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                           QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.previousBtn.sizePolicy().hasHeightForWidth())
        self.previousBtn.setSizePolicy(sizePolicy)
        self.previousBtn.setObjectName("previousBtn")
        self.horizontalLayout_2.addWidget(self.previousBtn)
        self.comboBox = QtWidgets.QComboBox(self.centralwidget)
        self.comboBox.setObjectName("comboBox")
        self.horizontalLayout_2.addWidget(self.comboBox)
        self.nextBtn = QtWidgets.QPushButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                           QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.nextBtn.sizePolicy().hasHeightForWidth())
        self.nextBtn.setSizePolicy(sizePolicy)
        self.nextBtn.setObjectName("nextBtn")
        self.horizontalLayout_2.addWidget(self.nextBtn)
        self.testCaseBtn = QtWidgets.QPushButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                           QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.testCaseBtn.sizePolicy().hasHeightForWidth())
        self.testCaseBtn.setSizePolicy(sizePolicy)
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap(":/resources/download.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.testCaseBtn.setIcon(icon2)
        self.testCaseBtn.setIconSize(QtCore.QSize(28, 28))
        self.testCaseBtn.setFlat(True)
        self.testCaseBtn.setObjectName("testCaseBtn")
        self.horizontalLayout_2.addWidget(self.testCaseBtn)
        self.problemDownloadBtn = QtWidgets.QPushButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                           QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.problemDownloadBtn.sizePolicy().hasHeightForWidth())
        self.problemDownloadBtn.setSizePolicy(sizePolicy)
        self.problemDownloadBtn.setIcon(icon2)
        self.problemDownloadBtn.setIconSize(QtCore.QSize(28, 28))
        self.problemDownloadBtn.setFlat(True)
        self.problemDownloadBtn.setObjectName("problemDownloadBtn")
        self.horizontalLayout_2.addWidget(self.problemDownloadBtn)
        self.verticalLayout.addLayout(self.horizontalLayout_2)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.statementWebView = QWebView(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                           QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.statementWebView.sizePolicy().hasHeightForWidth())
        self.statementWebView.setSizePolicy(sizePolicy)
        self.statementWebView.setContextMenuPolicy(QtCore.Qt.NoContextMenu)
        self.statementWebView.setUrl(QtCore.QUrl("about:blank"))
        self.statementWebView.setObjectName("statementWebView")
        self.horizontalLayout.addWidget(self.statementWebView)
        self.solutionWebView = QWebView(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                           QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.solutionWebView.sizePolicy().hasHeightForWidth())
        self.solutionWebView.setSizePolicy(sizePolicy)
        self.solutionWebView.setContextMenuPolicy(QtCore.Qt.NoContextMenu)
        self.solutionWebView.setUrl(QtCore.QUrl("about:blank"))
        self.solutionWebView.setObjectName("solutionWebView")
        self.horizontalLayout.addWidget(self.solutionWebView)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1189, 22))
        self.menubar.setObjectName("menubar")
        self.menuOpen = QtWidgets.QMenu(self.menubar)
        self.menuOpen.setObjectName("menuOpen")
        MainWindow.setMenuBar(self.menubar)
        self.statusBar = QtWidgets.QStatusBar(MainWindow)
        self.statusBar.setObjectName("statusBar")
        MainWindow.setStatusBar(self.statusBar)
        self.actionOpen = QtWidgets.QAction(MainWindow)
        self.actionOpen.setIcon(icon1)
        self.actionOpen.setObjectName("actionOpen")
        self.actionReset = QtWidgets.QAction(MainWindow)
        self.actionReset.setObjectName("actionReset")
        self.actionExit = QtWidgets.QAction(MainWindow)
        icon3 = QtGui.QIcon()
        icon3.addPixmap(QtGui.QPixmap(":/resources/exit.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionExit.setIcon(icon3)
        self.actionExit.setObjectName("actionExit")
        self.menuOpen.addAction(self.actionOpen)
        self.menuOpen.addAction(self.actionReset)
        self.menuOpen.addSeparator()
        self.menuOpen.addAction(self.actionExit)
        self.menubar.addAction(self.menuOpen.menuAction())

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Ejemplo n.º 28
0
    def __init__(self):
        super().__init__()
        self.linkstyle_list = ['single', 'double', '§']
        self.parser_list = ['native', 'mmd', 'pandoc']
        main_split = QSplitter(Qt.Horizontal)

        # Left Side
        left_widget = QWidget()
        left_vlay = QVBoxLayout()
        left_widget.setLayout(left_vlay)

        # ZK Folder
        zk_lbl_folder = QLabel('ZK Folder')
        zk_hlay = QHBoxLayout()
        zk_ed_folder = QLineEdit('(please select)')
        zk_ed_folder.setStyleSheet('color:#14148c')
        zk_bt_folder = QPushButton('...')
        zk_bt_folder.setFixedWidth(100)
        zk_hlay.addWidget(zk_ed_folder)
        zk_hlay.addWidget(zk_bt_folder)
        left_vlay.addWidget(zk_lbl_folder)
        left_vlay.addLayout(zk_hlay)

        # Output Folder
        out_lbl_folder = QLabel('Output Folder')
        out_hlay = QHBoxLayout()
        out_ed_folder = QLineEdit('(please select)')
        out_ed_folder.setStyleSheet('color:#14148c')
        out_bt_folder = QPushButton('...')
        out_bt_folder.setFixedWidth(100)
        out_hlay.addWidget(out_ed_folder)
        out_hlay.addWidget(out_bt_folder)
        left_vlay.addWidget(out_lbl_folder)
        left_vlay.addLayout(out_hlay)

        # Bib File
        bib_lbl = QLabel('Bib File')
        bib_hlay = QHBoxLayout()
        bib_ed = QLineEdit('(auto)')
        bib_ed.setStyleSheet('color:#14148c')
        bib_bt = QPushButton('...')
        bib_bt.setFixedWidth(100)
        bib_hlay.addWidget(bib_ed)
        bib_hlay.addWidget(bib_bt)
        left_vlay.addWidget(bib_lbl)
        left_vlay.addLayout(bib_hlay)

        # Extension
        ext_hlay = QHBoxLayout()
        ext_lbl = QLabel('Markdown Extension')
        ext_ed = QLineEdit('.md')
        ext_ed.setFixedWidth(100)
        ext_hlay.addWidget(ext_lbl)
        ext_hlay.addWidget(ext_ed)
        left_vlay.addLayout(ext_hlay)

        # Link Style
        lstyle_hlay = QHBoxLayout()
        lstyle_lbl = QLabel('Link Style')
        lstyle_choice = QComboBox()
        lstyle_choice.addItems(self.linkstyle_list)
        lstyle_choice.setFixedWidth(100)
        lstyle_choice.setCurrentIndex(1)
        lstyle_hlay.addWidget(lstyle_lbl)
        lstyle_hlay.addStretch(1)
        lstyle_hlay.addWidget(lstyle_choice)
        left_vlay.addLayout(lstyle_hlay)

        # Parser
        parser_hlay = QHBoxLayout()
        parser_lbl = QLabel('Parser')
        parser_choice = QComboBox()
        parser_choice.addItems(self.parser_list)
        parser_choice.setFixedWidth(100)
        parser_choice.setCurrentIndex(1)
        parser_hlay.addWidget(parser_lbl)
        parser_hlay.addStretch(1)
        parser_hlay.addWidget(parser_choice)
        left_vlay.addLayout(parser_hlay)

        # Separator
        sep = self.hline()
        left_vlay.addStretch(1)
        left_vlay.addWidget(sep)

        # remote URL
        baseurl_lbl = QLabel('Optional remote URL:')
        baseurl_ed = QLineEdit()
        baseurl_ed.setStyleSheet('color:#14148c')
        left_vlay.addWidget(baseurl_lbl)
        left_vlay.addWidget(baseurl_ed)

        # Separator
        sep = self.hline()
        left_vlay.addStretch(1)
        left_vlay.addWidget(sep)

        # FILTERS:
        lbl_filter = QLabel('<u>Note filters:</u>')
        left_vlay.addWidget(lbl_filter)
        from_hlay = QHBoxLayout()
        from_lbl = QLabel('from timestamp:')
        from_ed = QLineEdit('19000101')
        from_ed.setStyleSheet('color:#14148c')

        from_hlay.addWidget(from_lbl)
        from_hlay.addStretch(1)
        from_hlay.addWidget(from_ed)
        left_vlay.addLayout(from_hlay)

        to_hlay = QHBoxLayout()
        to_lbl = QLabel('to timestamp:')
        to_ed = QLineEdit('22001231')
        to_ed.setStyleSheet('color:#14148c')
        to_hlay.addWidget(to_lbl)
        to_hlay.addStretch(1)
        to_hlay.addWidget(to_ed)
        left_vlay.addLayout(to_hlay)

        tagwhite_hlay = QHBoxLayout()
        tagwhite_lbl = QLabel('<pre>Only Tags :</pre>')
        tagwhite_ed = QLineEdit('')
        tagwhite_ed.setStyleSheet('color: #328930')
        tagwhite_hlay.addWidget(tagwhite_lbl)
        tagwhite_hlay.addWidget(tagwhite_ed)
        left_vlay.addLayout(tagwhite_hlay)

        tagblack_hlay = QHBoxLayout()
        tagblack_lbl = QLabel('<pre>Never Tags:</pre>')
        tagblack_ed = QLineEdit('')
        tagblack_ed.setStyleSheet('color: #b40000')
        tagblack_hlay.addWidget(tagblack_lbl)
        tagblack_hlay.addWidget(tagblack_ed)
        left_vlay.addLayout(tagblack_hlay)

        # Separator
        sep = self.hline()
        left_vlay.addWidget(sep)

        # Convert Button
        convert_hlay = QHBoxLayout()
        convert_bt = QPushButton('Convert!')
        convert_hlay.setAlignment(Qt.AlignHCenter)
        convert_hlay.addWidget(convert_bt)
        left_vlay.addLayout(convert_hlay)

        # Progress
        progress_hlay = QHBoxLayout()
        progress_lbl = QLabel('Progress')
        progress_prg = QProgressBar()
        progress_hlay.addWidget(progress_lbl)
        progress_hlay.addWidget(progress_prg)
        left_vlay.addLayout(progress_hlay)

        # Info
        info_hlay = QHBoxLayout()
        info_lbl = QLabel('Info:')
        info_txt = QLabel()
        info_hlay.addWidget(info_lbl)
        info_hlay.addWidget(info_txt)
        info_hlay.addStretch(1)
        left_vlay.addLayout(info_hlay)

        # HTML view
        self.html_view = QWebView()
        self.html_view.setHtml('<center><h2>Preview</h2></center>')

        # Add to splitter
        main_split.addWidget(left_widget)
        main_split.addWidget(self.html_view)

        # Add to self
        lay_all = QHBoxLayout()
        lay_all.addWidget(main_split)
        self.setLayout(lay_all)

        # What to keep?
        self.info_txt = info_txt
        self.progressbar = progress_prg
        self.ed_zk_folder = zk_ed_folder
        self.ed_output_folder = out_ed_folder
        self.ed_bibfile = bib_ed
        self.ed_extension = ext_ed
        self.sel_linkstyle = lstyle_choice
        self.sel_parser = parser_choice
        self.ed_baseurl = baseurl_ed
        self.ed_from = from_ed
        self.ed_to = to_ed
        self.ed_tagblack = tagblack_ed
        self.ed_tagwhite = tagwhite_ed

        # Connections
        convert_bt.clicked.connect(self.on_convert_clicked)
        zk_bt_folder.clicked.connect(self.on_zk_folder_clicked)
        out_bt_folder.clicked.connect(self.on_output_folder_clicked)
        bib_bt.clicked.connect(self.on_bibfile_clicked)
Ejemplo n.º 29
0
import sys
from PyQt5.QtCore import *
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebEngineWidgets import QWebEngineView as QWebView

app = QApplication(sys.argv)

web = QWebView()
web.load(QUrl("http://newlucioch.temp.swtest.ru/form.html"))
web.show()

sys.exit(app.exec_())
Ejemplo n.º 30
0
 def __init__(self):
     QWebView.__init__(self)
     self.loadFinished.connect(self._result_available)