本文整理汇总了Python中PySide.QtCore.QUrl.fromLocalFile方法的典型用法代码示例。如果您正苦于以下问题:Python QUrl.fromLocalFile方法的具体用法?Python QUrl.fromLocalFile怎么用?Python QUrl.fromLocalFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtCore.QUrl
的用法示例。
在下文中一共展示了QUrl.fromLocalFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import fromLocalFile [as 别名]
def __init__(self):
QApplication.__init__(self, sys.argv)
self.setOrganizationName("Khertan Software")
self.setOrganizationDomain("khertan.net")
self.setApplicationName("KhtNotes")
self.settings = Settings()
self.view = FilteredDeclarativeView(settings=self.settings)
if os.path.exists('/etc/mer-release'):
fullscreen = True
elif os.path.exists('/etc/aegis'):
fullscreen = True
self.glformat = QGLFormat().defaultFormat()
self.glformat.setSampleBuffers(False)
self.glw = QGLWidget(self.glformat)
self.glw.setAutoFillBackground(False)
self.view.setViewport(self.glw)
else:
fullscreen = False
self.notesModel = NotesModel()
self.note = Note(settings=self.settings)
self.conboyImporter = TomboyImporter()
self.syncer = Sync()
self.rootContext = self.view.rootContext()
self.rootContext.setContextProperty("argv", sys.argv)
self.rootContext.setContextProperty("__version__", __version__)
self.rootContext.setContextProperty("__upgrade__", __upgrade__
.replace('\n', '<br />'))
self.rootContext.setContextProperty("Settings", self.settings)
self.rootContext.setContextProperty("Sync", self.syncer)
self.rootContext.setContextProperty("Importer", self.conboyImporter)
self.rootContext.setContextProperty('notesModel', self.notesModel)
self.rootContext.setContextProperty('Note', self.note)
try:
self.view.setSource(QUrl.fromLocalFile(
os.path.join(os.path.dirname(__file__),
'qml', 'Harmattan_main.qml')))
except:
self.view.setSource(QUrl.fromLocalFile(
os.path.join(os.path.dirname(__file__),
'qml', 'Desktop_main.qml')))
self.rootObject = self.view.rootObject()
if fullscreen:
self.view.showFullScreen()
else:
self.view.show()
self.note.on_error.connect(self.rootObject.onError)
self.syncer.on_error.connect(self.rootObject.onError)
self.syncer.on_finished.connect(self.rootObject.refresh)
self.conboyImporter.on_finished.connect(self.notesModel.reload)
示例2: serve_forever
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import fromLocalFile [as 别名]
def serve_forever(self):
self.jid = '[email protected]'
self.connect() # be sure we are "connected" before the first command
self.connect_callback() # notify that the connection occured
# create window and components
app = QtGui.QApplication(sys.argv)
self.mainW = QtGui.QWidget()
self.mainW.setWindowTitle('Err...')
icon_path = os.path.dirname(errbot.__file__) + os.sep + 'err.svg'
bg_path = os.path.dirname(errbot.__file__) + os.sep + 'err-bg.svg'
self.mainW.setWindowIcon(QtGui.QIcon(icon_path))
vbox = QtGui.QVBoxLayout()
help = QtGui.QLabel("CTRL+Space to autocomplete -- CTRL+Enter to send your message")
self.input = CommandBox(self.cmd_history, self.commands)
self.output = QtWebKit.QWebView()
# init webpage
self.buffer = """<html>
<head>
<link rel="stylesheet" type="text/css" href="%s/style/style.css" />
</head>
<body style=" background-image: url('%s'); background-repeat: no-repeat; background-position:center center; background-attachment:fixed; background-size: contain; margin:0;">
""" % (QUrl.fromLocalFile(BOT_DATA_DIR).toString(), QUrl.fromLocalFile(bg_path).toString())
self.output.setHtml(self.buffer)
# layout
vbox.addWidget(self.output)
vbox.addWidget(self.input)
vbox.addWidget(help)
self.mainW.setLayout(vbox)
# setup web view to open liks in external browser
self.output.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
# connect signals/slots
self.output.page().mainFrame().contentsSizeChanged.connect(self.scroll_output_to_bottom)
self.output.page().linkClicked.connect(QtGui.QDesktopServices.openUrl)
self.input.newCommand.connect(self.send_command)
self.conn.newAnswer.connect(self.new_message)
self.mainW.show()
try:
app.exec_()
finally:
self.disconnect_callback()
self.shutdown()
exit(0)
示例3: testMetaData
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import fromLocalFile [as 别名]
def testMetaData(self):
self.view = QWebView()
QObject.connect(self.view, SIGNAL('loadFinished(bool)'),
self.load_finished)
url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__))
self.view.setUrl(url)
self.app.exec_()
示例4: __init__
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import fromLocalFile [as 别名]
def __init__(self):
QApplication.__init__(self, sys.argv)
self.setOrganizationName("Khertan Software")
self.setOrganizationDomain("khertan.net")
self.setApplicationName("KhtSimpleText")
self.view = QtDeclarative.QDeclarativeView()
#Are we on mer ? So don't use opengl
#As it didn't works on all devices
if not os.path.exists('/etc/mer-release'):
self.glformat = QGLFormat().defaultFormat()
self.glformat.setSampleBuffers(False)
self.glw = QGLWidget(self.glformat)
self.glw.setAutoFillBackground(False)
self.view.setViewport(self.glw)
self.document = Document('~')
self.documentsModel= DocumentsModel(currentDoc=self.document)
self.rootContext = self.view.rootContext()
self.rootContext.setContextProperty("argv", sys.argv)
self.rootContext.setContextProperty("__version__", __version__)
self.rootContext.setContextProperty("__upgrade__", __upgrade__
.replace('\n', '<br>'))
self.rootContext.setContextProperty("Settings", Settings())
self.rootContext.setContextProperty("DocumentsModel",
self.documentsModel)
self.rootContext.setContextProperty("Document",
self.document)
self.view.setSource(QUrl.fromLocalFile(
os.path.join(os.path.dirname(__file__), 'qml', 'main.qml')))
self.rootObject = self.view.rootObject()
self.view.showFullScreen()
示例5: parseMarkdown
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import fromLocalFile [as 别名]
def parseMarkdown(self):
"""
Parse the Markdown stuff.
"""
self.updateStructure()
if self.sync is False:
return
y = self.web.page().mainFrame().scrollPosition().y()
txt = self.editor.toPlainText().encode('utf-8')
if txt is '' or None:
return
p = Popen([self.parser], stdout=PIPE, stdin=PIPE, stderr=STDOUT,
shell=False)
grep_stdout = p.communicate(input=txt)[0].decode('utf-8')
path = QUrl.fromUserInput(os.getcwd() + os.sep)
grep_stdout = grep_stdout.replace('img src=\"', 'img src=\"' +
path.toString())
# Can't use baseUrl=path because external img will not be loaded
# than :-/
self.web.setHtml(grep_stdout)
self.web.settings().setUserStyleSheetUrl(QUrl.fromLocalFile(os.getcwd()
+ os.sep + "/style.css"))
if y:
self.web.scroll(0, y)
self.web.page().mainFrame().scroll(0, y)
self.web.page().mainFrame().setScrollPosition(QPoint(0, y))
示例6: __init__
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import fromLocalFile [as 别名]
def __init__(self):
QApplication.__init__(self, sys.argv)
self.setOrganizationName("Khertan Software")
self.setOrganizationDomain("khertan.net")
self.setApplicationName("KhtNotes")
self.view = QtDeclarative.QDeclarativeView()
self.glw = QGLWidget()
self.view.setViewport(self.glw)
self.notesModel = NotesModel()
self.note = Note()
self.conboyImporter = TomboyImporter()
self.syncer = Sync()
self.rootContext = self.view.rootContext()
self.rootContext.setContextProperty("argv", sys.argv)
self.rootContext.setContextProperty("__version__", __version__)
self.rootContext.setContextProperty("__upgrade__", __upgrade__
.replace('\n', '<br>'))
self.rootContext.setContextProperty("Settings", Settings())
self.rootContext.setContextProperty("Sync", self.syncer)
self.rootContext.setContextProperty("Importer", self.conboyImporter)
self.rootContext.setContextProperty("QmlDirReaderWriter",
QmlDirReaderWriter())
self.rootContext.setContextProperty('notesModel', self.notesModel)
self.rootContext.setContextProperty('Note', self.note)
self.view.setSource(QUrl.fromLocalFile(
os.path.join(os.path.dirname(__file__),
'qml', 'Harmattan_main.qml')))
self.rootObject = self.view.rootObject()
self.view.showFullScreen()
self.note.on_error.connect(self.rootObject.onError)
self.syncer.on_error.connect(self.rootObject.onError)
self.syncer.on_finished.connect(self.notesModel.reload)
self.conboyImporter.on_finished.connect(self.notesModel.reload)
示例7: testAbstractItemModelTransferToQML
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import fromLocalFile [as 别名]
def testAbstractItemModelTransferToQML(self):
view = QDeclarativeView()
view.setSource(QUrl.fromLocalFile(adjust_filename('bug_814.qml', __file__)))
root = view.rootObject()
model = ListModel()
root.setProperty('model', model)
view.show()
示例8: testSignalEmission
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import fromLocalFile [as 别名]
def testSignalEmission(self):
qmlRegisterType(MyItem, "my.item", 1, 0, "MyItem")
view = QDeclarativeView()
view.setSource(QUrl.fromLocalFile(adjust_filename('bug_951.qml', __file__)))
self.app.exec_()
self.assertTrue(MyItem.COMPONENT_COMPLETE_CALLED)
示例9: iconName
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import fromLocalFile [as 别名]
def iconName(self):
if 'Icon' in self._prop.keys():
icon_name = './qml/icons/%s.png' % self._prop['Icon']
if not os.path.exists(icon_name):
icon_name = './qml/icons/unknow.png'
else:
icon_name = './qml/icons/unknow.png'
return QUrl.fromLocalFile(icon_name)
示例10: __init__
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import fromLocalFile [as 别名]
def __init__(self):
QApplication.__init__(self, sys.argv)
self.setOrganizationName("Khertan Software")
self.setOrganizationDomain("khertan.net")
self.setApplicationName("BitPurse")
self.view = QtDeclarative.QDeclarativeView()
# Are we on mer ? So don't use opengl
# As it didn't works on all devices
if os.path.exists('/etc/mer-release'):
fullscreen = True
elif os.path.exists('/etc/aegis'):
fullscreen = True
self.glformat = QGLFormat().defaultFormat()
self.glformat.setSampleBuffers(False)
self.glw = QGLWidget(self.glformat)
self.glw.setAutoFillBackground(False)
self.view.setViewport(self.glw)
else:
fullscreen = False
self.walletController = WalletController()
self.rootContext = self.view.rootContext()
self.rootContext.setContextProperty("argv", sys.argv)
self.rootContext.setContextProperty("__version__", __version__)
self.rootContext.setContextProperty("__upgrade__", __upgrade__
.replace('\n', '<br />'))
self.rootContext.setContextProperty('WalletController',
self.walletController)
self.rootContext.setContextProperty('AddressesModel',
self.walletController
.addressesModel)
self.rootContext.setContextProperty('TransactionsModel',
self.walletController
.transactionsModel)
self.rootContext.setContextProperty('Settings',
self.walletController
.settings)
self.view.setSource(QUrl.fromLocalFile(
os.path.join(os.path.dirname(__file__),
'qml', 'main.qml')))
self.rootObject = self.view.rootObject()
if fullscreen:
self.view.showFullScreen()
else:
self.view.show()
# self.loginPage = self.rootObject.findChild(QObject, "loginPage")
self.sendPage = self.rootObject.findChild(QObject, "sendPage")
self.aboutPage = self.rootObject.findChild(QObject, "aboutPage")
self.walletController.onError.connect(self.rootObject.onError)
# self.walletController.onConnected.connect(self.loginPage.onConnected)
self.walletController.onTxSent.connect(self.sendPage.onTxSent)
示例11: __init__
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import fromLocalFile [as 别名]
def __init__(self, parent=None):
super(MainLogic, self).__init__(parent)
self.setWindowTitle("RDA")
# Renders given file
self.setSource(QUrl.fromLocalFile("gui/main.qml"))
# QML resizes to main window
self.setResizeMode(QDeclarativeView.SizeRootObjectToView)
self.rootContext().setContextProperty("Logic", self)
self.connected = False
# get an instance of the network client
self.net = Client()
示例12: testQDeclarativeNetworkFactory
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import fromLocalFile [as 别名]
def testQDeclarativeNetworkFactory(self):
view = QDeclarativeView()
url = QUrl.fromLocalFile(adjust_filename('hw.qml', __file__))
view.setSource(url)
view.show()
self.assertEqual(view.status(), QDeclarativeView.Ready)
self.app.exec_()
示例13: drawMap
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import fromLocalFile [as 别名]
def drawMap(self):
#=======================================================================
# with open("sweattrails/qt/maps.html") as fd:
# html = fd.read()
# templ = string.Template(html)
# html = templ.substitute(
# bgcolor = "#343434",
# fgcolor = "#FFFFFF",
# mapskey = gripe.Config.app["config"].google_api_key)
#=======================================================================
self.setUrl(QUrl.fromLocalFile(os.path.join(gripe.root_dir(), "sweattrails/qt/maps.html")))
示例14: testModelExport
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import fromLocalFile [as 别名]
def testModelExport(self):
view = QDeclarativeView()
dataList = [MyObject("Item 1"), MyObject("Item 2"), MyObject("Item 3"), MyObject("Item 4")]
ctxt = view.rootContext()
ctxt.setContextProperty("myModel", dataList)
url = QUrl.fromLocalFile(adjust_filename("viewmodel.qml", __file__))
view.setSource(url)
view.show()
self.assertEqual(view.status(), QDeclarativeView.Ready)
示例15: createQmlComponent
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import fromLocalFile [as 别名]
def createQmlComponent(filename, engine, context, parent=None):
# Load the QML UI (this could take a while...)
qcomponent = QDeclarativeComponent(
engine, QUrl.fromLocalFile(QML(filename)), parent
)
qobject = qcomponent.create(context)
error = qcomponent.errorString()
if len(error) > 0:
print('Error while loading QML file: ' + error)
return QmlGuiComponent(qobject, qcomponent)