TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #381 · 23 окт.

Установить свойства виджета в PySide можно не только через соответствующие методы и конструктор класса. Можно их изменять с помощью метода setProperty по имени. btn = QPushButton("Click Me") btn.setProperty("flat", True) Это аналогично вызову btn.setFlat(True) Если указать несуществующее свойство, то оно просто создается btn.setProperty("btnType", "super") Получить его значение можно методом .property(name) btn_type = btn.property("btnType") Когда это может быть полезно? ▫️Можно просто хранить какие то данные в виджете и потом их доставать обратно widget = QWidget() widget.setProperty('my_data', 123) print(widget.property('my_data')) ▫️ Назначая эти свойства разным виджетам можно потом отличить виджеты во время итераци по ним. Например, найти все кнопки со свойством my_data="superbtn". Но ведь вместо кастомного свойства можно использовать objectName, будет тот же результат. Да, но y ObjectName есть ограничение - только строки. ▫️ Если нам потребуется не просто поиск а, например, сортировка по числу, то свойства позволяют нам это сделать. Поддерживается любой тип данных widget.setProperty('my_data', {'Key': 'value'}) widget.setProperty('order', 1) all_widgets.sort(key=w: w.property('order')) Но ведь Python позволяет всё вышеперечисленное сделать простым созданием атрибута у объекта widget.order = 1 widget.my_data = 123 Да, но я думаю что не надо объяснять почему не стоит так делать. К тому же, если у виджета нет свойства то метод .property(name) вернет None, а отсутствующий атрибут выбросит исключение. ▫️ Действительно полезное применение кастомным свойствам - контроль стилей. Здесь атрибутами не обойтись, нужны именно свойства. Дело в том, что в селекторах стилей можно указывать конкретные свойства виджетов на которые следует назначать стиль. Просто запустите этот код from PySide2.QtWidgets import * if __name__ == "__main__": app = QApplication([]) widget = QWidget(minimumWidth=300) layout = QVBoxLayout(widget) btn1 = QPushButton("Action 1") btn2 = QPushButton("Action 2") btn3 = QPushButton("Action 3", flat=True) layout.addWidget(btn1) layout.addWidget(btn2) layout.addWidget(btn3) # добавим кастомное свойство одной кнопке btn1.setProperty("btnType", "super") # добавляем стили widget.setStyleSheet( """ QPushButton[btnType="super"] { background-color: yellow; color: red; } QPushButton[flat="true"] { color: yellow; } """ ) widget.show() app.exec_() С помощью селектора мы избирательно назначили стили на конкретные кнопки. Как получить список всех кастомный свойств? Функция получения списка кастомных свойств отличается от получения дефолтных. def print_widget_dyn_properties(widget): for prop_name in widget.dynamicPropertyNames(): property_name = prop_name.data().decode() property_value = widget.property(property_name) print(f"{property_name}: {property_value}") #tricks#qt

Hashtags

Резултати

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

Пребарај: #harvard

当前筛选 #harvard清除筛选
PDF资料

@pdf_001 · Post #869 · 04.11.2020 г., 13:02

#Harvard Writing Project 提供的写作手册涵盖史学、文学、艺术史、人类学、哲学、宗教学、政治学、性别研究、经济学、心理学等。全部PDF,自由下载 https://writingproject.fas.harvard.edu/pages/disciplinary-writing-guides

Hashtags

