Skip to content

Commit

Permalink
v0.2.1, minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jankukacka committed Nov 11, 2021
1 parent f5bc25e commit d937c4c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 22 deletions.
2 changes: 1 addition & 1 deletion about.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, master, skin):
frame = tk.Frame(frame, bg='#ff0000')
frame.pack(side=tk.TOP, expand=True, fill=tk.X, padx=10)
tk.Label(frame, text='Image Viewer MK2', fg=self.skin.fg_color, bg=self.skin.bg_color, font=('Segoe UI', 14, 'bold')).pack(side=tk.TOP, expand=False, fill=tk.X)
tk.Label(frame, text='v0.2.0 (2021-11-10)', fg=self.skin.fg_color, bg=self.skin.bg_color).pack(side=tk.TOP, expand=False, fill=tk.X)
tk.Label(frame, text='v0.2.1 (2021-11-11)', fg=self.skin.fg_color, bg=self.skin.bg_color).pack(side=tk.TOP, expand=False, fill=tk.X)
tk.Label(frame, text='Author: Jan Kukačka, 2021', fg=self.skin.fg_color, bg=self.skin.bg_color).pack(side=tk.TOP, expand=False, fill=tk.X)
tk.Label(frame, text='Provided under MIT license.', fg=self.skin.fg_color, bg=self.skin.bg_color).pack(side=tk.TOP, expand=False, fill=tk.X)
tk.Label(frame, text='Icon credits: Icon home, Gregor Cresnar,\nFreepik and Pancracysdh.', fg=self.skin.fg_color, bg=self.skin.bg_color).pack(side=tk.TOP, expand=False, fill=tk.X)
Expand Down
36 changes: 30 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# ------------------------------------------------------------------------------

import numpy as np

import argparse
try:
from . import view as view_
from . import model as model_
Expand All @@ -18,6 +18,18 @@
import model as model_
import presenter as presenter_


# argument parsing
parser = argparse.ArgumentParser(description='Image Viewer MKII: Spectral image viewer')
parser.add_argument('-i', '--input', type=str, help='Filename of the image to open', default=argparse.SUPPRESS)
parser.add_argument('-c', '--config', type=str, help='Filename of the config file to import', default=argparse.SUPPRESS)

parser.add_argument('-d', '--debug', help='Print errors to console.', action='store_true', default=argparse.SUPPRESS)
parser.add_argument('-g', '--gpu', help='Use GPU rendering (default)', action='store_true', default=argparse.SUPPRESS)
parser.add_argument('-ng', '--no_gpu', help='Use CPU rendering', action='store_true', default=argparse.SUPPRESS)



def main(file=None, image=None, **kwargs):
'''
Starts the app and opens optionally given file or uses given image.
Expand All @@ -39,7 +51,7 @@ def main(file=None, image=None, **kwargs):
- (config dictionary. Only if return_config was set to True.)
'''

gpu = False
gpu = True
if 'gpu' in kwargs:
gpu = kwargs['gpu']

Expand Down Expand Up @@ -81,7 +93,19 @@ def main(file=None, image=None, **kwargs):

if __name__ == '__main__':
import sys
files = sys.argv[1:]
if len(files) == 0:
files = [None]
main(files[0])
kwargs = vars(parser.parse_args(sys.argv[1:]))
kwargs2 = {}

if 'no_gpu' in kwargs:
kwargs2['gpu'] = not kwargs['no_gpu']
if 'gpu' in kwargs:
kwargs2['gpu'] = kwargs['gpu']
if 'input' in kwargs:
kwargs2['file'] = kwargs['input']
if 'config' in kwargs:
kwargs2['config_filename'] = kwargs['config']
if 'debug' in kwargs:
kwargs2['debug'] = kwargs['debug']

print('Image Viewer MKII. Jan Kukacka, 2021')
main(**kwargs2)
16 changes: 4 additions & 12 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,29 +230,21 @@ def update_render(self, event=None):

def save(self):
model_dict = {}
# model_dict['colors'] = list(self.colors)
# model_dict['color_space'] = self.color_space
# model_dict['imoptions'] = dict(self.imoptions)
model_dict['channel_props'] = [dict(cp) for cp in self.channel_props]
# model_dict['special_options'] = dict(self.special_options)
return model_dict

def load(self, model_dict):
## Suspend rendering while loading
self.suspend_render = True

# for i, color in enumerate(model_dict['colors']):
# self.colors[i] = color
# self.color_space = model_dict['color_space']
# for key, value in model_dict['imoptions'].items():
# self.imoptions[key] = value
for i, channel_property in enumerate(model_dict['channel_props']):
if i >= len(self.channel_props):
break
for key, value in channel_property.items():
self.channel_props[i][key] = value
# if 'special_options' in model_dict:
# self.special_options = model_dict['special_options']
if key in self.channel_props[i]:
self.channel_props[i][key] = value
else:
print(f'Config key {key} could not be loaded.')

self.suspend_render = False
self.update_render()
Expand Down
3 changes: 0 additions & 3 deletions presenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,6 @@ def color_onchage(self):
if is_color_like(color) and channel_index < len(self.model.channel_props):
self.model.channel_props[channel_index]['color'] = str(to_hex(color))

# def colorspace_onchange(self, var):
# self.model.color_space = var.get()

def channel_var_onchange(self, var, key, cindex=None):
if cindex is None:
cindex = self.view.get_active_channel()
Expand Down
5 changes: 5 additions & 0 deletions tk_call_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ def __call__(self, *args):
raise SystemExit(msg)

except tk.TclError as err:
## Raised when numbers from textboxes cannot be parsed
pass

except ValueError as err:
## Raised when colors from textboxes cannot be parsed
pass

0 comments on commit d937c4c

Please sign in to comment.