@sickipedia · Post #9696 · 23.02.2025 г., 06:01
"Why are you so calm?". "I never argue with stupid people. I just say 'you're right' and move on. "That's ridiculous!". "You're right." #roast@Sickipedia
Hashtags
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
Пребарај: #roast
@sickipedia · Post #9696 · 23.02.2025 г., 06:01
"Why are you so calm?". "I never argue with stupid people. I just say 'you're right' and move on. "That's ridiculous!". "You're right." #roast@Sickipedia
Hashtags
@sickipedia · Post #9619 · 29.01.2025 г., 07:01
My buddy quit his job at BMW. He of course gave no indication that he was leaving. #roast@Sickipedia
Hashtags
@sickipedia · Post #9601 · 23.01.2025 г., 07:01
My wife asked me, “Can we have some peace and quiet while I cook dinner?” So I took out the batteries from the smoke alarm. #roast@Sickipedia
Hashtags
@sickipedia · Post #9558 · 08.01.2025 г., 11:01
I had a big fight with my wife, I yelled at her, "When you finally die, I'm getting you a headstone that says, 'Here Lies My Wife - Cold As Ever'." "Yeah well," she shouted back, "When you die, I'm getting you a headstone that says, 'Here Lies My Husband - Stiff At Last." #roast@Sickipedia
Hashtags
@sickipedia · Post #9550 · 05.01.2025 г., 15:01
My coworker said: “ You should not eat red meat.” I said, “My grandmother lived to be 97.”… She said, “Did she eat red meat?” I said, “No. She minded her own business.” #roast@Sickipedia
Hashtags
@sickipedia · Post #9512 · 24.12.2024 г., 07:01
I named my daughter after my mother-in-law. Raving Psycho will soon be a year old. #roast@Sickipedia
Hashtags
@sickipedia · Post #9506 · 22.12.2024 г., 07:01
My son’s teacher thinks my son has a low IQ judging by his homework. That’s absurd! My son is perfectly normal! I did his homework. #roast@Sickipedia
Hashtags
@sickipedia · Post #9485 · 15.12.2024 г., 06:01
My wife asked me, "is it just me or is the cat getting fat?" "no, it's just you." #roast@Sickipedia
Hashtags
@sickipedia · Post #9162 · 28.08.2024 г., 11:01
I asked my mom If I was an accident. She said, "No, of course not. Your brother was the accident. You were a mistake". #roast @Sickipedia
Hashtags
@sickipedia · Post #9055 · 24.07.2024 г., 11:01
Politicians and diapers have one thing in common: they should both be changed regularly… and for the same reason. #roast @Sickipedia
Hashtags
@sickipedia · Post #9052 · 23.07.2024 г., 11:01
A man who owned a sausage factory was showing his arrogant asshole son around his factory. Try as he might to impress his snobbish son, his son would just sneer and look down his nose at everything. They approached the heart of the factory, where the father thought, "This should impress him!" He showed his son a machine and said, "Son, this is the heart of the factory. With this machine here we can put in a pig, and out come sausages." The son, unimpressed, said, "Yes, but do you have a machine where you can put in a sausage and out comes a pig?" The father, "Yes son, we call it your mother." #roast @Sickipedia
Hashtags
@sickipedia · Post #8871 · 22.05.2024 г., 11:01
Wife: "How would you describe me?" Husband: "ABCDEFGHIJK." Wife: "What does that mean?" Husband: "Adorable, beautiful, cute, delightful, elegant, fashionable, gorgeous, and hot." Wife: "Aw, thank you, but what about IJK?" Husband: "I'm just kidding!" #roast @Sickipedia
Hashtags