0
したがって、pygtk appindicatorを作成しており、定期的に呼び出す特定の関数が必要です。 gobject.timeout_add(millisec、function)はこれに対する1つの解決策です。インポートエラーがなくてもgobject名エラーが発生する
私は、このように全てのGIモジュールをインポートしています
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GObject
gi.require_version('Notify', '0.7')
gi.require_version('AppIndicator3', '0.1')
from gi.repository import Gtk as gtk
from gi.repository import AppIndicator3 as appindicator
from gi.repository import Notify as notify
をし、一切のインポートエラーがなかったです。 はその後、私の主な機能には私が呼ん:
gobject.timeout_add(2000,pr)
これは、実際のコードスニペットです:私はとのGObjectを交換する場合であっても
Traceback (most recent call last):
File "appin.py", line 128, in <module>
gobject.timeout_add(2000,pr)
NameError: name 'gobject' is not defined
:
def main():
indicator = appindicator.Indicator.new(APPINDICATOR_ID, os.path.abspath('spotify.svg'), appindicator.IndicatorCategory.SYSTEM_SERVICES)
indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
indicator.set_menu(build_menu())
notify.init(APPINDICATOR_ID)
gobject.timeout_add(2000,pr)
gtk.main()
と次のエラーを取得しますGObject私は同じエラーが発生します。
ですから、同じ問題を解決するのを手伝ってください。 ありがとうございます!
ありがとうございます! – sjboss