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

Резултати

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

Пребарај: #smarthome

当前筛选 #smarthome清除筛选
🦅 [ perspective ix ]

@perspectiveix · Post #1143 · 11.03.2018 г., 14:30

This underwear can control your #SmartHome! Skiin smart underwear measure biometrics with sensors that are woven into the garments to track a user's health and make suggestions. 🚀@PerspectiveIX

Hashtags

Am Neumarkt 😱

@amneumarkt · Post #339 · 10.04.2022 г., 09:46

#smarthome#misc I have, somehow, 5 different brands of smart home products in our little apartment. I have no idea what is going on in the smart home industry. Every brand has its own app, hub, or even protocal. So I had to install five different apps to initialize the devices. I could, in principle, ditch these apps and use google/alexa only after I installed them, however, this is still extremely inconvenient as google/alexa doesn’t support all the fancy functions of the devices. Any solutions to this problem?

Chollazo Exprés 🔥 Ofertas y Descuentos

@ChollazoExpres · Post #5738 · 11.01.2026 г., 20:30

💥Detector de Humo Conectado Smartwares FSM-12601 Mantén tu hogar seguro en todo momento ✅OFERTA: 24.99€ ❌ Antes: 39.47€ 💰Ahorras un 37%🔥 Alerta temprana ante posibles incendios, fácil instalación y cumple con normas d 👉 Protege a tu familia ahora #rebajas#detectordehumo#seguridadenelhogar#smarthome#ofertas#descuentos#viral#rebajasdeinvierno 🛰️Oferta publicada en Hogar

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40096 · 15.11.2025 г., 19:03

Alexa is always listening. 🎤 (And so are other apps) Its microphones are constantly on, collecting voice recordings, tracking your habits, and building voice profiles. This data can be accessed by algorithms, human reviewers, and even third parties. 😬 Protect your privacy: - Mute the microphone when not in use 🔴 - Delete voice recordings regularly or auto-delete them 🗑️ - Disable human review in the app settings 📱 - Use white noise to mask conversations 🌊 Take control of your data! 🔒 [Source] @googlefactss#AlexaPrivacy#DataCollection#TechSafety#SmartHome#PrivacyTips

Chollazo Exprés 🔥 Ofertas y Descuentos

@ChollazoExpres · Post #5610 · 07.01.2026 г., 19:30

💥Detector de Humo Inteligente Meross MSH450 Protege tu hogar con tecnología de vanguardia ✅OFERTA: 85.49€ ❌ Antes: 109.99€ 💰Ahorras un 22%🔥 Doble sensor óptico para una detección más precisa, notificaciones en tiempo rea 👉 Mantén tu hogar seguro ahora #rebajas#detectordehumo#alarmadeincendios#smarthome#seguridadhogar#tecnologiainteligente#ofertas#descuentos 🛰️Oferta publicada en Hogar

Chollazo Exprés 🔥 Ofertas y Descuentos

@ChollazoExpres · Post #5496 · 04.01.2026 г., 10:30

💥Enchufe inteligente Wiz para un hogar conectado Haz de tu casa un lugar más inteligente esta Navidad ✅OFERTA: 7.98€ ❌ Antes: 15.99€ 💰Ahorras un 50%🔥 Controla tus dispositivos desde cualquier lugar y con comandos de voz 👉 Simplifica tu vida ahora #wiz#enchufeinteligente#hogarinteligente#smarthome#alexa#googlehome#ofertas#navidad 🛰️Oferta publicada en Hogar

Venture Village Wall 🦄

@venturevillagewall · Post #3859 · 12.01.2025 г., 22:00

Top Tech Announcements from CES 2025 🔍CES 2025 Highlights: 1. Roborock & Dreame: New vacuum robots with robotic arms, lifting items up to 500g. 2. Lenovo: Introduced ThinkBook Plus Gen 6 with expandable OLED display, from 14 to 16.7 inches. 3. Nvidia: Launched RTX 50 series, featuring DLSS 4 for significant performance boosts. 4. SwitchBot: Unveils modular robot K20 Plus Pro, combines various home tasks. 5. Razer: Debuted Project Ava, a real-time gaming assistant chat-bot. 6. Dell: Introduced a 32-inch QD-OLED monitor that adapts sound to user's head position. 7. TCL: Showcases Ai Me, a companion robot with interactive features. 8. Based Hardware: Reveals Omi, a wearable device with a neuro-helper powered by GPT-4. 9. Withings: Presents the Omnia smart mirror, integrating health data from wearables. 10. Halliday: Launches smart glasses with real-time translation capabilities. #CES2025#TechAnnouncements#Robots#AI#Nvidia#Gaming#Wearables#SmartHome#Lenovo#Roborock#Dreame#Razer#Dell#TCL#SmartGlasses#HealthTech#Innovations#Gadgets#VR#ComputerHardware#VC