@botsgram_cu · Post #3743 · 31.03.2021 г., 13:57
¿Que puede hacer este bot? @QuotAfBot Crea pegatinas animadas con un texto que le envíes Idiomas: varios incluido español (Visto en @botsgram_cu) #stickers#texto
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
Пребарај: #texto
@botsgram_cu · Post #3743 · 31.03.2021 г., 13:57
¿Que puede hacer este bot? @QuotAfBot Crea pegatinas animadas con un texto que le envíes Idiomas: varios incluido español (Visto en @botsgram_cu) #stickers#texto
@botsgram_cu · Post #4296 · 26.08.2021 г., 17:46
¿Que puede hacer este bot? @WebScrapperRoBot Con este bot puedes obtener todo el texto de un sitios web Idiomas: inglés (Visto en @botsgram_cu) #web#texto
@botsgram_cu · Post #3093 · 27.10.2020 г., 02:57
¿Que puede hacer este bot? @TextChangerBot Un bot para convertir texto a varias fuentes. Perfecto para configurar perfiles en redes sociales, apodos para juegos y más. Idioma: ruso (Visto en @botsgram_cu) #texto#fuentes
@botsgram_cu · Post #3061 · 11.10.2020 г., 05:40
¿Que puede hacer este bot? @COOLTEXTGENERATORBOT Bot para decorar y darle estilo al texto en muchas fuentes Idiomas: inglés (Visto en @botsgram_cu) #fuentes#texto
@botsgram_cu · Post #4473 · 31.10.2021 г., 03:27
¿Que puede hacer este bot? @TypographicBot Este bot puede cambiar la tipografía de los mensajes que le envías Idiomas: inglés (Visto en @botsgram_cu) #texto#estilo
@botsgram_cu · Post #4048 · 24.06.2021 г., 17:15
¿Que puede hacer este bot? @TheCarbonShBot Crea y comparte hermosas imágenes de su código fuente. Envíele un fragmento de código y le responderá con una bonita imagen de ese código. Idioma: inglés (soporta cualquier idioma en la conversión) (Visto en @botsgram_cu) #texto#fuente
@botsgram_cu · Post #3946 · 27.05.2021 г., 15:19
¿Que puede hacer este bot? @BettergramBot Crea textos creativos con fuentes personalizadas. Idiomas: inglés (Visto en @botsgram_cu) #texto#fuente
@botsgram_cu · Post #3738 · 30.03.2021 г., 18:54
¿Que puede hacer este bot? @MasquerBot Este bot utiliza un algoritmo de cifrado de última generación y manipulación de píxeles para enmascarar cualquier texto dentro de cualquier imagen dada. Idioma: inglés (Visto en @botsgram_cu) #edición#fotos#texto
@botsgram_cu · Post #4002 · 10.06.2021 г., 13:19
¿Que puede hacer este bot? @bacakubot Con este bot podrás extraer texto de una imagen o foto y traducirlo a cualquier idioma Idiomas: inglés (Visto en @botsgram_cu) #texto#imágenes#traductor
Hashtags
@botsgram_cu · Post #4212 · 13.08.2021 г., 11:22
¿Que puede hacer este bot? @DummyImageBot Bot para para generar imágenes con tus textos. Idiomas: portugués (Visto en @botsgram_cu) #texto#imágenes#convertidor
Hashtags
@botsgram_cu · Post #4903 · 06.09.2023 г., 13:44
¿Que puede hacer este bot? 🤖@IMG2TEXTBot 📎Este bot utiliza el reconocimiento óptico de caracteres (OCR) para detectar texto en imágenes. #Imagen#texto#IA ( Visto en: @BotsGram_Cu )
@botsgram_cu · Post #4950 · 29.03.2024 г., 13:02
¿Qué puede hacer este bot? 🤖@Ai_Text2Speechbot Es una herramienta fácil de usar que transforma texto escrito en audio hablado. Utiliza algoritmos avanzados de síntesis de voz para generar un habla precisa y con un sonido natural con gran variedad de acentos, para que puedas disfrutar de una experiencia auditiva de alta calidad. Además, es fácil de usar: simplemente envíe un texto escrito al bot y generará un archivo de audio en segundos. Idiomas: Más de 50 idiomas #ia#tts#voz#texto (Visto en @BotsGram_Cu)