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

Резултати

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

Пребарај: #carf

当前筛选 #carf清除筛选
IRAS

@irassg · Post #1579 · 27.06.2025 г., 07:45

The #IRASFam hosted the inaugural Workshop on the Global Forum's Crypto-Asset Reporting Framework (CARF) commitment and implementation of the requirements. This landmark event, bringing together participants from across the world - Asia-Pacific, Africa, Middle East & Central Asia, Europe, and the Americas - was jointly organised by IRAS and the Global Forum Secretariat. Over two engaging days, participants learned about CARF requirements and worked together in cross-jurisdictional teams to develop practical implementation plans through interactive sessions led by expert facilitators from the Global Forum Secretariat. The enthusiasm and dedication demonstrated by all participants were truly inspiring! We extend our heartfelt thanks to all our international colleagues for their active participation and hope they enjoyed their experience in Singapore. Looking forward to more opportunities for continued peer learning and collaboration! 🤝 #LifeatIRAS#CARF#InternationalCollaboration#OECD

以太坊区块链新闻| ETH 以太币圈热瓜

@ethereumglobalnews · Post #1697 · 02.01.2026 г., 08:58

🏛️📊加密稅務進入全球同步監管階段 📑 依據 OECD「Crypto-Asset Reporting Framework(CARF)」,48 個司法管轄區 已啟動首輪加密資產稅務資料蒐集,為 2027 年正式跨國自動交換做準備。 ——— 全文+ 分析 👇 🌍 首批涵蓋國家包含: 歐盟多國、英國、日本、韓國、巴西、南非等主要經濟體。 ⏱ 第二波國家(如 新加坡、瑞士、香港、阿聯酋、加拿大)預計 2028 年 納入完整交換機制。 ⚠️ 影響重點: • CEX / 託管商將回報用戶錢包與交易資料 • DeFi 與自託管錢包監管壓力持續上升 • 跨境逃稅空間被大幅壓縮 ⚡️ Insight CARF 標誌著「加密資產 = 全球金融資產」的監管定錨完成。對 ETH 生態而言,合規化 ≠ 利空,而是機構資金長期入場的必要前提。 #Ethereum#Updates #CARF#Regulation#Tax ⚡️ 問題来了,留言告诉我 👇 你最看好哪個國家的貨幣發展?

IRAS

@irassg · Post #1253 · 29.11.2024 г., 09:10

🎤 Assistant Commissioner Angela Ang contributed as a panellist, sharing our insights on the Common Reporting Standard. She wore two hats – one as an AEOI Peer Review Group member and another as an Assessed Jurisdiction. 🤝 Tax Director Gordon Cheong chimed in too, emphasising how we had teamed up with industry partners to implement CRS. He highlighted that we will continue to closely engage and partner with the industry as we implement the amended CRS and CARF in the coming years. Read our announcement here and discover more about the Global Forum plenary meeting here. #GlobalForum#AEOI#AutomaticExchangeOfInformation#CARF#TaxTransparency#GFplenary2024