Semanual
Semanual

Reputation: 93

How can I enable syntax highlighting, auto-complete etc. for GTK4 in python?

I'm using Visual Studio Code, and I am trying to develop my first application in GTK4 in python. So far, I managed to make some things, but everything without the IDE's help, because everything I try calling from GTK is white, and of type "Any".

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


class Window(Gtk.ApplicationWindow):
  def __init__(self, app):
    #...
    hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=20) # everything as Any type, and no help from the IDE with syntax highlighting or autocomplete

I tried looking for vs extensions with keywords such as "GTK" and "GTK Python", but none of them seems to be what I need.

So, is there any way to syntax highlight/auto-complete the GTK library in python?

Upvotes: 1

Views: 607

Answers (2)

Semanual
Semanual

Reputation: 93

The solution was simply to write:
pip install pygobject-stubs
as GTK is compiled dynamically and this repo does the job of assigning the correct class/function signatures

Upvotes: 0

Mostly vscode python extensions like

  1. vscode-python
  2. pylance
  3. intellicode

would lint and make code completions are you having these extensions installed please provide your code version and these extensions versions

Upvotes: 0

Related Questions