@dreamsgallerys · Post #2058 · 08.02.2024 г., 13:56
#MJ
Hashtags
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
Пребарај: #mj
@dreamsgallerys · Post #2058 · 08.02.2024 г., 13:56
#MJ
Hashtags
@stablediffusion · Post #1512 · 28.09.2022 г., 06:20
dante and virgil standing in a cue to a cashier in a modern supermarket, dante pushing a trolley, in gustav dore style, etched engraving, super high details #MJ • Creator
Hashtags
@stablediffusion · Post #1500 · 27.09.2022 г., 15:03
#mj
Hashtags
@stablediffusion · Post #1479 · 26.09.2022 г., 14:02
Подборка поездов #mj
Hashtags
@stablediffusion · Post #1476 · 26.09.2022 г., 05:32
pioneer with a camera, in the rays of the sun, Artgem and greg rutkowski masterpiece, hyperrealistic surrealism, award winning masterpiece with incredible details :: in the style of devilman #mj
Hashtags
@stablediffusion · Post #1392 · 24.09.2022 г., 10:17
wlop. room. garden. disney princess, art, highly detailed, digital painting, artstation, young girl, long hair, cute girl, belly dance, blueprint, detailed eyes, perfect faces, fine details, room, cute, elegant, art, gold sharms, concept art, smooth, sharp focus, illustration, artgerm, wlop, craig mullins, greg rutkowski --test --creative --upbeta --ar 1:2 #mj
Hashtags
@stablediffusion · Post #1323 · 21.09.2022 г., 12:30
ferrari camping bus in the beautiful mountains, intricate exterior, campsite, ultra detailed, photorealistic, octane render #mj • Creator
Hashtags
@stablediffusion · Post #1245 · 19.09.2022 г., 11:51
nuclear strike in eye, superrealism, close look, cg, cinematic --v 3 --s 5000 #mj
Hashtags
@inbox_all · Post #108 · 07.05.2021 г., 08:17
BILLIE JEAN (HIStory Tour, Munich 1997) 迈克尔·杰克逊(Michael Jackson)1997 年 HIStory 巡演德国慕尼黑演唱会表演《BILLIE JEAN》现场片段。 HIStory 世界巡回演唱会是 MJ 的第三次世界巡回演唱会,也是最后一次。1996年9月7日开始,1997年10月15日结束,横跨非洲、亚洲、欧洲、大洋洲和夏威夷。此次巡演共82场演出,共计4500000歌迷入场,总收入高达1.63亿美元,创造惊人神话。 1997 年 HIStory 巡演德国慕尼黑演唱会现场完整视频链接(4K修复):LIVE IN MUNICH, 1997 [ZDF Version] - HIStory World Tour (Munich, 1997) #音乐#MJ
@PensivePost · Post #5053 · 01.04.2021 г., 08:33
When you face your demon. The day when you feel every possible pain, confusion, darkness, the negativity you can imagine. When you can't able to sleep when you can't able to breathe peacefully, and so on. Consider this now you found your demon. You feel helpless, you feel so numb, you feel lost. But you know what? Even in the night of darkness, there is still hope of light that waiting for you. Gautam Buddha once said, whenever you fall into the worst situation never forget to pursue something good from it. Make your pain your best teacher your best friend. You're pain always trying to say become better than you used to be. Become stronger than you used to be. • This Universe beyond our thinking and imagination. In this universe, there is something or nothing. We don't know. No one does. I don't know where you live but I know you live somewhere in the world in this tiny world, we don't know why we here, we don't know why we born. We come into this world. We spend our lives with our loved ones, then we die they will cry and they will move on because this is very difficult to live with that pain and they also die one day. If you do something to help this world some more people remember you and some will cry some will not and they also move on. Something always with you withing you but we always underestimate that sense of existence. In this new world, we always greedy to feed logic and reasoning but our small brain not made out for that, this universe beyond our mind. Thoughts come and goes. Days come and goes. The feeling comes and goes. People come and goes. What remains at this moment? You! When you're day will come you also leave this world. Understand this and be grateful for this precious life. Be kind, be honest add value to your life. Find something that you can live or die for. Find your calling. Suppose even if you don't achieve what you planned for the last day of your life, you will have a smile of satisfaction on your face that you never give up you always stand back when you fall. You always fight back. This only enough to make you smile on your last day. When someone decides to give that precious life to something he/she loves, The great infinite universe starts giving them energy, potential, the courage to do that thing. Then nothing seems that important than your purpose. Believe in yourself the more you hurt the more you will become stronger. Have faith in my words, forgive yourself for everything and start again my love. Thanks for reading. #MJ#Review#story
@stablediffusion · Post #1649 · 05.10.2022 г., 11:07
Futuristic spaceship close-up, hidden in the forest, russian wooden buildings, the atmosphere of ancient Russia, Russian folklore, in the style of Shishkin --ar 16:9 --test --creative #Конкурс #MJ
@stablediffusion · Post #1615 · 02.10.2022 г., 12:52
old black and white photo, robot barber, 1850s style, by Studio Ghibli, ultra detailed, photo realistic --ar 9:12 --test --creative #конкурс#mj