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

Резултати

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

Пребарај: #submissions

当前筛选 #submissions清除筛选
bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1920 · 03.03.2026 г., 17:27

😁Magids Abstract Armlocks by Magid Hage😁 ➡️Get ready to see armlocks in a whole new light. In Magid’s Abstract Armlocks, world-class black belt and competition standout Magid Hage takes you deep into the world of unconventional, creative, and downright sneaky armlock attacks. ➡️Whether you're attacking from guard, top position, scrambles, or even from “bad” spots — you’ll learn how to hunt arms from anywhere. $79😍$6.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 👑MasterClass ✈️@bjjfanaticsinstructionals #MagidHage#Submissions#NoGi#IBJJF 💁‍♀️Buy 💁‍♀️

bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1842 · 17.07.2025 г., 23:47

😁Attacking Outside Finishing Inside by Lucas Kanard😁 ➡️Unlock the secret to seamless offense with Attacking Outside, Finishing Inside, the revolutionary BJJ instructional series by Lucas Kanard. ➡️Designed to elevate your game by blending lower body attacks with precise upper body finishes, this system keeps your opponents guessing—and trapped. ̶$̶7̶9̶😍$9.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 🌈UFC Picks 👑MasterClass ✈️@bjjfanaticsinstructionals #LucasKanard#Passing#NoGi#Submissions 💁‍♀️Buy 💁‍♀️

bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1952 · 30.04.2026 г., 23:43

🐈‍⬛NEW RELEASE 🐈‍⬛ 🐈‍⬛Woj Lock 2.0 - Completing The Leg Lock Game by Chris Wojcik 🐈‍⬛ 🐈‍⬛Chris Wojcik isn’t just a leg locker—he’s one of the most innovative finishers in modern grappling, known for catching high-level opponents with his signature “Woj Lock” system. 🐈‍⬛From foundational concepts to advanced 50/50 systems, cross ashi, inside ashi, and beyond—Wojcik shows you how to connect entries, control, and finishing mechanics into one seamless chain. $79 🐈‍⬛$9.99 🐈‍⬛ ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱📱 💰Submeta FOR FREE 👑MasterClass ✈️@bjjfanaticsinstructionals #ChrisWojcik#Submissions#NoGi#ADCC 🐈‍⬛Buy 🐈‍⬛

bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1933 · 12.04.2026 г., 00:33

😁Z locks and the Diagonal Ashi: the Complete Guide by Robert Degle😁 ➡️More than any other leglocking strategy the Diagonal Ashi and Z lock allow us to remain safe from counter leglocks and solve the problem of defensive hip movement by allowing us to adhere to the principle of double trouble while we execute devastating leglock submissions. $97😍$9.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 👑MasterClass ✈️@bjjfanaticsinstructionals #RobertDegle#Submissions#NoGi#ADCC

bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1932 · 12.04.2026 г., 00:32

😁Samurai Submissions: finish Quickly From Turtle by Kenta Iwamoto😁 ➡️In Samurai Submissions, BJJ’s fastest-rising star and B-Team standout breaks down his signature system for lightning-fast, high-percentage submissions from turtle — attacks so sneaky your opponents won’t realize they’re in danger until it’s already over. ➡️Kenta’s approach is brutally efficient: minimal movement, tight control, and submissions that hit before your opponent can react. $127😍$9.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 👑MasterClass ✈️@bjjfanaticsinstructionals #KentaIwamoto#Submissions#NoGi#CJI

bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1862 · 16.09.2025 г., 23:00

🔥NEW RELEASE🔥 😁Upper Lower Chains Links that Solve Problems Faster by Josh Saunders😁 ➡️Unlock the secret to faster problem-solving and fluid movement on the mats with Upper Lower Chains Links that Solve Problems Faster, an innovative BJJ instructional by Josh Saunders — a 2x ADCC Trials winner and ADCC semifinalist. ➡️This groundbreaking approach empowers practitioners to adapt, innovate, and respond to challenges in real-time, making your game more dynamic and intuitive. $79😍$9.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 🌈UFC Picks 👑MasterClass ✈️@bjjfanaticsinstructionals #JoshSaunders#Submissions#NoGi#Transitions 💁‍♀️Buy 💁‍♀️

bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1888 · 04.12.2025 г., 21:02

😁Rethink Front Headlocks: Control And Submit Larger People by Josh Janis😁 ➡️Discover a smarter, more effective way to dominate from the front headlock—especially against larger, stronger opponents. ➡️With this series, you’ll learn how to systematically break posture, create off-balance reactions, and chain submissions—even on opponents who normally overpower you. $79😍$9.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 👑MasterClass ✈️@bjjfanaticsinstructionals #JoshJanis#Guillotines#NoGi#Submissions 💁‍♀️Buy 💁‍♀️