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

Резултати

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

Пребарај: #mobilegaming

当前筛选 #mobilegaming清除筛选
DeckForge Announcement

@deckforge_official · Post #358 · 10.12.2025 г., 12:01

⏸ The Official DeckForge Gameplay Trailer is Here! Our official gameplay trailer is finally here — your first true glimpse into the chaos, beauty & raw power of the DeckForge multiverse. 🔵Where explosive combos ignite, 🔵where Bosses rise from the Void, 🔵where Jokers are forged, broken, reborn & where Genesis begins. This trailer marks the start of a new chapter — one that you will shape. 👀 Watch the trailer. Feel the energy. Step into the Forge. Share your thoughts in the comments — we’re reading every single one. Stay Forged! 🔥 #DeckForge#MobileGaming#GameplayReveal Join the DeckForge Community: 🌐YouTube𝕏Twitter🎮Discord 👉Chat👉Announcements👉DeckForge

DeckForge Announcement

@deckforge_official · Post #351 · 08.12.2025 г., 16:51

▶️DeckForge x RuStore Conference Recap RuStore Mobile Conference has officially wrapped — and it was incredible. 🔵Over 1,000+ industry leaders, studios, publishers and creators gathered under one roof 🔵Our showcase zone was packed all day — tons of gameplay sessions, powerful feedback & new connections with top experts across CIS & Asia 🔵RuStore shared big insights on the future of their platform and expansion into Asian markets — and we’re thrilled to grow alongside them as one of the most anticipated cross-platform titles of 2026 🔵This year, RuStore held its first-ever awards for the best mobile apps and games. Dozens of titles were recognized as the industry’s top performers But we know one thing for sure: next year, DeckForge is taking its place on that stage! Now it’s time to get back to the forge — polishing the upcoming release, preparing holiday events & crafting something truly special for our players. Stay Forged 🔥 #DeckForge#RuStore#GameDev#MobileGaming Join the DeckForge Community: 🌐YouTube𝕏Twitter🎮Discord 👉Chat👉Announcements👉DeckForge

GAMEFEST.UZ

@gamefestuz · Post #270 · 02.04.2026 г., 09:11

🎮 KATTA YANGILIK: TapNation — Game Fest 2026 markazida! Tayyor turing, geymerlar! Dunyoning eng yirik mobil o‘yin nashriyotlaridan biri bo‘lgan TapNation rasman Game Fest 2026 festivalida ishtirok etishini e’lon qiladi! 🚀 Bu shunchaki tadbir emas, bu mobil o‘yinlar olamidagi inqilobiy tajriba bo‘ladi. Biz bilan birga o‘yin sanoatining kelajagiga sho‘ng‘ing! ————————— 🎮 BIG NEWS: TapNation Takes Center Stage at Game Fest 2026! Get ready, gamers! We are thrilled to officially announce that TapNation, one of the world’s leading mobile game publishers, will be lighting up Game Fest 2026! 🚀 This isn’t just an event; it’s an immersive journey into the future of mobile gaming. Join us as we push the boundaries of innovation and dive deep into the next generation of play #TapNation#GameFest2026#MobileGaming#GamingCommunity#Gamedev#UzbekistanGaming#NewGames2026

Bounty Hunters 💎

@trustedairdropsss · Post #655 · 01.03.2021 г., 06:12

Unlock unlimited fun & winning at Rummy24. Download the App Now👉https://rummy24.sng.link/Averc/fcz2/lcft . . . #Rummy24#RummyApp#PlayRummy#UnlimitedFun#PlayRummy#onlinerummy#cardsgame#mobilegames#mobilegaming#mobilegame#cardgames#onlinegame#play#skills#win