Skip to content

Commit

Permalink
Merge pull request #14 from Myoldmopar/AddConfigureStep
Browse files Browse the repository at this point in the history
Add configure step
  • Loading branch information
Myoldmopar committed Apr 6, 2023
2 parents 14251cc + f9e0fbf commit 1e1d29c
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 19 deletions.
6 changes: 4 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ Installation
This program should be installed from PyPi using ``pip install energyplus_pet``.
Once installed, a new command will be available from that Python environment called ``energyplus_pet_gui``, with a
``.exe`` appended on Windows. Run this one time right from the command line where ``pip`` was executed to launch the
program. For easier access, there is an option in the top menu that allows creating a desktop icon. After that is
performed, the user can just launch the program right from the desktop icon.
program. For easier access, there is an additional executable right next to the main gui executable. The name
is ``energyplus_pet_configure``. Simply execute this binary entry point and it will create a desktop shortcut on
Windows, or install a .desktop launcher on Linux, or create an .app bundle on MacOS. After that, the user should be
able to launch the program from this icon, or from the system shell/spotlight/searcher/start menu.

To get updates to the program, you simply need to install the latest version using the same ``pip`` version, but let
``pip`` know that it can upgrade existing package installations: ``pip install --upgrade energyplus_pet``
Expand Down
2 changes: 1 addition & 1 deletion energyplus_pet/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NICE_NAME = "EnergyPlus P.E.T."
VERSION = "0.44"
VERSION = "0.45"
10 changes: 10 additions & 0 deletions energyplus_pet/configure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from plan_tools.entry_point import EntryPoint


def configure_cli() -> None:
source_dir = "energyplus_pet"
name = "energyplus_pet_gui"
description = "An EnergyPlus Parameter Estimation Tool"
nice_name = "EnergyPlus P.E.T."
s = EntryPoint(source_dir, name, nice_name, description, name)
s.run()
Binary file removed energyplus_pet/forms/favicon.ico
Binary file not shown.
Binary file removed energyplus_pet/forms/favicon.png
Binary file not shown.
36 changes: 24 additions & 12 deletions energyplus_pet/forms/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from pathlib import Path
from queue import Queue
from subprocess import check_call
from sys import executable
from threading import Thread
from tkinter import BOTH, LEFT, RIGHT, TOP, BOTTOM, X, Y # widget sides and directions to use in widget.pack commands
from tkinter import END # key used when adding data to the scrolledText object
Expand All @@ -15,7 +14,7 @@
from tkinter.ttk import LabelFrame, Progressbar, Treeview, Separator, Notebook # ttk widgets
from webbrowser import open as browser_open

from pyshortcuts import make_shortcut
from plan_tools.runtime import fixup_taskbar_icon_on_windows

from energyplus_pet import NICE_NAME, VERSION
from energyplus_pet.forms.correction_detail_form import DetailedCorrectionFactorForm
Expand Down Expand Up @@ -45,6 +44,29 @@ def __init__(self):
self._program_name = NICE_NAME
program_name_with_version = f"{self._program_name} {VERSION}"
self.title(program_name_with_version)
# add the taskbar icon, but its having issues reading the png on Mac, not sure.
if system() == 'Darwin':
self.icon_path = Path(__file__).resolve().parent.parent / 'icons' / 'icon.icns'
if self.icon_path.exists():
self.iconbitmap(str(self.icon_path))
else:
print(f"Could not set icon for Mac, expecting to find it at {self.icon_path}")
elif system() == 'Windows':
self.icon_path = Path(__file__).resolve().parent.parent / 'icons' / 'icon.png'
img = PhotoImage(file=str(self.icon_path))
if self.icon_path.exists():
self.iconphoto(False, img)
else:
print(f"Could not set icon for Windows, expecting to find it at {self.icon_path}")
else: # Linux
self.icon_path = Path(__file__).resolve().parent.parent / 'icons' / 'icon.png'
img = PhotoImage(file=str(self.icon_path))
if self.icon_path.exists():
self.iconphoto(False, img)
else:
print(f"Could not set icon for Windows, expecting to find it at {self.icon_path}")
fixup_taskbar_icon_on_windows(NICE_NAME)

