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

Резултати

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

Пребарај: #hantavirus

当前筛选 #hantavirus清除筛选
世界新闻 World News 📮

@media_rss · Post #4451771 · 11.05.2026 г., 07:21

Live: Evacuation of hantavirus-hit cruise ship underway A large-scale evacuation has started for passengers aboard a cruise ship stricken by a #hantavirus outbreak. The affected MV Hondius has anchored near Tenerife in Spain, where local health officials arranged orderly disembarkation. The viral outbreak has caused multiple infections and three fatalities. Asymptomatic travelers are prioritized for medical checks before being sent to the airport to return to their nations. The World Health Organization has released surveillance guidelines, advising all evacuated passengers to undergo prolonged health monitoring to stop further transmission. via CGTN

Hashtags

Swiss authorities have confirmed a case of #hantavirus identified in a passenger from the MV Hondius cruise ship. He had responded to an email from the ship’s operator informing the passengers of the health event, and presented himself to a hospital in Zurich, Switzerland, and is receiving care. In line with the International Health Regulations (IHR), WHO is working with relevant countries to support international contact tracing, to ensure that those potentially exposed are monitored and that any further disease spread is limited. The type of virus in this outbreak has been confirmed as Andes hantavirus by the National Institute for Communicable Diseases @nicd_sa, South Africa and the Geneva University Hospitals @hug_ge, Switzerland The support of the Institut Pasteur de Dakar @PasteurDakar, Senegal and the Administración Nacional de Laboratorios e Institutos de Salud @ANLIS_Malbran, Argentina has also been critical in responding to this event. As of 6 May, there are 8 cases, 3 of whom are confirmed as hantavirus by laboratory testing. WHO will continue to work with countries to ensure that the patients, contacts, passengers and crew have the information and support they need to stay safe and prevent spread. X LINK About Hantavirus (spread mainly by rodents)

Hashtags

Swiss authorities have confirmed a case of #hantavirus identified in a passenger from the MV Hondius cruise ship. He had responded to an email from the ship’s operator informing the passengers of the health event, and presented himself to a hospital in Zurich, Switzerland, and is receiving care. In line with the International Health Regulations (IHR), WHO is working with relevant countries to support international contact tracing, to ensure that those potentially exposed are monitored and that any further disease spread is limited. The type of virus in this outbreak has been confirmed as Andes hantavirus by the National Institute for Communicable Diseases @nicd_sa, South Africa and the Geneva University Hospitals @hug_ge, Switzerland The support of the Institut Pasteur de Dakar @PasteurDakar, Senegal and the Administración Nacional de Laboratorios e Institutos de Salud @ANLIS_Malbran, Argentina has also been critical in responding to this event. As of 6 May, there are 8 cases, 3 of whom are confirmed as hantavirus by laboratory testing. WHO will continue to work with countries to ensure that the patients, contacts, passengers and crew have the information and support they need to stay safe and prevent spread. X LINK About Hantavirus (spread mainly by rodents)

Hashtags

Ciencia, tecnología y política 🇦🇷

@cienciaytecnologiaarg · Post #666 · 21.01.2019 г., 23:10

Soberanía Sanitaria 🐦@SoberaniaSalud ____ #Hantavirus: el precio de desfinanciar ➡️Investigadorxs del CONICET cuentan en esta nota qué es lo que faltó, en qué se recortó, y cómo debería actuarse en estas situaciones. Siempre, la importancia de un Estado presente. @RAIIS_ARGhttps://t.co/oqkK5bXcf4 ____ 🔗http://twitter.com/SoberaniaSalud/status/1087361266790871045

Hashtags

America 🇺🇸 News & Politics

@America · Post #10649 · 14.05.2026 г., 13:06

🦠🚨HANTAVIRUS OUTBREAK HITS 36 AMERICANS ACROSS 16 STATES 🔹 16 cruise passengers quarantined at Nebraska Medical Center, 2 more at Emory Atlanta 🚢 🔹 Only known human-to-human hantavirus strain - rare Andes virus with 6-week incubation ⚠️ 🔹 42-day quarantine as 11 cases confirmed globally, 3 deaths, 150 total exposed 💀 🔹 Monitoring in Texas, Georgia, Arizona, Virginia, California with twice-daily checks 🌡️ CDC says pandemic risk 'extremely low' but one French patient on life support This Andes strain killed Gene Hackman's wife - could explode nationwide! 😰 #USNews#Hantavirus @america

Voir de ses propres yeux

@voir_yeux · Post #12780 · 04.05.2026 г., 11:11

🛥️🦠 Trois autres passagers à bord du bateau de croisière MV Hondius ont montré des symptômes du hantavirus, rapporte la chaîne CNN. Précédemment, la BBC, citant des responsables du ministère sud-africain de la Santé, avait rapporté qu’un passager de 70 ans et son épouse de 69 ans, tous deux de nationalité néerlandaise, figurent parmi les victimes d’une possible flambée de hantavirus à bord du paquebot de croisière MV Hondius, qui assurait la liaison entre l’Argentine et le Cap-Vert. Photo: New York Post/X #hantavirus#paquebot#victimes

MALI 24

@kamissokosekou3 · Post #37487 · 04.05.2026 г., 13:13

🛥️🦠 Trois autres passagers à bord du bateau de croisière MV Hondius ont montré des symptômes du hantavirus, rapporte la chaîne CNN. Selon CNN, le navire transportait 170 passagers et 71 membres d’équipage. Il est désormais amarré dans le port de Praia, la capitale du Cap-Vert. Les passagers et l’équipage n’ont pas l’autorisation de quitter le paquebot, des médecins les examinent à bord. Précédemment, la BBC, citant des responsables du ministère sud-africain de la Santé, avait rapporté qu’un passager de 70 ans et son épouse de 69 ans, tous deux de nationalité néerlandaise, figurent parmi les victimes d’une possible flambée de hantavirus à bord du paquebot de croisière MV Hondius, qui assurait la liaison entre l’Argentine et le Cap-Vert. Photo: New York Post/X #hantavirus#paquebot#victimes