This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def on_pressed(callback, args=()): | |
""" Invokes `callback` with `args` when the left button is pressed. """ | |
return on_button(callback, args, [LEFT], [DOWN]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style type="text/css"> | |
.dl_list{color: #666;} | |
</style> | |
<div class="dl_list"> | |
<a class="item" target="_blank" href="http://v.qq.com/download.html#phone" _stat="page_footer:download_1"> | |
<svg class="svg_icon svg_icon_iphone" viewBox="0 0 50 50" width="50" height="50"> <path d="M34 3h-18c-1.657 0-3 1.343-3 3v38c0 1.657 1.343 3 3 3h18c1.657 0 3-1.343 3-3v-38c0-1.657-1.343-3-3-3zm1 38h-20v-32h20v32z"></path> <!--[if lte IE 8 ]><image src="//puui.qpic.cn/vupload/0/20190105_svg_icon_iphone.png/0" xlink:href="" /><![endif]--> </svg> | |
<span class="text_icon">手机版</span> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PIL import ImageGrab | |
from PyQt5.QtCore import * | |
from PyQt5.QtGui import * | |
from PyQt5.QtWidgets import * | |
app = QApplication(sys.argv) | |
btn = QPushButton() | |
btn.clicked.connect(lambda: ImageGrab.grab(bbox=(0, 0, 900, 900))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PySide2.QtCore import * | |
from PySide2.QtWidgets import * | |
from PySide2.QtNetwork import * | |
class Window(QMainWindow): | |
def __init__(self, parent=None, **kwargs): | |
super().__init__(parent, **kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// console.log('tabTitle----onClicked----',tab.title,hostname); | |
fileExt = tabId2DownloadInfo[tab.id][1]; //{tabId:[targetUrl,fileExt]} ------->fileExt | |
np = nameParser[hostname]; | |
fileName = (np ? np(tabTitle) : tabTitle) + fileExt; //必须在三元运算符外加括号才会成为一个值,不然直接return | |
// console.log('downloadInfo fileName ' ,fileName.replace(/[\\/:*?"<>|]/g, '_')); | |
tabId2DownloadInfo[tabId][1] = fileName.replace(/[\\/:*?"<>|~]/g, '_'); //{tabId:[targetUrl,fileName]} 替换网页标题里不能包含于文件名(以Windows的文件命名为准)中的非法字符\/:*?"<>| | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def baiduTranslate(self, queryText): | |
queryUrl = 'http://fanyi.baidu.com/v2transapi' | |
response = requests.post(queryUrl, data={'from': 'en', 'to': 'zh', 'query': queryText, 'transtype': 'realtime', 'simple_means_flag': 3,'sign':'498118.235959','token':'40a25d2a0d533f7cc897a454a0a86812'}) | |
repliedJson = response.json() | |
print(repliedJson) | |
dictResult = repliedJson["dict_result"] | |
if not dictResult: # 句子的时候字典没结果,teaching posts也没有结果 | |
print('baiduTranslate 翻译', queryText) # , repliedJson["trans_result"]["data"][0]["dst"] | |
return repliedJson["trans_result"]["data"][0]["dst"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Credits go to the Qt Centre forum. | |
# import logging | |
# import sys | |
# logging.basicConfig(filename='LYYDownloader.log') | |
# def uncaughtExceptionHandler(type_, value, traceback): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PyQt4.QtGui import * | |
from PyQt4.QtCore import * | |
class MyFileSystemModel(QFileSystemModel): | |
def __init__(self, h_align=Qt.AlignLeft, v_align=Qt.AlignLeft, parent=None): | |
super().__init__(parent) | |
self.alignments = {Qt.Horizontal: h_align, Qt.Vertical: v_align} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# print('(QProcess)---------------',self.findChildren(QProcess)) | |
arguments = ['-f', 'concat', '-safe', '-1', '-i', fp.name, '-y', '-c', 'copy', absoluteFileName] | |
# print(os.path.join(os.getcwd(), 'ffmpeg'), ' '.join(arguments)) | |
# self.process.finished.connect(self.mergeFinished(self.process)) | |
# process.destroyed.connect(self.onProcessDestroyed) | |
if self.process.state()==QProcess.NotRunning: | |
self.process.start(os.path.join(os.getcwd(), 'ffmpeg'), arguments) | |
else: | |
self.process.tasks.add(sourceUrl) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#I write the slot of QClipboard::dataChanged() as this to avoid the bug, | |
@pyqtSlot() | |
def detectClipboardUrl(self): | |
clipboardText = self.clipboard.text() | |
if getattr(self.clipboard, 'lastClipboardUrl', None) != clipboardText: | |
url = clipboardText | |
setattr(self.clipboard, 'lastClipboardUrl', url) | |
QTimer.singleShot(400, lambda:setattr(self.clipboard, 'lastClipboardUrl', None))#the interval of successive call of this slot is less than 400ms, after 400ms this line would allow you copy the same Text again |
NewerOlder