Skip to content

Commit

Permalink
GUI recipe for Windows binary
Browse files Browse the repository at this point in the history
GUI runs flawlessly in a Windows exe packing
  • Loading branch information
bitlogik committed Sep 6, 2019
1 parent 1b98ca7 commit 6bcb1cd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.pyc
CoinList.db
dist
build

13 changes: 9 additions & 4 deletions GUI_crypto_prices.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>

import HomeTicker
import sys

try:
import tkMessageBox
except Exception as err:
print err
quit()
sys.exit()
import Tkinter
try:
myhometicker = HomeTicker.HomeTicker()
myhometicker.write("Loading ... ")
except Exception as error_msg:
Tkinter.Tk().withdraw()
tkMessageBox.showerror("HomeTicker Error", error_msg)
raise
sys.exit()

import urllib
import json
Expand All @@ -41,6 +43,9 @@ if os.name == 'nt':
import ctypes
myappid = 'fr.bitlogik.GUIHT.001'
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
def resource_path(relative_path):
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_path, relative_path)

# Getting the coin list
CoinListDBFileName = 'CoinList.db'
Expand All @@ -63,7 +68,7 @@ else:
tkMessageBox.showerror("Internet error",
"Can't reach the data server.\nPlease check your connection.\n\n" )
myhometicker.close()
raise
sys.exit()
# Sorting and cleaning the data
coin_list_keyrank = {}
coin_list_keyname = {}
Expand Down Expand Up @@ -236,7 +241,7 @@ master.resizable(False, False)
leftframe = Tkinter.Frame(master, padx=30, pady=20)
leftframe.winfo_toplevel().title("HomeTicker CryptoCurrencies Prices")
if os.name == 'nt':
leftframe.winfo_toplevel().wm_iconbitmap(bitmap='HTicon.ico')
leftframe.winfo_toplevel().wm_iconbitmap(bitmap=resource_path('HTicon.ico'))
else:
leftframe.winfo_toplevel().wm_iconbitmap(bitmap='@HTicon.xbm')
leftframe.pack(fill=Tkinter.Y)
Expand Down
30 changes: 30 additions & 0 deletions GUI_crypto_prices.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- mode: python ; coding: utf-8 -*-

block_cipher = None
a = Analysis(['GUI_crypto_prices.pyw'],
binaries=[],
datas=[('HTicon.ico','.')],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='HT-GUI',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False )

0 comments on commit 6bcb1cd

Please sign in to comment.