mountain_tapir package

Submodules

mountain_tapir.algorithm module

class mountain_tapir.algorithm.Algorithm[source]
COLLAGE = 0
FRAME = 2
GRID = 1

mountain_tapir.config module

class mountain_tapir.config.Config[source]
get(section, key, default=None, valueType='String')[source]

Get a value from the configuration.

Parameters:
  • section – The name of the config section.
  • key – The name of the option within the section.
  • default – Optional parameter specifying the default value.
update(section, key, value)[source]

Update a config entry and save the resulting options.

Parameters:
  • section – The name of the config section.
  • key – The name of the option within the section.
  • value – The value to set.

mountain_tapir.constants module

class mountain_tapir.constants.Constants[source]
INITIAL_HEIGHT = 400
INITIAL_REGIONS = 6
INITIAL_WIDTH = 600

mountain_tapir.controller module

class mountain_tapir.controller.Controller(model, uiVars)[source]
addRegions(delta)[source]

Change the number of regions. Note that the number of regions will not be decrease below one.

Parameters:delta – The change required in the number of regions (negative to decrease the number of regions).
adjustPreviewSize(event=None)[source]
clicked(canvas, region)[source]
initialise(preview, recentImages)[source]
putImageInPreviewRegion(imageFile, canvas, region)[source]

Put an image in a preview region (or remove the existing image if None is supplied)

redraw()[source]
redrawUsingImages(imageFiles)[source]

Redraw the preview pane and populate the regions using the supplied list of images.

Parameters:imageFiles – The list of image files to use. If there are more images than regions then some will not be

used. If there are fewer images than regions then some regions will end up empty.

refresh()[source]
save()[source]
selectPlaceTool(image)[source]
selectTool(tool)[source]

Select a tool.

setAlgorithm(algorithm)[source]

Create a new set of regions using the specified algorithm.

This will maintain the currently selected images in the new arrangement. It can also be used to create a new arrangement for the algorithm that was previously selected (this is useful e.g. in collage mode).

shuffle()[source]
updateHeight(event)[source]
updateWidth(event)[source]
mountain_tapir.controller.randColor()[source]

mountain_tapir.image_file module

class mountain_tapir.image_file.ImageFile(fileName)[source]

A class to provide image-based methods for a given file.

getImageObject(dimensions, purpose)[source]

Return a PIL.Image with the specified dimensions.

Parameters:
  • dimensions – An iterable pair - (width, height).
  • purpose – A string describing the purpose of the image. This is used for logging.
makeImage(purpose, dimensions, canvas)[source]

Make a PIL.Image and put it in the supplied canvas.

Parameters:
  • purpose – A string describing the purpose of the image. This is used for both logging and also when persisting the image so that TK doesn’t garbage collect it.
  • dimensions – An iterable pair - (width, height).
  • canvas – The tkinter.Canvas where the image will be displayed.
rotate()[source]

Rotate the image by 90 degrees.

Note that this rotates the image clockwise, as in a survey of random photos I found far more that needed a clockwise rotation than an anticlockwise rotation.

mountain_tapir.menu module

class mountain_tapir.menu.Menu(parent, controller)[source]

mountain_tapir.model module

class mountain_tapir.model.Model(config)[source]
getAlgorithm()[source]

Get the algorithm used to generate the collage.

getCurrentDirectory()[source]

Get the directory to start looking for images in.

getHeight()[source]

Get the height of the output collage.

getRegionCount()[source]

Get the number of regions in the collage.

getRegions()[source]

Get the regions in the collage.

getWidth()[source]

Get the width of the output collage.

setAlgorithm(algorithm)[source]

Set the algorithm used to generate the collage.

setCurrentDirectory(currentDirectory)[source]

Set the directory to start looking for images in.

setHeight(height)[source]

Set the height of the output collage.

setRegionCount(regionCount)[source]

Set the number of regions in the collage.

setRegions(regions)[source]

Set the regions in the collage.

setWidth(width)[source]

Set the width of the output collage.

mountain_tapir.mountain_tapir module

class mountain_tapir.mountain_tapir.MountainTapir(parent)[source]

mountain_tapir.preview module

class mountain_tapir.preview.Preview(parent, controller)[source]
clearAndCreateFrame(width, height)[source]

Clear the preview frame, then create a new one using the given dimensions.

Parameters:
  • width – The width of the new frame.
  • height – The height of the new frame.
createPreviewFrame(width, height)[source]

Create the preview frame using the given dimensions.

Parameters:
  • width – The width of the new frame.
  • height – The height of the new frame.

mountain_tapir.recent_images module

class mountain_tapir.recent_images.RecentImages(parent)[source]
addImage(imageFile, selectPlaceToolFunction)[source]
clearAll()[source]
createScrollFrame()[source]
updateImage(imageFile)[source]

mountain_tapir.region_maker module

class mountain_tapir.region_maker.RegionMaker[source]

A region is a tuple (left, top, width, height).

static findWorstRegion(regions)[source]
static makeCollageRegions(model)[source]

Start with the whole area as a region. Each iteration pick the ‘worst’ region and split it either horizontally or vertically at a random point. Remove the old region and add the two new regions.

The worst region is defined to be the region furthest from the TARGET_RATIO.

static makeFrameRegions(model)[source]
static makeGridRegions(model)[source]
static makeRegions(model)[source]

Split the preview pane into disjoint regions.

static ratioDiff(width, height)[source]

mountain_tapir.tool module

class mountain_tapir.tool.Tool[source]
EMPTY = 2
LOAD = 0
PLACE = 3
ROTATE = 4
SWAP = 1

mountain_tapir.ui_vars module

class mountain_tapir.ui_vars.UIVars(parent, model)[source]

Module contents