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

Резултати

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

Пребарај: #intermediate

当前筛选 #intermediate清除筛选
English Speakers

@English_Speakers · Post #4542 · 06.05.2021 г., 00:42

#intermediate 📌 made my day Meaning 👉 To cause one to feel very happy; to be a very positive highlight of one's day. Example When my neighbors surprised me with homemade chocolate chip cookies, it is really made my day. @English_Speakers

English Speakers

@English_Speakers · Post #4479 · 17.03.2021 г., 17:59

#Intermediate @English_Speakers 📌 When the cat a way the mice will play غاب القط فالعب يا فار people being supervised often do things they are not supposed to do when the supervising person is not around (expression often used in a humorous way about employer and employees, parents and children, etc.) 👉Example: "“His parents are away for the weekend.” “I see—while the cat's away.” @English_Speakers

New Psychedelics compounds search. Why? Deal with First gen psychedelic issues: - they were not created specifically to threat a particular disorder even if can do it with a certain efficacy - they have cardiotoxicity related to 5ht2b mechanism - long action duration length for therapy New hopes and ideas: - decouple halucenogetic from therapeutic effect - potentially reaching even newer states of mind - targetly engineered experience without so complex set and setting What? - Kanna alcaloids for premature ejaculation 😅 - BPL-003 for Treatment Resistant Depression (TRD). - IHCH-7113 Non halucenogetic psychedelic for depression - Ele-101 for depression and Alcohol Use Disorder (AUD). How? 1. AI assisted search - Predictive AI. Train on structure to properties (need big dataset of both) - Generative AI. Evolutionary machines 2. Natural compounds search and enchantment - Research existing less popular natural compounds rom indigenous communities - Enchance properties (Increase a half life, change blood barrier penetration, etc.. 3. Future approaches - computational chemistry (compounds VS receptors ) - test on brain organoids Skill level: #intermediate https://youtu.be/BQoIozpBU5Y

https://podcasts.google.com/feed/aHR0cHM6Ly9mZWVkcy5saWJzeW4uY29tLzgxODk1L3Jzcw/episode/NjgxMmNkZTUtYThmZi00OWIxLThkMmMtZGU5NGM4MDQ2YjRl?ep=14 Why MDMA analogs? 1. Safer options for mory risky categories of people: People with Cardiac deseas history People over the age of 65 2. Other medical application apart form PTD Social anxiety for Autism Parkinson's desease 3. Other impoovements Shorter therapy duration More cheaper production Skill level: #intermediate

Researchers Are Mapping DMT Dimensions Through DMTx Tech Seems like DMTX is finally started and we will see more exciting news from various labs all over the world. Any friends anesthesiologists?😁 "But that doesn’t mean we can’t have some kind of mapping. One can think about Level mapping for example, so do different levels of intensity experience reliably take you to different types of spaces? Is there a progression? I mean people talk already, about you know, moving to the waiting room and then the dome. There has already been developed in a very informal sense, a certain kind of mapping of the space.” Skill level #intermediate https://psychedelicspotlight.com/researchers-are-mapping-out-new-dimensions-through-dmtx-technology/

English With Natives*

@sirjimmy · Post #31213 · 10.10.2024 г., 05:11

1️⃣How often does he work? Everyday All day Rarely 2️⃣What is he starting to think about? Playing basketball Watching TV His health Work 3️⃣What decision is made to get more exercise? Running or Jogging Doing more outdoor activities Going to the local gym 4️⃣What type of lessons are they considering? Dance Tennis Basketball 5️⃣For $120, How often will they meet? Everyday for a month Once a week for two months Every afternoon Twice a week for one month 6️⃣Please fill the blank and tell me what does whole sentence mean? Playing tennis twice a week will be a good start. ..... me .... . #Listening #Intermediate #Teamjimmy @Sirjimmy

English With Natives*

@sirjimmy · Post #30337 · 19.05.2023 г., 07:30

1️⃣How often does he work? Everyday All day Rarely 2️⃣What is he starting to think about? Playing basketball Watching TV His health Work 3️⃣What decision is made to get more exercise? Running or Jogging Doing more outdoor activities Going to the local gym 4️⃣What type of lessons are they considering? Dance Tennis Basketball 5️⃣For $120, How often will they meet? Everyday for a month Once a week for two months Every afternoon Twice a week for one month 6️⃣Please fill the blank and tell me what does whole sentence mean? Playing tennis twice a week will be a good start. ..... me .... . #Listening #Intermediate #Teamjimmy @Sirjimmy

English With Natives*

@sirJimmy · Post #30259 · 28.04.2023 г., 06:37

1️⃣How often does he work? Everyday All day Rarely 2️⃣What is he starting to think about? Playing basketball Watching TV His health Work 3️⃣What decision is made to get more exercise? Running or Jogging Doing more outdoor activities Going to the local gym 4️⃣What type of lessons are they considering? Dance Tennis Basketball 5️⃣For $120, How often will they meet? Everyday for a month Once a week for two months Every afternoon Twice a week for one month 6️⃣Please fill the blank and tell me what does whole sentence mean? Playing tennis twice a week will be a good start. ..... me .... . #Listening #Intermediate #Teamjimmy @Sirjimmy

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