Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CONSTRUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ used on Windows. Possible values are `red`, `green`, `blue`, `yellow`.
The default is `blue`.


`welcome_image_text`:
----------------
If `welcome_image` is not provided, use this text when generating the image
(Windows only). Defaults to `name`.


`header_image_text`:
----------------
If `header_image` is not provided, use this text when generating the image
(Windows only). Defaults to `name`.


`add_to_path_default`:
----------------
Default choice for whether to add the installation to the PATH environment
Expand Down
10 changes: 10 additions & 0 deletions constructor/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@
The color of the default images (when not providing explicit image files)
used on Windows. Possible values are `red`, `green`, `blue`, `yellow`.
The default is `blue`.
'''),

('welcome_image_text', False, str, '''
If `welcome_image` is not provided, use this text when generating the image
(Windows only). Defaults to `name`.
'''),

('header_image_text', False, str, '''
If `header_image` is not provided, use this text when generating the image
(Windows only). Defaults to `name`.
'''),

('add_to_path_default', False, bool, '''
Expand Down
23 changes: 18 additions & 5 deletions constructor/imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,33 @@ def new_background(size, color, bs=20, boxes=50):
return im


def add_text(im, xy, text, min_lines, line_height, font, color):
x, y = xy
d = ImageDraw.Draw(im)
lines = text.splitlines()
text_height = len(lines) * line_height
min_text_height = min_lines * line_height
y = int(y * (im.height - text_height) / (im.height - min_text_height))
for line in text.splitlines():
d.text((x, y), line, fill=color, font=font)
y += line_height
return d


def mk_welcome_image(info):
font = ImageFont.truetype(ttf_path, 20)
im = new_background(welcome_size, info['_color'])
d = ImageDraw.Draw(im)
d.text((20, 100), info['name'], fill=white, font=font)
d.text((20, 130), info['version'], fill=white, font=font)
text = '\n'.join([info['welcome_image_text'], info['version']])
add_text(im, (20, 100), text, 2, 30, font, white)
return im


def mk_header_image(info):
font = ImageFont.truetype(ttf_path, 20)
im = Image.new('RGB', header_size, color=white)
d = ImageDraw.Draw(im)
d.text((20, 15), info['name'], fill=info['_color'], font=font)
text = info['header_image_text']
color = info['_color']
add_text(im, (20, 15), text, 1, 20, font, color)
return im


Expand Down
4 changes: 4 additions & 0 deletions constructor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def main_build(dir_path, output_dir='.', platform=cc_platform,
if verbose:
print('conda packages download: %s' % info['_download_dir'])

for key in ('welcome_image_text', 'header_image_text'):
if key not in info:
info[key] = info['name']

for key in ('license_file', 'welcome_image', 'header_image', 'icon_image',
'pre_install', 'post_install'):
if key in info:
Expand Down
9 changes: 9 additions & 0 deletions examples/grin/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,12 @@ license_file: eula.txt

# default install prefix
#default_prefix: /opt/example

# If `welcome_image` or `header_image` are not provided, their texts
# default to `name`, which may be overridden by the following keys
#welcome_image_text: |-
# multi-line
# welcome-text
#header_image_text: |-
# multi-line
# header-text