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

Резултати

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

Пребарај: #danaher

当前筛选 #danaher清除筛选
bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1799 · 05.04.2025 г., 23:24

🔥NEW RELEASE🔥 😁Only Way Out: Dynamic Back Escapes By Brian Glick😁 ➡️Unlock your path to freedom with Only Way Out: Dynamic Back Escapes by Brian Glick, one of the most sought-after instructors at BJJ Fanatics. Brian’s teaching ability is renowned for breaking down complex techniques into easily digestible steps, helping practitioners at all levels of Brazilian Jiu-Jitsu (BJJ) master the art of escaping back control. ➡️Whether you're a white belt or a seasoned competitor, Brian's step-by-step breakdowns will give you the tools to confidently escape back control in any situation ➡️This instructional covers a variety of dynamic back escapes, teaching you how to stay calm under pressure and develop the instincts needed to reclaim control. $197😍$19.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 🌈UFC Picks 👑MasterClass ✈️@bjjfanaticsinstructionals #BrianGlick#BJJFanatics#NewWave#NoGi#Danaher 💁‍♀️Buy 💁‍♀️

bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1801 · 10.04.2025 г., 19:26

🔥NEW RELEASE🔥 😁Master The Move: The Side Crucifix By John Danaher😁 ➡️Unlock the power of the Side Crucifix with John Danaher in this must-have instructional video from his best-selling "Master The Move" series ➡️With clear, step-by-step instructions, John reveals the fundamental principles behind the Side Crucifix, a position that allows you to dominate your opponent with high-percentage attacks, all without requiring advanced athletic ability. ➡️If you want to improve your upper body submission game and finish your opponents with efficiency and precision, the Side Crucifix is your new go-to position $197😍$19.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 🌈UFC Picks 👑MasterClass ✈️@bjjfanaticsinstructionals #JohnDanaher#BJJFanatics#NewWave#NoGi#Danaher 💁‍♀️Buy 💁‍♀️

bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1797 · 05.04.2025 г., 23:20

🔥NEW RELEASE🔥 😁The Ultimate Guide To Creating Back Exposure By Luke Griffith😁 ➡️Unlock the secrets to dominating your opponent’s back in Brazilian Jiu-Jitsu with The Ultimate Guide To Creating Back Exposure by Luke Griffith, one of the most promising talents to emerge from Team New Wave. ➡️In this exclusive instructional, Luke takes you through the critical principles and strategies behind creating back exposure, a pivotal aspect of the modern submission game. ➡️Whether you’re a white belt or a seasoned black belt, this guide will sharpen your ability to find and capitalize on back control from a variety of positions. $147😍$14.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 🌈UFC Picks 👑MasterClass ✈️@bjjfanaticsinstructionals #LukeGriffith#BJJFanatics#NewWave#Danaher 💁‍♀️Buy 💁‍♀️

bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1807 · 24.04.2025 г., 17:27

🔥NEW RELEASE🔥 😁Leg Locks Finishes By Helena Crevar😁 ➡️Unlock the secrets to finishing leg locks with Leg Locks Finishes, the highly anticipated Brazilian Jiu-Jitsu instructional by the rapidly rising star of the sport, Helena Crevar. ➡️Her impeccable technique, precise attention to detail, and aggressive competition record make her the perfect guide to take your leg lock game to the next level. ➡️In this comprehensive instructional, Helena breaks down her favorite leg lock finishes, focusing on efficient setups, seamless transitions, and perfecting the art of submission under pressure. $197😍$14.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 🌈UFC Picks 👑MasterClass ✈️@bjjfanaticsinstructionals #HelenaCrevar#WomenBJJ#Leglocks#NoGi#Danaher 💁‍♀️Buy 💁‍♀️

bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1806 · 24.04.2025 г., 17:25

🔥NEW RELEASE🔥 😁Leg Lock Entries By Helena Crevar😁 ➡️Unlock the power of leg locks with Helena Crevar's BJJ Instructional on Leg Lock Entries. As one of the fastest rising stars in Brazilian Jiu-Jitsu, Helena has been turning heads worldwide with her technical precision and mastery of the game ➡️Trained under the legendary John Danaher, Helena’s leg lock game is among the best in the world. This instructional video provides you with clear, step-by-step guidance on entries that will elevate your leg lock game to new heights. ➡️This is your opportunity to learn from one of the brightest talents in BJJ and take your leg lock entries from basic to lethal. $197😍$14.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 🌈UFC Picks 👑MasterClass ✈️@bjjfanaticsinstructionals #HelenaCrevar#WomenBJJ#Leglocks#NoGi#Danaher 💁‍♀️Buy 💁‍♀️