터미널에서 Inkscape 프로그램을 제어하려고합니다. 예를 들어, 프로그램 자체에서 메뉴를 클릭 할 필요없이 터미널에서 Inkscape의 파일 메뉴, 편집 메뉴 또는 확장 메뉴를 열고 싶습니다.
많이 검색했지만 내 문제에 대한 답을 찾을 수 없습니다. 터미널에서 그래픽 프로그램을 어떻게 제어합니까?
ldtp 가 Inkscape GUI를 자동화하는 데 도움이 될 수 있다고 확신합니다 . 먼저 터미널을 열고 Python 바인딩을 설치하십시오.
sudo apt-get install python-ldtp
그런 다음 파이썬 인터프리터를 시작하십시오.
$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ldtp import *
>>> launchapp('inkscape')
25362
>>> GTK Accessibility Module initialized
>>> selectmenuitem('*Inkscape', 'mnuExtensions')
또는 다음 스 니펫을 사용하여 전용 스크립트를 만듭니다.
#!/usr/bin/env python2
from ldtp import *
import time
launchapp('inkscape')
waittillguiexist('*-Inkscape')
selectmenuitem('*-Inkscape', 'mnuExtensions')
time.sleep(2)
selectmenuitem('*-Inkscape', 'mnuEdit')
time.sleep(2)
selectmenuitem('*-Inkscape', 'mnuFile')
time.sleep(2)
selectmenuitem('*-Inkscape', 'mnuQuit')
waittillguinotexist('*-Inkscape')
모든 GUI 구성 요소 이름을 아는 ldtpeditor
것은 더 이상 사용되지 않기 때문에 약간 어렵습니다 ( freedesktop 페이지 와 freedesktop-ldtp-dev 메일 링 목록의이 스레드 참조 ).
응용 프로그램을 자동화하는 데 사용할 컨트롤을 식별하기 위해 할 수있는 최선의 방법은 getobjectlist)('<window name>')
.
예 (Restack Horizontal 포인트 및 실시간 미리보기 설정) :
$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ldtp import *
>>> launchapp('inkscape')
11413
>>> GTK Accessibility Module initialized
>>> selectmenuitem('*Inkscape', 'Restack...')
1
>>> getobjectlist('Restack')
['dlgRestack', 'flr8', 'flr9', 'flr4', 'flr5', 'lblHorizontalPoint', 'flr7', 'flr0',
'flr1', 'flr2', 'flr3', 'lblVerticalPoint', 'mnuBottomtoTop(90)', 'mnuTop', 'spr1',
'mnu8', 'flr11', 'mnu0', 'cboLefttoRight(0)', 'mnuRight', 'mnuRadialInward',
'mnuMiddle1', 'mnu12', 'lblLivepreview', 'cboTop', 'flr6', 'mnuLefttoRight(0)',
'btnApply', 'lblAngle', 'chk0', 'mnuRighttoLeft(180)', 'mnuRadialOutward', 'sbtn0',
'mnuArbitraryAngle', 'lblRestackDirection', 'mnuLeft', 'btnClose', 'mnuMiddle',
'mnuBottom', 'flr12', 'flr10', 'spr0', 'mnuToptoBottom(270)', 'cboMiddle']
>>> click('dlgRestack', 'mnuMiddle1')
1
>>> click('dlgRestack', 'mnuMiddle')
1
>>> click('dlgRestack', 'chk0')
1
>>> click('dlgRestack', 'btnApply')
1
>>> click('dlgRestack', 'chk0')
1
>>> click('dlgRestack', 'btnApply')
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다