파이썬으로 PDF 결합 GUI 만들기 3

마지막회 그 3

그 1 Tkinter로 UI 작성
그 2 PyPDF2로 PDF 조작
그 3 pyinstaller로 exe화+아이콘을 붙인다

아이콘 찾기



무료 아이콘을 iconfinder 에서 검색
python (가라가라 뱀)보다 cobra (코브라)?


아이콘을 창에 포함



아래의 ▼를 누르면 png의 base64 encode가 표시되므로 복사하여 아래와 같이 코드에 삽입합니다.
(옆에 길고 죄송합니다)
#アイコンpngファイルのbase64エンコード
data = '''iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAALLElEQVR4Xu1ba5AcVRX+unu6e2Z2N/vKbnbzUAtE0EITFUEQIiBIUkEpA6gBUyaEVIlFIfKQACoWlMojEMDwCgGEQAChKAp5RSC8IlWSSAIBCxFjCHntbja7O5OZ6emn9d2ZnvTO9szsbjZmhvL8SWanb8+93z33PL5zroRRSPLg+nbNdNcBmDKK4WMy5MWMYzyTsRbdnnJv2ZcXSqMZbE2OftOV5FdGM3asxjybcXBWbxbz4/KF+wJCMQBHAKivNMnz6tRps+vkJZWeG+vvJykyDo7kpkwAvrcri5iEfQIhCMChAN4f60mP5fvaZAlbJ8UGAcAP+wJCEIBpANaP5YTH+l11ErB7cnwIAPxDVALOGcVxGDYAi5s0TFAkcBIygF7Xw99MFytTNvZ4uaX+uC6C43QZTbKECAATwFbbwxrTwdMZB2b+OT77w3gEJ0X5pqFyXp8JK/Cs/0Q5AEYLwrAByE7JIV8s/7I9HN9lYJfr4cnxOmbGlNDn/m17mLMri7ctV3x/Y5OG8xsI01Bp3JqGMQoAfBDmxdWL7kxZw7JRIwbghoSFB1IOjtFlLG3WoErAjUkLV/RbBQDesVws6DVRJwMnRxVc0qBCl4Ae18OXdxjiXx8AatKifmsQCg+lbDghwFTSAH8Ij8NwQRgxABf2mbhjjy1+66k2HadEFbxsOJjRky0A8FrWxcndRmEJs+MKHm7VxeerByz8NmEVANhiezhkRyZUE4r/OFwARqIJowaAO7qhI4aDIhL+lHYwt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PhfJag4nysiO6so64JTtuR5ihrYzYgou7TNxT2ovg8zvSH1T1f1EmNFj+7a9vcdnxhU8WI02gBXfVfk637I9VqGRisEMd5yRXWee8jq7LiISIMqVAxYWF/GItzVrODdApNZvTRciRjZ3vePzhdVgA+ixeZaZvfEyxZWNKmbHFMEM0eBRpusKnmvXccHu3I77Bo27zaNBDmBjoL2WydE/J8YEh8g6wafzmsN3TVIkbJqY61KtChvAnJ+VHF9onN7qiIpg5oQuo3BPgJcpLqhXMW1nRmhHoyzhgVZN9AYQlJ8W0ekkRUmO+qmx/352qK6ZkGeMD7QGrDIcfDfQGs8y2NWNmrj0RAl2kvIzqTCmw8HFnhpTRN2A7n5FmukyMCuq4Ow6BYsTtri8ERTalN835TLGA64Bx3YZwp1RrmpUccW4/MTyM6YBm7bTEDwhhXZg7YQobt1j4Q+B8hm/I1FK1a+TJLBrPeyOAXFlvYCFk/0OACe/0fKw2XbR50Jka01yzhd/RZVFhzl9NOXEqIJn2/RQ/o6BCxMZP7o/QstR3swCby7a3UFbHfLhrHgE97UGCq376wjwDsDDaVuQm++YrrgTFBSeX8fzBKnBtha2sLCFvpTwXaz2+q34zPnpzx/PsBRmlWzVDb6PARJJ0kEVpv0FQPFCeGnqoZSDe1O2ICeCQrWn+lcSMsSsHD2ZcYSK84bKilZNJD+3JG3w3gJjhTCh63usVYPf31x45n8FgP+DrP5e3s9bZrZQdxY6lreGVG3LoMElfmx7SHiecGlssKbwiNCesI1mk+0i4dJTAMfoijCK1LQhMlYAjPTyNP07LT0rOAdUJGmRviV1XXAOo5qR11HfZqri+vynDuiCRvDjruQlIxJmqB9l3ggO+y9K+1GbbWc4vwAAAABJRU5ErkJggg==
     ''' 

root.tk.call('wm', 'iconphoto', root._w, tkinter.PhotoImage(data=data))

할 수 있었습니다!


pyinstaller로 exe 파일 만들기



파이썬이 없는 환경에서도 움직일 수 있도록 exe화
아이콘 파일 MergerIcon.ico를 .py 파일과 같은 폴더에 둡니다.
콘솔에서 다음과 같이 작성
pyinstaller --onefile --noconsole --icon=MergerIcon.ico PDFMerger_01_qiita.py 

dist 폴더에 exe 파일이 생겼습니다!
파일 크기가 8M 이상인 것은 왜? !


참고



요약



치열한 코드 · 투고 기사를 보아 주셔서 감사합니다.
다음은 PDF의 전자 서명 툴(샤치하타 대신)에 대해서 투고 예정입니다.

좋은 웹페이지 즐겨찾기