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

Пребарај: #digitalpolicy

当前筛选 #digitalpolicy清除筛选
AI & Law

@ai_and_law · Post #802 · 08.04.2026 г., 07:04

🇪🇺EU AI Act FAQ Updated with Guidance on Agentic AI The European Commission’s AI Act Service Desk added a new section on agentic AI to its FAQ guide under the AI Pact. The update introduces key definitions related to “AI agents” and “agentic AI” and outlines how such systems are addressed within the AI Act framework. The guidance highlights that existing AI Act provisions apply to agentic AI, with particular emphasis on Article 5(1) prohibitions concerning harmful manipulation and exploitation of vulnerabilities, identifying these rules as especially relevant for this category of systems. #AIRegulation#EUAIAct#AgenticAI#AIgovernance#DigitalPolicy

AI & Law

@ai_and_law · Post #636 · 15.08.2025 г., 07:04

🇩🇪Germany’s Digital Minister Calls for a Leaner, More Innovation-Friendly AI Act Germany’s Federal Minister for Digital Transformation and Government Modernisation, Karsten Wildberger, has voiced sharp concerns over the EU AI Act, describing it as “overloaded and too complex.” Speaking to Euractiv, he argued that while addressing risks is essential, the current regulatory framework imposes excessive bureaucracy that could hinder innovation. Wildberger backed the European Commission’s plan to create AI training hubs, or “gigafactories,” as a step toward strengthening Europe’s technological capacity. His position underscores a tension within EU policymaking—balancing robust safeguards with an enabling environment for AI development. #AIRegulation#EUAIAct#Germany#DigitalPolicy

AI & Law

@ai_and_law · Post #806 · 14.04.2026 г., 07:04

📖How Metaphors Shape AI Regulation A research paper by the Centre for Digital Ethics (CEDE), “The Artificial in ‘Artificial Intelligence’: How Imagination Shapes AI Regulation,” examines how metaphorical language influences legal and regulatory approaches to AI. Drawing on cognitive linguistics, the paper argues that concepts such as “intelligence,” “black box,” and “hallucination” are not neutral descriptors but frameworks that shape how risks, responsibility, and authority are understood. The authors highlight that legal interpretation relies on language with normative force, meaning these metaphors can steer regulatory outcomes and create path dependence. For example, “intelligence” encourages anthropomorphism, “black box” narrows focus to the model rather than the broader system, and “hallucinations” mischaracterize predictable errors as anomalies. The paper proposes reframing such errors as design-related risks arising from system features and interaction dynamics. #AIRegulation#AIethics#LegalTheory#AIGovernance#DigitalPolicy

AI & Law

@ai_and_law · Post #796 · 31.03.2026 г., 07:04

🇪🇺EU Rights Bodies Warn on AI Act Amendments in Digital Omnibus Equinet and ENNHRI issued a joint statement raising concerns over proposed amendments to the AI Act within the Digital Omnibus package. The organizations state that changes are being advanced without sufficient impact assessments or public consultation, potentially affecting fundamental rights protections. They also highlight that the AI Act only entered into force on 1 August 2024, with most obligations applying from 2 August 2026, making meaningful assessment of its effects premature. The statement stresses the European Commission’s obligations under EU Treaties and Better Regulation Guidelines to ensure transparent consultation and evidence-based policymaking. It also warns that simplifying regulation based on company size rather than AI system risk could have systemic consequences, given the dominance of SMEs and Small Mid-Caps in the EU economy. Equinet and ENNHRI recommend preserving core safeguards, including AI system registration, powers of fundamental rights authorities, high-risk system timelines, strict necessity standards, AI literacy obligations, and key information requirements. They also oppose weakening GDPR definitions of personal data and proposed changes to automated decision-making rules. #AIRegulation#EUAIAct#FundamentalRights#DigitalPolicy#GDPR