@ragagazzetta · Post #231146 · 11.04.2026 г., 14:48
r/ #technology Умная гитара без струн изГонконга Инструмент Lava Genie от стартапа Lava Music считывает взмахи рукой и постукивания пальцами, переводя их в музыку.
Hashtags
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
Пребарај: #technology
@ragagazzetta · Post #231146 · 11.04.2026 г., 14:48
r/ #technology Умная гитара без струн изГонконга Инструмент Lava Genie от стартапа Lava Music считывает взмахи рукой и постукивания пальцами, переводя их в музыку.
Hashtags
@googlefactss · Post #40304 · 12.12.2025 г., 07:04
The first hard disk drive to reach the 1-gigabyte (GB) capacity weighed approximately 227-250 kgs (500 - 550 pounds) for the main unit. This device, the IBM 3380 direct access storage device, was announced by IBM in 1980. It was roughly the size of a refrigerator and carried a price tag of approximately $40,000. @googlefactss#technology
Hashtags
@googlefactss · Post #40297 · 11.12.2025 г., 07:04
The first website ever is still online and accessed at a restored CERN address: http://info.cern.ch. While the original site is gone, a 1992 copy of the page is available, which describes the World Wide Web project, its technical details, and how to use it. @googlefactss#technology
Hashtags
@googlefactss · Post #40294 · 10.12.2025 г., 19:05
Email has been around longer than the World Wide Web. The first email was sent by Ray Tomlinson to himself in 1971, a good 20 years before Tim Berners-Lee introduced the web in 1991. @googlefactss#technology [read more...]
Hashtags
@googlefactss · Post #40274 · 07.12.2025 г., 23:01
The internet is estimated to weigh about 50 grams, equivalent to a strawberry, based on the weight of the electrons used in electricity for data transfer. This does not account for the much larger physical weight of servers, cables, and data centers that support its infrastructure. @googlefactss#technology [read more....]
Hashtags
@droneswar · Post #9590 · 07.12.2024 г., 12:35
r/ #technology Грустная история на вечер: в Северной Калифорнии робот пылесос пытается найти свой дом после землетрясения Видимо, он отключился от своей базы во время стихии, а теперь потерялся.
Hashtags
@droneswar · Post #9479 · 21.10.2024 г., 15:51
r/ #technology Будущие космические роботы уже здесь Эти самоорганизующиеся роботы GITAI потенциально могут построить будущую инфраструктуру на Марсе и за его пределами. Скорость не так важна в космосе. Но выполнение работы и работа имеют первостепенное значение.
Hashtags
@dailychannels · Post #6703 · 23.02.2026 г., 01:00
Channel: Hustlers News Members: ~4.55K 💢 Username: @hustlers_news Description: Channel dedicated to post news. Official site: www.hustlers.ly 🏷 Tags: #technology https://lve.to/pvphboywru
Hashtags
@dailychannels · Post #6524 · 05.12.2025 г., 01:00
Channel: AI Post — Artificial Intelligence news Members: ~992.41K 💢 Username: @aipost Description: The #1 AI news source! We cover the latest artificial intelligence breakthroughs and emerging trends. Contact: @CaptainJamesCook 🏷 Tags: #technology https://telegramchannels.me/channels/aipost
Hashtags
@dailychannels · Post #6468 · 07.11.2025 г., 13:00
Channel: benedict cumberTech Members: ~1.27M 💢 Username: @cumbertech Description: ️the most valuable from the world of technologies, AI, crypto and innovational science buy ads: @cumberAds or https://telega.io/c/cumbertech 🏷 Tags: #technology https://telegramchannels.me/channels/cumbertech
Hashtags
@dailychannels · Post #6429 · 21.10.2025 г., 01:00
Channel: Analytics and growth mindset ️ Members: ~7.75K 💢 Username: @thinkbroadly Description: Free data analytics courses with certificates, hot internships and jobs - everything that needed data analyst. Buy ads: @maria_v2022 🏷 Tags: #technology https://telegramchannels.me/channels/thinkbroadly
Hashtags
@dailychannels · Post #6402 · 09.10.2025 г., 13:00
Channel: UXLINK Members: ~331.36K 💢 Username: @uxlink_community Description: UXLINK official channel 🏷 Tags: #technology https://telegramchannels.me/channels/uxlink_community
Hashtags