2017-01-09 4 views
0

그래서 pygtk appindicator를 만들고 있으며 특정 함수가 정기적으로 호출되어야합니다. gobject.timeout_add (millisec, function)가 이에 대한 하나의 솔루션입니다.가져 오기 오류가 없는데도 gobject 이름 오류가 발생합니다.

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 

을하고 어떠한 가져 오기 오류가 없었다 :

나는이 방법으로 모든 GI 모듈을 가져 왔습니다. 그런 다음 내 주요 기능에 내가 전화 :

gobject.timeout_add(2000,pr) 

이 실제 코드입니다 : 내가 함께 G 객체를 교체하더라도

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 동일한 오류가 발생합니다.

그래도 해결하도록 도와주세요. 미리 감사드립니다 !!

답변

3

수입 명세서에 as gobject을 잊어 버렸습니다. 당신은 적어도 다른 도서관을 위해 그것을 기억했습니다. 파이썬은 대소 문자를 구별합니다. GObjectgobject은 다릅니다.

+0

대단히 감사합니다! – sjboss

관련 문제