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 слични објави

Пребарај: #recycleright

当前筛选 #recycleright清除筛选
NEA Singapore

@NEASingapore · Post #1171 · 19.11.2025 г., 01:00

Clean recyclables belong in the blue recycling bin. But used batteries? They’re not that girl. 💅 Let’s #RecycleRight and avoid explosive drama.

NEA Singapore

@NEASingapore · Post #1167 · 12.11.2025 г., 01:02

Only fully emptied aerosol cans should go in the blue recycling bins. Partially filled ones pose fire hazards and can cause explosions or fires. 💡Tip: Press until you can no longer hear a hissing sound! Visit go.gov.sg/recycling-guide to learn how to #RecycleRight and prevent fires in recycling bins and trucks.

NEA Singapore

@NEASingapore · Post #706 · 29.11.2023 г., 01:00

Items that contain food or drink residue cannot be recycled. They may even contaminate other recyclables, putting everyone’s good effort to waste! Remember to empty and rinse your bottles or drink cans before recycling them. Let's #RecycleRight! ♻️🌟

NEA Singapore

@NEASingapore · Post #695 · 30.10.2023 г., 04:31

Explore refreshing new adventures in the world of sustainability by joining us on Lemon8. Let’s leave a trail of green footprints as we learn together, discover useful hacks and crafts, #RecycleRight guides and tips, and much more! Follow us at go.gov.sg/nea-lemon8 (or search for nea_sg), and let's sprinkle some citrusy eco magic together!

NEA Singapore

@NEASingapore · Post #557 · 01.06.2023 г., 01:02

Missed the nationwide Bloobox distribution? Good news! You can collect it at selected libraries on weekends this June, and learn more about how you can start a recycling corner at home and #RecycleRight. While stocks last!

NEA Singapore

@NEASingapore · Post #534 · 04.04.2023 г., 03:30

Planning to collect a Bloobox? Don’t forget to check the stock levels before heading down: https://www.gowhere.gov.sg/bloobox Together, let’s #RecycleRight: https://www.go.gov.sg/recycleright

NEA Singapore

@NEASingapore · Post #518 · 18.03.2023 г., 01:15

It’s Global Recycling Day, so let’s be reminded to #RecycleRight! If you’re not sure whether an item can be recycled, check with Bloobin: www.cgs.gov.sg/recycleright/check-my-item

NEA Singapore

@NEASingapore · Post #517 · 17.03.2023 г., 02:22

From 19 Mar to 30 Apr 2023, all households can collect a free Bloobox to start the habit of recycling at home. It also comes with guidelines on what can be recycled. Let’s #RecycleRight! More info at www.gowhere.gov.sg/bloobox

NEA Singapore

@NEASingapore · Post #502 · 05.02.2023 г., 02:01

As the Lunar New Year festivities come to an end, let’s recycle what we can! Instead of throwing away plastic containers that were used to contain the goodies, reuse or recycle them. Not sure whether an item can be recycled? Find out at www.cgs.gov.sg/recycleright/check-my-item #RecycleRight

NEA Singapore

@NEASingapore · Post #473 · 09.12.2022 г., 00:20

Are they friend or foe? Bloobin and the E-Waste Recycling Bin are working towards the same goal – to minimise waste and helping Singapore become a Zero Waste Nation. Here’s a quick guide to get to know them, so that you can #RecycleRight! go.gov.sg/recycleright

NEA Singapore

@NEASingapore · Post #380 · 12.07.2022 г., 07:05

Not sure what to do with your e-waste? Check out the infographics below to find out what you can recycle, and how to recycle. More information at https://go.gov.sg/e-waste#RecycleRight

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