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

Резултати

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

Пребарај: #referral

当前筛选 #referral清除筛选
English is ꏂꍏꌚꌩ

@englishiseasyet · Post #1327 · 23.06.2024 г., 08:51

ቶን በ #Referral እየተሰጠ ነው 1 ቶን 1000 ብር ነው ከታች ባለው ሊንክ start በሉና እየገባቹ ውሰዱ እዳያመልጣቹ ለትንሽ ቀን ነው ሚሰጠው..!! 👇👇👇👇👇👇👇 https://t.me/wontonairdrop_bot?start=5396172750

Hashtags

MoonPlay

@moonplay_official · Post #44 · 28.06.2024 г., 15:34

Referral System & CrewUpdate👥 We’re thrilled to announce a significant change to the gameplay in To The Moon! In a nutshell, it’s getting much simpler to launch an expedition, yet the impact of each friend invited is now more powerful than ever. 1️⃣One Friend for a Launch: From now on, having only one crew member hired is enough to fly to the moon. That’s right—one friend per expedition is all you need to land on the moon and level up. Simplified Crew requirement —> faster expeditions —> more fun! Feel free to hire all the rest of the crew by inviting up to 7 friends; but for an expedition, one is enough. 2️⃣Invite More, Earn More: For every 7 new referrals (up to 35), your 💸bonus increases for the next 7 referrals. E.g. you invited 7 friends and got 500 space bucks for each; then you invited more and got a total of 12 referrals, the bonus for these 5 referralsis 2500 space bucks!And so no. ❗️The progressive bonus system applies to referrals invited after this update. Remember, you still get a percentage of your friends' mined coins as long as they play, but this update is all about supercharging that initial bonus. 3️⃣TON Purchases Removed In compliance with regulatory policies from the App Store and Google Play, purchasing friends for TON is no longer available. As a token of appreciation for helping us expand our cosmic community, all players who have purchased bots for TON have received bonus Space Bucks! 🤩 Thank you for being a part of this journey. Together, we’re building a community that’s out of this world. To The Moon! | Website | Telegram Chat | X | Discord | Medium #ToTheMoon#MoonPlay#ecosystem#blockchain#gamefi#web3#milestone#invitefriends#wenlisting#airdropsoon#communityfirst#taptap#clicker#referral

Venture Village Wall 🦄

@venturevillagewall · Post #3745 · 29.12.2024 г., 16:00

Blum's Controversial Update Sparks Backlash Blum's recent announcement regarding its new point system has raised eyebrows among users, seen as devaluing months of effort. Critics argue that this move reflects a greed-driven strategy rather than rewarding loyal users. The absence of referral incentives further fuels dissatisfaction, with many questioning Blum's leadership approach. Some believe that this misstep may jeopardize future user trust if the token drop lacks transparency and fairness. For more details, read the full analysis here: TonUP_SRP and check the discussed token drop implications: Bybit. #Blum#Crypto#VC#TokenDrop#Loyalty#Referral#Sustainability#Users#Growth#Feedback#Strategy#Leadership#Earnings#Finance#Investing#WhaleAlert#BTC