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

Резултати

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

Пребарај: #fastapi

当前筛选 #fastapi清除筛选
Repositorio data science

@repo_science · Post #3832 · 31.12.2023 г., 21:38

#Python#FastAPI 🐍 Complete FastAPI masterclass from scratch Learn everything about FastApi with Python, Full Stack, OAuth2, SQLAlchemy, RESTful APIs, and practice projects ----- Main channel: @repo_science Coupons: @freecoupons_reposcience -----

GitHub Trends

@githubtrending · Post #15360 · 23.12.2025 г., 14:30

#python#docker#fastapi#kbqa#kgqa#llms#neo4j#rag#vue Yuxi-Know (语析) is a free, open-source platform built with LangGraph, Vue.js, FastAPI, and LightRAG to create smart agents using RAG knowledge bases and knowledge graphs. The latest v0.4.0-beta (Dec 2025) adds file uploads, multimodal image support, mind maps from files, evaluation tools, dark mode, and better graph visuals. It helps you quickly build and deploy custom AI agents for Q&A, analysis, and searches without starting from scratch, saving time and effort on development. https://github.com/xerrors/Yuxi-Know

GitHub Trends

@githubtrending · Post #14896 · 02.07.2025 г., 12:30

#python#ai#authentication#authorization#claude#cursor#fastapi#llm#mcp#mcp_server#mcp_servers#modelcontextprotocol#openapi#windsurf FastAPI-MCP is a tool that lets you easily turn your FastAPI web API endpoints into Model Context Protocol (MCP) tools, which AI agents can use directly. It requires almost no setup—just connect it to your FastAPI app, and it automatically preserves your request/response data models and documentation. It also includes built-in authentication using your existing FastAPI security methods. You can run the MCP server inside your app or separately, and it communicates efficiently using FastAPI’s ASGI interface. This makes it simple to integrate AI capabilities with your existing FastAPI services without rewriting code, saving you time and effort while keeping your API secure and well-documented[1][5]. https://github.com/tadata-org/fastapi_mcp

GitHub Trends

@githubtrending · Post #15066 · 16.08.2025 г., 12:30

#python#agents#ai#api_gateway#asyncio#authentication_middleware#devops#docker#fastapi#federation#gateway#generative_ai#jwt#kubernetes#llm_agents#mcp#model_context_protocol#observability#prompt_engineering#python#tools The MCP Gateway is a powerful tool that unifies different AI service protocols like REST and MCP into one easy-to-use endpoint. It helps you manage multiple AI tools and services securely with features like authentication, retries, rate-limiting, and real-time monitoring through an admin UI. You can run it locally or in scalable cloud environments using Docker or Kubernetes. It supports various communication methods (HTTP, WebSocket, SSE, stdio) and offers observability with OpenTelemetry for tracking AI tool usage and performance. This gateway simplifies connecting AI clients to diverse services, making development and management more efficient and secure. https://github.com/IBM/mcp-context-forge

GitHub Trends

@githubtrending · Post #14662 · 02.05.2025 г., 12:00

#typescript#aceternity_ui#agent#agents#ai#chrome_extension#extension#fastapi#glean#langchain#langgraph#nextjs#nextjs15#notebooklm#notion#ollama#perplexity#python#rag#slack#typescript SurfSense is a highly customizable AI research tool that helps you organize and search your personal knowledge base. It connects to many external sources like search engines, Slack, Notion, YouTube, and GitHub. You can upload various file types and interact with your saved content using natural language. SurfSense provides cited answers and supports local AI models, making it a powerful tool for research. It's also self-hostable and open-source, allowing you to control your data and customize it as needed. This helps you manage information more efficiently and privately. https://github.com/MODSetter/SurfSense

GitHub Trends

@githubtrending · Post #14678 · 07.05.2025 г., 11:30

#python#api#bracket#brackets#docker#docusaurus#fastapi#json#mantine#nextjs#postgresql#python#react#reactjs#selfhosted#sports#tournament_bracket#tournament_manager#tournaments#web#yarn Bracket is a tool for organizing tournaments. It supports different formats like single elimination, round-robin, and Swiss. You can create teams, add players, and manage multiple clubs with several tournaments. The system allows you to drag-and-drop matches to different courts or reschedule them. It also provides customizable dashboard pages for public viewing. This makes it easier to manage and engage with tournaments, offering more flexibility and control for organizers and participants. https://github.com/evroon/bracket

GitHub Trends

@githubtrending · Post #14761 · 29.05.2025 г., 13:00

#python#api#async#asyncio#fastapi#framework#json#json_schema#openapi#openapi3#pydantic#python#python_types#python3#redoc#rest#starlette#swagger#swagger_ui#uvicorn#web FastAPI is a modern Python web framework for building fast, reliable APIs that is easy to learn and quick to code, making it ready for production use right away. It uses standard Python type hints, which means you get automatic data validation, fewer bugs, and great editor support with code completion and type checks. FastAPI also generates interactive documentation automatically, so you and your team can understand and test your API easily. The main benefit is that you can develop robust, high-performance APIs much faster and with less effort, while reducing errors and making your code easier to maintain[1][2][3]. https://github.com/fastapi/fastapi