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

Резултати

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

Пребарај: #zahahadid

当前筛选 #zahahadid清除筛选

BEEAH Headquarters / Zaha Hadid Architects BEEAH Group's new headquarters in Sharjah, UAE, was opened on Wednesday, March 30 by His Highness Dr. Sheikh Sultan bin Muhammad Al Qasimi, Ruler of Sharjah. Powered by its solar array and equipped with next-generation technologies for operations at LEED Platinum standards, the new headquarters has been designed by Zaha Hadid Architects (ZHA) to achieve net-zero emissions and will be the group’s management and administrative centre that sets a new benchmark for future workplaces. #arch_shovel#architecture#archdaily#zahahadid

Zaha Hadid Architects wins competition to design the new Hangzhou International Sports Centre. Incorporating a 60,000-seat football stadium and practice pitches, the centre also includes a 19,000-seat indoor arena as well as an aquatics centre with two 50-metre pools. The centre establishes a new riverfront park and public plazas with direct access to Lines 3 and 5 of the city’s expanding metro network. Located within the warm temperate climate of Hangzhou, the International Sports Centre has been designed to the highest 3-Star rating of China’s Green Building Program with each venue providing optimal conditions using natural hybrid ventilation most of the year. Annual solar irradiation analysis has determined the composition of the façade’s external louvres while photovoltaics will harvest solar power for all venues. Ground heat exchange and recovery systems will ensure the most efficient operations of all facilities. #architecture#zahahadid#arch_shovel#archdaily

KAPSARC awarded five LEED EBOM Platinum certifications by the US Green Building Council . The only buildings in Saudi Arabia to receive Platinum LEED Existing Building: Operation & Maintenance (EBOM) certification, KAPSARC’s five community facilities achieved the highest sustainability standards throughout the centre’s design, construction, operations and maintenance procedures. . KAPSARC’s waste management program diverted 94% of solid waste from landfill through waste stream audits that eliminated single-use goods and developed an effective waste segregation strategy across multiple stages. KAPSARC also reduced the compound’s water consumption by 30% with weather-based micro-irrigation, mulching, native planting and efficient faucets. The centre’s energy usage was also reduced by 35% with energy audits regularly identifing energy conservation measures. . #architecture#zahahadid#zahahadidarchitects#architecture#arch_shovel#archidaily

Parametric Architecture. Works by Mariana Cabugueira ( a Senior Architectural Designer at Zaha Hadid Architects): 1 – the Concert Hall. 2 - Tower C - the Zaha Hadid tower. 3-6 – A Mega Luxury Hotel and Office Hybrid Tower. 7-8 – The Floating Park Island. 9-10 – the Mykonos Villa. #arch_shovel#architecture#parametric#maya#zahahadid

Штаб Зюзино

@zuzinoshtab · Post #432 · 01.10.2020 г., 15:00

👆🏿❗️Муниципальный депутат Зюзино Юрий Самгин побеседовал с исполнительным директором архитектурного бюро Zaha Hadid Кристосом Пассосом. Это архбюро разрабатывало концепцию застройки Кузьминок – «столицы реновации», как окрестили район столичные власти. 👉🏿Рекомендуем к просмотру: https://youtu.be/jdqerALE5OM Кстати, вот интервью с господином Пассосом от ноября 2017 г. #конкурс#москомархитектура#кузнецов#самгин#zahahadid#кузьминки