当我使用此代码时
widget.Battery(
format = 'Battery: {percent:2.0%}',
foreground = colors[2],
background = colors[5],
padding = 5
),
它工作完全正常,但是当我使用这段代码时
widget.CPU(
foreground = colors[2],
background = colors[4],
threshold = 90,
padding = 5
),
在酒吧它显示
Import Error: CPU
并且它与内存网络和所有这些小部件一起使用
这些东西是我进口的
import os
import re
import socket
import subprocess
from libqtile import *
from libqtile.config import Click, Drag, Group, KeyChord, Key, Match, Screen
from libqtile.command import lazy
from libqtile.lazy import lazy
from libqtile.utils import guess_terminal
from typing import List
from libqtile.widget import *
您需要安装每个小部件的所有要求。
例如,对于 CPU 小部件,您可能需要名为 psutil
的 Python 库您可以在 http://docs.qtile.org/en/latest/manual/ref/widgets.html#
中了解每个小部件的所有信息您需要更改此行
from libqtile.widget import *
到
from libqtile import widget
您需要在与 Qtile 相同的 Python 环境中安装 psutil。例如,我用 pipx 下载了 Qtile 和 psutil,所以我执行了:“pipx Inject qtile psutil”,问题就解决了!