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

Резултати

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

Пребарај: #sgunited

当前筛选 #sgunited清除筛选
REACH

@reachsg · Post #578 · 21.04.2020 г., 16:08

What are the services that will suspend operations from today till the end of Circuit Breaker? #SGUnited

Hashtags

REACH

@reachsg · Post #564 · 18.04.2020 г., 13:25

REACH Live! (Mandarin) Highlights #2 - How can we encourage the seniors to stay home? #SGUnited

Hashtags

REACH

@reachsg · Post #562 · 18.04.2020 г., 04:39

REACH Live! (Mandarin) Highlights #1 - Why should we wear mask whenever we go out? Let's hear from Ms Tin Pei Ling #SGUnited

Hashtags

REACH

@reachsg · Post #473 · 06.04.2020 г., 05:56

Tune into DPM Heng Swee Keat’s Solidarity Budget announcement later at 2PM today, where he will announce additional support for workers, businesses and households, to help tide them through this period. #SGUnited🇸🇬 📺 Catch the ‘live’ broadcast on CNA, on CNA938, and on Mediacorp’s meWATCH interactive service (www.mewatch.sg).

Hashtags

REACH

@reachsg · Post #228 · 12.03.2020 г., 13:42

[Sent by Gov.sg - 12 Mar] COVID-19 situation in S’pore - More imported cases expected as global numbers rise - More travel restrictions may be needed - If there are many cases here, may need to hospitalise only those seriously ill; those with mild symptoms to see GP, rest at home SG is NOT going to DORSCON Red — We have the situation under control Economic impact - Measures to help affected businesses, workers - Govt working on 2nd package of measures Staying #SGUnited 👩‍⚕ Frontline staff working hard 💪 Singaporeans’ support crucial to overcome this Everyone can do their part - Practise good personal hygiene, adopt new social norms 🧼🙌 - Maintain social distancing 👋 Watch: go.gov.sg/pmo12mar

Hashtags

NEA Singapore

@NEASingapore · Post #158 · 12.02.2021 г., 02:00

May you have good health and an OX-spicious new year! P.S. Use serving spoons and don’t double dip when having your reunion meals, let’s keep everyone safe and healthy! #SGUnited

Hashtags

REACH

@reachsg · Post #81 · 13.02.2020 г., 00:14

[Sent by Gov.sg - 13 Feb] 💪🇸🇬Helping those impacted by COVID-19: Contribute to The Courage Fund - To help those impacted by COVID-19 — patients, healthcare workers and those who need extra support www.comchest.sg/thecouragefund Go to the centralised online platform for ground-up efforts - Information on what’s needed - Information on ground-up groups and Govt-led initiatives - Details on platform soon Let’s show support for all in the healthcare and other sectors who have been working tirelessly. Look out for one another. #SGUnited

Hashtags

NEA Singapore

@NEASingapore · Post #46 · 24.04.2020 г., 04:00

Our hawkers are working hard to provide delicious food for all of us. So let’s show them our support by ordering takeaways or deliveries of our fave hawker dishes. Together we can overcome. #SGUnited

Hashtags

URA Singapore

@URASingapore · Post #46 · 29.06.2020 г., 11:11

🏃🏻‍♀️ Heading out to the stadiums? Check Space Out’s (www.spaceout.gov.sg) newly-added crowd level information at SportSG’s stadiums, and sweat it out in a safe environment. We are in Phase 2 but there’s no need to rush out. Keep our guard up and use Space Out for regular updates on crowd level information in malls, supermarkets, markets post offices and stadiums across Singapore. It’s also available in all four languages, and presents less crowded options near you. Crowd-level information on more places will be added in future. 👍🏼 Let’s continue to press on, stay safe, and be #SGUnited to fight this virus together.

Hashtags

MTI Singapore

@MTISingapore · Post #4 · 05.08.2021 г., 06:19

The Safe Management Measures have been tightened from 22 July to 18 August. More information on the SMM measures for F&B and Retail and Lifestyle establishments can be found in the infographics. Let's play our part against COVID-19 #SGUnited Click here for more details: https://go.gov.sg/updated-smm-advisory

Hashtags

MND Singapore

@mndsingapore · Post #172 · 01.05.2021 г., 02:14

It has been more than a year since COVID-19 happened. Many of us have had to adapt to new work situations and overcome the various challenges the pandemic brought with it. Today, we salute all workers, especially the frontliners who have been working extra hard to keep us safe this past year. Happy Labour Day! 💪🇸🇬 #SGUnited#SGTogether

123•••56
ПретходнаСтраница 1 од 6Следна