第一禁用Wayland 用回x11设置
raspi-config 里设置后 重启
xinput查看当前当前触摸屏与设备 xrandr也可查看当前屏幕
xinput map-to-output 7 HDMI-1
xinput map-to-output 8 HDMI-2
第一禁用Wayland 用回x11设置
raspi-config 里设置后 重启
xinput查看当前当前触摸屏与设备 xrandr也可查看当前屏幕
xinput map-to-output 7 HDMI-1
xinput map-to-output 8 HDMI-2
pyside6 导入文件
from PySide6.QtCore import *
from PySide6.QtGui import *
from PySide6.QtWidgets import *
pyqt5 导入文件
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
切记pyqt5 与 pyside6 不能混用
initialize sub component
self.Stack = QStackedWidget (self)
self.Stack.addWidget (self.stack1)
self.Stack.addWidget (self.stack2)
self.Stack.addWidget (self.stack3)
事件触发关联
self.leftlist.currentRowChanged.connect(self.display)
切换页面
def display(self,i):
self.Stack.setCurrentIndex(i)
convertToQtFormat = QtGui.QImage(rgbImage.data, rgbImage.shape[1], rgbImage.shape[0], QImage.Format_RGB888)
#在这里可以对每帧图像进行处理,
image = convertToQtFormat.scaled(440, 330, Qt.KeepAspectRatio)
self.video.setPixmap(QPixmap.fromImage(image))
rgbImage.data 是 python图片数组数据
所有组件都可以通过 setPixmap(QPixmap.fromImage(image)) 设置背景图像
import sysfrom PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(270, 180, 241, 101))
self.label.setText("")
self.label.setPixmap(QtGui.QPixmap(":/img/logo.png"))
self.label.setObjectName("label")
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
if __name__ == '__main__':import resource
# 导入添加的资源(根据实际情况填写文件名)
app = QApplication(sys.argv)
MainWindow = QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
设置icon
self.pushButton_9.setIcon(QtGui.QIcon(QtGui.QPixmap("./resources/setting.png")))
self.pushButton_9.setIconSize(QtCore.QSize(30,30))
使用QT designer会生成一系列ui后缀文件
通过pyuic可以将ui文件转化为py文件
python -m PyQt5.uic.pyuic 1.ui -o 1.py
pyuic5 1.ui -o 1.py
pyside6-uic form.ui -o ui_form.py
把1.ui 转换为 1.py
class MainForm(QtWidgets.QMainWindow):
def __init__(self,parent=None):
super(MainForm,self).__init__(parent)
__content = Ui_MainWindow.Ui_MainWindow()
__content.setupUi(self)
if __name__ == "__main__" :
try:
print('start')
__app = QtWidgets.QApplication(sys.argv)
__win = MainForm()
__win .show()
sys.exit(__app.exec_())
except KeyboardInterrupt :
print('destroy')
__content = Ui_MainWindow.Ui_MainWindow()
这段代码可以换成不同的UI generate的代码 就可以 切换ui文件 看效果

UIImageView 是IOS图片控件。点击右上角 加号。可以打开控件窗口

绑定图片到UIImageView
点击UIImageView。右上角image选择图片绑定

调用的是TokenGuard 这个类
数据库user 表有 字段名为 api_token 的校验 用来存放token
用户登录后会获取该token 之后所有请求 都要带上该token
该token没有超时机制 每次获取user个人信息需要根据token查一次数据库 比jwttoken 性能要差
为api 调用提供身份校验功能
docs https://jwt-auth.readthedocs.io/
install
composer require tymon/jwt-auth
Add the service provider to the providers array in the config/app.php config file as follows:
'providers' => [
...
Tymon\JWTAuth\Providers\LaravelServiceProvider::class,
]
Run the following command to publish the package config file:
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"
Generate secret key
This will update your .env file with something like JWT_SECRET=XXX
php artisan jwt:secret
该包 修改laravel api 路径下默认的 token校验方式 把token改为JWT token
其实生成流程和校验流程和之前没变化
login 通过用户账号密码 作为 credentials 然后去数据库获取用户信息 该用户信息会生成JWT token 放在laravel 默认缓存管理器
后续请求 在请求头带上 Authorazation : bear $token
通过auth:api 中间件校验
docs https://docs.guzzlephp.org/
install
composer require guzzlehttp/guzzle
sync get
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle');
echo $response->getStatusCode(); // 200
echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
echo $response->getBody(); // '{"id": 1420053, "name": "guzzle", ...}'
async get
$request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org');
$promise = $client->sendAsync($request)->then(function ($response) {
echo 'I completed! ' . $response->getBody();
});
$promise->wait();
post
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.github.com/repos/guzzle/guzzle',
[
'headers' => [
'User-Agent' => 'testing/1.0',
'Accept' => 'application/json',
'X-Foo' => ['Bar', 'Baz']
],
//'query' => ['foo' => 'bar'] //query params
//'body' => 'foo' // plain string BODY
/* 'form_params' => [ // application/x-www-form-urlencoded
'foo' => 'bar',
'baz' => ['hi', 'there!']
]*/
//'json' => ['foo' => 'bar']] //json body application/json
/*'multipart' => [ multipart multipart/form-data
[
'name' => 'foo',
'contents' => 'data',
'headers' => ['X-Baz' => 'bar']
],
[
'name' => 'baz',
'contents' => Psr7\Utils::tryFopen('/path/to/file', 'r')
],
[
'name' => 'qux',
'contents' => Psr7\Utils::tryFopen('/path/to/file', 'r'),
'filename' => 'custom_filename.txt'
],
]*/
],
);
echo $response->getStatusCode(); // 200
echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
echo $response->getBody(); // '{"id": 1420053, "name": "guzzle", ...}'