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

Резултати

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

Пребарај: #hipo

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

@tonlines · Post #7701 · 04.12.2025 г., 08:04

⚡️Hipo: Track Your hTON Rewards Now #TON#Hipo Hipo has launched a new feature in their app that allows users to track staking rewards for TON and HPO airdrops. This includes viewing rewards per round, total accumulated rewards, and estimated yearly earnings. Users can now easily monitor their progress and contribute to Hipo's TVL. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7652 · 30.11.2025 г., 12:07

Hipo: New hTON Rewards Now Available #TON#Hipo Hipo has launched its new hTON rewards system, allowing stakers to earn boosted HPO rewards alongside regular TON staking yields. Members can track and withdraw their rewards in Hipo Club, with the potential to increase rewards by up to 10 times based on club level. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7387 · 27.05.2025 г., 11:54

Hipo: Launching HPO and Hipo Fund #Hipo#TON Hipo announces the launch of HPO and Hipo Fund to foster sustainable, community-owned growth. A recent blog post elaborates on their role in ensuring Hipo’s long-term success. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7386 · 27.05.2025 г., 10:43

Hipo: Wallet Security Upgraded #Hipo#TON Hipo has enhanced the security of the Hipo Fund wallet by upgrading it to a multisig address, following a similar upgrade of the HPO tokenomics wallets. A portion of the funds remains in the old single-signature wallet for operational needs. Both wallets can be tracked on-chain via Hipo Docs. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7370 · 26.05.2025 г., 09:06

Hipo Unveils Redesigned Website #Hipo#TON Hipo has launched a redesigned website to better illustrate its mission and community involvement. The new platform provides detailed insights into Hipo’s projects and invites feedback from visitors. Explore the new website at hipo.finance. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7273 · 19.05.2025 г., 10:14

⚡️Hipo: HPO Tokenomics Wallets Security Upgrade #Hipo#TON The Hipo channel announced an upgrade of the HPO tokenomics wallets to multisig addresses to enhance security. This move ensures a committed approach to transparency, allowing users to track wallet activities on-chain through Hipo Docs. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7246 · 16.05.2025 г., 17:22

Hipo Fund Launches in the TON Community #TON#Hipo Hipo Fund has been introduced in the TON Community as the first fully transparent, on-chain investment fund, focusing on community-centric investing within the TON ecosystem. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7223 · 15.05.2025 г., 11:57

Hipo: Launch of the Hipo Club #Hipo#TON Hipo has launched the Hipo Club as a strategic initiative to strengthen the community around HPO. Their latest blog post details the experiences and lessons learned during the formation of Hipo Gang and the launch of HPO. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7194 · 13.05.2025 г., 12:28

⚡️Hipo: Now Available on MyTonWallet Explore Section #TON#Hipo Hipo is now listed in the Explore section of MyTonWallet, the first multichain wallet built on TON. With over 9 million users, MyTonWallet offers a secure and user-friendly experience, boasting features like a swap aggregator for optimal token exchange rates. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7193 · 13.05.2025 г., 12:13

⚡️ Hipo Joins MyTonWallet Explore Section #Hipo#TON Hipo Protocol has been added to the Explore section of MyTonWallet, a multichain wallet on TON with over 9 million users. This integration enhances access to Hipo’s features, including open-source liquid staking, within a secure and user-friendly environment. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #6870 · 21.04.2025 г., 08:55

⚡️Hipo: Exclusive HPO OTC for Strategic Investors #TON#Hipo Hipo is offering a limited round of HPO OTC deals for major investors and VCs. These deals will support the Hipo ecosystem by contributing directly to the on-chain Hipo Fund. This opportunity emphasizes transparent and community-first growth on the TON network. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #6794 · 16.04.2025 г., 11:13

Celebrate Hipo Verification with a Giveaway! #Hipo#TON Hipo has announced a giveaway of 5,000 HPO to celebrate the verification of their Telegram channel. Ten lucky winners will receive 500 HPO each by participating with a GIF, photo, or meme in the comments. Hipo’s socials, including Telegram, X, and YouTube, are now verified, ensuring safer engagement for the community. Source: link @tonlines

Hashtags

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