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

Резултати

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

Пребарај: #wish

当前筛选 #wish清除筛选
Journey to Fluency

@fluencyinenglish · Post #7001 · 28.03.2019 г., 03:43

‍ #wish @fluencyinenglish ❇️ کاربردهای کلمه “wish” به معنای خواستن، آرزو، میل داشتن 🔷 Wish + to + infinitive همان معادل want to است اما کمتر رایج است و رسمی تر. 👉 I wish to see the manager. 👉 Wish + somebody + something 🔷 wish + somebody + something تقدیم آرزوهای خوب برای دیگران 👉 I wish you all the best in your new job. 🔶 همانند مثال اخیر را میتوان همراه با فعل نیز به کار برد، که در آن صورت بایستی از hope استفاده نماییم. 👉 We wish you the best of luck. 👉We hope you have the best of luck. 🔷 Wish + would / could صحبت درباره ی آرزوها و تمایلات آینده. 👉 I don’t like my work. I wish I could get a better job. 👉 That’s a dreadful noise. I wish it would stop. 🔷 Wish + (that) + past simple صحبت درباره ی شرایطی که نسبت به آن پشیمان هستیم و تمایل داریم در حال یا آینده، متفاوت از گذشته باشند. 👉 I wish that I had a big house (I don't have a big house, but it's a nice idea!). 👉 I wish that we didn't need to work today (we do need to work today, unfortunately). 🔑نکته : در اکثر متون و مکالمات رسمی انگلیسی، مشاهده خواهید کرد که به جای was از were استفاده می شود، لذا هر دو مورد صحیح می باشند. 👉 I wish I were rich 👉 I wish I was rich 🔷 Wish + (that) + past perfect صحبت درباره ی موقعیتی که در گذشته اتفاق افتاده است و ما نسبت به آن پشیمانیم. 👉 I wish that I had studied harder at school. (I didn't study hard at school, and now I'm sorry about it.) 👉I wish that I hadn't eaten so much yesterday! (But I did eat a lot yesterday. Now I think it wasn't a good idea.) @fluencyinenglish

Hashtags

Journey to Fluency

@fluencyinenglish · Post #6410 · 04.09.2018 г., 18:08

#grammar #wish #hope @fluencyinenglish @ieltsstrategies How should I use "I hope" and "I wish"? @fluencyinenglish @ieltsstrategies ✅If you want to use "I hope" and "I wish" correctly, you just need to memorize these two phrases: I hope I can... I wish I could... You may be wondering: why do English speakers use the present tense for "hope" and the past tense for "wish"? The secret is that "could" is not really past tense. It looks like past tense, but it's secretly something different. It's the "unreal" aspect. In other words, it expresses something that's not really true, or not very likely. We use "wish" to talk about things that are impossible, or things that probably won't happen: I wish I could fly. I wish there were more hours in the day. I wish I'd studied something a little more practical. On the other hand, we use "I hope..." when there's a good chance that something might happen. You can use it to say what you want to happen in the future: I hope this cake turns out OK. I hope we can still be friends. The grammar of "wish" and "hope" Here's how "wish" and "hope" look in present, past, and future. @fluencyinenglish @ieltsstrategies ❇️Present I hope this is the last mistake. I wish my phone worked here. @fluencyinenglish @ieltsstrategies ❇️Past I hope Antonio got home safely.* I wish you'd told me sooner. * You can't use "hope" to talk about something in the past, unless you don't know what happened yet. In this example, you haven't heard whther Antonio got home safely. @fluencyinenglish @ieltsstrategies ❇️Future I hope it stops raining soon.* I wish it would stop raining. * You follow "hope" with the present tense of a verb, even when you're talking about the future. So you say "I hope it stops" instead of "I hope it will stop." @fluencyinenglish @ieltsstrategies

JS Organization

@jsorganization · Post #401 · 18.06.2024 г., 08:03

Public Wishing With Show Profile Photo Post. Javascript Code🤖 Command Name : /post Code ; Api.sendPhoto({ chat_id: "@JSOrganization",// Replace To Your Channel Username photo:"https://t.me/JSOrganization" , caption: "*👋Hello! @JSOrganization*", parse_mode: "Markdown", reply_markup: {inline_keyboard : [[{text: "CLICK TO WISH ", callback_data: "/post2"}]] } }) Command Name :/post2 Code: // Get the user Telegram ID let userId = user.telegramid; // Array of random wishing captions const randomCaptions = [ "May your wishes come true! 🌟", "Sending you warm wishes on this special day! 🌸", "Wishing you happiness and prosperity!", "May your heart be filled with joy and peace.", "Here's to a wonderful Eid ul Adha celebration!" ]; // Function to get a random element from an array function getRandomElement(array) { return array[Math.floor(Math.random() * array.length)]; } // Define the new property name const newPropertyName = "hasGreeted"; // Check if the user has already greeted if (!User.getProperty(newPropertyName)) { // Increment the total wishes by 1 let totalWishes = Bot.getProperty("total_wishes", 0) + 1; Bot.setProperty("total_wishes", totalWishes, "integer"); // Set a flag to indicate that the user has greeted User.setProperty(newPropertyName, true, "boolean"); // Send the response with an alert Api.answerCallbackQuery({ callback_query_id: request.id, text: `Successfully Wished 🌟\n\nTotal Wishes: ${totalWishes}`, show_alert: true }); // Select a random wishing caption let randomCaption = getRandomElement(randomCaptions); // Prepare the enhanced caption with the updated total wishes count and random wishing caption let caption = `${user.first_name}, wishing you all a blessed Eid ul Adha! 🌸\n\n` + `Thank you for your wish! ${randomCaption}\n\n` + `Total Wishes So Far: ${totalWishes}`; // Edit the message with the updated caption and media Api.editMessageMedia({ chat_id: request.chat_id, message_id: request.message.message_id, media: { type: "photo", media: "t.me/" + user.username, caption: caption }, parse_mode: "markdown", reply_markup: { inline_keyboard: [ [{ text: "✨ Wish Now ✨", callback_data: "/post2"}] ] } }); } else { // User has already greeted, no action needed Api.answerCallbackQuery({ callback_query_id: request.id, text: "You have already greeted!", show_alert: true }); } Replace Your Greetings Random Message As Your Wish 🔴 #Greeting#Wish#EidPost#PublicWish#BotsBusiness#JSOrganization ©@JSOrganization🤖 If Anyone Face Any Error Or Problem. So Message@itsSowrov🙂

跑跑資訊站 KartInfo

@KartInfoTW · Post #403 · 21.07.2022 г., 09:59

韓服 2022 跑跑聯賽第二季將於本週六開打,本季聯賽一大看點就是首位台灣選手「NEAL」參戰,也讓更多台服玩家開始關注韓服聯賽,相信本次聯賽原廠也將秉持最高原則呈現最精彩的賽事給觀眾,更多聯賽資訊和活動獎勵,立即點擊查看 👇👇 🏁 詳細聯賽資訊:https://kinf.cc/Xiq1U ▶️ 追蹤 Google 新聞:https://kinf.cc/gn ▶️ 立即加入 Discord:https://kinf.cc/dc #跑跑卡丁車#KartRider#韓服#職業#聯賽#跑跑聯賽#카트리그#第二季#Season2#懶人包#NEAL#DFIBLADES#KWANGDONGFreecs#LiivSANDBOX#Sinkhole#Savage#FINALEesports#APEX#WISH#開幕賽