🕵🏻‍♀️How Harvard rates your application? part 4 For part 1: https://t.me/farangizmurodiy/14 🏛 When you apply to Harvard, Harvard rates your application from 1 to 6 in four categories and gives one overall rating. Part 4: Athletic Rating 🏅🏅🏅 1️⃣Unusually strong prospect for varsity sports at Harvard, desired by Harvard coaches. 2️⃣ Strong secondary school contribution in one or more areas; possible leadership role(s). 3️⃣ Active participation. 4️⃣ Little or no interest. 5️⃣ Substantial activity outside of conventional EC participation such as family commitments or term-time work (could be included with other e/c to boost the rating or left as a "5" if it is more representative of the student's commitment). 6️⃣Physical condition prevents significant activity. Note: After watching lots of videos of Harvard students talking about their admission files, I understood that not being athlete will not damage your application, but if you're an international level athlete, it will benefit you a lot. Because the calculation of an application's overall rating is not just arithmetical, getting a low athletic rating will not disadvantage you if you are very successful in other areas. However, getting 1, being recruited athlete, will boost your application significantly. 👩🏻‍⚖️ This was the part 4 of#Harvard admission series. Finally, in the next Harvard post, I’ll be sharing strategies on how you can apply those valuable infos from all four parts to your own application. @farangizmurodiy

Hashtags

🕵🏻‍♀️How Harvard rates you? part 3 🏛 When you apply to Harvard, Harvard rates your application from 1 to 6 in four categories and gives one overall rating. Part 3: Personal Rating ❤️ 1) Outstanding 2) Very Strong 3) Generally Positive 4) Bland or somewhat negative or immature 5) Questionable personal qualities 6) Worrisome personal qualities 🤯 This is the most subjective rating in Harvard admissions. Also, this subjectiveness is the reason why Harvard is dealing with an affirmative action lawsuit. More info: https://rb.gy/tjr3zl What determines your personal rating is: 📝 Essays 👩‍🏫 Recommendation Letters Because it's very subjective, your application as a whole plays a role in this rating. Part 1: https://t.me/farangizmurodiy/14 Part 2:https://t.me/farangizmurodiy/23 👩🏻‍⚖️ This was the part 3 of 4 #Harvard admission series. In the end of the series, I’ll be sharing strategies on how you can apply this valuable info to your own application. @farangizmurodiy

Hashtags

🕵🏻‍♀️How Harvard rates you? part 2 🏛 When you apply to Harvard, Harvard rates your application from 1 to 6 in four categories and gives one overall rating. Part 2: Extracurricular Rating 🏆 1️⃣ Unusual strength in one or more areas. Possible national-level achievement or professional experience. A potential major contributor at Harvard. Truly unusual achievement. 2️⃣Strong secondary school contribution in one or more areas such as class president, newspaper editor, etc. Local or regional recognition; major accomplishment(s).[in another filing]: "Significant school, and possibly regional accomplishments: for example, an applicant who was the student body president or captain of the debate team and the leader of multiple additional clubs." 3️⃣Solid participation but without special distinction. (Upgrade 3+ to 2- in some cases if the e/c is particularly extensive and substantive.) 4️⃣ Little or no participation. 5️⃣Substantial activity outside of conventional EC participation such as family commitments or term-time work (could be included with other e/c to boost the rating or left as a "5" if it is more representative of the student's commitment). 6️⃣Special circumstances limit or prevent participation (e.g. a physical condition). 👩🏻‍⚖️ This was the part 2 of 4#Harvard admission series. In the end of the series, I’ll be sharing strategies on how you can apply this valuable info to your own application. @farangizmurodiy

Hashtags

🕵🏻‍♀️How Harvard rates you? When you apply to Harvard, Harvard rates your application from 1 to 6 in four categories and gives one overall rating. Part 1: Academic Achievement 📚 1) Summa potential: Genuine scholar; near-perfect scores and grades (in most cases) combined with unusual creativity and possible evidence of original scholarship. 2) Magna potential: Excellent student with superb grades and mid-to-high-700 scores (33+ ACT). 3) Cum laude potential: Very good student with excellent grades and mid-600 to low-700 scores (29 to 32 ACT). 4) Adequate preparation: Respectable grades and low-to-mid-600 scores (26 to 29) ACT). 5) Marginal potential: Modest grades and 500 scores (25 and below ACT). 6) Achievement or motivation marginal or worse. 👩🏻‍⚖️ This was the part 1 of 4 #Harvard admission series. In the end of the series, I’ll be sharing strategies on how you can apply this valuable info to your own application. 🏆 Follow for more unique admission strategies: @farangizmurodiy

Hashtags

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