파이썬에서 Appindicators를 작성하는 방법은 무엇입니까? 파이썬에서 표시기를 만드는

numlock / capslock 및 brigthness 등에 대한 간단한 표시기를 개발하려고합니다. 파이썬에서 표시기를 만드는 방법은 무엇입니까? 첫 번째 Appindicator를 작성하는 과정을 안내하는 자습서가 있습니까? 빠른 템플릿처럼 쉽게 시작할 수있는 솔루션이 있습니까?



답변

앱 지표 작성 페이지는 여기에서 찾을 수 있습니다.

참조 :

이 페이지에는 Python 및 API 설명서의 예제에 대한 링크가 있습니다. Quickly의 ubuntu-application 템플릿에는 appindicator 사용에 대한 예제가 있어야합니다. 행운을 빕니다!


답변

@fossfreedom 에서 언급했듯이 Python, GIR 및 GTK3 을 사용한 지표 작성은 Unity 지표를 작성하는 방법을 다루고 있다고 생각 합니다. (그것을 읽으십시오)

Ubuntu 14.04, Quickly 12.08.1을 사용하고 있습니다. 이 템플릿은 Quickly 템플릿을 사용한 완전한 실제 예제 빌드 데모입니다.

  1. OP는 GUI 응용 프로그램이 아닌 표시기를 원하므로 ubuntu-cli 빠른 템플릿으로 시작하십시오.

    quickly create ubuntu-cli indicator-demo

    이 템플릿에서 릴리스 되지 않은 버그 수정 ( bug # 1064110 )에 대한 오류 메시지가 표시 될 수 있습니다 .

    Creating project directory indicator-demo
    Creating bzr repository and committing
    Launching your newly created project!
    Traceback (most recent call last):
    ...
    OSError: [Errno 13] Permission denied
    ERROR: create command failed
    Aborting

    권한 수정

    cd indicator-demo/
    chmod +x bin/indicator-demo

    테스트

    $ quickly run
    I'm launched and my args are:
  2. Ubuntu Wiki : Application Indicators 의 멋진 PYGI 예제가 있습니다 . 통합하기 쉬워야합니다.

    편집을 위해 엽니 다.

    quickly edit
    • 수정 __init__.py, 필요한 모듈 가져 오기 추가 :

      from gi.repository import Gtk
      from gi.repository import AppIndicator3 as appindicator
    • 에서 main()함수 간의 :

      print _("I'm launched and my args are: %s") % (" ".join(args))
      logging.debug(_('end of prog'))

      더하다:

      ind = appindicator.Indicator.new_with_path (
                          _("Indicator demo for Quickly"),
                          "indicator-demo-icon-normal",
                          appindicator.IndicatorCategory.APPLICATION_STATUS,
                          indicator_democonfig.get_data_path())
      ind.set_status (appindicator.IndicatorStatus.ACTIVE)
      ind.set_attention_icon ("indicator-demo-icon-attention")
      
      # create a menu
      menu = Gtk.Menu()
      
      # create one item 
      menu_items = Gtk.MenuItem(_("Quit"))
      menu.append(menu_items)
      # this is where you would connect your menu item up with a function:
      menu_items.connect("activate", Gtk.main_quit )
      # show the item
      menu_items.show()
      
      ind.set_menu(menu)
      
      Gtk.main()
  3. 새로 작성된 데이터 폴더에 아이콘을 추가하십시오.

    mkdir data

    예제를 만들기 위해 설치된 패키지에서 일부 아이콘을 복사했습니다.

    cp /usr/share/icons/ubuntu-mono-dark/status/22/indicator-messages.svg data/indicator-demo-icon-normal.svg
    cp /usr/share/icons/ubuntu-mono-dark/status/22/indicator-messages-new.svg data/indicator-demo-icon-attention.svg
  4. 그것을 테스트하십시오 :

    quickly run
  5. 패키지를 작성하고 공개하십시오.

    quickly package
    quickly share --ppa your-ppa

노트:

  1. 글쎄, 데비안 패키지 제어 파일을 업데이트하지는 않았지만 생성 된 DEB에 종속성이 자동으로 추가되었습니다.

    Package: indicator-demo
    Version: 0.1
    Architecture: all
    Maintainer: UNKNOWN <UNKNOWN>
    Installed-Size: 57
    Depends: python (>= 2.7), python (<< 2.8), python:any (>= 2.7.1-0ubuntu2), gir1.2-gtk-3.0, gir1.2-appindicator3-0.1
    Section: python
    Priority: extra
    Description: UNKNOWN
     UNKNOWN

    또한 데이터 폴더에 이전에 추가 된 아이콘이 패키지에 포함되었습니다.

  2. 키보드 패널 수정 자 상태 애플릿을 Unity 패널에 추가하는 방법 과 비슷한 경우가 발생했습니다 . . 답은 libappindicator를 사용하는 예제 / 시제품 키보드 표시기를 포함합니다 (그러나 c 프로그래밍 언어에서는).

    libappindicator에는 다른 데스크탑 표시기를 쉽게 이식 할 수있는 중요한 기능이 없습니다. 아이콘은 경로에서만로드 할 수 있습니다. 버그 # 812067 API 필요 : pixbuf 아이콘 설정 지원 참조

참고 문헌 :

관련 질문 :


답변

링크는 GMail과 함께 작동하는 python + unity로 기본 새 메일 표시기를 작성하는 방법을 알려줍니다. 이렇게하면 애플릿의 기본 구조를 확실하게 접지 할 수 있으며 쉽게 확장 할 수있는 실제 (단순하지만) 예제를 제공 할 수 있습니다. 최종 스크립트를 하나씩 살펴 봅니다.
이것은 코드에 주석이있는 또 다른 파이썬 프로그램입니다. Pygtk