I needed to turn the python app into a standalone app, so I did a lot of research. There were various conversion tools, but in the end I decided to use pyinstaller. By the way, using qtcreator makes it really easy to create a GUI. (It costs money after the free period.)
OUTLINE --Environment --Create an environment with pyenv
MacOSX El Capitan 10.11.5
python3.5.0 (homebrew pyenv-virtualenv)
qt5,pyqt5 (homebrew)
I feel that there are many people who manage the python version with pyenv in the mac environment, and there are many people who put pyenv and qt with homebrew, but even if I look for a set of information, it comes out quite easily. There wasn't.
When I try to use pyinstaller with python3.5.0 which I put in pyenv without thinking about anything I don't have libpython3.4.dylib! Error. It seems that python must be included as a framework. I had to be careful about compiling and install python.
env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install -v 3.5.0
~I'm going to do various things.~
pyenv virtualenv 3.5.0 stand_app
And this too.
pip install --upgrade pip
PyQt5 Install for the time being
brew install pyqt5 --with-python
It seems that pyqt cannot be installed with pip, so pyqt5 installed with brew can be used by symbolically linking it to the pyenv environment.
ln -s /usr/local/Cellar/pyqt5/5.6/lib/python3.5/site-packages/PyQt5/ /usr/local/opt/pyenv/versions/stand_app/lib/python3.5/site-packages/
You can use it for the time being. It's a little bit harsh. ..
pyinstaller pyinstaller can be installed from pip.
pip install pyinstaller
For the time being, write a simple qt app.
Save the following as qt.py
import sys
from PyQt5.QtWidgets import (QWidget, QToolTip,
QPushButton, QApplication)
from PyQt5.QtGui import QFont
from PyQt5.QtCore import QCoreApplication
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
QToolTip.setFont(QFont('SansSerif', 10)) #font-Specifying family and font size
self.setToolTip('This is a <b>QWidget</b> widget')#Insert a tooltip with the mouse on.
btn = QPushButton('Button', self) #Button generation
btn.setToolTip('This is a <b>QPushButton</b> widget') #Insert a tooltip with the mouse on.
btn.clicked.connect(QCoreApplication.instance().quit) #Press the button to close the screen
btn.resize(btn.sizeHint()) #It specifies a nice button size and button effect.
btn.move(50, 50)#Button position setting
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('Tooltips')
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
And finally this is the one I've been waiting for. From the command line
pyinstaller --onefile --windowed qt.py
Dorya. ./dist/ qt.app Can be done! !! !! !!
I did it! !!
Recommended Posts