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

Пребарај: #cameroon

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

@popularxfront · Post #5052 · 19.02.2026 г., 23:01

🇨🇲#Cameroon: ISWAP militants have attempted to storm a new position of The Rapid Intervention Battalion (Bataillon d'intervention rapide - BIR, a special forces unit of the Cameroonian Armed Forces) in the town of Bargaram, near the Nigerian border. At least five militants were killed in the failed attack, including one who was reportedly a foreigner. Footage shows the equipment that the BIR captured from the dead militants, including a camera which was supposed to be used in order to film the attack as further propaganda. (via @BrantPhilip_ on X)

Hashtags

POPULAR FRONT

@popularxfront · Post #4727 · 25.01.2026 г., 16:39

🇨🇲#Cameroon: ISWAP militants claimed responsibility today for the burning of a Cameroonian military outpost in the town of Darak, in northern Cameroon, on Thursday. (via @AIW898)

Hashtags

Reuters: World

@reutersworldchannel · Post #149398 · 15.10.2021 г., 11:16

Cameroon officer lynched for killing five-year-old A mob lynched a military police officer after he killed a five-year-old girl when he fired on a car at a checkpoint in the capital of Cameroon's English-speaking South West Region, the defense ministry said. #News#Reuters#Cameroon#mob 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➖

Addis Standard

@addisstandardeng · Post #21602 · 04.03.2026 г., 06:54

#UK to end study visas for #Sudan, #Cameroon, Myanmar, Afghanistan students ⁠The United Kingdom says it will end study visas for students from #Afghanistan, Cameroon, #Myanmar and Sudan, and work visas for Afghans, amid a rise in anti-immigration sentiment ⁠in the country. The UK Home Office said in a statement on Tuesday that “an ’emergency brake’ on visas has been imposed for the first time on nationals from four countries”, following a surge in asylum claims by students on study visas. The Home Office said the number of asylum applications by students from Afghanistan, Cameroon, Myanmar and Sudan had “rocketed” by more than 470 percent between 2021 and 2025. “Britain will always provide ⁠refuge to people fleeing war and persecution, but our visa ⁠system must not be ⁠abused,” Secretary of State for the Home Department Shabana Mahmood said. “That is why I am taking the unprecedented...... https://www.aljazeera.com/news/2026/3/4/uk-to-end-study-visas-for-myanmar-afghanistan-cameroon-sudan-students

Russian Embassy in Asmara

@rusembasmara · Post #536 · 11.11.2024 г., 18:24

#Day1 🗓 On November 9, Russia's Foreign Minister Sergey Lavrov held a series of bilateral meetings with his counterparts from the African nations on the sidelines of the First Ministerial Conference of the Russia-Africa Partnership Forum in Sochi, including: #RussiaMali 🇷🇺🇲🇱 Minister of Foreign Affairs and International Cooperation of the Republic of #MaliAbdoulaye Diop. The Parties discussed a range of issues concerning the further strengthening of Russian-Mali relations, which are traditionally friendly in nature. In this context, they examined in detail various aspects of enhancing bilateral trade and economic and investment partnership. Moscow and Bamako also reaffirmed their unwavering commitment to deepening political dialogue and enhancing coordination on key issues within the global and regional agendas at the United Nations and in other multilateral formats. #RussiaUganda 🇷🇺🇺🇬 Minister of Foreign Affairs of the Republic of #Uganda Gen. Jeje Odongo. The Sides discussed in detail the key trends in furthering Russian-Ugandan multifaceted cooperation with a focus on enhancing the mutually beneficial trade, economic and investment partnership, as well as developing joint projects in energy, mining, agriculture, science, education, medicine, and digital technologies. They also reaffirmed the intent of Moscow and Kampala to strengthen constructive interaction and coordination at the UN and other international venues. #RussiaCameroon 🇷🇺🇨🇲 Minister of External Relations of the Republic of #CameroonLejeune Mbella Mbella. The Parties discussed a range of issues concerning the further strengthening of the traditionally friendly Russia-Cameroon relations. This includes enhancing bilateral trade, economic cooperation and investment partnership, as well as improving the legal framework and implementing promising joint projects. Moscow and Yaounde also reaffirmed their commitment to deepening their trust-based political dialogue and closer coordination on topical international and regional issues at the United Nations and in other multilateral formats. #RussiaCAR 🇷🇺🇨🇫 Minister of Foreign Affairs, Francophonie and Central Africans Abroad of the Central African Republic Sylvie Baipo-Temon. The Sides discussed in detail a range of issues related to advancing the traditionally friendly Russian-Central African relations, focusing on promoting promising projects in mineral exploration and production, agriculture, healthcare, and personnel training. They also reaffirmed Moscow and Bangui’s intent to intensify political dialogue and close coordination at the UN and other multilateral formats while addressing global and regional problems based on the fundamental principles of international law and the UN Charter. Sergey Lavrov and Sylvie Baipo-Temon signed an Agreement between the Government of the Russian Federation and the Government of the Central African Republic on the Mutual Cancellation of Visa Requirements for Holders of Diplomatic and Service Passports, as well as a Memorandum on Consultations between the Ministry of Foreign Affairs of the Russian Federation and the Ministry of Foreign Affairs, Francophonie and Central Africans Abroad of the Central African Republic. #RussiaRwanda 🇷🇺🇷🇼 Minister of Foreign Affairs and International Cooperation of the Republic of #Rwanda Olivier Nduhungirehe. The Parties discussed a range of issues pertaining to further strengthening the friendly Russian-Rwandan relations, with a particular focus on expanding cooperation in trade, the economy, investment, humanitarian matters. Moscow and Kigali also reaffirmed their commitment to deepening political dialogue and maintaining close coordination at the UN to address global and regional issues. The Ministers signed a Russian-Rwandan intergovernmental agreement on visa-free travel for holders of diplomatic or service passports. #RussiaAfrica