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

Резултати

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

Пребарај: #gatto

当前筛选 #gatto清除筛选
TONlines – News

@tonlines · Post #7346 · 23.05.2025 г., 14:36

Gatto Official Channel: Weekend Tournament and PvP Event #Gatto#TON Gatto is hosting a weekend tournament alongside a PvP event against its developers, launching on May 23. Players will have the chance to win various rewards by competing in both events, with the tournament ending on May 26 and the PvP event concluding on May 23. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7213 · 14.05.2025 г., 14:31

Support Gatto in Telegram Apps Center Voting #Telegram#Gatto Gatto | Official Channel encourages users to vote for the Gatto app in the Telegram Apps Center. By participating, users can win Telegram Gifts or Telegram SBT and help raise their favorite app to the top. Source: link @tonlines

TONlines – News

@tonlines · Post #7429 · 29.05.2025 г., 09:23

⚡️Gatto Announces Temporary NFT Feature Downtime #NFT#Gatto Gatto | Official Channel (18+) informs users of a temporary halt to NFT functionality, citing ongoing technical resolutions which will last more than a day. Users are advised not to purchase Gattomon Eggs created between 5:00 p.m. and 6:30 p.m. UTC due to potential game recognition issues. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7427 · 28.05.2025 г., 20:01

⚡️Gatto: NFT Minting Temporarily Unavailable #NFT#Gatto Gatto announces that NFT minting is currently on hold. Users are advised not to create NFT pets and eggs to avoid permanent loss. Updates will be shared once technical work concludes. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7697 · 03.12.2025 г., 15:46

Gatto | Official Channel: Creative Contest Announcement #Gatto#GTON Gatto | Official Channel has announced a creative contest to celebrate a birthday, inviting talented individuals to participate by creating drawings, stories, and crafts dedicated to Gatto. Participants are categorized by age, with the chance to win $GTON rewards. Submissions are open until December 8th. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #6778 · 15.04.2025 г., 13:50

⚡️Gatto Official Channel: PvP Battle Event with Rewards #GTON#Gatto The Gatto Official Channel invites players to join a special PvP event starting at 14:00 UTC. Participants who defeat the GTeam in consecutive battles can earn various rewards, including Silver Coins, Legendary Gattoboxes, and more. The event takes place exclusively on the European server and runs until April 15, 15:00 UTC. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7394 · 27.05.2025 г., 18:20

⚡️Gatto: Temporary Unavailability of the Game #Gatto#game The Gatto team has announced that the game is currently unavailable due to server issues. They are actively working to resolve the problems, and the game will be restored soon. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7267 · 18.05.2025 г., 19:12

Gatto: Upcoming Technical Works Announced #Gatto#game Mr. Chipmunkus will be performing technical work on the Gatto game starting at 20:30 UTC. Although the game will remain accessible, players might encounter some bugs during this period. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7118 · 08.05.2025 г., 19:37

Expand Your Play Area with Gatto Official Channel! #Gatto#game Gatto Official Channel introduces a new opportunity to expand the playing field from 40 to 42 squares by inviting friends. Players can unlock new plain and ice biomes with eggs after their friends complete training by Sage Moc. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #6987 · 30.04.2025 г., 14:43

Technical Update at Gatto | Official Channel #Gatto#game Gatto | Official Channel has scheduled technical work with Mr. Chipmunkus. Players may experience some bugs until the game operations return to normal. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #6955 · 29.04.2025 г., 08:12

Gatto: Ongoing Technical Works #Gatto#game Gatto is undergoing technical maintenance by Mr. Chipmunkus. Though the game remains accessible, players might encounter some bugs until everything is fully restored. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #6925 · 24.04.2025 г., 12:42

⚡️Gatto: Temporary Downtime for Technical Maintenance #Gatto#game Gatto | Official Channel announces upcoming technical maintenance by Mr. Chipmunkus after mine completion. The game will be unavailable today from 13:00 UTC. Source: link @tonlines

Hashtags

ПретходнаСтраница 1 од 4Следна