Python PyQt5.QtWebEngineWidgets.QWebEngineView() Examples

The following are 30 code examples of PyQt5.QtWebEngineWidgets.QWebEngineView(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtWebEngineWidgets , or try the search function .
Example #1
Source File: apagar.py    From controleEstoque with MIT License 7 votes vote down vote up
def imprimirReciboPag(self):

        self.documento = QWebEngineView()

        self.renderTemplate(
            "recibopagamento.html",
            estilo=self.resourcepath('Template/estilo.css'),
            cod=self.tx_Cod.text(),

            descricao=self.tx_descricao.text(),
            valor=self.tx_valor.text().replace('.', ','),
            valor_ext=retorno(self.tx_valor.text()),
            data=date.today().strftime("%d-%m-%Y")

        )

        self.documento.load(QUrl.fromLocalFile(
                                 self.resourcepath("report.html")))
        self.documento.loadFinished['bool'].connect(self.previaImpressao) 
Example #2
Source File: loginui.py    From yiban-api with GNU General Public License v3.0 6 votes vote down vote up
def setupUi(self, LoginWindow):
        LoginWindow.setObjectName("LoginWindow")
        LoginWindow.resize(501, 425)
        self.centralwidget = QtWidgets.QWidget(LoginWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.webEngineView = QtWebEngineWidgets.QWebEngineView(self.centralwidget)
        self.webEngineView.setUrl(QtCore.QUrl("https://www.yiban.cn/"))
        self.webEngineView.setZoomFactor(1.5)
        self.webEngineView.setObjectName("webEngineView")
        self.gridLayout.addWidget(self.webEngineView, 0, 0, 1, 1)
        LoginWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(LoginWindow)
        QtCore.QMetaObject.connectSlotsByName(LoginWindow) 
Example #3
Source File: maincompras.py    From controleEstoque with MIT License 6 votes vote down vote up
def imprimirTabCompra(self):
        self.documento = QWebEngineView()

        headertable = ["Fornecedor", "Emissão ",
                       "Vencimento", "Valor"]

        data_inicio = QDate.toString(self.dt_InicioCompra.date(), "dd-MM-yyyy")
        data_fim = QDate.toString(self.dt_FimCompra.date(), "dd-MM-yyyy")

        cliente = []
        descricao = []
        vencimento = []
        valor = []

        for i in range(self.tb_Compras.rowCount()):
            cliente.append(self.tb_Compras.cellWidget(i, 2).text())
            descricao.append(self.tb_Compras.cellWidget(i, 3).text())
            vencimento.append(self.tb_Compras.cellWidget(i, 4).text())
            valor.append(self.tb_Compras.cellWidget(i, 5).text())

        self.renderTemplate(
            "vendas.html",
            estilo=self.resourcepath('Template/estilo.css'),
            titulo="Relatório Compras de de {} à {}".format(
                data_inicio, data_fim),
            headertable=headertable,
            nome=cliente,
            desc=descricao,
            venc=vencimento,
            valor=valor)

        self.documento.load(QUrl.fromLocalFile(
                                 self.resourcepath("report.html")))
        self.documento.loadFinished['bool'].connect(self.previaImpressao) 
Example #4
Source File: window.py    From visma with GNU General Public License v3.0 6 votes vote down vote up
def popupBrowser(self):
        w = QDialog(self)
        w.resize(600, 500)
        w.setWindowTitle('Wiki')
        web = QWebEngineView(w)
        web.load(QUrl('https://github.com/aerospaceresearch/visma/wiki'))
        web.resize(600, 500)
        web.show()
        w.show() 
Example #5
Source File: pyqt_gui.py    From examples-of-web-crawlers with MIT License 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.DomainCookies = {}

        self.setWindowTitle('微信读书助手') # 设置窗口标题
        self.resize(900, 600) # 设置窗口大小
        self.setWindowFlags(Qt.WindowMinimizeButtonHint) # 禁止最大化按钮
        self.setFixedSize(self.width(), self.height()) # 禁止调整窗口大小

        url = 'https://weread.qq.com/#login' # 目标地址
        self.browser = QWebEngineView() # 实例化浏览器对象

        self.profile = QWebEngineProfile.defaultProfile()
        self.profile.cookieStore().deleteAllCookies() # 初次运行软件时删除所有cookies
        self.profile.cookieStore().cookieAdded.connect(self.onCookieAdd) # cookies增加时触发self.onCookieAdd()函数

        self.browser.loadFinished.connect(self.onLoadFinished) # 网页加载完毕时触发self.onLoadFinished()函数

        self.browser.load(QUrl(url)) # 加载网页
        self.setCentralWidget(self.browser) # 设置中心窗口





    # 网页加载完毕事件 
Example #6
Source File: tdmgr.py    From tdm with GNU General Public License v3.0 6 votes vote down vote up
def openWebUI(self):
        if self.device and self.device.p.get('IPAddress'):
            url = QUrl("http://{}".format(self.device.p['IPAddress']))

            try:
                webui = QWebEngineView()
                webui.load(url)

                frm_webui = QFrame()
                frm_webui.setWindowTitle("WebUI [{}]".format(self.device.p['FriendlyName1']))
                frm_webui.setFrameShape(QFrame.StyledPanel)
                frm_webui.setLayout(VLayout(0))
                frm_webui.layout().addWidget(webui)
                frm_webui.destroyed.connect(self.updateMDI)

                self.mdi.addSubWindow(frm_webui)
                self.mdi.setViewMode(QMdiArea.TabbedView)
                frm_webui.setWindowState(Qt.WindowMaximized)

            except NameError:
                QDesktopServices.openUrl(QUrl("http://{}".format(self.device.p['IPAddress']))) 
Example #7
Source File: communicate.py    From vise with GNU General Public License v3.0 5 votes vote down vote up
def python_to_js(page_or_tab, name, *args):
    page = page_or_tab.page() if isinstance(page_or_tab, QWebEngineView) else page_or_tab
    page.runJavaScript('window.send_message_to_javascript(%s, %s)' % (json.dumps(name), json.dumps(args)), QWebEngineScript.ApplicationWorld) 
Example #8
Source File: mainclientes.py    From controleEstoque with MIT License 5 votes vote down vote up
def imprimirCliente(self):
        self.documento = QWebEngineView()

        headertable = ["Cod", "Nome ", "Telefone", "Email"]
        cod = []
        nome = []
        telefone = []
        email = []

        i = 0
        for row in range(self.tb_Clientes.rowCount()):
            cod.append(self.tb_Clientes.cellWidget(i, 1).text())
            nome.append(self.tb_Clientes.cellWidget(i, 2).text())
            telefone.append(self.tb_Clientes.cellWidget(i, 3).text())
            email.append(self.tb_Clientes.cellWidget(i, 4).text())

        self.renderTemplate(
            "clientes.html",
            estilo=self.resourcepath('Template/estilo.css'),
            titulo="LISTAGEM CLIENTES",
            headertable=headertable,
            codcliente=cod,
            nome=nome,
            telefoneFornecedor=telefone,
            emailFornecedor=email
        )

        self.documento.load(QUrl.fromLocalFile(
            self.resourcepath("report.html")))
        self.documento.loadFinished['bool'].connect(self.previaImpressao) 
Example #9
Source File: mainprodutos.py    From controleEstoque with MIT License 5 votes vote down vote up
def imprimirProdutos(self):
        self.documento = QWebEngineView()

        headertable = ["Cod", "Descrição", "Disponível",
                       "Valor Unitário", "Valor Atacado"]

        cod = []
        produto = []
        qtde = []
        vunit = []
        vatac = []
        qtdeatac = []

        i = 0
        for i in range(self.tb_produtos.rowCount()):
            cod.append(self.tb_produtos.cellWidget(i, 2).text())
            produto.append(self.tb_produtos.cellWidget(i, 3).text())
            qtde.append(self.tb_produtos.cellWidget(i, 4).text())
            vunit.append(self.tb_produtos.cellWidget(i, 5).text())
            vatac.append(self.tb_produtos.cellWidget(i, 6).text())

        html = self.renderTemplate(
            "estoque.html",
            estilo=self.resourcepath('Template/estilo.css'),
            titulo="LISTAGEM PRODUTOS",
            headertable=headertable,
            codProduto=cod,
            descPRoduto=produto,
            qtdeEstoque=qtde,
            valorUnitario=vunit,
            valorAtacado=vatac


        )

        self.documento.load(QUrl.fromLocalFile(
            self.resourcepath("report.html")))
        self.documento.loadFinished['bool'].connect(self.previaImpressao) 
Example #10
Source File: mainfornecedor.py    From controleEstoque with MIT License 5 votes vote down vote up
def imprimir(self):
        self.documento = QWebEngineView()

        headertable = ["Cod", "Nome Fantasia", "Telefone", "Email", "Site"]

        codcliente = []
        nomeFornecedor = []
        telefoneFornecedor = []
        siteFornecedor = []
        emailFornecedor = []

        i = 0
        for i in range(self.tb_Fornecedor.rowCount()):
            codcliente.append(self.tb_Fornecedor.cellWidget(i, 1).text())
            nomeFornecedor.append(self.tb_Fornecedor.cellWidget(i, 2).text())
            telefoneFornecedor.append(
                self.tb_Fornecedor.cellWidget(i, 3).text())
            siteFornecedor.append(self.tb_Fornecedor.cellWidget(i, 4).text())
            emailFornecedor.append(self.tb_Fornecedor.cellWidget(i, 5).text())
            i += 1

        html = self.renderTemplate(
            "report.html",
            estilo=self.resourcepath('Template/estilo.css'),
            titulo="LISTAGEM FORNECEDOR",
            headertable=headertable,
            codcliente=codcliente,
            nomeFornecedor=nomeFornecedor,
            telefoneFornecedor=telefoneFornecedor,
            siteFornecedor=siteFornecedor,
            emailFornecedor=emailFornecedor
        )

        self.documento.load(QtCore.QUrl.fromLocalFile(
                                        self.resourcepath("report.html")))
        self.documento.loadFinished['bool'].connect(self.previaImpressao) 
Example #11
Source File: mainvendas.py    From controleEstoque with MIT License 5 votes vote down vote up
def imprimirTabVenda(self):
        self.documento = QWebEngineView()

        headertable = ["Cliente", "Emissão ",
                       "Vencimento", "Valor"]

        data_inicio = QDate.toString(self.dt_InicioVenda.date(), "dd-MM-yyyy")
        data_fim = QDate.toString(self.dt_FimVenda.date(), "dd-MM-yyyy")

        cliente = []
        descricao = []
        vencimento = []
        valor = []

        for i in range(self.tb_Vendas.rowCount()):
            cliente.append(self.tb_Vendas.cellWidget(i, 2).text())
            descricao.append(self.tb_Vendas.cellWidget(i, 3).text())
            vencimento.append(self.tb_Vendas.cellWidget(i, 4).text())
            valor.append(self.tb_Vendas.cellWidget(i, 5).text())

        self.renderTemplate(
            "vendas.html",
            estilo=self.resourcepath('Template/estilo.css'),
            titulo="Relatório Vendas de de {} à {}".format(
                data_inicio, data_fim),
            headertable=headertable,
            nome=cliente,
            desc=descricao,
            venc=vencimento,
            valor=valor)

        self.documento.load(QUrl.fromLocalFile(
            self.resourcepath("report.html")))
        self.documento.loadFinished['bool'].connect(self.previaImpressao) 
Example #12
Source File: track_hmd_qt.py    From pyopenvr with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self):
        QWidget.__init__(self)
        
        self.resize(1600, 940)
        self.setWindowTitle('OpenVR tracking data')
        
        self.webview = QWebEngineView()

        self.button = QPushButton('Quit', self)
        self.button.clicked.connect(self.close)
        layout = QVBoxLayout(self)
        layout.setSpacing(0)
        # layout.setMargin(0)
        layout.addWidget(self.button)
        layout.addWidget(self.webview)
        
        # XXX check result
        openvr.init(openvr.VRApplication_Scene)        
        poses_t = openvr.TrackedDevicePose_t * openvr.k_unMaxTrackedDeviceCount
        self.poses = poses_t()
        
        self.timer = QTimer()
        self.timer.timeout.connect(self.update_page)
        self.timer.start(200)   # ms 
Example #13
Source File: DyStockTableWidget.py    From DevilYuan with MIT License 5 votes vote down vote up
def _stockInfoAct(self):
        code, name = self.getRightClickCodeName()
        if code is None: return

        browser = DyWebView()
        url = 'http://basic.10jqka.com.cn/32/{0}/'.format(code[:-3])
        browser.load(QUrl(url))

        browser.setWindowTitle(name)
        
        rect = QApplication.desktop().availableGeometry()
        taskBarHeight = QApplication.desktop().height() - rect.height()

        browser.resize(rect.width()//3 * 2, rect.height() - taskBarHeight)
        browser.move((rect.width() - browser.width())//2, 0)

        browser.show()

        self._windows.append(browser) 
Example #14
Source File: webengineinspector.py    From qutebrowser with GNU General Public License v3.0 5 votes vote down vote up
def createWindow(self,
                     wintype: QWebEnginePage.WebWindowType) -> QWebEngineView:
        """Called by Qt when a page wants to create a new tab or window.

        In case the user wants to open a resource in a new tab, we use the
        createWindow handling of the main page to achieve that.

        See WebEngineView.createWindow for details.
        """
        return self.page().inspectedPage().view().createWindow(wintype) 
Example #15
Source File: v2widget.py    From v2net with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.resize(1280, 720)
        self.browser = QWebEngineView()
        self.setCentralWidget(self.browser) 
Example #16
Source File: simple_browser.py    From Mastering-GUI-Programming-with-Python with MIT License 5 votes vote down vote up
def add_tab(self, *args):
        webview = qtwe.QWebEngineView()
        tab_index = self.tabs.addTab(webview, 'New Tab')

        webview.urlChanged.connect(
            lambda x: self.tabs.setTabText(tab_index, x.toString()))
        webview.urlChanged.connect(
            lambda x: self.urlbar.setText(x.toString()))

        # make it so pop-up windows call this method
        webview.createWindow = self.add_tab

        # History
        webview.urlChanged.connect(self.update_history)

        # Profile
        page = qtwe.QWebEnginePage(self.profile)
        webview.setPage(page)

        # Add the finder script
        page.scripts().insert(self.finder_script)

        # set default content
        webview.setHtml(
            '<h1>Blank Tab</h1><p>It is a blank tab!</p>',
            qtc.QUrl('about:blank'))

        return webview 
Example #17
Source File: __init__.py    From PyFladesk with MIT License 5 votes vote down vote up
def init_gui(application, port=0, width=800, height=600,
             window_title="PyFladesk", icon="appicon.png", argv=None):
    if argv is None:
        argv = sys.argv

    if port == 0:
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.bind(('localhost', 0))
        port = sock.getsockname()[1]
        sock.close()

    # Application Level
    qtapp = QtWidgets.QApplication(argv)
    webapp = ApplicationThread(application, port)
    webapp.start()
    qtapp.aboutToQuit.connect(webapp.terminate)

    # Main Window Level
    window = QtWidgets.QMainWindow()
    window.resize(width, height)
    window.setWindowTitle(window_title)
    window.setWindowIcon(QtGui.QIcon(icon))

    # WebView Level
    webView = QtWebEngineWidgets.QWebEngineView(window)
    window.setCentralWidget(webView)

    # WebPage Level
    page = WebPage('http://localhost:{}'.format(port))
    page.home()
    webView.setPage(page)

    window.show()
    return qtapp.exec_() 
Example #18
Source File: demoBrowser.py    From Qt5-Python-GUI-Programming-Cookbook with MIT License 5 votes vote down vote up
def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(563, 339)
        self.widget = QWebEngineView(Dialog)
        self.widget.setGeometry(QtCore.QRect(10, 60, 531, 251))
        self.widget.setObjectName("widget")
        self.pushButtonGo = QtWidgets.QPushButton(Dialog)
        self.pushButtonGo.setGeometry(QtCore.QRect(450, 20, 91, 23))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.pushButtonGo.setFont(font)
        self.pushButtonGo.setObjectName("pushButtonGo")
        self.lineEditURL = QtWidgets.QLineEdit(Dialog)
        self.lineEditURL.setGeometry(QtCore.QRect(100, 20, 331, 21))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.lineEditURL.setFont(font)
        self.lineEditURL.setObjectName("lineEditURL")
        self.label = QtWidgets.QLabel(Dialog)
        self.label.setGeometry(QtCore.QRect(10, 20, 71, 16))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label.setFont(font)
        self.label.setObjectName("label")

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog) 
Example #19
Source File: web_browser.py    From PyIntroduction with MIT License 5 votes vote down vote up
def mainPyQt5():
    # 必要なモジュールのimport
    from PyQt5.QtWidgets import QApplication
    from PyQt5.QtCore import QUrl
    from PyQt5.QtWebEngineWidgets import QWebEngineView

    url = 'https://github.com/tody411/PyIntroduction'

    app = QApplication(sys.argv)

    # QWebEngineViewによるWebページ表示
    browser = QWebEngineView()
    browser.load(QUrl(url))
    browser.show()

    sys.exit(app.exec_()) 
Example #20
Source File: DyStockSelectItemMenu.py    From DevilYuan with MIT License 5 votes vote down vote up
def _stockInfoAct(self):
        code, name = self._interface.getCodeName()
        if code is None: return

        browser = DyWebView()
        url = 'http://basic.10jqka.com.cn/32/{0}/'.format(code[:-3])
        browser.load(QUrl(url))

        browser.setWindowTitle(name)
        
        rect = QApplication.desktop().availableGeometry()
        taskBarHeight = QApplication.desktop().height() - rect.height()

        browser.resize(rect.width()//3 * 2, rect.height() - taskBarHeight)
        browser.move((rect.width() - browser.width())//2, 0)

        browser.show()

        self._browsers.append(browser) 
Example #21
Source File: app.py    From bitmask-dev with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kw):
        url = kw.pop('url', None)
        first = False
        if not url:
            url = get_authenticated_url()
            first = True
        self.url = url
        self.closing = False

        super(QWebView, self).__init__(*args, **kw)
        self.setWindowTitle('Bitmask')
        self.bitmask_browser = NewPageConnector(self) if first else None
        self.loadPage(self.url)

        self.bridge = AppBridge(self) if first else None

        if self.bridge is not None and HAS_WEBENGINE:
            print "[+] registering python<->js bridge"
            channel = QWebChannel(self)
            channel.registerObject("bitmaskApp", self.bridge)
            self.page().setWebChannel(channel)

        icon = QtGui.QIcon()
        icon.addPixmap(
            QtGui.QPixmap(":/mask-icon.png"),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.setWindowIcon(icon) 
Example #22
Source File: pyqt5_1.py    From Python_Master_Courses with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # 设置窗口标题
        # self.setWindowTitle('My Browser')
        # 设置窗口图标
        # self.setWindowIcon(QIcon('icons/penguin.png'))
        # 设置窗口大小900*600
        # self.resize(900, 600)
        # self.show()



        # 2
        self.view = QWebEngineView()
        channel = QWebChannel()
        handler = CallHandler()
        channel.registerObject('handler', handler)
        self.view.page().setWebChannel(channel)
        self.view.loadFinished.connect(self._loadFinish)


        # 添加浏览器到窗口中
        # self.setCentralWidget(self.view)

        #
        htmlUrl = 'file:////Users/play/github/Python_Master_Courses/GUI图形界面/pyqt5/pyqt5-javascript-互相传值/js1.html'
        self.view.load(QUrl(htmlUrl))
        self.view.show()

    # 3 
Example #23
Source File: ScreenShotPage.py    From PyQt with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(Window, self).__init__(*args, **kwargs)
        self.resize(600, 400)
        layout = QHBoxLayout(self)

        # 左侧
        widgetLeft = QWidget(self)
        layoutLeft = QVBoxLayout(widgetLeft)
        # 右侧
        self.widgetRight = QListWidget(
            self, minimumWidth=200, iconSize=QSize(150, 150))
        self.widgetRight.setViewMode(QListWidget.IconMode)
        layout.addWidget(widgetLeft)
        layout.addWidget(self.widgetRight)

        self.webView = QWebEngineView()
        layoutLeft.addWidget(self.webView)

        # 截图方式一
        groupBox1 = QGroupBox('截图方式一', self)
        layout1 = QVBoxLayout(groupBox1)
        layout1.addWidget(QPushButton('截图1', self, clicked=self.onScreenShot1))
        layoutLeft.addWidget(groupBox1)

        # 截图方式二(采用js)
        groupBox2 = QGroupBox('截图方式二', self)
        layout2 = QVBoxLayout(groupBox2)
        self.codeEdit = QLineEdit(
            'body', groupBox2, placeholderText='请输入需要截图的元素、ID或者class:如body、#id .class')
        layout2.addWidget(self.codeEdit)
        self.btnMethod2 = QPushButton(
            '', self, clicked=self.onScreenShot2, enabled=False)
        layout2.addWidget(self.btnMethod2)
        layoutLeft.addWidget(groupBox2)

        # 提供访问接口
        self.channel = QWebChannel(self)
        # 把自身对象传递进去
        self.channel.registerObject('_self', self)
        # 设置交互接口
        self.webView.page().setWebChannel(self.channel)
        # 支持截图
        settings = QWebEngineSettings.globalSettings()
        settings.setAttribute(QWebEngineSettings.ScreenCaptureEnabled, True)
        self.webView.loadStarted.connect(self.onLoadStarted)
        self.webView.loadFinished.connect(self.onLoadFinished)
        self.webView.load(QUrl("https://pyqt.site")) 
Example #24
Source File: DyStockSelectItemMenu.py    From DevilYuan with MIT License 4 votes vote down vote up
def _stockInfoAct(self):
        code, name = self._interface.getCodeName()
        if code is None: return

        browser = DyWebView()
        url = 'http://basic.10jqka.com.cn/32/{0}/'.format(code[:-3])
        browser.load(QUrl(url))

        browser.setWindowTitle(name)
        
        rect = QApplication.desktop().availableGeometry()
        taskBarHeight = QApplication.desktop().height() - rect.height()

        browser.resize(rect.width()//3 * 2, rect.height() - taskBarHeight)
        browser.move((rect.width() - browser.width())//2, 0)

        browser.show()

        self._browsers.append(browser) 
Example #25
Source File: qt_webengine.py    From imperialism-remake with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, icon_provider):
        """

        """
        super().__init__()

        # start with empty home url
        self.home_url = None
        self.clear_history = False

        # create and add tool bar on top (non floatable or movable)
        tool_bar = QtWidgets.QToolBar(self)

        # create actions, connect to methods, add to tool bar
        action_home = QtWidgets.QAction(self)
        action_home.setIcon(icon_provider('icon.home.png'))
        action_home.setToolTip('Home')
        action_home.triggered.connect(self.home)
        tool_bar.addAction(action_home)

        action_backward = QtWidgets.QAction(self)
        action_backward.setEnabled(False)  # initially not enabled
        action_backward.setIcon(icon_provider('icon.backward.png'))
        tool_bar.addAction(action_backward)
        self.action_backward = action_backward

        action_forward = QtWidgets.QAction(self)
        action_forward.setEnabled(False)  # initially not enabled
        action_forward.setIcon(icon_provider('icon.forward.png'))
        tool_bar.addAction(action_forward)
        self.action_forward = action_forward

        # create and add web view, also store history
        web_view = QtWebEngineWidgets.QWebEngineView()
        self.web_view = web_view
        self.web_view.loadFinished.connect(self.load_finished)

        # wire forward, backward
        action_backward.triggered.connect(self.backward)
        action_forward.triggered.connect(self.forward)

        # set Layout
        layout = QtWidgets.QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(tool_bar)
        layout.addWidget(web_view) 
Example #26
Source File: movconta.py    From controleEstoque with MIT License 4 votes vote down vote up
def imprimirMovimento(self):
        self.documento = QWebEngineView()

        headertable = ["Receitas", "  Despesas"]

        data_inicio = QDate.toString(self.dt_inicio.date(), "dd-MM-yyyy")
        data_fim = QDate.toString(self.dt_fim.date(), "dd-MM-yyyy")

        desc_receita = []
        total_desc = []
        desc_despesa = []
        total_descDespesa = []
        print(self.usuario)

        if self.tb_receita.rowCount() >= 1:
            for i in range(self.tb_receita.rowCount()):
                desc_receita.append(self.tb_receita.item(i, 0).text())
                total_desc.append(self.tb_receita.item(i, 1).text())

        if self.tb_despesa.rowCount() >= 1:
            for i in range(self.tb_despesa.rowCount()):
                desc_despesa.append(self.tb_despesa.item(i, 0).text())
                total_descDespesa.append(self.tb_despesa.item(i, 1).text())

        if self.lb_despesaPaga.text():
            totaldespesa = self.lb_despesaPaga.text()
        else:
            totaldespesa = 0.00

        if self.lb_entradaRecebido.text():
            totalreceita = self.lb_entradaRecebido.text()
        else:
            totalreceita = 0.00

        totalFinal = self.lb_totalMovimento.text()
        totalFinal2 = re.sub(r'([^\d]+) ', '', totalFinal)

        self.renderTemplate(
            "movimento.html",
            estilo=self.resourcepath('Template/estilo.css'),
            titulo="Fluxo de Caixa periodo {} à {}".format(
                data_inicio, data_fim),
            headertable=headertable,
            desc_receita=desc_receita,
            total_desc=total_desc,
            desc_despesa=desc_despesa,
            total_descDespesa=total_descDespesa,
            totaldespesa=totaldespesa,
            totalreceita=totalreceita,
            totalFinal=totalFinal,
            totalFinal2=float(totalFinal2)
        )

        self.documento.load(QUrl.fromLocalFile(
                                 self.resourcepath("report.html")))
        self.documento.loadFinished['bool'].connect(self.previaImpressao) 
Example #27
Source File: areceber.py    From controleEstoque with MIT License 4 votes vote down vote up
def imprimirAReceber(self):
        self.documento = QWebEngineView()

        headertable = ["Cliente", "Descrição ",
                       "Vencimento", "Valor", "V. Pendente"]

        data_inicio = QDate.toString(self.dt_Inicio.date(), "dd-MM-yyyy")
        data_fim = QDate.toString(self.dt_Fim.date(), "dd-MM-yyyy")

        if self.cb_Situacao.currentData() == '1':
            situacao = "Recebida"

        elif self.cb_Situacao.currentData() == '2':
            situacao = "Pendente"

        cliente = []
        descricao = []
        vencimento = []
        valor = []
        pendente = []
        for i in range(self.tb_AReceber.rowCount()):
            cliente.append(self.tb_AReceber.cellWidget(i, 2).text())
            descricao.append(self.tb_AReceber.cellWidget(i, 3).text())
            vencimento.append(self.tb_AReceber.cellWidget(i, 4).text())
            valor.append(self.tb_AReceber.item(i, 5).text())
            pendente.append(self.tb_AReceber.item(i, 6).text())

        self.renderTemplate(
            "areceber.html",
            estilo=self.resourcepath('Template/estilo.css'),
            titulo="Relatório de conta a receber {} de {} à {}".format(
                situacao, data_inicio, data_fim),
            headertable=headertable,
            nome=cliente,
            desc=descricao,
            venc=vencimento,
            valor=valor,
            pendente=pendente,
            totalPen=format(self.totalPendente, '.2f'),
            totalRec=format(self.totalRecebido, '.2f')


        )

        self.documento.load(QUrl.fromLocalFile(
                                 self.resourcepath("report.html")))
        self.documento.loadFinished['bool'].connect(self.previaImpressao)

    # Imprimindo 
Example #28
Source File: apagar.py    From controleEstoque with MIT License 4 votes vote down vote up
def imprimirAPagar(self):
        self.documento = QWebEngineView()

        headertable = ["Fornecedor", "Descrição ",
                       "Vencimento", "Valor", "V. Pendente"]

        data_inicio = QDate.toString(self.dt_Inicio.date(), "dd-MM-yyyy")
        data_fim = QDate.toString(self.dt_Fim.date(), "dd-MM-yyyy")

        if self.cb_Situacao.currentData() == '1':
            situacao = "Pago"

        elif self.cb_Situacao.currentData() == '2':
            situacao = "Pendente"

        cliente = []
        descricao = []
        vencimento = []
        valor = []
        pendente = []
        for i in range(self.tb_APagar.rowCount()):
            cliente.append(self.tb_APagar.cellWidget(i, 2).text())
            descricao.append(self.tb_APagar.cellWidget(i, 3).text())
            vencimento.append(self.tb_APagar.cellWidget(i, 4).text())
            valor.append(self.tb_APagar.item(i, 5).text())
            pendente.append(self.tb_APagar.item(i, 6).text())

        self.renderTemplate(
            "apagar.html",
            estilo=self.resourcepath('Template/estilo.css'),
            titulo="Relatório de conta a pagar {} de {} à {}".format(
                situacao, data_inicio, data_fim),
            headertable=headertable,
            nome=cliente,
            desc=descricao,
            venc=vencimento,
            valor=valor,
            pendente=pendente,
            totalPen=format(self.totalPendente, '.2f'),
            totalRec=format(self.totalRecebido, '.2f')

        )

        self.documento.load(QUrl.fromLocalFile(
                                 self.resourcepath("report.html")))
        self.documento.loadFinished['bool'].connect(self.previaImpressao)

# Imprimindo 
Example #29
Source File: 利用Python和PyQt5实现简易浏览器.py    From Python_Master_Courses with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # 设置窗口标题
        self.setWindowTitle('My Browser')
        # 设置窗口图标
        self.setWindowIcon(QIcon('icons/penguin.png'))
        # 设置窗口大小900*600
        self.resize(900, 600)
        self.show()

        # 设置浏览器
        # self.browser = QWebView()
        self.browser = QWebEngineView()
        url = 'http://cn.bing.com'
        # 指定打开界面的 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) 
Example #30
Source File: webview.py    From qutebrowser with GNU General Public License v3.0 4 votes vote down vote up
def createWindow(self, wintype):
        """Called by Qt when a page wants to create a new window.

        This function is called from the createWindow() method of the
        associated QWebEnginePage, each time the page wants to create a new
        window of the given type. This might be the result, for example, of a
        JavaScript request to open a document in a new window.

        Args:
            wintype: This enum describes the types of window that can be
                     created by the createWindow() function.

                     QWebEnginePage::WebBrowserWindow:
                         A complete web browser window.
                     QWebEnginePage::WebBrowserTab:
                         A web browser tab.
                     QWebEnginePage::WebDialog:
                         A window without decoration.
                     QWebEnginePage::WebBrowserBackgroundTab:
                         A web browser tab without hiding the current visible
                         WebEngineView.

        Return:
            The new QWebEngineView object.
        """
        debug_type = debug.qenum_key(QWebEnginePage, wintype)
        background = config.val.tabs.background

        log.webview.debug("createWindow with type {}, background {}".format(
            debug_type, background))

        if wintype == QWebEnginePage.WebBrowserWindow:
            # Shift-Alt-Click
            target = usertypes.ClickTarget.window
        elif wintype == QWebEnginePage.WebDialog:
            log.webview.warning("{} requested, but we don't support "
                                "that!".format(debug_type))
            target = usertypes.ClickTarget.tab
        elif wintype == QWebEnginePage.WebBrowserTab:
            # Middle-click / Ctrl-Click with Shift
            # FIXME:qtwebengine this also affects target=_blank links...
            if background:
                target = usertypes.ClickTarget.tab
            else:
                target = usertypes.ClickTarget.tab_bg
        elif wintype == QWebEnginePage.WebBrowserBackgroundTab:
            # Middle-click / Ctrl-Click
            if background:
                target = usertypes.ClickTarget.tab_bg
            else:
                target = usertypes.ClickTarget.tab
        else:
            raise ValueError("Invalid wintype {}".format(debug_type))

        tab = shared.get_tab(self._win_id, target)
        return tab._widget  # pylint: disable=protected-access