Когда разрабатываете свой 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
🌐The Internet's History
The #Internet's history goes back some decades by now – #Email has been around since the 1960s, file sharing since at least the 1970s, and TCP/IP was standardized in 1982. But it was the creation of the world wide web (www) in 1989 that revolutionised our history of communication. The inventor of the world wide web was the English scientist Tim Berners-Lee who created a system to share information through a network of computers. At the time he was working for the European physics laboratory CERN in the Swiss Alps.
The chart below shows the share and number of people that are using the Internet, which in these statistics refers to all those who have used the Internet in the last 3 months.
Read more on OurWorldInData and see the full-size chart here.
🚀@PerspectiveIX
Eppie — open protocol encrypted p2p email
=> https://eppie.io
=> https://github.com/Eppie-io
Eppie is a next-gen providerless email that allows its users to own their accounts, addresses and data. In addition to its own p2p network Eppie can communicate with other popular decentralized networks, like Ethereum, and is capable of interacting with conventional IMAP/SMTP email. It is beautiful and easy to use, just like a normal email client.
Features:
🌎 Works on all platforms: Windows, MacOS, Linux, iOS, Android
🕶 Privacy-first: there's no such thing as optional encryption
🚀 P2P messaging: without servers nobody's holding your hand anymore
🔑 Identity manager: key management is a breeze
💾 Decentralized backup: your data is safe and only yours
🤙 Ultimate interoperability: Eppie can communicate with Ethereum, Bitcoin and more
📬 IMAP/SMTP compatible: connect to Gmail, Microsoft Outlook etc.
🦄 Proton Mail Authentication: Eppie is the first native desktop client capable of that
🔐 PGP encryption: stay safe even with conventional email
🤖 Local AI agents
NOTE: the project is early in development, not all of the features are publicly availabe
via @dcntr
#email#p2p
📩 Не пропускаем почту вместе с @GmailBot
Бот для уведомлений, быстрых действий и отправки почты с вашего Gmail ящика
Немного советов для удобства:
- СоблюдайтеInbox Zero(не пожалеете..)
- Настройте пересылку писем с других ваших ящиков на основной Gmail
- Отпишитесь от ненужных рассылок.. в конце то концов ._.
Inbox Zero - начал применять очень давно не замечая, позже узнал как это называется. На самом деле здесь ничего сложного, просто нужно следить за чистотой вкладки входящих.
Наверное многие уже давно пользуются им, даже в последней новости об обновлении 5.13 он упоминался, но надеюсь будет кому-то ещё в новинку.
#bot#email
💌EMAIL by the Digits
3.7 billion: Number of email accounts worldwide
269 billion: Emails sent daily in 2017
121: Number of emails the average office worker gets per day
6: Average seconds within which people reply to a work email
45%: Percentage of spam in email traffic
95: Percentage of spam that gets delivered
3.1%: Average click-through rate for emails in North America
1.2 billion: Number of Gmail users
70 million: Amount of emails that Slack likes to boast it has “saved the world from”
775%: Percent increase in emojis in emails from 2015–2016
43%: Percentage of people that check email in the bathroom
#FunFact#Email
🚀@PerspectiveIX
🌀 http://prs.pctvix.co/TelegramIX
📱Email & Mobile Notifications in Driving Loyalty
Generating more direct traffic to websites and apps is an important priority for publishers, with #email#newsletters a particularly favoured tactic for retaining subscribers but also for attracting new users. The Washington Post operates around 70 different newsletters & has found that recipients consume around three times as much content as those who don’t use email news. RI’s own data this year show that 42% of US digital subscribers have used one or more email newsletters in the last week compared with 35% in the UK but just 17% in Norway and 19% in Sweden. It is clear this is one area where Nordic publishers could learn a few tricks from the United States.
via The Reuters Institute.
🔗 Read more & download the RI's Digital News Report 2019 in yesterday's Pulse - don't forget to subscribe.
Country analysis for: 🇬🇧🇦🇹🇧🇪🇧🇬🇭🇷🇨🇿🇩🇰🇫🇮🇫🇷🇩🇪🇬🇷🇭🇺🇮🇪🇮🇹🇳🇱🇳🇴🇵🇱🇵🇹🇷🇴🇸🇰🇪🇸🇸🇪🇨🇭🇹🇷| 🇺🇸🇦🇷🇧🇷🇨🇦🇨🇱🇲🇽| 🇦🇺🇭🇰🇯🇵🇲🇾🇸🇬🇰🇷🇹🇼| 🇿🇦
🚀@PerspectiveIX