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

Резултати

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

Пребарај: #token

当前筛选 #token清除筛选
American Crypto©

@americancryptotrading · Post #27367 · 07.09.2025 г., 08:42

🇺🇸#TOKEN/USDT is testing the supportzone on the daily chart💁‍♂️ Strong upside potential on a bounce✈️ American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27150 · 10.02.2025 г., 12:47

🇺🇸#TOKEN/USDT is bouncing from the supportzone on the 3D timeframe🧐 Looking for a rise🐃 American Crypto©

Hashtags

Airdrop Presents 🗽

@airdrop_presents · Post #2082 · 07.12.2022 г., 16:52

🪂New airdrop: Smart Link Solution (SLS) 💰 Reward: 100,000 #token ($15,000) prize pool 👥 Referral: +1 Entries 🕰 Distribution: 1st January, 2023 🔗Airdrop Link:https://wn.nr/fgmdnH -Complete all tasks of the airdrop -Complete all tasks of the airdrop Done ✅Done✅Done✅Done✅ ⚠️Please remember: Only participate in completely free airdrops, never spend any penny for airdrop tokens

Hashtags

Airdrop Presents 🗽

@airdrop_presents · Post #1652 · 01.07.2022 г., 14:14

💧Airdrop : Naga Alpha Test💧 📣Complete Task: ➕ $5000 - IDO #token Price $0.01 📊Referral : 50 Top referrers will jave a whitelist details. 🏆Winners: 250 Player Lucky random have gift token, Nft game up to 5000$ 📅End date: 3th July 2022 💎Ratings: ⭐️⭐️⭐️ 🔛Naga Alpha Airdrop For Click 🔛 🌀 Follow Naga Alpha on Twitter and retweet the pinned post. 🌀 Follow Naga Alpha on Facebook 🌀 Enter Your Gmail 🌀 Submit Bep-20 address 📡 Enter your information to the airdrop bot. 🗞Note: All airdrop steps should be completed. 👨‍💼Business Inquiry: Admin || Admin2

Hashtags

Crypto GALAXY

@crypto_galaxy_signals · Post #1490 · 17.05.2024 г., 10:10

Coin: #TOKEN/USDT Direction: LONG Leverage: 10x - Cross - TAKE-PROFIT: 1 - 0,09847 ✔️ 2 - 0,10042 ✔️ 3 - 0,10237 ✔️ 4 - 0,10725 ✔️ 🔥 Profit: 101.69% 🔥 VIP 👉t.me/cryptoxadmin

Hashtags

SingSing Announcement

@singsingchannel · Post #958 · 03.11.2024 г., 00:32

We're eagerly counting down to Nov 11 for the IDO of the $SING token! Check out this handy $SING #token IDO Cheat Sheet below for all the essential info you need to know👇 🔸Total Supply: 2.4B 🔸IDO Price: $0.018 🔸Allocation: 11.11M (0.46% Total Supply) 🔸IDO Date: Nov 11, 2024 🔸Network: BSC, ARB, POLYGON 🔸Currency: USDT 🔸Terms: 20% at TGE, then linearly monthly vesting for the next 6 months 🔸LaunchPad:@Kommunitas - details 🎤Announcement | Chat | X (Twitter) | Website | Game

Hashtags

SingSing Announcement

@singsingchannel · Post #942 · 28.10.2024 г., 13:31

🎉 Exciting Announcement! 🎉 Mark your calendars for Nov 11, 2024,when the $SING Token Sale begins on the @Kommunitas launchpad! 🔗 Check out the project on Kommunitas platform here: https://launchpad.kommunitas.net/pool/SING/PublicCross 🧵 Dive into the X thread for essential details about the upcoming #token sale! 🎤Announcement | Chat | X (Twitter) | Website | Game

Hashtags

Venom Foundation Official

@venomfoundationofficial · Post #5 · 14.10.2022 г., 07:35

Venom Foundation explicitly states that by any means not going to do any kind of a #token pre-sale (private or public) or any other form of equity allocation. More in our statement ➡️ https://medium.com/@venom.foundation/mportant-venom-foundation-does-not-distribute-venom-utility-tokens-prior-to-the-official-launch-b3ffe84326f9

Hashtags

TONlines – News

@tonlines · Post #7253 · 17.05.2025 г., 16:26

⚡️Gatto Official Channel: Major Milestone with GTON Token Burn #GTON#token The Gatto Official Channel announces that the total burn of $GTON tokens has reached 1,000,000, effectively removing 5% of the supply from circulation. This community-driven effort strengthens the token's value and stability. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7683 · 02.12.2025 г., 15:03

Gatto Official Channel: December Staking Begins #staking#token The Gatto Official Channel announces the start of the December staking period after taking the first snapshot of game balances. Staking will conclude on December 29th, and token holders should maintain their balances to receive rewards. Balance cuts will occur randomly each day. Source: link @tonlines

123•••67
ПретходнаСтраница 1 од 7Следна