pymandel package

Submodules

pymandel.about_dialog module

About Dialog Box class for tkinter application.

Created on 3 Apr 2020

author:

semuadmin

copyright:

SEMU Consulting © 2020

license:

GPL3

This file is part of PyMandel.

PyMandel is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PyMandel is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PyMandel. If not, see <https://www.gnu.org/licenses/>.

class pymandel.about_dialog.AboutDialog(app)[source]

Bases: object

About dialog box class

__init__(app)[source]

Initialise Toplevel dialog

body()[source]

Set up widgets

ok_press(*args, **kwargs)[source]

Handle OK button press

pymandel.app module

Mandelbrot generator - Main tkinter application class

Created on 29 Mar 2020

author:

semuadmin

copyright:

SEMU Consulting © 2020

license:

GPL3

This file is part of PyMandel.

PyMandel is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PyMandel is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PyMandel. If not, see <https://www.gnu.org/licenses/>.

class pymandel.app.App(master)[source]

Bases: object

Main GUI Application Class

__init__(master)[source]

Set up main application and add frames

body()[source]

Set up frame and widgets

toggle_settings()[source]

Toggle Settings Frame on or off

toggle_status()[source]

Toggle Status Bar on or off

toggle_axes()[source]

Toggle plot axes on or off

set_status(message, color='black')[source]

Sets text of status bar

get_master()[source]

Returns application master (Tk)

howto()[source]

Open Howto dialog

about()[source]

Open About dialog

exit(*args, **kwargs)[source]

Kill any running processes and quit application

pymandel.fractal_frame module

Fractal frame class for tkinter application.

This handles all the user interaction (mouse and key clicks) and image mechanics.

Created on 3 Apr 2020

author:

semuadmin

copyright:

SEMU Consulting © 2020

license:

GPL3

This file is part of PyMandel.

PyMandel is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PyMandel is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PyMandel. If not, see <https://www.gnu.org/licenses/>.

class pymandel.fractal_frame.FractalFrame(app, *args, **kwargs)[source]

Bases: Frame

Frame inheritance class for plotting area.

__init__(app, *args, **kwargs)[source]

Constructor.

body()[source]

Set up frame and widgets.

plot()[source]

Plot Mandelbrot set as an ImageTk.PhotoImage and load this into the GUI’s Canvas widget for display.

axes(width, height)[source]

Draw complex space axes on plot. Bit simple - only really works at low magnifications

get_autoiter(zoom)[source]

Arbitrary algorithm to derive ‘optimal’ max iterations from zoom level.

cancel_press()[source]

Cancel in-progress plot.

get_size()[source]

Get current canvas size.

get_coords(event)[source]

Get and display complex space coordinates of current mouse location.

on_mouse_wheel(event)[source]

Zoom in and out using mouse wheel

Mouse wheel event.delta increment differs between Windows and MacOS/Linux platforms. These settings seem to work OK for Logitech and Apple wireless mice but may need to be tweaked for other devices

on_right_click(event)[source]

Right-Click - center and redraw image at mouse position.

on_left_click(event)[source]

Left-click - zoom in at cursor position (ZOOMIN mode). Left-click & Shift - zoom out (ZOOMOUT mode). Left-click & Ctrl-L or Alt-L - switch to Julia mode and plot Julia set corresponding to current cursor (cx, cy) position (GOJULIA mode).

on_key_down(event)[source]

Left-click - zoom in at cursor position (ZOOMIN mode). Left-click & Shift - zoom out (ZOOMOUT mode). Left-click & Ctrl-L or Alt-L - switch to Julia mode and plot Julia set corresponding to current cursor (cx, cy) position (GOJULIA mode). Left or Right Arrow keys - in Julia mode, rotate Julia set about its origin

(for some reason tkinter doesn’t appear to recognise an Alt-L event on all Windows platforms)

on_key_release(event)[source]

Revert to normal left-click mode (ZOOMIN)

on_button_down(event)[source]

Left-click - start to draw zoom area

on_button_drag(event)[source]

Left-drag - extend drawn zoom area

on_button_release(event)[source]

Left-release - zoom to drawn area

rotate_julia(angle)[source]

Rotate Julia set about its origin by the angle in radians

animate_zoom()[source]

Animate Julia spin mode

animate_spin()[source]

Animate zoom mode

animate(animatemode)[source]

Generates and saves a series of frames at a specified offset. The individual frames can then be assembled into e.g. an animated .gif or short video using external tools.

Also used to generate a ‘Spinning Julia’ animation, rotating a Julia Set anti-clockwise around its origin.

pymandel.howto_dialog module

How To Dialog Box class for tkinter application.

Created on 19 Apr 2020

author:

semuadmin

copyright:

