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

Резултати

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

Пребарај: #getgems

当前筛选 #getgems清除筛选
☎️ Phoneword

@Morgan · Post #423 · 28.10.2024 г., 05:18

💎Stats in Top3 Collections 💠 + Top Owners #GetGems Date: 2024/10/28 1) Telegram Usernames (Total Volume: 70M TON) Owners: 45,231 Avg. owned: 4.21 Unique Holders: 23.74 % Items / Owners 1: 27,979 2–5: 11,862 6–24: 4,317 25-50: 590 Over 50: 483 2) Anonymous Telegram Numbers (Total Volume: 21M TON) Owners: 45,057 Avg. owned: 3.03 Unique Holders: 32.99 % Items / Owners 1: 30,739 2–5: 11,188 6–24: 2,624 25-50: 271 Over 50: 235 3) TON DNS Domains (Total Volume: ~7M TON) Owners: 35,872 Avg. owned: 3.13 Unique Holders: 31.92 % Items / Owners 1: 26,133 2–5: 7,087 6–24: 2,165 25-50: 269 Over 50: 218 📡@Phoneword

Hashtags

TONlines – News

@tonlines · Post #7631 · 27.11.2025 г., 13:14

Celebrate Thanksgiving with Getgems NFT #Getgems#TON Getgems NFT invites its community to share a holiday toast in their Holiday Drinks collection this Thanksgiving. Participants can win prizes such as Bling Binky and Money Pots by submitting heartfelt comments before November 29. Comments cost 0.5 TON and will be manually approved. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7282 · 19.05.2025 г., 15:21

Getgems NFT: Selling Subdomains on Getgems #Getgems#TON Getgems NFT now allows TON DNS domain holders to create and sell collections of third-level domains on the Getgems platform. Domain owners can set prices, manage their mini marketplaces, and earn royalties from subdomain transactions. The first such collection has been launched with the Lost Dogs project using the woof.ton domain. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7278 · 19.05.2025 г., 14:18

Getgems NFT: The Rise of Subdomains #TON#Getgems Getgems NFT discusses the introduction of subdomains on TON DNS. These subdomains offer a new way for domain holders and projects to monetize and create distinct ecosystems. More details on pricing and launch will be shared soon. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7635 · 27.11.2025 г., 16:22

⚡️Getgems NFT: Gift Fest Launches an Exciting Prize Hunt #Telegram#Getgems Getgems NFT announces the launch of Gift Fest, the largest gift festival on Telegram, featuring 100,000 gifts valued at $400,000. Participants can join by using the festival mini-app to play, merge gifts, and enter weekly raffles, culminating in a main raffle on December 29. Source: link @tonlines

TONlines – News

@tonlines · Post #7603 · 24.11.2025 г., 14:05

New Telegram Gifts at Getgems #Telegram#Getgems Getgems has launched new Telegram Gifts which are now tradable with 0% fees. Users can transfer or purchase items like Bling Binkies, Money Pots, and Pretty Posies through the mini app or website. Source: link @tonlines

TONlines – News

@tonlines · Post #6863 · 20.04.2025 г., 12:23

Getgems NFT: Easter Giveaway for Easter Domain Holders #Telegram#Getgems Getgems NFT is hosting a Flash Easter Giveaway for all holders of Easter-themed Getgems Domains and Telegram Usernames. Participants have a chance to win one of 20 Telegram Gifts totaling 100 TON. Winners will be announced on April 21. Source: link @tonlines

TONlines – News

@tonlines · Post #7638 · 28.11.2025 г., 13:04

⚡️Getgems NFT: Black Friday Raffle Announced #Getgems#NFT The Getgems NFT channel has launched a Black Friday raffle with unique black-background gifts. From November 28 to November 30, users can enter by importing specific collectible items, such as Instant Ramens or Money Pots, via @gemsrelayer. Winners will receive special editions of these items. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7178 · 12.05.2025 г., 17:00

New Commenting Features on Getgems NFT #Getgems#NFT Getgems NFT introduces a new feature allowing users to make announcements and comments on NFT collections. Messages undergo moderation and can cost 0.5 to 10 TON, depending on the type of collection. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #6967 · 29.04.2025 г., 16:35

Getgems NFT: Celebrate with Your Collector Wrap #Getgems#NFT Getgems NFT celebrates its three-year anniversary by offering users a unique Collector Wrap experience on TON. Connect your wallet to explore your NFT journey, claim a limited-edition anniversary SBT, and create a custom avatar. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7568 · 21.11.2025 г., 15:22

Getgems NFT: Sticker Digest Unveiled #TON#Getgems#NFT Getgems NFT introduces the Sticker Digest, highlighting notable developments in the TON sticker market. Key updates include the trading success of Goodies with over 250K TON, the pioneering Sticker Pack collections, and recent collaborations within the ecosystem. Enhanced browsing with new filters is now available. Source: link @tonlines

TONlines – News

@tonlines · Post #6840 · 18.04.2025 г., 14:46

Getgems NFT: Marketplace Technical Issues #Getgems#marketplace The Getgems NFT marketplace is currently facing technical difficulties. However, the team is actively working to resolve the issues, and the website will be operational shortly. Source: link @tonlines

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