Python PyQt5.QtCore.QUrl.fromLocalFile() Examples
The following are 30
code examples of PyQt5.QtCore.QUrl.fromLocalFile().
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.QtCore.QUrl
, or try the search function
.
Example #1
Source File: apagar.py From controleEstoque with MIT License | 7 votes |
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: qmltools.py From code-jam-5 with MIT License | 7 votes |
def QmlWidget(qmlpath: str, context: dict, parent: QWidget) -> QWidget: """ Generate a QtWidgets widget from a QML file. :qmlpath The pat of the QML file. :context The context objects to expose to QML. """ qmlpath = os.fspath(qmlpath) view = QQuickView() engine = view.engine() for name, obj in context.items(): engine.rootContext().setContextProperty(name, obj) container = QWidget.createWindowContainer(view, parent) container.setStyleSheet("Widget { padding: 7px; }") view.setSource(QUrl.fromLocalFile(qmlpath)) return container
Example #3
Source File: areceber.py From controleEstoque with MIT License | 6 votes |
def imprimirReciboRec(self): self.documento = QWebEngineView() self.renderTemplate( "recibo.html", estilo=self.resourcepath('Template/estilo.css'), cod=self.tx_Cod.text(), nome=self.tx_NomeFantasia.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 #4
Source File: QtApplication.py From Uranium with GNU Lesser General Public License v3.0 | 6 votes |
def addFileToRecentFiles(self, file_name: str) -> None: file_path = QUrl.fromLocalFile(file_name) if file_path in self._recent_files: self._recent_files.remove(file_path) self._recent_files.insert(0, file_path) if len(self._recent_files) > 10: del self._recent_files[10] pref = "" for path in self._recent_files: pref += path.toLocalFile() + ";" self.getPreferences().setValue("%s/recent_files" % self.getApplicationName(), pref) self.recentFilesChanged.emit()
Example #5
Source File: CloudFlowMessage.py From Cura with GNU Lesser General Public License v3.0 | 6 votes |
def __init__(self, address: str) -> None: image_path = os.path.join( CuraApplication.getInstance().getPluginRegistry().getPluginPath("UM3NetworkPrinting") or "", "resources", "svg", "cloud-flow-start.svg" ) super().__init__( text=I18N_CATALOG.i18nc("@info:status", "Send and monitor print jobs from anywhere using your Ultimaker account."), lifetime=0, dismissable=True, option_state=False, image_source=QUrl.fromLocalFile(image_path), image_caption=I18N_CATALOG.i18nc("@info:status Ultimaker Cloud should not be translated.", "Connect to Ultimaker Cloud"), ) self._address = address self.addAction("", I18N_CATALOG.i18nc("@action", "Get started"), "", "") self.actionTriggered.connect(self._onCloudFlowStarted)
Example #6
Source File: player.py From MusicBox with MIT License | 6 votes |
def play(self): try: media = self.musics[self.currentIndex] except: logger.error("unknow error. musics info: {0}".format(self.musics)) return if type(media) == str: if 'http' in media or 'file' in media: content = QMediaContent(QUrl(media)) else: content = QMediaContent(QUrl.fromLocalFile(media)) self.musics = self.musics[:self.currentIndex] + [content] + self.musics[self.currentIndex+1:] media = content self.parent.setMedia(media) self.parent.playMusic() self.tabMusicEvent()
Example #7
Source File: player.py From MusicBox with MIT License | 6 votes |
def setCurrentIndex(self, index): try: media = self.musics[index] except: logger.error("unknow error. musics info: {0}".format(self.musics)) return if type(media) == str: if 'http' in media or 'file' in media: content = QMediaContent(QUrl(media)) else: content = QMediaContent(QUrl.fromLocalFile(media)) self.musics = self.musics[:index] + [content] + self.musics[index+1:] self.parent.setMedia(content) else: self.parent.setMedia(media) self.parent.playMusic() self.tabMusicEvent() self.currentIndex = index
Example #8
Source File: plotly_viewer.py From pandasgui with MIT License | 6 votes |
def __init__(self, fig): # Create a QApplication instance or use the existing one if it exists self.app = QApplication.instance() if QApplication.instance() else QApplication(sys.argv) super().__init__() # This ensures there is always a reference to this widget and it doesn't get garbage collected global instance_list instance_list.append(self) # self.file_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "temp.html")) self.file_path = os.path.join(os.getcwd(), 'temp.html') self.setWindowTitle("Plotly Viewer") plotly.offline.plot(fig, filename=self.file_path, auto_open=False) self.load(QUrl.fromLocalFile(self.file_path)) self.resize(640, 480) self.show()
Example #9
Source File: main.py From PyQt5-Apps with GNU General Public License v3.0 | 6 votes |
def connectSlots(self): """connect slots with buttons/ short cuts/signals """ # home tab self.download.clicked.connect(self.downloadSound) self.download.setShortcut("CTRL+L") self.search.clicked.connect(self.searchInfo) self.search.setShortcut("CTRL+Return") self.toolButton.clicked.connect( lambda: QDesktopServices.openUrl(QUrl.fromLocalFile("./sound")) ) # self.clearBtn.clicked.connect(self.clearAllDownloaded)
Example #10
Source File: view.py From equant with GNU General Public License v2.0 | 5 votes |
def create_content_vbox(self): # self.content_vbox = QGroupBox('内容') self.content_vbox = QWidget() self.content_layout = QGridLayout() self.content_layout.setContentsMargins(0, 0, 0, 0) self.content_layout.setSpacing(0) self.save_btn = QPushButton('保存') self.run_btn = QPushButton('运行') self.run_btn.setMaximumWidth(100) self.save_btn.setMaximumWidth(100) self.run_btn.setEnabled(False) # self.contentEdit = MainFrmQt("localhost", 8765, "pyeditor", os.path.join(os.getcwd(), 'quant\python_editor\editor.htm')) self.contentEdit = CodeEditor() self.contentEdit.setObjectName('contentEdit') if self.settings.contains('theme') and self.settings.value('theme') == 'vs-dark': self.contentEdit.load( QUrl.fromLocalFile(os.path.abspath(r'qtui/quant/python_editor/editor.htm'))) else: self.contentEdit.load( QUrl.fromLocalFile(os.path.abspath(r'qtui/quant/python_editor/editor_vs.htm'))) self.contentEdit.on_switchSignal.connect(self.switch_strategy_path) self.statusBar = QLabel() self.statusBar.setText(" 极星9.5连接失败,请重新打开极星量化!") self.statusBar.setStyleSheet('color: #0062A3;') self.content_layout.addWidget(self.statusBar, 0, 0, 1, 1) self.content_layout.addWidget(self.run_btn, 0, 1, 1, 1) self.content_layout.addWidget(self.save_btn, 0, 2, 1, 1) self.content_layout.addWidget(self.contentEdit, 2, 0, 20, 3) self.content_vbox.setLayout(self.content_layout) self.run_btn.clicked.connect(self.emit_custom_signal) # 改为提示用户保存当前的文件 self.run_btn.clicked.connect( lambda: self.create_strategy_policy_win({}, self.strategy_path, False)) self.save_btn.clicked.connect(self.emit_custom_signal) self.save_btn.setShortcut("Ctrl+S") # ctrl + s 快捷保存
Example #11
Source File: video_dialog.py From CvStudio with MIT License | 5 votes |
def play(self): if self._source: self.media_player.setMedia( QMediaContent(QUrl.fromLocalFile(self._source))) self.media_player.play()
Example #12
Source File: mainclientes.py From controleEstoque with MIT License | 5 votes |
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 #13
Source File: mainprodutos.py From controleEstoque with MIT License | 5 votes |
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 #14
Source File: mainvendas.py From controleEstoque with MIT License | 5 votes |
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 #15
Source File: resourcely.py From code-jam-5 with MIT License | 5 votes |
def QUrl(self) -> 'QUrl': """Return a QUrl object built from the original url.""" from PyQt5.QtCore import QUrl return QUrl.fromLocalFile(os.fspath(self))
Example #16
Source File: desktop.py From gridsync with GNU General Public License v3.0 | 5 votes |
def _desktop_open(path): QDesktopServices.openUrl(QUrl.fromLocalFile(path))
Example #17
Source File: DirectoryTreeView.py From urh with GNU General Public License v3.0 | 5 votes |
def on_open_explorer_action_triggered(self): file_path = self.model().get_file_path(self.rootIndex()) QDesktopServices.openUrl(QUrl.fromLocalFile(file_path))
Example #18
Source File: TestActiveToolProxy.py From Uranium with GNU Lesser General Public License v3.0 | 5 votes |
def test_activeToolPanel(self): # There is no active tool, so it should be empty assert self.proxy.activeToolPanel == QUrl() with patch.object(self.tool, "getMetaData", MagicMock(return_value={"tool_panel": "derp"})): with patch("UM.PluginRegistry.PluginRegistry.getPluginPath", MagicMock(return_value = "OMG")): Application.getInstance().getController().setActiveTool(self.tool) assert self.proxy.activeToolPanel == QUrl.fromLocalFile("OMG/derp") # Try again with empty metadata with patch("UM.PluginRegistry.PluginRegistry.getMetaData", MagicMock(return_value={"tool": {}})): Application.getInstance().getController().setActiveTool("") Application.getInstance().getController().setActiveTool(self.tool) assert self.proxy.activeToolPanel == QUrl.fromLocalFile("")
Example #19
Source File: calculate_all_shortest_paths.py From Offline-MapMatching with GNU General Public License v3.0 | 5 votes |
def helpUrl(self): ''' Returns the URL for the help document, if a help document does exist. ''' dir = os.path.dirname(__file__) file = os.path.abspath(os.path.join(dir, '..', 'help_docs', 'help.html')) if not os.path.exists(file): return '' return QUrl.fromLocalFile(file).toString(QUrl.FullyEncoded)
Example #20
Source File: docwindow.py From bluesky with GNU General Public License v3.0 | 5 votes |
def show_cmd_doc(self, cmd): if not cmd: cmd = 'Command-Reference' if not isinstance(self.view, QLabel): self.view.load(QUrl.fromLocalFile( QFileInfo(f'data/html/{cmd.lower()}.html').absoluteFilePath()))
Example #21
Source File: clip_network_algorithm.py From Offline-MapMatching with GNU General Public License v3.0 | 5 votes |
def helpUrl(self): ''' Returns the URL for the help document, if a help document does exist. ''' dir = os.path.dirname(__file__) file = os.path.abspath(os.path.join(dir, '..', 'help_docs', 'help.html')) if not os.path.exists(file): return '' return QUrl.fromLocalFile(file).toString(QUrl.FullyEncoded)
Example #22
Source File: offline_map_matching_algorithm.py From Offline-MapMatching with GNU General Public License v3.0 | 5 votes |
def helpUrl(self): ''' Returns the URL for the help document, if a help document does exist. ''' dir = os.path.dirname(__file__) file = os.path.abspath(os.path.join(dir, '..', 'help_docs', 'help.html')) if not os.path.exists(file): return '' return QUrl.fromLocalFile(file).toString(QUrl.FullyEncoded)
Example #23
Source File: map_matching_preparation_algorithm.py From Offline-MapMatching with GNU General Public License v3.0 | 5 votes |
def helpUrl(self): ''' Returns the URL for the help document, if a help document does exist. ''' dir = os.path.dirname(__file__) file = os.path.abspath(os.path.join(dir, '..', 'help_docs', 'help.html')) if not os.path.exists(file): return '' return QUrl.fromLocalFile(file).toString(QUrl.FullyEncoded)
Example #24
Source File: JsSignals.py From PyQt with GNU General Public License v3.0 | 5 votes |
def __init__(self, *args, **kwargs): super(Window, self).__init__(*args, **kwargs) layout = QVBoxLayout(self) self.webview = WebEngineView(self) layout.addWidget(self.webview) layout.addWidget(QPushButton( '发送自定义信号', self, clicked=self.webview.sendCustomSignal)) self.webview.windowTitleChanged.connect(self.setWindowTitle) self.webview.load(QUrl.fromLocalFile( os.path.abspath('Data/JsSignals.html')))
Example #25
Source File: desktop.py From parsec-cloud with GNU Affero General Public License v3.0 | 5 votes |
def open_file(path): QDesktopServices.openUrl(QUrl.fromLocalFile(QFileInfo(path).absoluteFilePath()))
Example #26
Source File: notifications.py From vidcutter with GNU General Public License v3.0 | 5 votes |
def playMedia(self) -> None: if os.path.isfile(self.filename): QDesktopServices.openUrl(QUrl.fromLocalFile(self.filename))
Example #27
Source File: LocalFileOutputDevice.py From Uranium with GNU Lesser General Public License v3.0 | 5 votes |
def _onMessageActionTriggered(self, message, action): if action == "open_folder" and hasattr(message, "_folder"): QDesktopServices.openUrl(QUrl.fromLocalFile(message._folder))
Example #28
Source File: TestTheme.py From Uranium with GNU Lesser General Public License v3.0 | 5 votes |
def test_getKnownIcon(theme): icon_location = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_theme", "icons", "test.svg") assert theme.getIcon("test") == QUrl.fromLocalFile(icon_location)
Example #29
Source File: TestStage.py From Uranium with GNU Lesser General Public License v3.0 | 5 votes |
def test_iconSource(): stage = Stage() # Should be empty if we didn't do anything yet assert stage.iconSource == QUrl() stage.setIconSource("DERP") assert stage.iconSource == QUrl.fromLocalFile("DERP") stage.setIconSource(QUrl.fromLocalFile("FOO")) assert stage.iconSource == QUrl.fromLocalFile("FOO")
Example #30
Source File: TestStage.py From Uranium with GNU Lesser General Public License v3.0 | 5 votes |
def test_addGetDisplayComponent(): stage = Stage() stage.addDisplayComponent("BLORP", "location") assert stage.getDisplayComponent("BLORP") == QUrl.fromLocalFile("location") stage.addDisplayComponent("MEEP!", QUrl.fromLocalFile("MEEP")) assert stage.getDisplayComponent("MEEP!") == QUrl.fromLocalFile("MEEP")