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

Резултати

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

Пребарај: #ieltsprep

当前筛选 #ieltsprep清除筛选
Andijan Development Center

@adceducate · Post #8208 · 17.02.2024 г., 11:51

We recently hosted a mock IELTS test at our educational center, offering participants a true-to-life exam experience. 📚✍️ The event meticulously recreated the conditions of the actual test, helping attendees familiarize themselves with the IELTS format and timing. ⏳ Participants had the chance to practice their English under timed conditions, assessing their readiness for the real exam. 🇬🇧🕒 Feedback from attendees was overwhelmingly positive, appreciating the opportunity to simulate the test day in a supportive and structured setting. 👏💼#IELTSPrep#MockTest#EnglishPractice

Erkinov Otabek || IELTS

@cambridgeieltsbooks · Post #4424 · 21.04.2024 г., 14:10

✅Listening Time 😎High Frequency Words in IELTS Listening🎧 Knowing what kind of vocabulary to expect in IELTS listening can greatly improve your performance in the actual exam. Come to @cambridgeIELTSbooks and see if you know the meaning of all 378 high frequency words. #listening#IELTSprep ♡ ㅤ ❍ㅤ ⎙ㅤ ⌲ ˡᶦᵏᵉ ᶜᵒᵐᵐᵉⁿᵗ ˢᵃᵛᵉ ˢʰᵃʳᵉ ━━━━━━━━━━━━━ ❤️Sharing is caring❤ ©️Channel:@cambridgeieltsbooks

Erkinov Otabek || IELTS

@cambridgeieltsbooks · Post #3324 · 21.09.2023 г., 08:01

✅ Useful 🤓Identifying Opinion Indicators 💠 Giving personal opinions In my opinion,… I think… I believe… I’d say… I personally feel that… In my point of view,… From my way of thinking… In my mind… 💠 Asking for opinions What do you think about…? How do you feel about…? What are your views on…? Do you think…? Don’t you think…? 💠 Agreeing Yes. You’re right. I suppose you’re right. I (completely) agree. I couldn’t agree more. Exactly. Definitely. Absolutely. 💠 Disagreeing Yes, but… I’m afraid I don’t really agree. I can’t say that I agree. I (completely) disagree. I don’t think so. I doubt it. I wouldn’t say that. Not really. 💠 Expressing reservation Yes, but the problem is… I’m not so sure if… But there’s one problem… I’m a little worried about… #IELTSprep#writing#speaking 🤓Kanalga qo'shiling 👇 ♻️@cambridgeIELTSbooks YouTube|Instagram|Telegram

Erkinov Otabek || IELTS

@cambridgeieltsbooks · Post #3206 · 10.09.2023 г., 02:18

#writing#IELTSprep#task1 ✅ Essay corrections ⁉️IELTS writing siz uchun muhimmi? Uni yaxshilash uchun nima qilish kerak deb o'ylaysiz? ✅ Eng yaxshi yechim, insholaringizni tekshirtirish orqali xatolar ustida ishlashdir. Siz ham shu fikrga qo'shilasizmi? 🤝Biz sizga bir nechta insho tahlilini ulashyapmiz. Siz ham do'stingizga ilining! ♻️Channel: @cambridgeIELTSbooks

Erkinov Otabek || IELTS

@cambridgeieltsbooks · Post #4105 · 23.03.2024 г., 00:59

✅Writing Time 📝Writing task 2 insho savoli o'z ichida 3 qismga boʻlinadi va ular introduction(kirish) qismida quyidagicha o'zgartirilishi kerak. 🍇Background statement (umumiy insho mavzusi) 🍎Specific statement (aniq talab etilayotgan insho mavzusi) 🍓Question (insho savoli) ‼️Ana endi keling, insho kirish qismini qismma-qism yozib chiqaylik. 🍇 When a country develops its technology, traditional skills and ways of life die out.🔁With the development of technology, a nation loses its traditional skills and way of life. 🍎 It is pointless to try and keep them alive. 🔁Many believe that these become irrelevant and there is no use trying to maintain them. 🍓To what extent do you agree or disagree with this? 🔁I completely disagree, however, and will explain why I believe keeping a nation's traditional skills and lifestyle is important, despite the rise of new technologies. If you find it useful, don't forget to share with your friends ☺️ #writing#task2#IELTSprep ❤️Sharing is caring❤ ©️Channel:@cambridgeieltsbooks

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