Pacharapol Withayasakpunt Pacharapol Withayasakpunt
Tue, February 13, 2018
[Python-web.py] Turning website into a desktop app

This is what I have got:

from ui.mainWindow import MainWindow
from webview.controller import initServer

from PyQt5.QtWidgets import *
import sys
import httplib2
from time import sleep

if _<i>name_</i> == '__main__':
    initServer().start()

    h = httplib2.Http()
    while True:
        try:
            resp = h.request("http://0.0.0.0:8080/", 'HEAD')
            break
        except ConnectionRefusedError:
            sleep(1)
            continue

    app = QApplication(sys.argv)
    window = MainWindow()
    window.showUI()
    window.setBaseSize(1000, 600)
    window.move(QDesktopWidget().rect().center().x()-window.rect().center().x(), window.rect().y())
    sys.exit(app.exec_())
Pacharapol Withayasakpunt Pacharapol Withayasakpunt
Fri, January 26, 2018
A successful py2app setup.py code

py2app and py2exe are how to compile a Python package bundle into a single file app. However, I had problem simply running py2applet --make-setup PatientLogbook.py database/user.db, so I have to edit the config file myself.

Root causes of the problem running python setup.py py2app include the following.