@cryptobull_360 · Post #49537 · 29.04.2026 г., 02:24
#BLEND📈👀
Hashtags
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
Пребарај: #blend
@cryptobull_360 · Post #49537 · 29.04.2026 г., 02:24
#BLEND📈👀
Hashtags
@Ai_artz · Post #1306 · 28.05.2023 г., 17:47
#from#blend A cute adorable will smith in a gym with low poly eye's surrounded by dumbell aura, flamming sparkles highly detailed intricated concept art trending artstation 8k ✅ Realartsociety _Discord @ai_artz
@Ai_artz · Post #1120 · 28.04.2023 г., 17:20
#from#blend ✅DarkestKnight 🦇🩸 _Discord Join us for more @ai_artz
@Ai_artz · Post #1089 · 25.04.2023 г., 22:06
#from#blend ✅Bestwebbs AI Tools _facebook Join us for more @ai_artz
@Ai_artz · Post #917 · 07.04.2023 г., 16:17
#from#blend Full color caricature, of brad pitt, highly detailed, 64k, highly intracite. ✅peakfreans#6877 _Discord @ai_artz
@Ai_artz · Post #799 · 27.03.2023 г., 14:29
#from#blend ✅ Ando#6782 _Discord Join us for more @ai_artz
@Ai_artz · Post #723 · 21.03.2023 г., 19:30
#from#blend ✅ Will Martins _facebook @ai_artz
@Ai_artz · Post #634 · 16.03.2023 г., 06:44
#from#blend Prompt: Asian Barack Obama realistic ✅ tofulab#6432 _Discord @ai_artz
@AI_artz · Post #1337 · 14.06.2023 г., 12:12
#from#blend Donald Trump dressed as a ballerina 🍒--- --- --- --- --- --- --- --- --- --- --- --- --- --🌿 ✅ lukasz247 _Discord @ai_artz💃
@AI_artz · Post #1322 · 13.06.2023 г., 06:48
#from#blend An ultra realistic photography style portrait of an Oompa Loompa wearing a bitcoin necklace. The style is a cross between Tim Burton and steam punk. ✅ clakskit _ Discord @ai_artz🍒
@AI_artz · Post #1976 · 17.02.2024 г., 17:40
#blend A digital painting of Donald trump and Joe biden sitting in a couch in a style a video game called minecraft, short height, 3d render ✅#made by @ai_artz @ai_artz🇺🇸
@Ai_artz · Post #1239 · 13.05.2023 г., 17:01
#from#blend#fantasy Young Harry Potter as cosmonaut , round glasses, dark clothrs, full body, wand as gun, talking magic on a translucid cosmic helmet that is impressionism glowing and radiating neon vibration architecture, wizard closeup of head and cellular, eerie sandu baciu style , hyper realistic, volumetric golden hour, photography award, creative --q 2 --niji 5 --style expressive ✅ Sandu _Discord Join us for more @ai_artz