简体   繁体   English

VS Code 中的 gi.repository 代码完成支持

[英]code completion support with gi.repository in VS Code

I'm trying do code a simple app with GTK4 in Python using VS Code.我正在尝试使用 VS Code 在 Python 中使用 GTK4 编写一个简单的应用程序。

What I do:我所做的:

gi.require_version("Gtk", "4.0")
from gi.repository import Gtk

I don't have any auto completion or type hints in my IDE because gi.repository uses dynamic imports, is there any way to change this behavior?我的 IDE 中没有任何自动完成或类型提示,因为 gi.repository 使用动态导入,有没有办法改变这种行为?

In Python typing annotations can be written separately from the main module code (in .pyi files or as a stubs module).在 Python 中,键入注释可以与主模块代码分开编写(在.pyi文件中或作为存根模块)。

Run $ pip install PyGObject-stubs to install 3d-party type annotations and reload VS Code window运行$ pip install PyGObject-stubs以安装 3d 方类型注释并重新加载 VS 代码 window

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM