Skip to content

Commit

Permalink
adds fix to prevent missing image files due to local filepaths
Browse files Browse the repository at this point in the history
  • Loading branch information
JeaustinSirias committed Nov 5, 2020
1 parent fbb9e31 commit e3b933e
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ celerybeat.pid
# Environments
.env
.venv
.vscode
env/
venv/
ENV/
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include README.md
include source/image/*.gif
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name='SMPG-Project',
packages=['test', 'source'],
packages=['test', 'source', 'source.image'],
entry_points={'console_scripts': ['runfile = source.build:main']},
version='1.2.0',
description='This is a rainfall forecast generator & analysis tool',
Expand All @@ -18,5 +18,6 @@
author_email='jeaustin.sirias@ucr.ac.cr',
url='https://github.com/JeaustinSirias/Seasonal_Monitoring_Probability_Generator',
license=license,
include_package_data=True,
)

22 changes: 18 additions & 4 deletions source/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,31 @@
# Copyright (c) 2020 Jeaustin Sirias
#
import os
import tkinter as tk
import webbrowser
from .utils import *
from .core import smpgTool
import tkinter as tk
from ttk import Combobox
import webbrowser

'''
script_dir = os.path.dirname(__file__)
rel_path = 'image/'
abs_file_path = os.path.join(script_dir, rel_path)
current_file = 'background.gif'
current_file2 = 'icon.gif'
file1 = abs_file_path + current_file
file2 = abs_file_path + current_file2
'''

class App():
def __init__(self, master):

# LOADING ABS PATH
files = 'background.gif', 'icon.gif'
bgs, icon = filepath('image/', *files)

# BACKGROUND CANVAS
self.background = tk.PhotoImage(file='./source/image/background.gif')
self.background = tk.PhotoImage(file=bgs)
bg = tk.Canvas(master, width=800, height=100)
bg.create_image(0, 0, image=self.background, anchor='nw')
bg.pack()
Expand All @@ -24,7 +38,7 @@ def __init__(self, master):
master.title('SMPG Project v1.2.0')

# WINDOWED LOGO
self.logo = tk.PhotoImage(file='./source/image/icon.gif')
self.logo = tk.PhotoImage(file=icon)
master.iconphoto(True, self.logo)

# GUI ATTRIBUTES
Expand Down
2 changes: 1 addition & 1 deletion source/image/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#from .api import App
from .dirpath import images
6 changes: 6 additions & 0 deletions source/image/dirpath.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2020 Jeaustin Sirias
#
def images():
return
7 changes: 7 additions & 0 deletions source/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# Copyright (c) 2020 Jeaustin Sirias
#
import os
import numpy
import pandas
from scipy.stats import rankdata
Expand Down Expand Up @@ -342,5 +343,11 @@ def lt_stats(act_accums, sstats, estats):

return lt_sts
#============================================================
def filepath(rel_path, *filenames):
path = os.path.dirname(__file__)
abspath = os.path.join(path, rel_path)
paths = [abspath + files for files in filenames]
return paths
#============================================================
#============================================================

0 comments on commit e3b933e

Please sign in to comment.