pyqt5 / pyqt Goto Github PK
View Code? Open in Web Editor NEWPyQt Examples(PyQt各种测试和例子) PyQt4 PyQt5
License: GNU Lesser General Public License v2.1
PyQt Examples(PyQt各种测试和例子) PyQt4 PyQt5
License: GNU Lesser General Public License v2.1
Environment : / 环境
安徽-无业游民-今天天气好 :
重写了QWidget的鼠标移动事件,在QWidget上添加了一个控件之后,鼠标在这个控件上面移动不会触发QWidget的鼠标移动事件.
格式:
1.使用的打包框架(e.g. pyinstaller/py2exe ... 版本号) 例如 pyinstaller 3.4;
2.出现的错误;
...
3.解决办法;
像腾讯视频那样的排版,用pyqt5和html加css组成
评估标准:
1.硬件消耗;
2.智能提示;
...
不知阁下是否有兴趣研究论证一番我们使用 一些特殊的手段 设计出使用 Python + PyQt WebEngein打造的对HTML+CSS+JS前端技术兼容的框架呢, 简单的说,我们能不能用现有的Python框架,完成Electron一样的事儿呢...
群主,你的客户端的换皮肤功能,能不能单独抽离出来做个例子,最好带生成配置文件的。
请教如何实现?
https://github.com/pytest-dev/pytest-qt
http://johnnado.com/pyqt-qtest-example/
https://www.quora.com/How-can-a-GUI-application-be-built-using-Test-driven-Development
TDD的一些讨论 https://coolshell.cn/articles/3649.html#comments
TDD案例1 https://ervin.ipsquad.net/share/slides/2007-12-05-fossin-qt-kde-tdd.pdf
TDD案例2 https://www.slideshare.net/ICSinc/webinar-qt-testdriven-development-using-google-test-and-google-mock
pyinstaller -key 并 16个字符串
评估标准:
...
ps : 目的: 通过读一些开源项目提高代码设计水平.
ps : 官方说明的一些项目 https://wiki.python.org/moin/PyQt/SomeExistingApplications
ps : 开源项目很少有画 UML图的 , 可以在读项目的时候尝试画图来锻炼逻辑 ;
Python 代码
from PyQt5.Qt import *
错误提示
This Windows version(6.3.9600)does not support the requiredBluetooth Apl. Consider updating to a more recent Windows(10.0.10586 or above)
db = QtSql.QSqlDatabase.addDatabase('QOCI')
db.setHostName('192.168.101.81')
db.setDatabaseName('orcl')
db.setUserName('ankole')
db.setPassword('jsdx_1234')
db.setPort(1521)
dbconn=db.open
print(db.open())
这样子返回是false,不知道怎么搞
我用了QMovie,加载了gif文件,但是使用isValid()函数之后,返回结果总是FALSE
Environment : / 环境
def confirm(self):
mask_btn=self.sender()
model=self.model()
btn_index = self.indexAt(mask_btn.parent().mapFromGlobal(QCursor.pos()))
row=btn_index.row()
比如QTextEdit设置了软换行,能否实现把它的软换行变成硬换行?因为自己在插入时按像素或者字符长度调整时,无法达到预期效果。而软换行的效果是自己想要的,但前提是能实现通过什么方法把它转换成硬换行,不知道软换行的地方是否能得到什么标记?本人水平很菜,提的问题可能有点可笑,还望别在意。
基于 qtav 或者 迅雷 APlayer 的视频播放器
同时截取的部分包括看到的和需要滚动才可以看到的页面
Environment : / 环境
查询功能函数是buttonTest(self) 数据格式和航班数据在下面图片中显示 现在需要在buttonTest这个函数添加代码实现动态SQL语句,并将查询得到的结果显示在self.tableWidget 里
姓名对应self.checkBox和self.lineEdit 证件号对应self.checkBox_2和self.lineEdit_2 航班号对应self.checkBox_3和self.lineEdit_3 座位号对应self.checkBox_4和self.lineEdit_15 登机口对应self.checkBox_6和self.lineEdit_16 序号对应self.checkBox_8和self.lineEdit_17
数据库链接语句为
self.conn = MySQLdb.connect( host='localhost', user='root', passwd='zdki', db='wenzhou', # charset='utf8', ) self.cur = self.conn.cursor() self.sqlstring = "select * from tourist2 where "
1、嵌入后,能否居中显示Word、Excel内容;
2、嵌入后,能否设置不允许编辑状态;
3、嵌入后,能否设置编辑状态下,显示Word、excel的工具栏;
4、嵌入后,能否完成编辑并进行保存;
5、嵌入后,能否正常进行退出;
在主界面里面,开启多个进程,将信号传递给子进程,依此来更新主界面对应的进度条,发现子进程不能发送信号给主界面。老哥来个例子
点击按钮 动态加载表格数据的列子
pyinstaller -key 并 16个字符串
--key=s424rrtgdfwlmndo
打包就报这样的错误
File "/usr/local/lib/python3.6/site-packages/Crypto/Util/_raw_api.py", line 109, in c_uint8_ptr
raise TypeError("Object type %s cannot be passed to C code" % type(data))
TypeError: Object type <class 'str'> cannot be passed to C code
QJsonDocument({"abc": QJsonValue("abc")})
如果运行以上代码程序会闪退,只能使用以下代码(去掉QJsonValue):
QJsonDocument({"abc": "abc"})
上面的用法有什么错误呢?
If the repo could add a simple music player example, that would be great :)
我这里新写了一个GraphicsScene类,用来找到点击的坐标值,可是怎样能将这个值提取出来呢?
class GraphicsScene(QGraphicsScene):
def __init__(self, parent=None):
QGraphicsScene.__init__(self, parent)
def mouseDoubleClickEvent(self, event):
x = int(event.scenePos().x())
y = int(event.scenePos().y())
return x, y
下面是我在主窗口调用使用的
self.graphicsView.scene = GraphicsScene(self)
item = QGraphicsPixmapItem(self.image.scaled(512,512))
self.graphicsView.scene.addItem(item)
self.graphicsView.setScene(self.graphicsView.scene)
就是很想在主窗口返回x与y的值,PyQt新手求救😂
老哥,想更你讨论一下下面这种情形,如若你知道些什么,还望赐教一二:
QWebChannel允许我们JS和PyQt之间使用信号与槽进行通信,但是我发现一个很奇怪的问题:
一个button,设置其点击的槽函数为发送我们的信号,该信号将在qwebchannel.js中进行接受处理:
this.transport.onmessage = function (message) {
var data = message.data;
console.warn(data); // 我们在这里把消息数据打印出来
if (typeof data === "string") {
data = JSON.parse(data);
}
switch (data.type) {
case QWebChannelMessageTypes.signal:
channel.handleSignal(data);
break;
case QWebChannelMessageTypes.response:
channel.handleResponse(data);
break;
case QWebChannelMessageTypes.propertyUpdate:
channel.handlePropertyUpdate(data);
break;
default:
console.error("invalid message received:", message.data);
break;
}
}
然后奇怪的问题来了:
图形化界面对Button点击,执行槽函数,槽函数中发送相关信号:
js: {"args":[""],"object":"agent","signal":5,"type":1}
一切都很正常。
但是如果我直接在代码中对button对象执行button.click()
:
js: {"data":{"agent":{"methods":[["deleteLater",3],["data_pack_received",6]],"properties":[[0,"objectName",[1,2],""]],"signals":[["destroyed",0],["send_data_pack",5]]}},"id":0,"type":10}
这里的信号就被标记为被破坏了,然后js就无法正常的进行我们的回调函数了。
如问题所述,代码如下:
from threading import Thread
from time import sleep
from PyQt5.QtCore import QObject, pyqtSignal, QTimer, Qt
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QProgressBar, QApplication
class A:
def __init__(self):
print('I am A')
class _Signals(A, QObject):
updateProgress = pyqtSignal(int)
def __init__(self):
super().__init__() #如果采用这种初始化方式就会报错:RuntimeError: super-class __init__() of type _Signals was never called
A.__init__(self)#如果采用这种初始化方式不会报任何错误,为什么呢?
QObject.__init__(self)
Signals = _Signals()
class UpdateThread(Thread):
def run(self):
self.i = 0
for i in range(101):
self.i += 1
Signals.updateProgress.emit(i)
# print(f'current value is: {i}')
sleep(1)
self.i = 0
Signals.updateProgress.emit(i)
class Window(QWidget):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
self.resize(400, 400)
layout = QVBoxLayout(self)
self.progressBar = QProgressBar(self)
layout.addWidget(self.progressBar)
Signals.updateProgress.connect(
self.updatep, type=Qt.QueuedConnection)
QTimer.singleShot(2000, self.doStart)
def updatep(self, i):
self.progressBar.setValue(i)
QApplication.processEvents()
def doStart(self):
self.updateThread = UpdateThread(daemon=True)
self.updateThread.start()
if __name__ == '__main__':
import sys
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_())
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.