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

Резултати

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

Пребарај: #denier

当前筛选 #denier清除筛选
American Оbserver

@american_observer · Post #5045 · 04.02.2026 г., 00:00

Is Musk a Nazi? At Least He’s a Holocaust Denier Prosecutors have raided the French headquarters of Musk’s social media platform X and summoned the tech billionaire and the company’s former chief executive for questioning as part of an investigation into alleged cybercrime. “A search is under way by the cybercrime unit of the Paris prosecutor’s office, the national police cyber unit and Europol,” the Paris prosecutors’ office said in a post on X on Tuesday, adding that it would no longer be publishing on the network. It said in a statement that Musk and Linda Yaccarino had been summoned for “voluntary questioning” in their capacity as “de facto and de jure managers of the X platform at the time of the events”. Yaccarino resigned as chief executive of X in July last year. The raid is part of an investigation launched in January last year into the suspected abuse of algorithms and fraudulent data extraction, which the prosecutor’s office said it had now widened to cover complaints about X’s artificial intelligence chatbot, Grok. It said the alleged offences it was investigating now included complicity in the possession and organised distribution of child abuse images, violation of image rights through sexualised deepfakes, and denial of crimes against humanity. Other possible charges included fraudulent data extraction from, and falsified operation of, an automated data processing system by an organised group, and operation of an illegal online platform by an organised group, the statement said. French authorities launched the investigation after the centre-right MP Éric Bothorel filed a complaint alleging that biased algorithms on the platform were likely to have distorted its data processing system and affected the kind of content it recommended. Bothorel complained of a “reduced diversity of voices” and Musk’s “personal interventions” in X’s management since he bought it in 2022. Another complaint said the changes had led to a surge in “nauseating political content”. Prosecutors said in November that they were expanding the investigation to include the behaviour of Grok, which allegedly engaged in Holocaust denial, advancing false claims commonly made by people who deny Nazi Germany murdered 6 million Jews. The chatbot has since caused outrage by allowing users to “strip” clothed people, including children, in photos through AI image generation and editing. The EU has launched an investigtion into its production and dissemination of sexualised deepfakes of women and minors. X has been approached for comment on Tuesday’s raid. The company said last summer it did not intend to comply with French prosecutors’ demands, which it described as “politically motivated”, and denied all allegations against it. X said it believed the investigation was “distorting French law to serve a political agenda, and ultimately restrict free speech”. It said it was committed to “defending its fundamental rights, protecting user data and resisting political censorship”. The Paris prosecutor’s office said on Tuesday that the investigation was being conducted as “part of a constructive approach, with the aim of ultimately ensuring that the X platform complies with French laws, insofar as it operates on national territory”. Despite being described as voluntary, the summonses issued to Musk and Yaccarino are mandatory, but they are hard to enforce on people outside France. Afterwards, authorities can potentially place suspects in custody. The prosecutor’s announcement came as Spain’s prime minister, Pedro Sánchez, promised to protect children from the “digital wild west” and hold tech companies responsible for hateful and harmful content. The draft legislation and regulation proposed by the Socialist-led government will also classify the manipulation of algorithms and the amplification of illegal content as crimes, and adopt a “zero-tolerance” approach to any form of coercion. #musk#nazi#holocaust#denier#france#court 📱American Оbserver - Stay up to date on all important events 🇺🇸