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

Резултати

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

Пребарај: #honduras

当前筛选 #honduras清除筛选

🇭🇳🇮🇱Israel, la prioridad del nuevo Gobierno hondureño La Biblia ceremonial de juramento aún no se había enfriado y ya el presidente hondureño Nasry Asfura estaba saludando efusivamente a Nadav Goren, embajador de Israel en la nación centroamericana. Tanto así, que el Ministerio de Relaciones Exteriores de Israel no pudo ocultar su emoción: "Minutos después de prestar juramento, Nasry Asfura eligió su primer acto: aceptar las credenciales del embajador de Israel, señalando un fuerte compromiso con las relaciones entre Israel y Honduras". Asfura, de 67 años, obtuvo el respaldo de Trump, Milei y la notoria banda de narcotraficantes MS-13, que "hizo campaña" en su nombre con una amplia acción de intimidación a los votantes en el período previo a la votación del 30 de noviembre. Trump amenazó abiertamente con cortar la ayuda estadounidense a Honduras si Asfura no era elegido… Ahora sabemos por qué. #honduras ——— Únete a la lucha por la verdad en 📱Telegram 🫥Odysee 📱X (Twitter)

Hashtags

RTDocumentary

@rtdocumentary · Post #566 · 01.04.2022 г., 14:00

#video#Honduras Honduras is one of the most dangerous places to be a woman. The country has the highest rate of femicide, gender-based murder, in Latin America. Women are easy targets for gangs that wage war against each other on the streets of Honduras. Stepping outside your home can sometimes be deadly. These parents lost their daughter, and they have little hope the perpetrators will be held to account. For more, watch the new documentary Honduran Femicide. It's also available on Odysee odysee.com/@RTDocumentary:4 Watch all of our films there! Follow: https://t.me/rtdocumentary

RTDocumentary

@rtdocumentary · Post #429 · 28.01.2022 г., 10:01

#photo#Honduras This woman kills for a living. She’s an assassin in one of the gangs in San Pedro Sula, once known as the most dangerous city in the world with the highest murder rate. RT Documentary’s Natalya Karachkova interviewed her during a trip to Honduras. She had to kill three people in a week to become a gang member, which she joined when she was only 12. During the interview, she put a gun between her legs to have quick access to it just in case. Members of the gang like her don’t get paid. Everything she gets has to be brought to the boss, who distributes it among the gang members. If you’d like to learn more about the criminal gangs in Honduras, subscribe to our channel on Telegram and YouTube. You’ll be the first to find out about the film premiere ;) Follow: https://t.me/rtdocumentary

Noticias de LAD🇷🇺

@LAD_MAERusia · Post #22027 · 31.12.2025 г., 14:47

📄 El comunicado de prensa de la Cancillería de Rusia respecto a los resultados de las elecciones generales en #Honduras El 30 de noviembre se celebraron las elecciones generales en la República de Honduras. Tras un prolongado recuento de resultados en la contienda presidencial, el 24 de diciembre el Consejo Nacional Electoral del país anunció oficialmente el ganador del máximo cargo Estatal al líder del Partido Nacional, Nasry Juan Asfura Zablah, quien obtuvo el 40,26% de los votos. En Moscú provienen del respeto incondicional a la voluntad de los ciudadanos de Honduras, su soberanía nacional e independencia de la República. 🤝 La Parte Rusa confía en que las relaciones tradicionalmente amistosas entre Moscú y Tegucigalpa mantendrán su continuidad y seguirán desarrollándose de manera constructiva en beneficio de nuestros países y pueblos. 🇷🇺🇭🇳#RusiaHonduras

Partido Comunista de Cuba

@PartidoComunistadeCuba · Post #10080 · 09.04.2025 г., 15:53

Miguel Díaz-Canel Bermúdez (@DíazCanelB) en X) A pocas horas de la Cumbre #CELAC en Tegucigalpa, hemos tenido un encuentro muy emotivo con colaboradores cubanos de salud y educación, y con hondureños que sienten profundo amor por nuestro país. Les aseguramos que #Honduras y su querido pueblo pueden seguir contando con #Cuba.

Partido Comunista de Cuba

@PartidoComunistadeCuba · Post #10075 · 09.04.2025 г., 13:27

Miguel Díaz-Canel Bermúdez (@DíazCanelB) en X) A pocas horas de la Cumbre #CELAC en Tegucigalpa, hemos tenido un encuentro muy emotivo con colaboradores cubanos de salud y educación, y con hondureños que sienten profundo amor por nuestro país. Les aseguramos que #Honduras y su querido pueblo pueden seguir contando con #Cuba. https://x.com/i/status/1909828113183224024

Communia

@communia · Post #37850 · 15.01.2024 г., 19:07

#México revive el viejo corredor creado para el galeón de Manila y que perdió su relevancia con el canal de #Panamá. https://www.bbc.com/mundo/articles/cj5vj0yjqydo #Honduras intenta impulsar la competencia https://www.portafolio.co/internacional/el-plan-de-honduras-para-construir-un-tren-interoceanico-para-unir-el-atlantico-con-el-pacifico-590072

Interesting Planet 🌍

@interesting_planet_facts · Post #942 · 20.10.2025 г., 22:11

🌎 In the skies over Honduras and Nicaragua, the mysterious “Lluvia de Peces,” or "Rain of Fish," has been reported for over a century. After intense storms, locals find live fish on land—scientists suspect waterspouts or flooding lift fish from rivers and drop them during heavy rainfall. This phenomenon usually happens near the town of Yoro, typically once or twice a year. ✨ #weather⚡#phenomenon⚡#rainfish⚡#Honduras 👉subscribe Interesting Planet 👉more Channels ​

12
ПретходнаСтраница 1 од 2Следна