Когда разрабатываете свой 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
🔥NEW RELEASE🔥
😁Shotgun K Guard By Mateusz Szczeciński😁
➡️Unlock the full potential of your guard game with Shotgun K Guard — the ultimate Brazilian Jiu-Jitsu instructional by Mateusz Szczeciński.
➡️This comprehensive course dives deep into the K guard, a dynamic and highly effective position that offers control, sweep opportunities, and powerful lower body attacks.
➡️Whether you’re looking to elevate your guard retention or dominate with precise submissions and sweeps, Mateusz breaks down every detail to help you master this modern, versatile guard style.
$79😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#MateuszSzczeciński#Leglocks#NoGi
💁♀️Buy
💁♀️
😁How To Beat The Pros: Leg Lock Attacks By Paul Ardila-Ibarra😁
➡️Surprise The High Level Guys with Fresh Technique and High Percentage Attacks from 2022 ADCC West Coast Trials Champion Paul Ardila Ibarra
➡️Paul Ardila is a multiple-time ADCC Trials Champion with an infamously vicious heel hook game and in this one of a kind instructional you'll get inside access to his most high percentage entries, attacks, and finishes, so you can add ADCC quality technique to your leglock arsenal
➡️Learn the moves that Ardila has used to decimate competitors at the highest levels of grappling
$79😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#PaulArdila#NoGi#Leglocks
💁♀️Buy
💁♀️
🔥NEW RELEASE🔥
😁Understanding The Reap By Jason Rau😁
➡️Unlock the power of one of Brazilian Jiu-Jitsu’s most misunderstood and effective positions with Understanding The Reap by Jason Rau.
➡️This incredibly comprehensive course takes you deep into the intricacies of the "reap" — a position that is often overlooked, yet crucial for mastering lower body submissions, sweeps, guard passes, and even back takes.
➡️Whether you’re a beginner or an advanced practitioner, Jason Rau’s detailed breakdown of the reap will give you the tools to control and submit your opponent, defend with confidence, and add an entirely new dimension to your BJJ game.
$99😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#JasonRau#BJJFanatics#NoGi#Leglocks
💁♀️Buy
💁♀️
😁Milk The System: Defending Leg Locks From Cross Ashi And 5050 By Dan Manasoiu😁
➡️Unlock the secrets to defending and escaping the most dangerous leg lock positions with Milk the System: Defending Leglocks from Cross Ashi and 50/50, an elite instructional by Dan Manasoiu — a top No-Gi star and proud member of the legendary New Wave BJJ team.
➡️Leg locks are dominating the modern grappling game, and mastering defense is crucial for every competitor.
$197😍$14.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
👑MasterClass
✈️@bjjfanaticsinstructionals
#DanManasoiu#Leglocks#NoGi#NewWave
💁♀️Buy
💁♀️
🔥NEW RELEASE🔥
😁Slicin' Calves By Mikey Musumeci😁
➡️Mikey Musumeci, one of the most accomplished and detail-oriented American grapplers of all time, brings you a game-changing BJJ instructional that dives deep into one of the most lethal and versatile submissions in no-gi grappling: the Calf Slicer
➡️Whether you’re attacking the legs with a heel hook, straight footlock, or kneebar, Mikey shows you how to use the inevitable escape of your opponent to effortlessly transition into the calf slicer.
➡️With Mikey’s methodical approach and world-class attention to detail, you’ll gain the tools to dominate from bottom to top, turning every leg attack into a calf slicer opportunity.
$197😍$14.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#MikeyMusumeci#Leglocks#NoGi#IBJJF
💁♀️Buy
💁♀️
🔥NEW RELEASE🔥
😁P.E.D. Footlock system: Leg locks on Steroids by Dima Murovanni😁
➡️Unlock the full potential of your leg lock game with the P.E.D. Footlock System, a groundbreaking instructional by B-Team's own Dima Murovanni.
➡️Dima breaks down why the straight footlock should be the foundation of your leg lock system—showing how its mechanics, control positions, and finishing pathways translate into heel hooks, kneebars, inside sankaku, and more..
̶$̶1̶2̶7̶😍$14.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#DimaMurovanni#Leglocks#NoGi#BTeam
💁♀️Buy
💁♀️
😁Leg Locks for Beginners by Standard Jiu Jitsu😁
➡️A collection of games that can be used to start developing leg entanglements and heel hook finishes using the constraints led approach.
̶$̶9̶9̶😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#StandardJiuJitsu#Leglocks#Drills#NoGi
💁♀️Buy
💁♀️
🔥NEW RELEASE🔥
😁Outside Ashi Reloaded by Jason Rau😁
➡️Take your leg lock game to the next level with Outside Ashi Reloaded, an innovative instructional series by Jason Rau — a black belt under Matt Serra and one of our best-selling instructors.
➡️Jason dives deep into the strategic interplay between these attacks, teaching you how to create relentless pressure and chain submissions so that when your opponent defends one, they inevitably expose themselves to the other.
$127😍$11.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#JasonRau#Leglocks#NoGi#OutsideAshi
💁♀️Buy
💁♀️
🔥NEW RELEASE🔥
😁X Lock: For When Letting Go Was Never Your Strong Suit By Owen Jones😁
➡️Unlock a devastating new layer to your leg lock game with X Lock, the cutting-edge instructional by Owen Jones, one of the most technical minds rising through the ranks of B Team Jiu-Jitsu.
➡️Whether you're a straight ankle lock specialist or want to add serious firepower to your lower body arsenal, this instructional is designed to elevate your game, from positional awareness to crushing submissions.
➡️Use the X Lock to make your straight ankle locks faster, tighter, and more lethal—with precision grip mechanics that force the tap.
$99😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#OwenJones#Leglocks#CJI#NoGi
💁♀️Buy💁♀️
😁The Junny Lock by Junny Ocasio😁
➡️The Junny lock is an innovative leg-lock submission developed and used at the highest level of competition. First conceived as a counter-attack to the outside reap, the Junny lock was further developed by Junny Ocasio to be used as a counter-attack, attack and control position.
➡️This course will cover the Junny lock in depth, including the mechanics of the submission, concepts, entries, transitioning to and from other leg entanglements as well as using the Junny lock to transition to the back.
$169😍$14.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#Submeta#LegLocks#JunnyOcasio
💁♀️Buy
💁♀️
🔥NEW RELEASE🔥
😁MILF Mastering Inside Leglocks & False Reaps by Pawel Jaworski😁
➡️Discover one of the most powerful modern entries in Brazilian Jiu-Jitsu — the False Reap — and turn it into a reliable, high-percentage pathway to inside leg entanglements and devastating finishes.
➡️Pawel doesn’t just show moves — he builds a structured system that connects the dots between entries, control points, and finishes.
$99😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#PawelJaworski#Leglocks#NoGi#FalseReap
💁♀️Buy
💁♀️
😁Blue Print To Beginner: Intermediate Leglocks By Tom DeBlass😁
➡️Attack The Lower Body With Highly Effective Submission Locks, Taught By One Of Grappling’s Most In-Demand Instructors - Tom DeBlass
➡️Tom DeBlass is a Renzo Gracie black belt who has spent years training with, learning from, and training some of the best grapplers and instructors in all of Brazilian jiu-jitsu - including Gordon Ryan, Garry Tonon, and more
➡️Set up your attacks from common grappling positions like the butterfly guard, closed guard, half guard, and more as Tom shares how to learn faster and cut through the mistakes easier
$127😍$11.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#TomDeblass#Leglocks#Beginners#NoGi
💁♀️Buy
💁♀️