Когда разрабатываете свой GUI с помощью PyQt для какого-либо софта бывает необходимо позаимствовать цвета из текущего стиля интерфейса. Например, чтобы правильно раскрасить свои виджеты, подогнав их по цвету. Ведь бывает, что ваш GUI используется в разных софтах. Причём некоторые со светлой темой а другие с тёмной.
По умолчанию стили наследуются, но если вы задаёте какую-либо раскраску для части виджета через свой styleSheet, то требуется ссылаться на цвета текущего стиля.
Как это сделать? Как получить нужный цвет из палитры имеющегося стиля? Это достаточно просто, нужно использовать класс QPalette и его роли.
Например, мне нужно достать цвет текста из одного виджета и применить его в другом как цвет фона (не важно зачем именно так, просто захотелось😊).
Получаем палитру виджета и сразу достаём нужный цвет, указав его роль.
from PySide2.QtGui import QPalette
color = main_window.palette().color(QPalette.Text)
теперь можем использовать этот цвет в стилях
my_widget.setStyleSheet(f'background-color: {color.name()};')
Готово, мы динамически переопределили дефолтный стиль используя текущий стиль окна!
На самом деле есть запись покороче, в одну строку и без лишних переменных. Не очень-то по правилам CSS, но Qt это понимает.
my_widget.setStyleSheet('background-color: palette(Text);')
Этот способ не подходит если вам нужно как-то модифицировать цвет перед применением в своих стилях. В этом случае потребуется первый способ.
Зато он прекрасно сработает в файле .qss, то есть не придётся в коде прописывать раскраску отдельных элементов через ссылки на палитру, всё красиво сохранится в отдельном файле .qss!
QListView#my_widget::item:selected {
background: palette(Midlight);
}
Про имеющиеся роли можно почитать здесь🌍
#qt#tricks
https://github.com/Monadical-SAS/django-channels-router
django-channels-router
A Python library for routing and handling #websocket messages using #django-channels.
Routing socket messages in the view
Routing socket messages using a handler
#React
https://www.fullstackpython.com/websockets.html
A #WebSocket is a standard protocol for two-way data transfer between a #client and #server. The WebSockets protocol does not run over #HTTP, instead it is a separate implementation on top of #TCP.
#AJAX
#javascript#approval_process#cms#crm#ehr#erp#hr#layui#mysql#oa#privileges#redis#skyeye#springboot#springboot2#springcloud_vue#websocket
This platform uses Springboot, Layui, UNI-APP, and Ant Design Vue to create a low-code system for intelligent manufacturing. It includes over 30 application modules and more than 50 electronic workflows, covering CRM, ERP, MES, and more. This system streamlines business processes from customer relations to production and after-sales service, improving efficiency and data transparency. It also manages employee operations, providing a comprehensive solution for businesses. The benefits include faster development, reduced redundancy, and enhanced data management, making it ideal for companies seeking digital transformation.
https://github.com/dromara/skyeye
#cplusplus#c_plus_plus#cpp#datachannel#libdatachannel#libnice#p2p#peer_to_peer#peerconnection#rfc_8831#rfc_8834#rtcdatachannel#rtcpeerconnection#sctp#webrtc#webrtc_datachannel#webrtc_video#websocket
libdatachannel is a lightweight, easy-to-use C/C++ library that lets you add real-time peer-to-peer data, media, and WebSocket communication to your apps across many platforms like Linux, Windows, macOS, Android, and iOS. It simplifies WebRTC by providing a smaller, simpler alternative to Google's library, with compatibility for browsers like Firefox and Chrome. You can use it to connect native apps directly to web browsers with minimal dependencies, supporting secure connections via GnuTLS, Mbed TLS, or OpenSSL. It also supports compiling to WebAssembly for browser use, making it flexible for cross-platform real-time communication development[1][4]. This helps you build fast, efficient apps for video, audio, or data sharing without heavy libraries.
https://github.com/paullouisageneau/libdatachannel
#go#coolq#cqhttp#cqhttp_mirai#go#go_cqhttp#golang#group_manager#mirai#mirai_bot#nonebot#onebot#onebot_plugin#onebot_sdk#plugin#qq#qq_bot#qqbot#qqrobot#websocket#zerobot
ZeroBot-Plugin is a comprehensive utility plugin collection for the ZeroBot chatbot framework, offering over 100 features across entertainment, management, and productivity categories. The system provides high-priority functions like chat management, sleep tracking, and group administration, alongside mid-tier features such as image generation, music streaming, and game simulations. Users benefit from flexible plugin control—enabling or disabling specific features per group—and dynamic loading capabilities that reduce program size. The platform supports multiple deployment methods, from pre-compiled releases to local compilation, making it accessible whether you prefer ready-to-use binaries or customized builds. With extensive command options, scheduled task triggers, and AI integration, ZeroBot-Plugin transforms group chat management into an automated, entertaining experience while maintaining user control over which features activate in specific communities.
https://github.com/FloatTech/ZeroBot-Plugin