Когда разрабатываете свой 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
#html
The Agent Development Kit (ADK) is an open-source toolkit that helps you build, test, and deploy advanced AI agents easily. It lets you create flexible, multi-agent systems using Python or Java, supports many AI models, and works with different deployment options. ADK offers a rich set of tools, built-in monitoring, and simple integration with Google services, making it easier to develop, debug, and scale your AI applications. This means you can focus on creating smart, efficient agents without worrying about complex setup or compatibility issues.
https://github.com/google/adk-docs
#html
You get access to a huge, well-organized collection of 2,053 ready-to-use n8n automation workflows covering 365 different services, all searchable instantly with a super fast, mobile-friendly documentation system. This system offers lightning-fast full-text search, smart categorization by service and use case, and clear, meaningful workflow names, making it easy to find exactly what you need. You can run the documentation locally with simple setup steps, explore workflows by category or complexity, and even download or visualize them. This saves you time and effort in building automations, helps you discover proven workflows quickly, and supports efficient workflow management and customization.
https://github.com/Zie619/n8n-workflows
#html
The International Obfuscated C Code Contest (IOCCC) is a programming contest where participants write the most confusing and hard-to-understand C code, often under 512 bytes. It started in 1984 to highlight bad coding styles and show how poor structure can ruin a program. The contest uses satire to teach programmers about C’s tricky parts and the importance of clear coding by showing what not to do. Winning entries are both educational and entertaining, helping you learn subtle C language details while having fun. The contest encourages you to explore and understand complex code, improving your programming skills and appreciation for good style.
https://github.com/ioccc-src/winner
#html
You can easily create a secure Octra blockchain wallet by running a simple webserver on your computer. Just clone the wallet generator from GitHub, start the server, and open your browser to generate a new wallet. The tool shows your mnemonic phrase, private and public keys, and address, lets you test signatures, derive addresses for different networks, and automatically saves your wallet file. This helps you safely manage your Octra blockchain assets with full control over your keys and easy access to wallet features without needing complex setups. It’s a user-friendly way to secure and use your Octra wallet locally.
https://github.com/octra-labs/wallet-gen
#html
"开往 Travellings" is a project that helps unknown websites get more visitors. It does this by creating a network where users can click a button to randomly visit other participating sites. This project started in 2020 and aims to make the internet more diverse and open. By joining, users can discover new sites and help smaller websites grow. It benefits users by introducing them to new content and supporting lesser-known creators.
https://github.com/travellings-link/travellings
Is Skia the works-everywhere feature-rich text rendering engine I’ve always been looking for? It seems to work on all sorts of platforms, even on #HTML Canvas with WebAssembly (!)
It even used to have particles support, but was sadly removed from 2 months ago.
https://skia.org/
🐘
Frontend
2-dars. HTML asoslari(davomi)
-Formalar bilan ishlash
-Table bilan ishlash
-Layout va semantik taglar
Mentor : Mahammadamin Abbosov
#frontend#html
👉Telegram | Instagram | YouTobe