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

Резултати

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

Пребарај: #bulcoin

当前筛选 #bulcoin清除筛选
BLC Market - mini-app BulCoin

@bulcoin_blc · Post #258 · 23.02.2026 г., 17:00

If you're just considering BulCoin — here's what you can do right now: 1️⃣ Create a TON-wallet 2️⃣ Add BLC manually 3️⃣ Check trading pairs 4️⃣Find out what you can buy with BulCoin 5️⃣ Keep up with DAO decisions on our channel This is the system entry. BulCoin is being built as an infrastructure. And infrastructure requires participation. Those who enter earlier - understand the mechanics better. #BulCoin FAQ | BUY

Hashtags

BLC Market - mini-app BulCoin

@bulcoin_blc · Post #250 · 17.02.2026 г., 09:30

🟡 Why is BulCoin (BLC) needed at all BulCoin is not just a token. It's a part of infrastructure. Infrastructure where transactions are made without intermediaries. Without blockages. Without "permissions". We are creating an environment where: • value is transferred directly • calculations are made in digital form • participants interact without third parties Mini-app is the first step in using BLC. More to come. A free market is impossible without its own infrastructure. BulCoin is an element of such a system. #BulCoin FAQ | BUY

Hashtags

BLC Market - mini-app BulCoin

@bulcoin_blc · Post #261 · 25.02.2026 г., 11:00

🔥 We are opening the first round of BulCoin participants! 20 random participants will be selected. Each will receive 200 000 BLC. Additionally, a team of 50 early testers of the mini-app will be formed. Participation conditions: — subscription to the channel — comment under this post specifying your TON-address Results will be in 7 days. Results announcement date: 2026-03-04 at 20:00. This is the first stage of forming an active core of BulCoin. #giveaway#BulCoin FAQ | BUY

Асқарбиновая Орда

@askar4308 · Post #15265 · 25.02.2026 г., 17:07

🔥 We are opening the first round of BulCoin participants! 20 random participants will be selected. Each will receive 200 000 BLC. Additionally, a team of 50 early testers of the mini-app will be formed. Participation conditions: — subscription to the channel — comment under this post specifying your TON-address Results will be in 7 days. Results announcement date: 2026-03-04 at 20:00. This is the first stage of forming an active core of BulCoin. #giveaway#BulCoin FAQ | BUY

🔥 Мы открываем первый круг участников BulCoin! Будет выбрано 20 случайных участников. Каждый получит 200 000 BLC. Дополнительно формируется команда из 50 ранних тестеров mini-app. Условия участия: — подписка на канал — комментарий под этим постом указав свой TON-адрес Итоги — через 7 дней. Дата подведения итогов: 2026-03-04 в 20:00. Это первый этап формирования активного ядра BulCoin. #giveaway#BulCoin FAQ | Купить

BLC Market - mini-app BulCoin

@bulcoin_blc · Post #242 · 14.02.2026 г., 19:30

Why do you need BulCoin (BLC)? BulCoin is not just a token. It's an early stage of an ecosystem that is being built around: • a mini-game app • digital economy • early participant community The project is currently in the formation phase. It's at this stage that: — the core of the community is being formed — the first holders appear — history is being laid BulCoin (BLC) is a TON network token. In the coming months, a mini-app will be launched, where BLC will become the gaming currency. But the main thing is that early participants get more opportunities. We don't make loud promises. We are building the system step by step. If you have already created a wallet - you are prepared. It's going to be more interesting from here. #BulCoin#TON#DAO FAQ | BUY

BLC Market - mini-app BulCoin

@bulcoin_blc · Post #314 · 27.03.2026 г., 17:25

We continue to show what the BLC Market will look like. Currently, the basic logic of interaction within the app is under development: — user profile — task structure — navigation within the interface This is the first layer on which the entire system will be built. Next, we will show how exactly users will interact with each other. #freelance#community#BulCoin#BLC#TON FAQ | BUY

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