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

Резултати

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

Пребарај: #eas

当前筛选 #eas清除筛选
Russian Mission to ASEAN

@aseanrussia · Post #1908 · 19.10.2025 г., 10:28

🗓 On October 17, the Russian delegation comprising representatives from the Ministry of Energy and the Ministry of Foreign Affairs 🇷🇺 — took part in the 19th East Asia Summit (#EAS) Energy Ministers’ Meeting held in Kuala Lumpur 🇲🇾. 🔹️The discussions focused on enhancing regional energy connectivity and resilience, with participants exchanging views on practical cooperation, energy transition pathways, and cross-border investments in energy development.

Hashtags

Russian Mission to ASEAN

@aseanrussia · Post #1885 · 26.09.2025 г., 03:56

🗓 On September 25, the delegation of the Ministry of Economic Development of the Russian Federation 🇷🇺 took part in the 13th East Asia Summit (#EAS) Economic Ministers’ Meeting in Kuala Lumpur, Malaysia 🇲🇾. 🔹️The Meeting underscored the importance of fostering closer economic cooperation between ASEAN and the EAS Participating Countries and highlighted the importance of engaging in constructive dialogue, open communication, and collaboration to address challenges. 🔹️Participants also discussed possible areas for cooperation to support efforts to drive robust economic growth in the region.

Hashtags

Russian Mission to ASEAN

@aseanrussia · Post #1847 · 10.09.2025 г., 04:59

🗓 On September 10, Russia's Alternate SOM Leader, Director-General of the Department of Asian and Pacific Cooperation of the Russian MFA Mr. Alexey Ovchinnikov🇷🇺 participated in the East Asia Summit Senior Officials' Meeting (#EAS SOM) in Port Dickson, Malaysia 🇲🇾. 🔹️Senior officials discussed issues related to preparation for the EAS Summit in October and joint efforts on strengthening tangible cooperation within the EAS. #EAS

Hashtags

Russian Mission to ASEAN

@aseanrussia · Post #1777 · 11.07.2025 г., 04:56

📸 Russia's Foreign Minister Sergey Lavrov takes part in the 15th meeting of the Foreign Ministers of the countries participating in the East Asia Summit (#EAS) 📍 Kuala Lumpur, July 11

Hashtags

Russian Mission to ASEAN

@aseanrussia · Post #1343 · 23.10.2024 г., 12:11

🎙 Excerpts from the Comment by Russia's Foreign Ministry Spokeswoman Maria Zakharova on the developments around the East Asia Summit (#EAS). https://telegra.ph/Comment-by-Russias-Foreign-Ministry-Spokeswoman-Maria-Zakharova-on-the-developments-around-the-East-Asia-Summit-10-23

Hashtags

Russian Mission to ASEAN

@aseanrussia · Post #1308 · 18.10.2024 г., 09:02

Ambassador of Russia to ASEAN H.E. Mr. Evgeny Zagaynov 🇷🇺 💬 "Attempts to politicize the East Asia Summit (#EAS) agenda are detrimental to the regional cooperation". https://m.antaranews.com/berita/4400313/rusia-ada-upaya-masukkan-geopolitik-di-ktt-asia-timur?utm_source=antaranews&utm_medium=mobile&utm_campaign=latest_category

Hashtags

Russian Mission to ASEAN

@aseanrussia · Post #1281 · 23.09.2024 г., 10:06

🗓 On September 21, the delegation of the Ministry of Economic Development of the Russian Federation 🇷🇺 took part in the 12th East Asia Summit (#EAS) Economic Ministers’ Meeting in Vientiane, Lao PDR 🇱🇦. 🔹️The Meeting exchanged views on the global and regional economic developments and discussed how EAS Participating Countries can take concerted actions to mitigate global economic challenges. 🔹️Participants also discussed possible areas for cooperation to support efforts to drive robust economic growth in the region.

Hashtags

Russian Mission to ASEAN

@aseanrussia · Post #1235 · 23.08.2024 г., 03:16

🗓 On August 22, Russian delegation 🇷🇺 took part in the East Asia Summit Senior Officials' Meeting (#EAS SOM) in Luang Prabang, Lao PDR 🇱🇦. 🔹️Participants discussed the preparation for the upcoming 19th EAS Summit in October 2024 in Vientiane and exchanged views on the EAS agenda. 🇷🇺 Russian Ambassador to ASEAN H.E. Evgeny Zagaynov underlined Russia's unwavering support of the Lao PDR during its ASEAN Chairmanship and emphasized the need to further promote tangible cooperation within the EAS in particular in such areas as fight against infectious diseases and tourism.

Hashtags

123•••89
ПретходнаСтраница 1 од 9Следна