Python Tkiinter

Hi,
I tried to install tkinter in my idx project.
This is my repo → GitHub - KayBeckmann/python-uebungen: hier kommen die Übungen rein, die in dem neuen Buch sind.
I try to learn a little bit python and I try to do some projects with tkinter.

How can i install it in the idx enviroment?

I tried this:
‘’’

To learn more about how to use Nix to configure your environment

see: ปรับแต่งพื้นที่ทำงาน IDX  |  Project IDX  |  Google for Developers

{ pkgs, … }: {

Which nixpkgs channel to use.

channel = “stable-23.11”; # or “unstable”

Use NixOS Search to find packages

packages = [
# pkgs.go
pkgs.python311
pkgs.python311Packages.pip
pkgs.python311Packages.tkinter
# pkgs.nodejs_20
# pkgs.nodePackages.nodemon
];

Sets environment variables in the workspace

env = {};
idx = {
# Search for the extensions you want on https://open-vsx.org/ and use “publisher.id”
extensions = [
# “vscodevim.vim”
];

# Enable previews
previews = {
  enable = true;
  previews = {
    # web = {
    #   # Example: run "npm run dev" with PORT set to IDX's defined port for previews,
    #   # and show it in IDX's web preview panel
    #   command = ["npm" "run" "dev"];
    #   manager = "web";
    #   env = {
    #     # Environment variables to set for your server
    #     PORT = "$PORT";
    #   };
    # };
  };
};

# Workspace lifecycle hooks
workspace = {
  # Runs when a workspace is first created
  onCreate = {
    # Example: install JS dependencies from NPM
    # npm-install = "npm install";
    create-venv = ''
      python -m venv .venv
      source .venv/bin/activate
      pip install -r requirements.txt
    '';
  };
  # Runs when the workspace is (re)started
  onStart = {
    # Example: start a background task to watch and re-build backend code
    # watch-backend = "npm run watch-backend";
    source = "source .venv/bin/activate";
  };
};

};
}
‘’’

Thanks for help

So the best practice right now in IDX is to use python virtual environments.

You can see an example of this with the python flask template here:
https://idx.google.com/new/flask

Thank you. I’m a bit to stupid for it.

Workspace lifecycle hooks

workspace = {
  # Runs when a workspace is first created
  onCreate = {
    install =
      "python -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt";
  };
  # Runs when the workspace is (re)started
  onStart = {
    # Example: start a background task to watch and re-build backend code
    # watch-backend = "npm run watch-backend";
    source = "source .venv/bin/activate";
  };
};

I try to start a little script for testing:

import tkinter as tk

root = tk.Tk()
root.mainloop()

and I got this error:

(.venv) python-uebungen-79155:~/python-uebungen{master}$ /home/user/python-uebungen/.venv/bin/python /home/user/python-uebungen/tk.py
Traceback (most recent call last):
File “/home/user/python-uebungen/tk.py”, line 1, in
import tkinter as tk
File “/usr/lib/python3.11/tkinter/init.py”, line 38, in
import _tkinter # If this fails your Python may not be configured for Tk
^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named ‘_tkinter’

the enc is started.

maybe idx dosn’t support windows?