icon_path = Path(__file__).parent / 'favicon.png'
image = PhotoImage(file=str(icon_path))
self.iconphoto(True, image)
Expand Down Expand Up @@ -152,7 +174,6 @@ def _build_menu(self):
menu_help = Menu(menubar, tearoff=0)
menu_help.add_command(label="Open online documentation...", command=self._help_documentation)
menu_help.add_command(label="Open examples folder...", command=self._open_examples)
menu_help.add_command(label="Create desktop icon", command=self._create_shortcut)
menu_help.add_command(label="About...", command=self._help_about)
menubar.add_cascade(label="Help", menu=menu_help)
self.config(menu=menubar)
Expand Down Expand Up @@ -274,15 +295,6 @@ def _help_documentation(self):
browser_open('https://energypluspet.readthedocs.io/en/stable/')
self._update_status_bar('Launched online documentation')

def _create_shortcut(self):
runner_script = str(Path(__file__).resolve().parent.parent / 'runner.py')
icon_extension = 'ico' if system() == 'Windows' else 'png'
icon_path = str(Path(__file__).resolve().parent / f"favicon.{icon_extension}")
make_shortcut(
runner_script, name=self._program_name, terminal=False, icon=icon_path,
executable=executable, startmenu=False
)

@staticmethod
def _open_examples():
examples_dir = str(Path(__file__).resolve().parent.parent / 'examples')
Expand Down
Binary file added energyplus_pet/icons/icon.icns
Binary file not shown.
Binary file added energyplus_pet/icons/icon.ico
Binary file not shown.
Binary file added energyplus_pet/icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ numpy
scipy
pyperclip
tksheet
pyshortcuts

# for building documentation
sphinx
Expand All @@ -22,3 +21,6 @@ coveralls # really just for github, but it's fine

# for building wheels, mostly from github, but it's fine
wheel

# for polishing up the Pip install
PLAN-Tools==0.5
12 changes: 9 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
import pathlib
from platform import system
from setuptools import setup

from energyplus_pet import VERSION

readme_file = pathlib.Path(__file__).parent.resolve() / 'README.md'
readme_contents = readme_file.read_text()

install_requires = ['pyperclip', 'tksheet', 'matplotlib', 'numpy', 'scipy']
if system() == 'Windows':
install_requires.append('pypiwin32')

setup(
name="energyplus_pet",
version=VERSION,
packages=['energyplus_pet', 'energyplus_pet.forms', 'energyplus_pet.equipment'],
description="Parameter Estimation Tools for Generating EnergyPlus Inputs from Raw Performance Data",
package_data={"energyplus_pet.forms": ["*.png", "*.ico"], "energyplus_pet": ["examples/*.ods"]},
package_data={"energyplus_pet": ["icons/*.png", "icons/*.ico", "icons/*.icns", "examples/*.ods"]},
include_package_data=True,
long_description=readme_contents,
long_description_content_type='text/markdown',
author='Edwin Lee',
author_email='a@a.a',
url='https://github.com/Myoldmopar/EnergyPlusPet',
license='UnlicensedForNow',
install_requires=['pyperclip', 'tksheet', 'matplotlib', 'numpy', 'scipy', 'pyshortcuts'],
install_requires=install_requires,
entry_points={
'console_scripts': ['energyplus_pet_gui=energyplus_pet.runner:main_gui']
'gui_scripts': ['energyplus_pet_gui=energyplus_pet.runner:main_gui'],
'console_scripts': ['energyplus_pet_configure=energyplus_pet.configure:configure_cli',]
}
)

0 comments on commit 1e1d29c

Please sign in to comment.