반응형
# PySide 를 사용하는 경우
import os
import sys
from PySide6.QtWidgets import *
from PySide6.QtCore import Qt
from PySide6 import QtUiTools
# pyinstaller .ui 파일 포함
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_path, relative_path)
form = resource_path('kakao_sender.ui')
form_class = QtUiTools.loadUiType(form)[0]
# PyQt5 를 사용하는 경우
import sys
import os
from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt
from PyQt5 import uic
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_path, relative_path)
form = resource_path('untitled.ui')
form_class = uic.loadUiType(form)[0]
pyinstaller test.py --onefile --noconsole
a = Analysis(['test.py'],
...
datas=[ ('untitled.ui', '.') ],
...)
pyinstaller test.spec
반응형
'코드보관소 > Python' 카테고리의 다른 글
[python] 2진수 비트를 뒤집는 방법 (0) | 2023.05.11 |
---|---|
[python] CRC-16 msb fast , lsb fast 생성 함수 (0) | 2023.05.11 |
파이스크립트 테스트 (0) | 2022.07.03 |
[win32api] WM_MESSAGE CONSTANCE (0) | 2021.07.20 |
[python] hello, world! (0) | 2021.05.02 |