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

Резултати

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

Пребарај: #sentinels

当前筛选 #sentinels清除筛选
NewUU Student Council

@newuu_sc · Post #671 · 23.06.2023 г., 11:35

📢 Election Update: Renaissance Team Emerges Victorious!🎉 We are thrilled to announce the conclusion of the Student Council elections, held online through Google Forms from June 20 to 22. After an intense battle for leadership, the results are finally in! ✨ Team Renaissance has emerged as the winner, securing an impressive 59.3% of the votes! 🎊 We extend our warmest congratulations to their members for their outstanding campaign and commitment to making a positive impact on our school community. 🏅 We also commend the Sentinels team for their dedication and hard work, as they garnered a respectable 40.7% of the votes. Your participation and contributions have been invaluable throughout this process. We would like to express our gratitude to all candidates who put themselves forward for the Student Council elections. Your passion, ideas, and willingness to serve are truly commendable. A special thanks goes out to every student who participated in the voting process. Your engagement and enthusiasm have played a crucial role in shaping the future of our Student Council and the initiatives it will undertake. Let us now join hands and offer our full support to the Renaissance Team as they embark on their journey of leadership. Together, we can strive to create an inclusive and vibrant school environment that fosters growth, innovation, and collaboration. Best Regards, Student Affairs. 🎓🌟#StudentCouncilElections#Renaissance#Sentinels#Congratulations

NewUU Student Council

@newuu_sc · Post #639 · 14.06.2023 г., 09:06

📢 Attention all students of New Uzbekistan University! 🎓 The highly anticipated debates between the two candidates vying for the position of President of the Student Council will take place in the university Conference Hall. 🎙🏛 Join us for an engaging discussion as these candidates present their visions, plans, and goals for the next academic year. It's an excellent opportunity to get to know the potential leaders who will shape our university's future! 🌟✨ Whether you're passionate about academic improvements, extracurricular activities, or enhancing student welfare, this debate is the perfect platform to hear the candidates' perspectives and evaluate their abilities to meet our diverse needs. 📚🎉 Spread the word and see you all there! 🎉🗣 Date: June 16 Time: 16:00 Location: Conference hall #NewUzbekistanUniversity#StudentCouncilElections#Debate2023#Renaissance#Sentinels