TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #380 · 21 окт.

Регулярно приходится писать и ревьюить код, где используется PySide2-6. Заметил, что в подавляющем большинстве случаев настройка создаваемых базовых виджетов происходит через методы. Думаю, всем знаком такой способ. Простой пример с кнопкой: button = QPushButton("Click Me") button.setMinimumWidth(300) button.setFlat(True) button.setStyleSheet("font-size: 20pt") button.setToolTip("Super Button") button.clicked.connect(lambda: print("Button clicked")) Но есть и альтернативный способ - настройка через свойства. Это просто ключевые аргументы конструктора класса. Хоть они и не указаны в документации как аргументы, но они есть) Этот код делает тоже самое но с помощью Property button = QPushButton( "Click Me", minimumWidth=300, flat=True, styleSheet="font-size: 20pt", toolTip="Super Button", clicked=lambda: print("Button clicked"), ) Где это может быть полезно ▫️ Это выглядит более аккуратно и коротко, уже повод использовать ▫️ Может использоваться в заполнении лейаута, когда нам не нужно никакое другое взаимодействие с виджетом и поэтому сохранять его в переменную не требуется. Например, лейбл или кнопка. widget = QWidget(minimumWidth=400) layout = QHBoxLayout(widget) layout.addWidget(QLabel("Button >", alignment=Qt.AlignRight)) layout.addWidget(QPushButton("Click Me", clicked=lambda: print("Button clicked"))) widget.show() Либо так widget = QWidget(minimumWidth=400) layout = QHBoxLayout(widget) for wd in ( QLabel("Button >", alignment=Qt.AlignRight), QPushButton("Click Me", clicked=lambda: ...) ): layout.addWidget(wd) widget.show() ▫️ Можно хранить настройки в каком-то конфиге или генерировать на лету, после чего передавать как kwargs. kwargs = {"text": "Hello " * 30, "wordWrap": True} my_label = QLabel(**kwargs) Как получить полный список доступных свойств? Эта функция распечатает в терминал все свойства виджета и их текущие значения def print_widget_properties(widget): meta_object = widget.metaObject() for i in range(meta_object.propertyCount()): property_ = meta_object.property(i) property_name = property_.name() property_value = property_.read(widget) print(f"{property_name}: {property_value}") #tricks#qt

Hashtags

Резултати

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

Пребарај: #newyear

当前筛选 #newyear清除筛选
SAMPLE

@sampleart · Post #7619 · 21.12.2025 г., 10:40

Десять елочных украшений от художников и брендов Собрали несколько вариантов елочных украшений: от тех, что вызывают ностальгию, до декора, который призван обратить внимание на хрупкость животного мира. Смотрите карточки и забирайте украшения к себе в вишлист! #newyear

Hashtags

🎄The Russian Embassy School hosted a New Year's fairy tale “New Year Knocks at the Door!” In his address, Ambassador Albert P. Khorev thanked the Embassy staff for their hard work and wished them happiness, health, and success in serving their Motherland in the New Year. #NewYear

Hashtags

📱 𝗗𝗡𝗭 𝗧𝗛𝗘𝗠𝗘𝗦 𝗙𝗢𝗥 𝗧𝗘𝗟𝗘𝗚𝗥𝗔𝗠 📱 📢 𝗖𝗵𝗮𝗻𝗻𝗲𝗹: @DNZ_Temas🇧🇷 #NewYear 𝗖𝗼𝗺𝗽𝗮𝘁í𝘃𝗲𝗹 𝗰𝗼𝗺 𝗠𝗗𝗚𝗿𝗮𝗺 𝗖𝗼𝗺𝗽𝗮𝘁𝗶𝗯𝗹𝗲 𝘄𝗶𝘁𝗵 𝗠𝗗𝗚𝗿𝗮𝗺 ================================== ⬇️ ⬇️ ⬇️ ⬇️ ⬇️ ⬇️ FOR ANDROID ONLY ➡️𝐀𝐏𝐏𝐋𝐘 𝐓𝐇𝐄𝐌𝐄 📱 ( Telegram ) ➡️𝗕‌𝐀𝐂𝐊𝐆𝐑𝐎𝐔𝐍𝐃 🖼𝐖𝐀𝐋𝐋𝐏𝐀𝐏𝐄𝐑 ╚════ ღ 𝔻ℕℤ 𝕋𝔼𝕄𝔸𝕊 ღ ══╝ ⬇️ TELEGRAM X ⬇️

Hashtags

HDB

@SingaporeHDB · Post #1083 · 01.01.2022 г., 06:30

As we begin the #newyear, here’s a recap of key housing news in 2021. 🏠✨ Our new year resolution = continue delivering homes to new flat buyers, while increasing supply to meet the strong housing demand from Singaporeans.

Hashtags

Venom Foundation Official

@venomfoundationofficial · Post #17 · 31.12.2022 г., 17:20

Happy New Year from the Venom team! We hope 2023 brings new opportunities and growth for all of our ecosystem participants and partners. We are excited to continue building and improving our platform to serve our community better. Here's to a successful and blockchain-filled year ahead! #NewYear#Blockchain

Learn RCRussian🤍💙❤️

@learnrcrussian · Post #3937 · 31.12.2024 г., 14:59

How to Make a New Year's Wish in Russian 🔻On New Year's Eve in Russia, there is a tradition of making a wish as the Kremlin clock strikes midnight: 1⃣Я хочу (+ noun in Genitive case): • Я хочу счастья! (I want happiness). • Я хочу здоровья! (I want health.) 2⃣Я хочу (+ Infinitive, perf./imperf.): • Я хочу путешествовать! (I want to travel). • Я хочу получить повышение! (I want to get a promotion). 3⃣Пусть (+ verb in the Future Tense): • Пусть наступит мир! (May there be peace). • Пусть придёт любовь! (May love come). • Пусть все будут здоровы и счастливы! (May everyone be healthy and happy.) 🥂Let's write some wishes in Russian the comments! 🎧🗣👇 #NewYear #useful_vocabulary 😎 Stay with @learnRCRussian

Learn RCRussian🤍💙❤️

@learnrcrussian · Post #3949 · 02.01.2025 г., 15:00

Father Frost Saddled a Fir Tree and Rode Through the Streets of Chelyabinsk, Launching Fireworks. 🔻The festive tree was tied to an Audi. Police are searching for the "New Year's wizard" and his "reindeer" to clarify the circumstances. That's Russia, baby:) #NewYear #news 🎄 Stay with @learnRCRussian

Learn RCRussian🤍💙❤️

@learnrcrussian · Post #3940 · 01.01.2025 г., 11:00

🎄Father Frost, a rescuer from Murmansk, delivers gifts on mountain skis, a snowmobile and a festive illuminated all-terrain vehicle Бурлак(Burlak). Video: Ministry of Emergency Situations (Russia) #news #NewYear 🎄 Stay with @learnRCRussian

123•••1011
ПретходнаСтраница 1 од 11Следна