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

Резултати

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

Пребарај: #onto

当前筛选 #onto清除筛选
English Speakers

@English_Speakers · Post #3541 · 10.08.2018 г., 03:32

Important Five: Common Errors in the use of Prepositions 1) For #Days#, we use 'On', For Dates, we use 'On', For months we use, 'In', For seasons we use 'In', For a particular time, we use 'At'. For morning and evening, we use 'In'. For night, we use# 'At'.# #At:# at 7 o'clock; at midday; at dinner; at Christmas #In:# in the evening; in Easter week; in September; in (the) winter; in 1864; in the 20th century #On:# on Friday; on April 1st; on Christmas Day #Incorrect:# My brother completed the project in a month’s time. #Correct:# My brother completed the project in a month. #Incorrect:# We love to visit the nearest market on Sunday. #Correct:# We love to visit the nearest market on #Sundays.# 2)The verbs lack, approach and enter are directly followed by objects without prepositions. Other verbs that do not normally take prepositions are: discuss, marry and resemble. #Incorrect:# Although my sister is intelligent, she lacks of confidence. #Correct:# Although my sister is intelligent, she# lacks confidence.# #Incorrect:# The train is now approaching to my city. #Correct:# The train is now #approaching my city.# #Incorrect:# The boys were not allowed to enter into the house. #Correct:# The boys were not allowed to #enter the house.# 3) The prepositions #in# and #on# are used to show position. To say where things are going, we use #into# and #onto.# #Incorrect: #The ball rolled slowly in the goal. #Correct:# The ball rolled slowly# into# the goal. #Incorrect:# She ran in the room crying. #Correct:# She ran #into# the room crying. 4) We use #in# to say how soon something will happen. #Within# means ‘inside’ or ‘not beyond’. #Incorrect:# The train will arrive #within# six minutes. #Correct:# The train will arrive# in# six minutes. #Incorrect#: You need to complete this book in a month. #Correct:# You need to complete this book within a month. #Incorrect:# If you don’t live by your income, you will have to pay huge debts. #Correct:# If you don’t live# within# your income, you will have to pay huge debts. 5) #Through# is used for movement in a three-dimensional space. #Incorrect:# The ball went #to# the window and fell on the ground. #Correct#: The ball went #through# the window and fell on the ground.