Когда разрабатываете свой 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
#members
👍Oktyabr va Noyabr oylarida 112 ta eksportga yo‘naltirilgan kompaniya IT Park a’zosi bo‘ldi, ulardan 59 tasi AQSh, Kanada, Buyuk Britaniya, Yaponiya, Xitoy, Shveytsariya va boshqa davlatlardan xorijiy kapitalli kompaniyalar.
📈Asosiy faktlar:
- Yangi eksportchilar asosan IT va biznes xizmatlarini taqdim etishga e'tibor qaratmoqda.
- Dastlabki yil ichida 2,500+ yangi ish o‘rni yaratiladi, jumladan mintaqaviy hududlarda – mahalliy mutaxassislar yetakchi xalqaro kompaniyalarga qo‘shilish va global bozorda ishlash imkoniyatiga ega bo‘ladi.
- Asosiy eksport bozorlari: AQSh, Kanada, Yevropa va Osiyo.
🌍 Xalqaro muvaffaqiyat namunalari:
KARAM (Portugaliya-Vengriya): global bozorlarda moliyaviy rejalashtirish.
BEUKITCH EV (Malayziya): AQSh va Malayziya uchun dasturiy ta'minot ishlab chiqish.
INVERSON OPERATIONS (Shveytsariya): AQSh va Shveytsariya uchun IT-konsalting va kiberxavfsizlik.
UNLOCKWARE IT SERVICES (Kanada): Qatar, Saudiya Arabistoni, Kanada va AQShga xizmat eksporti.
FUJIYAMA LOGISTICS (Yaponiya): ta’minot zanjiri boshqaruv tizimlarini qo‘llab-quvvatlash bo‘yicha mahalliy mutaxassislar.
Umumiy prognoz qilingan eksport hajmi: birinchi yil davomida 70 million AQSh dollari!
🇺🇿O‘zbekiston IT sohasidagi qudratli davlat sifatida global e’tiborni jalb etishda davom etmoqda va o‘sish hamda hamkorlik uchun yangi imkoniyatlar yaratmoqda.
🕸 Batafsil ma'lumotni bizning veb-saytimizda o‘qing
______
👍During October and November, 112 export-oriented companies have become IT Park members, including 59 companies with foreign capital from the USA, Canada, the UK, Japan, China, Switzerland, and other countries.
📈 Key Facts:
- New exporters mostly focus in providing IT and business services.
- 2,500+ new jobs will be created wihin the first year of activity, including in regional areas -- local specialists have the opportunity to join the leading international companies and work on the global market.
- Main export markets: the USA, Canada, Europe, and Asia.
🌍 Examples of international success:
KARAM (Portugal-Hungary): financial planning for global markets.
BEUKITCH EV (Malaysia): software development for the USA and Malaysia.
INVERSON OPERATIONS (Switzerland): IT consulting and cybersecurity for the USA and Switzerland.
UNLOCKWARE IT SERVICES (Canada): exporting services to Qatar, Saudi Arabia, Canada, and the USA.
FUJIYAMA LOGISTICS (Japan): local specialists supporting supply chain management systems.
Total projected export volume: $70 million in the first year of operations!
🇺🇿Uzbekistan continues to attract global attention as an IT powerhouse, creating opportunities for growth and collaboration.
🕸 Read more on our website
Telegram | Instagram | Facebook | Youtube | LinkedIn
#members
👍 IT Park rezidenti“UIC Games” $400 000 miqdoridagi grantni e’lon qilmoqda!
Agar siz o‘yinlar ishlab chiqishga ishtiyoqmand bo‘lsangiz va bu sohadagi eng yaxshi mutaxassislar bilan jamoada ishlashni istasangiz, bu grant aynan siz uchun mo‘ljallangan.
Grant nimalar taqdim etadi:
🟢 bir yil davomida o‘yinlar ishlab chiqishni bepul o‘rganish uchun noyob imkoniyat
🟢 o‘qish davri mobaynida stipendiya
🟢 o‘qishni tugatgach kafolatlangan ish o‘rni
⭐️ Grantlar soni cheklangan. Imkoniyatni boy bermaslik uchun @UICGames_bot orqali ro‘yxatdan o‘ting!
_____________
👍 IT Park membersUIC Games Announces Grant of $400,000!
If you are passionate about game development and wish to collaborate with top professionals in the industry, this grant is designed for you.
Benefits of the Grant:
🟢 A unique opportunity to engage in a one-year, tuition-free study program in game development
🟢 A stipend provided throughout the duration of the program
🟢 Guaranteed employment upon completion of the training
⭐️ The number of grants is limited. Register through @UICGames_bot to seize this opportunity!
Telegram | Instagram | Facebook | Youtube | LinkedIn
#members
👍 IT Park rezidenti“UIC Games” $400 000 miqdoridagi grantni e’lon qilmoqda!
Agar siz o‘yinlar ishlab chiqishga ishtiyoqmand bo‘lsangiz va bu sohadagi eng yaxshi mutaxassislar bilan jamoada ishlashni istasangiz, bu grant aynan siz uchun mo‘ljallangan.
Grant nimalar taqdim etadi:
🟢 bir yil davomida o‘yinlar ishlab chiqishni bepul o‘rganish uchun noyob imkoniyat
🟢 o‘qish davri mobaynida stipendiya
🟢 o‘qishni tugatgach kafolatlangan ish o‘rni
⭐️ Grantlar soni cheklangan. Imkoniyatni boy bermaslik uchun @UICGames_bot orqali ro‘yxatdan o‘ting!
_____________
👍 IT Park membersUIC Games Announces Grant of $400,000!
If you are passionate about game development and wish to collaborate with top professionals in the industry, this grant is designed for you.
Benefits of the Grant:
🟢 A unique opportunity to engage in a one-year, tuition-free study program in game development
🟢 A stipend provided throughout the duration of the program
🟢 Guaranteed employment upon completion of the training
⭐️ The number of grants is limited. Register through @UICGames_bot to seize this opportunity!
Telegram | Instagram | Facebook | Youtube | LinkedIn
#members
Делимся лайфхаком: дарим в подарок своему мужчине костюм самого маленького размера и носим с ним по очереди 🤍
В преддверии 14 февраля, ознакомьтесь с актуальными позициями зимней капсулы в данном посте и не забывайте, что релиз спортивных костюмов состоится уже 20.02, а это значит, что их осталось совсем немного.
🔥The Religion Order | Support
@ThankStickerBot
Qué puede hacer este bot?
Envía automáticamente pegatinas de miembros de agradecimiento cuando su grupo llega a los miembros 'x'.
Idioma: Inglés
(visto en @BotsGram_cu)
#thankyou, #thanks, #group, #members, #sticker, #stickers