SEMU Consulting © 2020

license:

GPL3

This file is part of PyMandel.

PyMandel is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PyMandel is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PyMandel. If not, see <https://www.gnu.org/licenses/>.

class pymandel.howto_dialog.HowtoDialog(app)[source]

Bases: object

How To dialog box class

__init__(app)[source]

Initialise Toplevel dialog

body()[source]

Set up widgets

ok_press(*args, **kwargs)[source]

Handle OK button press

pymandel.mandelbrot module

Mandelbrot & Julia set class for tkinter application.

This handles the computation of the Mandelbrot or Julia set as a numpy rgb array which is loaded into a ImageTk.PhotoImage (and ultimately into a Tk.Canvas for viewing in the GUI).

NB: use of Numba @jit decorators and pranges to improve performance. For more information refer to http://numba.pydata.org.

Created on 29 Mar 2020

author:

semuadmin

copyright:

SEMU Consulting © 2020

license:

GPL3

This file is part of PyMandel.

PyMandel is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PyMandel is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PyMandel. If not, see <https://www.gnu.org/licenses/>.

pymandel.mandelbrot.plot(imagemap, settype, setvar, width, height, zoom, radius, exponent, zxoff, zyoff, maxiter, theme, shift, cxoff, cyoff)[source]

Plots selected fractal type in the numpy rgb array ‘imagemap’

pymandel.mandelbrot.fractal(settype, setvar, width, height, x_axis, y_axis, zxoff, zyoff, zoom, maxiter, radius, exponent, cxoff, cyoff)[source]

Calculates fractal escape scalars i, za for each image pixel and returns them for use in color rendering routines.

pymandel.mandelbrot.ptoc(width, height, x, y, zxoff, zyoff, zoom)[source]

Converts actual pixel coordinates to complex space coordinates (zxoff, zyoff are always the complex offsets).

pymandel.mandelbrot.ctop(width, height, zx_coord, zy_coord, zxoff, zyoff, zoom)[source]

Converts complex space coordinates to actual pixel coordinates (zxoff, zyoff are always the complex offsets).

pymandel.mandelbrot.get_color(i, za, radius, maxiter, theme, shift)[source]

Uses escape scalars i, za from the fractal algorithm to drive a variety of color rendering algorithms or ‘themes’.

NB: If you want to add more rendering algorithms, this is where to add them, but you’ll need to ensure they are ‘Numba friendly’ (i.e. limited to Numba-recognised data types and suitably decorated library functions).

pymandel.mandelbrot.sel_colormap(i, za, radius, shift, theme)[source]

Select from indexed colormap theme

pymandel.mandelbrot.get_colormap(i, za, radius, shift, colmap)[source]

Get pixel color from colormap

pymandel.mandelbrot.normalize(i, za, radius)[source]

Normalize iteration count from escape scalars to produce smoother color gradients.

pymandel.mandelbrot.interpolate(col1, col2, ni)[source]

Linear interpolation between two adjacent colors in color palette.

pymandel.mandelbrot.hsv_to_rgb(h, s, v)[source]

Convert HSV values (in range 0-1) to RGB (in range 0-255).

class pymandel.mandelbrot.Mandelbrot(master)[source]

Bases: object

Main computation and imaging class.

__init__(master)[source]

Constructor

plot_image(settype, setvar, width, height, zoom, radius, exp, zxoff, zyoff, maxiter, theme, shift, cxoff, cyoff)[source]

Creates empty numpy rgb array, passes it to fractal calculation routine for populating, then loads populated array into an ImageTk.PhotoImage.

get_image()[source]

Return populated PhotoImage for display or saving.

get_cancel()[source]

Return kill flag.

cancel_plot()[source]

Cancel in-flight plot operation (plot is normally so quick this is largely redundant).

pymandel.mandelcli module

Mandelbrot generator

A command line utility which invokes the Mandelbrot class methods to create a sequence of Mandelbrot images as .png files. It is the command line equivalent of the GUI Animate function, but can also be used to generate single, very high resolution images.

Can also import settings from a previously saved metadata file.

Created on 29 Mar 2020

author:

semuadmin

copyright:

SEMU Consulting © 2020

license:

GPL3

This file is part of PyMandel.

PyMandel is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PyMandel is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PyMandel. If not, see <https://www.gnu.org/licenses/>.

class pymandel.mandelcli.BatchMandelbrot(**kwargs)[source]

Bases: object

Main class of command line utility

__init__(**kwargs)[source]

Command line utility class

animate() int[source]

Generates and saves a series of frames at a specific point and zoom increment.

import_metadata(filepath)[source]

Import settings from json metadata file.

get_autoiter(zoom)[source]

