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 слични објави

Пребарај: #mozambique

当前筛选 #mozambique清除筛选
POPULAR FRONT

@popularxfront · Post #4895 · 04.02.2026 г., 17:38

🇲🇿#Mozambique: IS-Mozambique (ISMP, Islamic State in Mozambique) released a video today claiming responsibility for an attack last Sunday targeting Mozambican military bases in the Katuba and Namapo areas of Cabo Delgado in the northern part of the country. As a result of the attacks, it is reported that nine Mozambican soldiers were killed. The militants also posted footage showing weapon caches and equipment they captured from the bases. (via @BrantPhilip_ on X)

Hashtags

Russian MFA 🇷🇺

@MFARUSSIA · Post #28776 · 19.03.2026 г., 12:59

⚡️Russia's EMERCOM: On March 19, a special flight of Russia's EMERCOM delivered humanitarian aid to the Republic of #Mozambique. By decision of Russia's President Vladimir Putin, following instructions from the Government of Russia and on the orders of EMERCOM Head Alexander Kurenkov, around 29 tonnes of humanitarian cargo were transported from Moscow. 🛬 An Il-76 aircraft delivered food, essential supplies, as well as tents and blankets for flood-affected communities in the African republic. #RussiaHelps

ጠቅላይ ሚኒስትር ዐቢይ አሕመድ (ዶ/ር) ለሞዛምቢኩ ፕሬዝደንት ዳንኤል ፍራንሲስኮ ቻፖ ደማቅ አቀባበል አደረጉ ************** ጠቅላይ ሚኒስትር ዐቢይ አሕመድ (ዶ/ር) በኢትዮጵያ ይፋዊ የሥራ ጉብኝት ለማድረግ የመጡትን የሞዛምቢክ ፕሬዝደንት ዳንኤል ፍራንሲስኮ ቻፖን በቦሌ ዓለም አቀፍ አውሮፕላን ማረፊያ በመገኘት በክብር ተቀብለዋል። የፕሬዝደንቱ ጉብኝት በሁለቱ ሀገራት መካከል ያለውን ዲፕሎማሲያዊ እና ኢኮኖሚያዊ ግንኙነት ወደ አዲስ ምዕራፍ ያሸጋግራል ተብሎ ይጠበቃል። ጉብኝቱ የሁለቱን ሀገራት ታሪካዊ ግንኙነት ወደ ላቀ ደረጃ የሚያሸጋግር ሲሆን፣ ኢትዮጵያ ለእውነተኛ አፍሪካዊ አጋርነት ያላትን የማይናወጥ ቁርጠኝነት የሚያረጋግጥ መሆኑን የጠቅላይ ሚኒስትር ጽ/ቤት አስታውቋል። #EBC#Ethiopia#PMOEthiopia#Mozambique#diplomacy

Reuters: World

@reutersworldchannel · Post #149314 · 13.10.2021 г., 16:57

The struggle for water in Mozambique's unstable north Aid agencies warn that a shortage of safe water, poor sanitation and inadequate medical services are a looming threat for the communities in Mozambique's Cabo Delgado province #News#Reuters#Mozambique#RedCross Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

Russian MFA 🇷🇺

@MFARUSSIA · Post #27890 · 26.12.2025 г., 09:35

#RussiaHelps 💬Maria Zakharova: OnDecember 17 inMaputo (#Mozambique) and December 18 inLusaka (#Zambia), official ceremonies marking the delivery of Russian food assistance were held, attended by the Russian Ambassadors to these countries. 🇲🇿 Mozambique received 70 tonnes of vitamin-fortified sunflower oil for those in need. 🇿🇲 Zambia received a similar shipment of 93 tonnes, as well as 648 tonnes of yellow split peas. These humanitarian deliveries were carried out through the UN World Food Programme, funded by Russia’s voluntary contribution for African countries, which amounts to USD 10 million annually. Humanitarian assistance is an integral part of Russia’s support for its partners on the African continent, primarily aimed at helping the most vulnerable groups. 🇷🇺 Russia will continue to contribute to addressing Africa’s socio-economic challenges, using both bilateral assistance mechanisms and the potential of relevant international organizations. (Excerpt from Russian MFA Spokeswoman Maria Zakharova's weekly briefing on December 26)

AREA

@area_eng · Post #120 · 24.07.2025 г., 20:46

Russia and Mozambique may expand energy cooperation During a visit to Moscow, Mozambique Foreign Minister Maria Manuela dos Santos Lucas said that the country views Russia as a strategic partner in the development of the oil and gas sector. For Mozambique, which has the sixth largest natural gas reserves in Africa (about 100 trillion cubic feet), partnership with Russia is indeed of strategic value. Russian companies offer not only investments, but also unique competencies in the development of offshore fields, construction of gas transportation infrastructure and training of qualified personnel. Today, about 40% of Mozambican students in the Russian Federation are studying in specialties needed in the oil and gas sector. Despite Rosneft's withdrawal from the Mozambique LNG project in 2022, Russian companies remain interested in the region. In particular, Gazprom continues to explore the possibility of working on the Mozambican shelf. According to experts, there are several key vectors of cooperation between the parties. This could be the creation of an LNG cluster using Russian technologies, joint projects for gasification of Mozambique regions, as well as the development of educational programs for training personnel. #AREA#Africa#Russia#RussiaAfrica#energy#Mozambique