TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #62 · 4 апр.

Когда разрабатываете свой 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

Hashtags

Резултати

Пронајдени 23 слични објави

Пребарај: #legend

当前筛选 #legend清除筛选

Один из ключевых летних привозов для поклонников электронной музыки состоится 19 июля. Алматы впервые посетит именитый японец ¥ØU$UK€ ¥UK1MAT$U, который является яркой фигурой андеграунда Японии. Его выступление в Алматы станет последним в рамках его летнего тура. BONUS that we deserve: https://www.youtube.com/live/WvyvwlowHWM?si=21Q6cN70A6szW6W6&t=1357 -- -- -- -- @AlmaDvizh#legend#epic#dj

Interesting Planet 🌍

@interesting_planet_facts · Post #1099 · 04.12.2025 г., 18:11

🌎 The Aztec legend of Quetzalcoatl describes a feathered serpent god who brought knowledge and culture to people. Spanish chronicles report Aztecs believed Quetzalcoatl created humans by mixing his blood with ground bones from the underworld. ✨ #aztecs⚡#mythology⚡#legend 👉subscribe Interesting Planet 👉more Channels ​

Alexa Mods

@itsmealexaliza · Post #1056 · 10.10.2024 г., 08:11

India has lost a legend today. Ratan Tata, an extraordinary industrialist, visionary, and humanitarian, has left us. His contributions to the business world and society are unparalleled. He was not just a leader but an inspiration, embodying humility, integrity, and compassion. The legacy he built through the Tata Group and his philanthropic efforts will continue to inspire generations to come. Rest in peace, Ratan Tata Sir. You will forever be in our hearts. 🙏 #RIPRatanTata#Legend#EndOfAnEra”

News and Tips

@NewsAndTipsNT · Post #4028 · 27.01.2026 г., 02:42

My brother Pavel Durov! 💪 In a world where governments are tightening their grip on our freedoms, big respect to Pavel Durov, the unbreakable force behind Telegram! This man is a true fighter: exiled from Russia for refusing to sell out user data, building an empire on privacy and free speech, and now calling out the EU’s “war against privacy” with their impossible rules that punish innovation. He’s warning us we’re running out of time to save the free internet from a dystopian nightmare of surveillance and censorship. Even after his arrest in France and being blocked from speaking at freedom forums, he stands firm, removing harmful content without compromising principles. Pavel, you’re a legend and you are inspiring entrepreneurs and rebels everywhere to never back down. You are a dear friend and a loyal brother and I stand alongside you all the way 100%! #PavelDurov#FreeSpeechWarrior#Telegram#Legend - Conor McGregor

12
ПретходнаСтраница 1 од 2Следна