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

Резултати

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

Пребарај: #nostalgia

当前筛选 #nostalgia清除筛选
Comping_Uz

@Comping_Uz · Post #4993 · 08.12.2025 г., 16:11

#nostalgiaMahalladagi 10ta kompyuteri bor kompyuterxona, soati 500 so'm bo'lgan paytlar va bir talay o'yinlar😄 ➖➖➖➖➖➖➖➖➖ 📍Manzil: [ Kichik halqa yo'li 8A ] ⏰ Ish vaqti: [10:00 dan 20:00] 📞 +998338082030 🔵@Comping_admin ➖➖➖➖➖➖➖➖➖ 🔵Telegram📷Instagram🟥Youtube

Hashtags

🦅 [ perspective ix ]

@perspectiveix · Post #1119 · 20.02.2018 г., 19:00

​​💿 The Rise and Fall of the Compact Disc Having been hit by the rise of MP3 players in the early 2000s, #CD sales nearly halved between 2000 and 2007, which is when smartphones and the first music streaming services emerged to put the final nail in the compact disc’s little round coffin. #Nostalgia 🚀@PerspectiveIX 🌀 ⁣http://prs.pctvix.co/TelegramIX

AWTH

@wall_amv · Post #8697 · 18.04.2024 г., 10:50

Anime: Digimon Adventure 2020, Digimon Adventure Tri, Digimon Tamers, Eden, Ef: A Fairy Tale of the Two, Mobile Suit Gundam 00, Shakugan no Shana Music: Digimon - Butter-fly (Tri Version) #Amv #Digimon #Mix #Action #Nostalgia #AnimWorld @Wall_Amv

NewUU Student Council

@newuu_sc · Post #606 · 16.05.2023 г., 19:25

✨Get ready for a blast from the past! It's Retro Day! 🎮🎶 Mark your calendars for May 18, this Thursday, as we transport ourselves back to the magical era of our childhood. 🌟 Join us for a day filled with nostalgia, colorful retro games, and the iconic music that defined our younger years. 🕹🎵 We've curated an exciting lineup of classic games that will make you feel like a kid again. From Tetris to Domino, there's something for everyone to enjoy! Let's relive those epic gaming moments together. 🎮👾 Don your favorite retro outfits and get ready to immerse yourself in the vibrant atmosphere of our childhood. From neon colors to leg warmers, let's embrace the fashion trends that defined an era. It's time to bring back the style! 👕👖 Date: May 18, Thursday Time: Whole day Location: New Uzbekistan University Spread the word and let's make this Retro Day a celebration of our shared past! See you there! 🎉✨ #RetroDay#Nostalgia#ChildhoodMemories Best Regads, Student Government.

First Love Should Be Forever... Right? 💔#shorts#cinema#firstlove#loveforever#heartbreak#romance#relationships#emotions#cinematic#lovequotes#drama#nostalgia#movingon https://pdmovies.substack.com/p/the-big-combo-1955

Yukiokhruner

@yukiokhruner · Post #15 · 05.04.2022 г., 16:16

L'attaccamento agli oggetti é uno degli ostacoli maggiori per la nostra felicità, come se infondessimo in essi parte della nostra anima. #vaporonda#vaporwave#vapourwave#vaporart#seapunk#webpunk#glitch#glitchart#glitchartistscollective#chillwave#aesthetic#vaporwaveaesthetic#vaporwaveaesthetics#malinconia#melancholy#tristezza#sadness#sadboy#lofi#disagio#nostalgia#illusione#illusion#windows95#windows98#windowsxp

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