Arbitrary algorithm to derive ‘optimal’ max iterations from zoom level.

pymandel.mandelcli.main()[source]

Entry point for CLI.

pymandel.menu_bar module

Menubar class for tkinter application.

This handles the menu bar.

Created on 27 Mar 2020

author:

semuadmin

copyright:

SEMU Consulting © 2020

license:

GPL3

This file is part of PyMandel.

PyMandel is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PyMandel is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PyMandel. If not, see <https://www.gnu.org/licenses/>.

class pymandel.menu_bar.MenuBar(app, *args, **kwargs)[source]

Bases: Menu

Menu inheritance class for menu bar.

__init__(app, *args, **kwargs)[source]

Constructor

pymandel.settings_frame module

Settings frame class for tkinter application.

This handles all the settings and file storage/retrieval.

Created on 3 Apr 2020

author:

semuadmin

copyright:

SEMU Consulting © 2020

license:

GPL3

This file is part of PyMandel.

PyMandel is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PyMandel is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PyMandel. If not, see <https://www.gnu.org/licenses/>.

class pymandel.settings_frame.SettingsFrame(app, *args, **kwargs)[source]

Bases: Frame

Frame inheritance class for application settings and controls.

__init__(app, *args, **kwargs)[source]

Constructor

body()[source]

Set up frame and widgets.

body_arrange()[source]

Position widgets in frame

set_traces()[source]

Set up entry variable traces for validation and event handling

val_settings(*args, **kwargs)[source]

Validate all user-entered settings. (A personal choice but I find this user experience more intuitive than the standard validatecommand method for Entry widgets)

flag_entry(ent, flag)[source]

Flag entry field as valid or invalid and set global validity status flag. This flag is used throughout to determine whether functions can proceed or not.

is_float(flag)[source]

Validate if entry is a float.

is_integer(flag)[source]

Validate if entry is a positive integer.

is_filename(flag)[source]

Validate if entry represents a valid filename using a regexp.

reset()[source]

Reset settings to defaults.

get_sel_theme(*args, **kwargs)[source]

Get selected theme from listbox and set global variable.

set_sel_theme()[source]

Lookup index of selected theme and highlight that listbox position. NB: this requires ‘exportselection=False’ option to be set on listbox to work properly.

get_settings()[source]

Return all current settings as a dict.

update_settings(**kwargs)[source]

Update settings from keyword parms.

set_filepath()[source]

Sets filepath for saved files for the duration of this session.

save_image()[source]

Save image as PNG file to selected filepath and automatically increment default image name. NB: currently this will overwrite any existing file of the same name without warning.

save_metadata()[source]

Save json file containing meta data associated with image, allowing it to be imported and reproduced.

import_metadata()[source]

Update settings from imported json metadata file.

pymandel.status_frame module

Status Bar frame class for tkinter application.

This handles the status bar notifications.

Created on 7 Apr 2020

author:

semuadmin

copyright:

SEMU Consulting © 2020

license:

GPL3

This file is part of PyMandel.

PyMandel is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PyMandel is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PyMandel. If not, see <https://www.gnu.org/licenses/>.

class pymandel.status_frame.StatusFrame(app, *args, **kwargs)[source]

Bases: Frame

Frame inheritance class for _status bar.

__init__(app, *args, **kwargs)[source]

Constructor

body()[source]

Set up frame and widgets.

set_status(message, color='black')[source]

Sets text of status bar.

clear_status()[source]

Clears text of status bar.

pymandel.strings module

ENGLISH language string literals for PyMandel tkinter application

Created on 22 Apr 2020

author:

semuadmin

copyright:

SEMU Consulting © 2020

license:

GPL3

This file is part of PyMandel.

PyMandel is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PyMandel is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PyMandel. If not, see <https://www.gnu.org/licenses/>.

pymandel.stringsDE module

DEUTSCHE Sprachzeichenfolgenliterale für die PyMandel tkinter-Anwendung

Erstellt am 22. April 2020

@author: semuadmin

pymandel.stringsEN module

ENGLISH language string literals for PyMandel tkinter application

Created on 22 Apr 2020

@author: semuadmin

pymandel.stringsES module

Literales de cadena de idioma ESPAÑOL para la aplicación PyMandel tkinter

Creado el 22 abr 2020

@autor: semuadmin

pymandel.stringsFR module

Littéraux de chaîne de langue FRANCAIS pour l’application PyMandel tkinter

Créé le 22 avr 2020

@author: semuadmin

Module contents

Created on 27 Sep 2020

author:

semuadmin

copyright:

SEMU Consulting © 2020

license:

GPL3

This file is part of PyMandel.

PyMandel is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PyMandel is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PyMandel. If not, see <https://www.gnu.org/licenses/>.