Python PyQt5.QtCore 模块,QUrl() 实例源码
我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt5.QtCore.QUrl()。
def setupUi(self, Window):
Window.setObjectName("Window")
Window.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(Window)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.centralwidget)
self.verticalLayout_2.setContentsMargins(-1, 4, -1, 4)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.webView = QtWebKitWidgets.QWebView(self.centralwidget)
self.webView.setUrl(QtCore.QUrl("http://qt.nokia.com/"))
self.webView.setObjectName("webView")
self.verticalLayout_2.addWidget(self.webView)
Window.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(Window)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 27))
self.menubar.setObjectName("menubar")
Window.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(Window)
self.statusbar.setObjectName("statusbar")
Window.setStatusBar(self.statusbar)
self.dockWidget = QtWidgets.QDockWidget(Window)
self.dockWidget.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea)
self.dockWidget.setObjectName("dockWidget")
self.dockWidgetContents = QtWidgets.QWidget()
self.dockWidgetContents.setObjectName("dockWidgetContents")
self.verticalLayout = QtWidgets.QVBoxLayout(self.dockWidgetContents)
self.verticalLayout.setContentsMargins(4, 4, 4, 4)
self.verticalLayout.setObjectName("verticalLayout")
self.treeWidget = QtWidgets.QTreeWidget(self.dockWidgetContents)
self.treeWidget.setObjectName("treeWidget")
self.treeWidget.headerItem().setText(0, "1")
self.treeWidget.header().setVisible(False)
self.verticalLayout.addWidget(self.treeWidget)
self.dockWidget.setWidget(self.dockWidgetContents)
Window.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockWidget)
self.retranslateUi(Window)
QtCore.QMetaObject.connectSlotsByName(Window)
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_())
def setupUi(self, MiniBrowserWidget):
MiniBrowserWidget.setObjectName("MiniBrowserWidget")
MiniBrowserWidget.resize(665, 483)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(MiniBrowserWidget.sizePolicy().hasHeightForWidth())
MiniBrowserWidget.setSizePolicy(sizePolicy)
self.horizontalLayout = QtWidgets.QHBoxLayout(MiniBrowserWidget)
self.horizontalLayout.setObjectName("horizontalLayout")
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.browser = QtWebKitWidgets.QWebView(MiniBrowserWidget)
self.browser.setUrl(QtCore.QUrl("http://yandex.ru/"))
self.browser.setObjectName("browser")
self.verticalLayout.addWidget(self.browser)
self.horizontalLayout.addLayout(self.verticalLayout)
self.retranslateUi(MiniBrowserWidget)
QtCore.QMetaObject.connectSlotsByName(MiniBrowserWidget)
def mainPyQt4Simple():
# ?????????import
from PyQt4.QtCore import QUrl
from PyQt4.QtGui import QApplication
from PyQt4.QtWebKit import QWebView
url = 'https://github.com/tody411/PyIntroduction'
app = QApplication(sys.argv)
# QWebView???Web?????
browser = QWebView()
browser.load(QUrl(url))
browser.show()
sys.exit(app.exec_())
## PyQt4??Web???????(Youtube?).
def loadPage(self, web_page):
try:
if os.environ.get('DEBUG'):
self.settings().setAttribute(
QWebSettings.DeveloperExtrasEnabled, True)
except Exception:
pass
if os.environ.get('DEBUG'):
self.inspector = QWebInspector(self)
self.inspector.setPage(self.page())
self.inspector.show()
if os.path.isabs(web_page):
web_page = os.path.relpath(web_page)
url = QtCore.QUrl(web_page)
# TODO -- port this to QWebEngine
self.frame = self.page().mainFrame()
self.frame.addToJavaScriptWindowObject(
"bitmaskBrowser", self.bitmask_browser)
self.load(url)
def main():
# This is required so that app.quit can be invoked when the quickview
# is closed. If it is not present then the app does not exit. It is
# possibly a bug in PyQt or Qt.
global app
app = QtWidgets.QApplication(sys.argv)
quickview = QtQuick.QQuickView()
if getattr(sys, 'frozen', None):
basedir = sys._MEIPASS
else:
basedir = os.path.dirname(__file__)
# The app dir is in the default import path but we can't put the QtQuick
# import lib dirs there because of a name clash (on OSX) with the QtQuick
# dll.
print(("Qt5 Qml import paths: " \
+ unicode(quickview.engine().importPathList())))
quickview.setSource(QtCore.QUrl('qrc:/hello.qml'))
quickview.engine().quit.connect(app.quit)
quickview.show()
app.exec_()
def capture(self, url):
print('--load')
self.load(QUrl(url))
self.wait_load()
self.show()
size = self.page().contentsSize()
self.page().view().resize(*[int(s) for s in [size.width(), size.height()]])
print('--take image')
image = QImage(800, 800, QImage.Format_ARGB32)
painter = QPainter(image)
print('--render')
self.page().view().render(painter)
painter.end()
print('Saving QImage')
img_bytes = QByteArray()
bio = QBuffer(img_bytes)
bio.open(QIODevice.WriteOnly)
image.save(bio, 'PNG')
return img_bytes
def __init__(self):
""" Initialize main window. """
QMainWindow.__init__(self)
self.setupUi(self)
self.resize(QSize(settings.get('citewidth'),
settings.get('citeheight')))
self.move(QPoint(settings.get('citex'),
settings.get('citey')))
self.tabWidget.tabBar().setCurrentIndex(0)
self.searchTab.setFocus()
self.setWindowTitle('Cite')
self.show()
self.raise_()
self.linkSettings()
self.searchQuery.installEventFilter(self)
self.text = self.bibtext = self.lastquery = ""
self.batchBibtext = self.batchText = ""
self.neverOpened = True
self.helpText.setSource(QUrl('doc/help.html'))
def dropEvent(self,e):
"Modify incoming drag and dropped urls to use a relative path."
try:
#The startswith thing witll only filter out some of the annoying exception logs but it's better than nothing
#todo: only modify things that actuall
if e.mimeData().hasUrls() and e.mimeData().urls()[0].toString().startswith("file://"):
droppedpath = e.mimeData().urls()[0].toString()[len("file://"):]
here = self.url().toString()[len("file://"):]
print(here, droppedpath)
#Don't modify absolute paths to anything outside the notes directory.
if not os.path.relpath(droppedpath, config.notespath).startswith(".."):
#e.mimeData().setUrls([QtCore.QUrl(os.path.relpath(self.url().toString(), e.mimeData().urls()[0].toString()))])
#Create a link as Html that looks the way we want it to.
e.mimeData().setHtml('<a href="'+
urllib.parse.quote_plus(os.path.relpath(droppedpath, os.path.dirname(here) ) )+
'">'+capitalize(fn_to_title(
'.'.join(
os.path.basename(droppedpath).split(".")[:-1]))) +"</a>")
except:
logging.exception("Failed to modify to relative path")
QWebView.dropEvent(self,e)
def dropEvent(self,e):
"Modify incoming drag and dropped urls to use a relative path."
try:
#The startswith thing witll only filter out some of the annoying exception logs but it's better than nothing
#todo: only modify things that actuall
if e.mimeData().hasUrls() and e.mimeData().urls()[0].toString().startswith("file://"):
droppedpath = e.mimeData().urls()[0].toString()[len("file://"):]
here = self.url().toString()[len("file://"):]
print(here, droppedpath)
#Don't modify absolute paths to anything outside the notes directory.
if not os.path.relpath(droppedpath, config.notespath).startswith(".."):
#e.mimeData().setUrls([QtCore.QUrl(os.path.relpath(self.url().toString(), e.mimeData().urls()[0].toString()))])
#Create a link as Html that looks the way we want it to.
e.mimeData().setHtml('<a href="'+
urllib.parse.quote_plus(os.path.relpath(droppedpath, os.path.dirname(here) ) )+
'">'+capitalize(fn_to_title(
'.'.join(
os.path.basename(droppedpath).split(".")[:-1]))) +"</a>")
except:
logging.exception("Failed to modify to relative path")
QWebView.dropEvent(self,e)
def __init__(self, parent=None):
super(FormExtractor, self).__init__(parent)
self.ui = Ui_Form()
self.ui.setupUi(self)
webView = self.ui.webView
webView.setUrl(QUrl('qrc:/form.html'))
webView.page().mainFrame().javaScriptWindowObjectCleared.connect(
self.populateJavaScriptWindowObject)
self.resize(300, 300)
def setupUi(self, Window):
Window.setObjectName("Window")
Window.resize(640, 480)
self.verticalLayout = QtWidgets.QVBoxLayout(Window)
self.verticalLayout.setObjectName("verticalLayout")
self.webView = QtWebKitWidgets.QWebView(Window)
self.webView.setUrl(QtCore.QUrl("http://webkit.org/"))
self.webView.setObjectName("webView")
self.verticalLayout.addWidget(self.webView)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.formLayout = QtWidgets.QFormLayout()
self.formLayout.setFieldGrowthPolicy(QtWidgets.QFormLayout.ExpandingFieldsGrow)
self.formLayout.setObjectName("formLayout")
self.elementLabel = QtWidgets.QLabel(Window)
self.elementLabel.setObjectName("elementLabel")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.elementLabel)
self.elementLineEdit = QtWidgets.QLineEdit(Window)
self.elementLineEdit.setObjectName("elementLineEdit")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.elementLineEdit)
self.horizontalLayout.addLayout(self.formLayout)
self.highlightButton = QtWidgets.QPushButton(Window)
self.highlightButton.setObjectName("highlightButton")
self.horizontalLayout.addWidget(self.highlightButton)
self.verticalLayout.addLayout(self.horizontalLayout)
self.elementLabel.setBuddy(self.elementLineEdit)
self.retranslateUi(Window)
QtCore.QMetaObject.connectSlotsByName(Window)
def _set_connections(self):
"""
Build signal/slot connections once the app started.
:return: None
"""
self.action_about.triggered.connect(self.init_about)
# To make the link in About page clickable
self.label_2.linkActivated.connect(open_url)
def open_help_url():
url = QtCore.QUrl('https://github.com/bioinformatist/Gao-s-SB#examples')
try:
QDesktopServices.openUrl(url)
except:
self.raise_warnings('Network error: No connection', 'Please check your network connection.')
return
self.action_help.triggered.connect(open_help_url)
self.action_setWorkingDirectory.triggered.connect(self.set_working_directory)
self.action_queryAligner.triggered.connect(self.init_align_queries)
self.action_downloadSequence.triggered.connect(self.init_download_sequences)
self.action_filtering.triggered.connect(self.init_filtering)
def open_url(url):
QDesktopServices.openUrl(QtCore.QUrl(url))
# Create a set of arguments which make a ``subprocess.Popen`` (and
# variants) call work with or without Pyinstaller, ``--noconsole`` or
# not, on Windows and Linux. Typical use::
#
# subprocess.call(['program_to_run', 'arg_1'], **subprocess_args())
#
# When calling ``check_output``::
#
# subprocess.check_output(['program_to_run', 'arg_1'],
# **subprocess_args(False))
def start(self):
"""Display the GUI"""
myApp = QApplication(sys.argv)
myEngine = QQmlApplicationEngine()
sys.excepthook = lambda typ, val, tb: self.error_handler(typ, val, tb)
myEngine.rootContext().setContextProperty("python", self) # Need to set this before loading
myEngine.load(QUrl(qml_file))
# These two are hacks, because getting them in the __init__ and RAII working isn't
self.debug_window = ScrollableDialog()
self.clipboard = myApp.clipboard()
self.analyze_loadorder(None)
sys.exit(myApp.exec_())
def play_audio(self) -> None:
try:
settings = mc.model.SettingsM.get()
audio_path_str = settings.breathing_reminder_audio_path_str
volume_int = settings.breathing_reminder_volume_int
sound_effect = QtMultimedia.QSoundEffect(self)
# -PLEASE NOTE: A parent has to be given here, otherwise we will not hear anything
sound_effect.setSource(QtCore.QUrl.fromLocalFile(audio_path_str))
sound_effect.setVolume(float(volume_int / 100))
sound_effect.play()
except NameError:
logging.debug(
"NameError - Cannot play audio since QtMultimedia has not been imported"
)
def __init__(self, url, file_path=None):
if file_path is None:
self.file_handler = None
self.file_downloaded_size = None
else:
self.file_handler = open(file_path, "wb")
self.file_downloaded_size = 0
self._qt_network_manager = QtNetwork.QNetworkAccessManager()
self.deferred = defer.Deferred()
self.deferred._store_it_because_qt_needs_or_wont_work = self
request = QtNetwork.QNetworkRequest(QtCore.QUrl(url))
self.req = self._qt_network_manager.get(request)
self.req.error.connect(self.error)
self.req.finished.connect(self.end)
if self.file_handler is not None:
self.req.downloadProgress.connect(self._save_partial)
# program the eventual unlock
QtCore.QTimer.singleShot(10000, self.unlock) # ten seconds should be more than enough (?)
def save(self, path=None):
if not path:
path = self._file.filename
elif isinstance(path, QtCore.QUrl):
path = path.toLocalFile()
self._file.filename = path
# logger.debug('MainController, saving file: %s.', path)
try:
self._file.save(path)
except OSError as ex:
logger.exception("Error saving file %s", path)
self.showError(ex)
return
self._settings.setValue("last_open_file", path)
self._settings.sync()
def setupUi(self, go2mapillaryDockWidgetBase):
go2mapillaryDockWidgetBase.setObjectName(_fromUtf8("go2mapillaryDockWidgetBase"))
go2mapillaryDockWidgetBase.resize(320, 260)
self.dockWidgetContents = QtWidgets.QWidget()
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.dockWidgetContents.sizePolicy().hasHeightForWidth())
self.dockWidgetContents.setSizePolicy(sizePolicy)
self.dockWidgetContents.setMinimumSize(QtCore.QSize(320, 240))
self.dockWidgetContents.setMaximumSize(QtCore.QSize(320, 240))
self.dockWidgetContents.setObjectName(_fromUtf8("dockWidgetContents"))
self.gridLayout = QtWidgets.QGridLayout(self.dockWidgetContents)
self.gridLayout.setMargin(0)
self.gridLayout.setSpacing(0)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.webView = QtWebKitWidgets.QWebView(self.dockWidgetContents)
self.webView.setUrl(QtCore.QUrl(_fromUtf8("about:blank")))
self.webView.setObjectName(_fromUtf8("webView"))
self.gridLayout.addWidget(self.webView, 0, 0, 1, 1)
go2mapillaryDockWidgetBase.setWidget(self.dockWidgetContents)
self.retranslateUi(go2mapillaryDockWidgetBase)
QtCore.QMetaObject.connectSlotsByName(go2mapillaryDockWidgetBase)
def main():
# This is required so that app.quit can be invoked when the quickview
# is closed. If it is not present then the app does not exit. It is
# possibly a bug in PyQt or Qt.
global app
app = QtWidgets.QApplication(sys.argv)
quickview = QtQuick.QQuickView()
if getattr(sys, 'frozen', None):
basedir = sys._MEIPASS
else:
basedir = os.path.dirname(__file__)
# The app dir is in the default import path but we can't put the QtQuick
# import lib dirs there because of a name clash (on OSX) with the QtQuick
# dll.
print(("Qt5 Qml import paths: " \
+ unicode(quickview.engine().importPathList())))
quickview.setSource(QtCore.QUrl('qrc:/hello.qml'))
quickview.engine().quit.connect(app.quit)
quickview.show()
app.exec_()
def testApiKey(self, base_url, api_key, basic_auth_username = "", basic_auth_password = ""):
self._instance_responded = False
self._instance_api_key_accepted = False
self._instance_supports_sd = False
self._instance_supports_camera = False
self.selectedInstanceSettingsChanged.emit()
if api_key != "":
Logger.log("d", "Trying to access OctoPrint instance at %s with the provided API key." % base_url)
## Request 'settings' dump
url = QUrl(base_url + "api/settings")
settings_request = QNetworkRequest(url)
settings_request.setRawHeader("X-Api-Key".encode(), api_key.encode())
settings_request.setRawHeader("User-Agent".encode(), self._user_agent)
if basic_auth_username and basic_auth_password:
data = base64.b64encode(("%s:%s" % (basic_auth_username, basic_auth_password)).encode()).decode("utf-8")
settings_request.setRawHeader("Authorization".encode(), ("Basic %s" % data).encode())
self._settings_reply = self._manager.get(settings_request)
else:
if self._settings_reply:
self._settings_reply.abort()
self._settings_reply = None
def open_log_file(self):
assert self.last_log_file is not None
QDesktopServices.openUrl(QUrl(self.last_log_file))
def show_about(self):
msg = QMessageBox()
msg.setIcon(QMessageBox.Question)
msg.setText("SpyKING CIRCUS v%s" %circus.__version__)
msg.setWindowTitle("About")
msg.setInformativeText("Documentation can be found at\n"
"http://spyking-circus.rtfd.org\n"
"\n"
"Open a browser to see the online help?"
)
msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
msg.setDefaultButton(QMessageBox.No)
answer = msg.exec_()
if answer == QMessageBox.Yes:
QDesktopServices.openUrl(QUrl("http://spyking-circus.rtfd.org"))
def open_plot_folder(self):
f_next, _ = os.path.splitext(str(self.ui.edit_file.text()))
plot_folder = os.path.join(f_next, 'plots')
QDesktopServices.openUrl(QUrl(plot_folder))
def help_phy(self):
QDesktopServices.openUrl(QUrl("https://github.com/kwikteam/phy-contrib"))
def help_matlab(self):
QDesktopServices.openUrl(QUrl("http://ch.mathworks.com/products/matlab/"))
def raise_issue_github(self):
url = QtCore.QUrl('https://github.com/LCA-ActivityBrowser/activity-browser/issues/new')
QtGui.QDesktopServices.openUrl(url)
def setValue(self, property, val):
propType = QVariant(val).userType()
if (not propType):
return
valType = self.valueType(property)
if (propType != valType and not QVariant(val).canConvert(valType)):
return
internProp = propertyToWrappedProperty().get(property, 0)
if (internProp == 0):
return
manager = internProp.propertyManager()
tm = type(manager)
if tm==QtStringPropertyManager:
tv = type(val)
if tv==QUrl:
val = val.toString()
elif tv != str:
val = str(val)
manager.setValue(internProp, val)
###
# Sets the value of the specified \a attribute of the given \a
# property, to \a value.
#
# The new \a value's type must be of the type returned by
# attributeType(), or of a type that can be converted to
# attributeType() using the QVariant.canConvert() function,
# otherwise this function does nothing.
#
# \sa attributeValue(), QtVariantProperty.setAttribute(), attributeChanged()
###
def get_hoster_name(link: str) -> str:
name = QUrl(link).host().replace('www.', '').replace('.com', '').replace('.net', '') \
.replace('.org', '').replace('.co', '')
return 'uploaded' if name == 'ul.to' else name
def open_link(self, link: str) -> None:
QDesktopServices.openUrl(QUrl(link))
self.close()
def appActionUserGuide( self ):
user_guide = wb_platform_specific.getDocUserGuide()
if not user_guide.exists():
self.log.error( 'Expected user guide %s to exist' % (user_guide,) )
return
# replace \ on windows with / for a good URL.
url = user_guide.as_uri()
url = QtCore.QUrl( url )
rc = QtGui.QDesktopServices.openUrl( url )
if not rc:
self.log.error( 'Failed to open documentation for URL %r' % (url,) )
def mainPyQt4Youtube():
# ?????????import
from PyQt4.QtCore import QUrl
from PyQt4.QtGui import QApplication
from PyQt4.QtWebKit import QWebView, QWebSettings
from PyQt4.QtNetwork import QNetworkProxyFactory
url = 'https://www.youtube.com/?hl=ja&gl=JP'
app = QApplication(sys.argv)
# Youtube????????????
QNetworkProxyFactory.setUseSystemConfiguration(True)
QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
QWebSettings.globalSettings().setAttribute(QWebSettings.DnsPrefetchEnabled, True)
QWebSettings.globalSettings().setAttribute(QWebSettings.JavascriptEnabled, True)
QWebSettings.globalSettings().setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True)
QWebSettings.globalSettings().setAttribute(QWebSettings.AutoLoadImages, True)
QWebSettings.globalSettings().setAttribute(QWebSettings.LocalStorageEnabled, True)
QWebSettings.globalSettings().setAttribute(QWebSettings.PrivateBrowsingEnabled, True)
QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
# QWebView???Web?????
browser = QWebView()
browser.load(QUrl(url))
browser.setEnabled(True)
browser.show()
sys.exit(app.exec_())
## PyQt5??Web???????.
def Browse(self,url):
if os.path.exists(self.cookie_file):
content = ccurl(url+'#'+'-b'+'#'+self.cookie_file)
print(content)
if 'checking_browser' in content:
os.remove(self.cookie_file)
self.add_cookie = True
else:
self.add_cookie = False
else:
self.add_cookie = True
self.tab_web = QtWidgets.QWidget()
self.tab_web.setMaximumSize(300,50)
self.tab_web.setWindowTitle('Wait!')
self.horizontalLayout_5 = QtWidgets.QVBoxLayout(self.tab_web)
self.horizontalLayout_5.addWidget(self)
if self.add_cookie:
self.web = BrowserPage(url,self.quality,self.add_cookie,self.cookie_file,self.media_val)
self.web.cookie_signal.connect(self.cookie_found)
self.web.media_signal.connect(self.media_source_found)
self.setPage(self.web)
print('add_cookie')
self.load(QUrl(url))
print('--')
#self.load(QUrl(url))
self.cnt = 1
QtWidgets.QApplication.processEvents()
QtWidgets.QApplication.processEvents()
self.tab_web.show()
def handleDropEvent(self, e):
"""
Handle adding items into the playlist
"""
if e.mimeData().hasFormat('application/x-qabstractitemmodeldatalist'):
return QtWidgets.QListWidget.dropEvent(self.listItemsPrimary, e)
data = e.mimeData().urls()[0]
if isinstance(data, QtCore.QUrl): self.listItemsPrimary.addItem(self.createQListWidgetItem(data=data))
def __init__(self, parent=None, flags=Qt.Dialog | Qt.WindowCloseButtonHint):
super(Updater, self).__init__(parent, flags)
self.parent = parent
self.logger = logging.getLogger(__name__)
self.api_github_latest = QUrl('https://api.github.com/repos/ozmartian/vidcutter/releases/latest')
self.manager = QNetworkAccessManager(self)
self.manager.finished.connect(self.done)
def get(self, url: QUrl) -> None:
if url.isValid():
self.manager.get(QNetworkRequest(url))
def __init__(self, parent=None):
super(LicenseTab, self).__init__(parent)
self.setObjectName('license')
self.setSource(QUrl('qrc:/license.html'))
def __init__(self):
super().__init__()
self.view = QWebEngineView()
self.page = self.view.page() # type: QWebEnginePage
self.view.load(QUrl('http://127.0.0.1:12345'))
self.view.show()
def setDoc(self, url):
try:
self.taskMannual.setSource(QtCore.QUrl(url))
except:
pass
def browse(self):
url = self.tb_url.text()
if url.count("://")==0:
url = "http://"+url
self.tb_url.setText(url)
self.html.load(QUrl(url))
def play_voice(self, url):
"""????"""
content = QMediaContent(QtCore.QUrl(url))
self.player.setMedia(content)
print(url)
self.player.play()
def addUrl(self, url):
print(url)
self.request = QNetworkRequest(QUrl(url))
self.request.setRawHeader(b"User-Agent", b"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1")
self.reply = self.get(self.request)
self.reply.downloadProgress.connect(self.setProgress)
return self.request
def setHtml(self,html):
self.edit.setHtml(html, QUrl(self.path))
def project_url():
url = QUrl('https://github.com/ScriptSmith/reaper')
QDesktopServices.openUrl(url)
def help_url():
url = QUrl('https://reaper.readthedocs.io')
QDesktopServices.openUrl(url)
def bug_url():
url = QUrl('https://gitreports.com/issue/ScriptSmith/reaper')
QDesktopServices.openUrl(url)
def bugAdressConnect(self):
QDesktopServices.openUrl(QUrl("https://github.com/mthnzbk/lilii/issues"))
def releaseInfoConnect(self):
QDesktopServices.openUrl(QUrl("http://limelinux.com/limelinux-indir.html"))
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(911, 688)
self.horizontalLayout_4 = QtWidgets.QHBoxLayout(Form)
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.splitter = QtWidgets.QSplitter(Form)
self.splitter.setOrientation(QtCore.Qt.Horizontal)
self.splitter.setObjectName("splitter")
self.editorBox = QtWidgets.QGroupBox(self.splitter)
self.editorBox.setObjectName("editorBox")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.editorBox)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.verticalLayout_2 = QtWidgets.QVBoxLayout()
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.plainTextEdit = QtWidgets.QPlainTextEdit(self.editorBox)
self.plainTextEdit.setObjectName("plainTextEdit")
self.verticalLayout_2.addWidget(self.plainTextEdit)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.clearButton = QtWidgets.QPushButton(self.editorBox)
self.clearButton.setObjectName("clearButton")
self.horizontalLayout.addWidget(self.clearButton)
self.previewButton = QtWidgets.QPushButton(self.editorBox)
self.previewButton.setObjectName("previewButton")
self.horizontalLayout.addWidget(self.previewButton)
self.verticalLayout_2.addLayout(self.horizontalLayout)
self.horizontalLayout_2.addLayout(self.verticalLayout_2)
self.previewerBox = QtWidgets.QGroupBox(self.splitter)
self.previewerBox.setObjectName("previewerBox")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.previewerBox)
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.webView = QtWebKitWidgets.QWebView(self.previewerBox)
self.webView.setUrl(QtCore.QUrl("about:blank"))
self.webView.setObjectName("webView")
self.horizontalLayout_3.addWidget(self.webView)
self.horizontalLayout_4.addWidget(self.splitter)
self.retranslateUi(Form)
self.clearButton.clicked.connect(self.plainTextEdit.clear)
QtCore.QMetaObject.connectSlotsByName(Form)