File: frigcal-products/unzipped/frigcal_configs_base.py

# -*- coding: utf-8 -*-
r"""
======================================================================================
frigcal_configs_base.py:
Default configuration settings, in Python code, loaded at frigcal startup.

DON'T EDIT THIS FILE: instead, tailor your frigcal's appearance and behavior
by adding code to "frigcal_configs.py" that reassigns any of the names here.
That way, your settings will be immune to changes in this file on upgrades.

This file is shipped in UTF-8 Unicode and Windows end-line formats; see
UserGuide.html's "Using the Program" => "Configurations File" section. 

BASE AND USER FILES
-------------------
As of version 2.0, configuration settings are now split into two files:

    frigcal_configs_base.py
        this base file, with system-provided defaults and examples

    frigcal_configs.py
        the user file, with any user-provided customizations (EDIT THIS)

These files are related and used by frigcal as follows:

  -The base file has all the preset defaults, and may change in new versions
  -The user file imports "*" from the base and overrides any of its settings
  -frigcal imports all its settings from the user file, not the base

This simplifies editing work when upgrading to new releases: users normally
need just copy over their prior user file to the new release's folder, instead
of pasting individual settings into the new base file.  Users should still
inspect the base file to see if any new settings are available, and in-place
edits in this base file still work as before (but are discouraged).


THE ESSENTIALS
--------------

HOW TO EDIT
  This file gives multiple example settings for some names; per normal Python
  semantics, only the LAST assignment listed and run will be used.  These
  example settings may be freely changed, reordered, commented-out, or deleted.
  Each name should generally be assigned once, though the program fills in
  defaults (and prints warnings on the console) if they are not.

FOR COLORS
  Give a string color name (e.g., 'maroon') or RGB hex-code triple string
  '#RRGGBB'.  For example, '#B7DA8D' is moss green, and '#DD76C7' is rose.
  Try http://www.tcl.tk/man/tcl8.4/TkCmd/colors.htm for defined color names.
  [1.7] For custom colors, see the newly-included "pickcolor.py" utility script;
  it displays a chosen color's '#RRGGBB' string in a GUI, for cut-and-paste.
  Caution: using the same color for text and background will be unreadable.

FOR FONTS
  Give either a tuple ('family', size?, 'style? style? ...) or a string
  'family size? style? style? ...' if the family name contains no spaces.
  The optional size must appear second; negative means pixels instead of
  points, 0 means default size, and omission means 0.  Styles may include
  any mix of: 'bold', 'normal' (non-bold) 'italic', 'roman' (non-italic),
  'underline', and 'overstrike'.  The default style is 'normal roman'.

  For example: ('arial', 16, 'bold'), 'courier 14 normal', 'times 15 italic',
  ('consolas', 12, 'bold italic underline').  Some partial specifiers work
  too ('times', 'times 20'), but don't skip the size ('times bold' fails).
  Note: on Linux, some Asian characters may render better if non-bold,
  and larger font sizes may help in general; see LINUX_ASIAN_FONTS below.
  In [2.0], some fonts have been tailored for Mac OS X appearance as well.

EDIT WITH CARE
  frigcal won't start if there is a syntax error in this file (and you'll get
  error details in both the console window and a GUI popup), so be careful with
  changes here.  You may want to save a backup copy before making edits.  If
  there are no syntax errors, most invalid or missing setting values do not
  cause the program to fail or stop, but are replaced with defaults and may
  trigger messages on the console; please verify your values.  Import this
  module separately in a Python interactive session to error check.


ADDITIONAL NOTES
----------------

USING NON-ENGLISH STRINGS HERE [1.7]
  The first line in this file gives the Unicode encoding of its content,
  including all its embedded string literals.  Python defaults to UTF-8
  (which handles simple ASCII) if no such line is present, but other encodings
  can be used above too (e.g., latin-1).  You can also use Python's '\uhhhh'
  and '\Uhhhhhhhh' Unicode code-point escapes in any of this file's strings.
  Non-English strings can be used in file paths, category names, and more;
  see the example in event-color category names below.

EVENT FOREGROUND COLORS [1.7]
  As of version 1.7, event summary color values can be either a string giving
  background only (the former scheme), or a 2-item tuple giving both background
  and foreground colors (the new enhanced scheme). For example, a color setting:

    'wheat'
         sets the event widget's background color only, leaving its
         foreground (the event text) the default black

    ('navy', 'orange')
         sets the event widget's background color to 'navy' and its
         foreground (the event text) color to 'orange'

  In all cases, the default event background and foreground are white and black,
  and each color value may still be either a color name or #RRGGBB hex code.
  Caution: using the same color for text and background will be unreadable, and
  some error cases may result in this; see the console for color error messages.

COLOR NAME CHANGES [1.6]
  Standard Windows installs of Pythons 3.4+ use version 8.6 of the Tk library
  underlying tkinter, which changes the meaning of four color names.  "green",
  "purple", "maroon", and "grey/gray" render more darkly, and some of the new
  8.6 name equivalents aren't available in older Tk versions (e.g., the former
  "green" becomes "lime", but "lime" doesn't work in prior Tks!).

  This file maps changed colors to portable names (e.g., GREEN).  As a rule of
  thumb, though, using '#RRGGBB' hex strings instead of color names will make
  your colors portable across all Pythons and Tks (see "pickcolor.py" to create
  these strings).  For more details on this Tk change:

    http://learning-python.com/books/python-changes-2014-plus.html#s359
    http://www.tcl.tk/cgi-bin/tct/tip/403.html
    https://bugs.python.org/issue23982, or
    https://www.tcl.tk/man/tcl/TkCmd/colors.htm.

TBDs
  A plain text configs file wouldn't require Python coding skills, but also
  wouldn't help much, as errors may still preclude program launch.  Values
  could also be verified once at startup instead of on each config.
======================================================================================
"""


# For platform/version-dependent settings
import sys, tkinter, os



# For platform-specific choices (available in frigcal_configs.py too: see its docs)

RunningOnMacOS   = sys.platform.startswith('darwin')           # all macOS (f/k/a OS X)
RunningOnWindows = sys.platform.startswith('win')              # all Windows
RunningOnAndroid = hasattr(sys, 'getandroidapilevel')          # all Android, py3.7+
RunningOnLinux   = sys.platform.startswith('linux')            # all Linux + Android
RunningOnLinux   = RunningOnLinux and not RunningOnAndroid     # Linux ONLY, not Android



# For Python- or Tk-specific choices

# [3.0] fails for 2-digit minor numbers, like 3.12
#PyVersion = float(sys.version[:3])                          # '3.5.0 ...' => 3.5
PyVersion  = '.'.join(str(i) for i in sys.version_info[:2])  # => (3, 12) => '3.12'

# [3.0] caveat: _fullTkVersion in frigcal.py is more complete
TkVersion = tkinter.TkVersion         # e.g., 8.5 or 8.6 (Win Py 3.4+ use Tk 8.6)
print('Using Python', PyVersion, 'and Tk', TkVersion)    # display versions [1.6]



# Portable color choices that differ between Tk 8.6 and earlier (see above) [1.6]

GREEN  = 'green'  if TkVersion < 8.6 else 'lime'         # 'lime' only in 8.6+
PURPLE = 'medium purple'                                 # same in all versions
MAROON = 'maroon' if TkVersion < 8.6 else 'indian red'   # not exactly, but close
GRAY   = 'grey'   if TkVersion < 8.6 else 'silver'       # 'silver' only in 8.6+



#=====================================================================================
# MONTH AND IMAGE WINDOW BEHAVIOR (last setting wins: multiple examples)
#=====================================================================================


# Event click/press bindings model, 'mouse' or 'touch': see UserGuide.html

# [3.0] The current Tk has a bug on macOS only, which opens dialogs twice 
# for double taps in a window that does not have focus.  This was worked 
# around in code, but if it ever resurfaces, either set single-tap (touch)
# per here, or tap once to focus then twice for dialogs.
#
# Tradeoffs: single-tap requires Summary edits in dialogs instead of event 
# fields inline, and may open spurious dialogs if tap to focus over widget 
# that spawns one (most of month window does, except blank days at bottom).
# OK on Android (just one window), but subjective on Windows youch screens.

if RunningOnAndroid:
    clickmode = 'touch'           # single-tap model (+macOS Tk bug workaround?)
else:
    clickmode = 'mouse'           # double-tap model, with inline summary edits



# Month windows' initial size in pixels or % (but fully resizable thereafter)

initwinsize = None          # if None, automatically sized by content (but may vary)
initwinsize = '1000x800'    # string giving absolute pixels: '<width>x<height>'
initwinsize = 0.75          # float <= 1.0 giving % of full screen's width and height
initwinsize = (0.60, 0.80)  # tuple = (% of full screen width, % of full screen height)



# Month windows' minimum size in pixels (to avoid shrinking too much if few events)

minwinsize = None           # if None, no limit on shrink (but some controls vanish)
minwinsize = initwinsize    # if same, can only grow, not shrink
minwinsize = '650x400'      # pixels: '<width>x<height>'



# Month windows' start position (or add at end of initwinsize: '800x600+10+10') 

initwinposition = '+10+10'  # start +X+Y offset in pixels from top left (clones too)
initwinposition = None      # if None, default = GUI chooses (generally preferred)



# Month image-windows' start position (for all month's images) [1.4]

initimgposition = '+0+0'    # start +X+Y offset in pixels from top left corner
initimgposition = None      # if None, default = GUI chooses (generally preferred)



#=====================================================================================
# MONTH WINDOW APPEARANCE (last setting wins: multiple examples)
#=====================================================================================


# Month window background color

rootbg = None                   # None=tk default
rootbg = 'tan'                  # see above for format
rootbg = 'navy'                 
rootbg = 'steelblue'



# Month day-tiles background color

daysbg = None                   # None=tk default
daysbg = 'beige'                # see above for format
daysbg = 'lightblue'
daysbg = 'powderblue'



# Month day-tiled forground (label) color (else white in latest Tk) [3.0]
daysfg = 'black'



# Font for text on month day-tiles: number and events (and event-select list)

daysfont = None                              # None=tk default
daysfont = ('courier', 16, 'bold italic')    # see above for format
daysfont = ('times', 9, 'bold underline')
daysfont = ('calibri', 12, 'normal')
daysfont = ('arial', 9, 'bold')              # default

# Customize by platform: larger font on Mac and Linux [2.0]

if RunningOnMacOS:
    daysfont = ('arial', 14, 'normal')         # or menlo, monaco        

elif RunningOnWindows:
    pass  # use default (last) above         # or consolas

elif RunningOnLinux:
    daysfont = ('arial', 10, 'bold')         # or inconsolata



# Font for text on month and day names at top of window

monthnamefont = ('times', 12, 'bold italic')
daynamefont = ('times', 9)

# Customize by platform

if RunningOnMacOS:
    monthnamefont = ('arial', 15, 'bold italic')  
    daynamefont = ('monaco', 10)

elif RunningOnWindows:
    monthnamefont = ('arial', 14, 'bold italic')
    daynamefont = ('consolas', 9)

elif RunningOnLinux:
    monthnamefont = ('arial', 14, 'bold italic')
    daynamefont = ('inconsolata', 9)



# Font for text on buttons and toggles at top and bottom of month windows
# This is also used for buttons in event-edit, even-list, and Find dialog popups

controlsfont = None                          # None=tk default
controlsfont = ('arial', 8, 'bold')          # see above for format

# Customize by platform

if RunningOnMacOS:
    controlsfont = ('arial', 9, 'bold')      # use larger fonts on Mac



# Current-day shading color, defaults to gray if not set or None [1.6]

currentdaycolor = GRAY                       # or rootbg to match border?



#=====================================================================================
# EVENT VIEW/EDIT DIALOG: appearance (None=tk default, see intro for values)
#=====================================================================================


eventdialogfg    = 'black'                          # input areas fg
eventdialogbg    = 'tan'                            # entire dialog bg
eventdialoginpbg = 'ivory'                          # [3.0] input areas bg
eventdialogfont  = ('courier', 12, 'bold')          # default


# Customize by platform: larger on Linux and Mac, non-bold on Mac [2.0]

if RunningOnMacOS:
    eventdialogfont = ('menlo', 16, 'bold')        # or courier, menlo, monaco, arial

elif RunningOnWindows:
    pass  # use default (last) above               # or consolas

elif RunningOnLinux: 
    eventdialogfont = ('courier', 13, 'bold')      # or inconsolata


# Event view/edit dialog's description text area size (new in [2.0])

eventdialogtextheight = 10      # number lines (None=default=5; Tk default=24)
eventdialogtextwidth  = None    # number characters (None=Tk default=80)


# See also controlsfont above, used for buttons in event-edit (and other) dialogs



#=====================================================================================
# SPECIAL-CASE FONTS (e.g., for Asian or monospace characters on Linux)
#=====================================================================================


#-------------------------------------------------------------------------------------
# Bold fonts can make some Asian characters (and possibly others) render unreadably
# on Linux, but bold seems to work well on Windows for all fonts, and non-bold seems
# too dull for other cases to be the default (though YMMV).  You may also want to
# use a larger font size here, but this is too subjective to set a policy here.
#-------------------------------------------------------------------------------------

LINUX_ASIAN_FONTS = False   # and/or test RunningOnLinux?

if LINUX_ASIAN_FONTS:
    daysfont        = ('arial', 9, 'normal')
    footerfont      = ('courier', 10, 'normal')
    eventdialogfont = ('courier', 12, 'normal')


#-------------------------------------------------------------------------------------
# Monospace fonts: platform-specific (currently unused - example only).
# Consolas isn't monospace on Linux, but inconsolata isn't monospace on Windows.
# Courier works for monospace on all three, but may have a duller appearance.
#-------------------------------------------------------------------------------------

MONOSPACE_FONTS = False

if MONOSPACE_FONTS:
    if RunningOnMacOS:                             # or monaco, courier
        daysfont = ('menlo', 10, 'bold')

    elif RunningOnWindows:                         # or courier
        daysfont = ('consolas', 10, 'bold')

    elif RunningOnLinux:                           # or courier                              
        daysfont = ('inconsolata', 10, 'bold')

    else:                                          # others?
        daysfont = ('courier new', 10, 'bold')



#=====================================================================================
# ICS CALENDAR-FILE FORMATTING
#=====================================================================================


#-------------------------------------------------------------------------------------
# [1.4] Retain literal backslashes in Summary and Description text, via quoted-printable
# '=5C' notation escapes?  See version 1.4 notes in UserGuide.html for full details.
# If True, retains '\' but risks file portability: other GUIs may not undo '=5C' (if any).
# If False, drops some '\', and 2-char literal '\n' becomes 1-char newline on reloads.
#-------------------------------------------------------------------------------------

retainLiteralBackslashes = True          # True=escape and retain any literal '\'



#=====================================================================================
# CALENDAR-FILES FOLDER (last setting wins: multiple examples)
#=====================================================================================


#-------------------------------------------------------------------------------------
# iCalendar '.ics' event files folder path, with auto-created 'Backups' subfolder.
# All '*.ics' files in this folder are loaded as calendars at program start-up.
# The Backups subfolder saves prior versions of changed files before they are updated.
# DEFAULT is 'Calendars\*.ics' files, in subfolder of the main script's folder.
#-------------------------------------------------------------------------------------

icspath = r'C:\my-archived-folder\Calendar\ICSFiles'         # other folders
icspath = r'Calendars\subfolder-for-event-type'              # subsets
icspath = None                                               # None=DEFAULT


#-------------------------------------------------------------------------------------
# iCalendar '.ics' files 'Backup' subfolder maximum size.
# Keep up to this many latest backups of each .ics in 'icspath\Backups' subfolder.
#-------------------------------------------------------------------------------------

maxbackups = 10


#-------------------------------------------------------------------------------------
# On Linux + Mac: change any Windows '\' path separators to '/' [1.6].
# This code fixes paths if you keep the Windows '\' in the examples above.
#-------------------------------------------------------------------------------------

if not RunningOnWindows:
    if icspath: icspath = icspath.replace('\\', os.sep)    # may be None = default



#=====================================================================================
# EVENT SUMMARY COLORS (by category name and/or calendar-file name)
#=====================================================================================


#-------------------------------------------------------------------------------------
# The following settings are meant as examples only: edit or replace as you prefer.
# Event category colors span calendars, and override any calendar color settings.
#
# To colorize events:
# 1) Edit the category and/or calendar color dictionaries here, giving either
#    a color name or #RRGGBB hex-code string for each color value.
# 2) Enter event category and calendar names in the GUI's View/Edit and Create
#    dialogs opened on event and day clicks, respectively.  An empty category
#    name in the GUI picks up either the calendar's color, or the color of a
#    category-dictionary entry whose key is an explicit empty string (a default). 
#
# See also the top of this file for:
#   -More on color setting values, and the chooser utility script "pickcolor.py"
#   -Notes about color name changes in in Tk 8.6+ (e.g., Python 3.4+ on Windows)
#   -Version 1.7's event foreground colors extension: color values can now be strings
#    giving background only, or (bg, fg) tuples giving both background and foreground
#
# Also note that the widget used to select from category names may have a limited
# size on some systems (e.g., Linux) and small screens; use fewer names if needed.
#-------------------------------------------------------------------------------------


#-------------------------------------------------------------------------------------
# CATEGORIES MAP: event category name => event summary widget color.
# Category entered in event's GUI, color = color name or RGB hex triple '#RRGGBB'.
# These span all calendars, and override calendar_colors below for specific events.
# Category name '' can be used to provide default for all events with no category.
# Default is 'white' if category's name is not listed here (and calendar not colored).
#-------------------------------------------------------------------------------------

category_ignorecase = True   # caseless lookup? (if True: travel=Travel, Travel=travel)


# Basic category names (color neutral)

category_colors = {
    'travel':           'tan',             # example names/colors: EDIT OR REPLACE
    'birthday':         'yellow',          # key=category, value='bg' or ('bg', 'fg')
    'anniversary':      'red',            
    'milestone':        'sky blue',
    'business':         'orange',
    'pybooks':          'pink',
    'education':         PURPLE,           # [1.6] differs in Tk 8.6+
    'politics':          MAROON,           # [1.6] differs in Tk 8.6+
    'weather':          'wheat',
    'conference':       'lavender',
    'gadgets':          'forest green',
    'other':            'light green'
    }


# Add any legacy categories (used in other calendars)

category_colors.update({
    'Red Category':     'red',
    'Green Category':    GREEN             # [1.6] differs in Tk 8.6+
    })


# Add any absolute color names (_x names appear early in list sort order);
# the leading '_' here is not significant - for sort order grouping only

category_colors.update({
    '_red':             'red',
    '_green':            GREEN,            # [1.6] differs in Tk 8.6+
    '_oldgreen':        'green',
    '_purple':           PURPLE,           # [1.6] differs in Tk 8.6+
    '_oldpurple':       'purple', 
    '_orange':          'orange',
    '_blue':            'sky blue',
    '_wheat':           'wheat',
    '_cyan':            'cyan',
    '_gray':             GRAY,             #[1.6] differs in Tk 8.6+
    '_yellow':          'yellow',
    '_lavender':        'lavender',
    '_violet':          'violet',
    '_dark red':        'indian red',
    '_beige':           'beige'            # plus _many_ more: see the web
    #,'':               'yellow'           # if used: a default category
    })


# [1.7] Add (bg, fg) color tuples (can also be mixed into other tables above);
# the leading '+' here is not significant - for sort order grouping only

category_colors.update({
    '+blues':           ('navy', 'white'),
    '+christmas':       ('dark green', 'red'),
    '+Важное событие':  ('black', 'orange'),
    '+purples':         ('purple', 'lavender'),       # key = 'category'
    '+orangeblue':      ('orange', 'blue'),           # value = 'bg' or ('bg', 'fg')
    '+navygreen☂':      ('navy', GREEN),              # [3.0] drop personal info
    '+blackwhite':      ('black', 'white'),           # [3.0] new themese
    '+blackred':        ('black', 'red'),
    '+重要事件':         ('indian red', 'white'),      # [1.7] non-English text 
    '+greens':          ('forest green', 'white'),    # [2.0] white foreground
    '+neons':           ('cyan', 'yellow'),
    '+goth':            ('black', GRAY),
    })


# For testing only: error cases and None=default

"""
category_colors.update({
    '+BAD1':            [1, 2, 3],
    '+BAD2':            (25,  'black'),               # fails on bg
    '+BAD3':            ('black', 25),                # fails on fg
    '+BAD4':            ('nonesuch', 'black'),
    '+BAD5':            ('black', 'nonsuch'),
    '+BADNonesuch':     'nonesuch',
    '+OKNone':          None,                         # None=''=nonmatch=>dflt
    })
"""


#-------------------------------------------------------------------------------------
# CALENDARS MAP: ics calendar file name => event summary widget color.
# File is basename (no path), color = color name or RGB hex triple '#RRGGBB'.
# These span all events in a calendar file, but category_colors above overrides these.
# Default is 'white' if a file's name is not listed here (and category not colored).
# Examples only: edit me (and okay if an ics file name in the table does not exist).
#-------------------------------------------------------------------------------------

calendar_colors = {                        # example names/colors: EDIT OR REPLACE
    'Bills.ics':        'cyan',            # key=filename, value='bg' or ('bg', 'fg')
    'Holidays.ics':     ('red', 'white'),  # [1.7] (bg, fg) tuple works here too
    'trips.ics':         GREEN,            # [1.6] differs in Tk 8.6+
    'business.ics':      GRAY,             # [1.6] differs in Tk 8.6+            
    'Personal.ics':     'beige'
    }             



#=====================================================================================
# ANDROID CHANGES SECTION [3.0] (in base here, to allow mods in frigcal_configs.py)
#=====================================================================================


if RunningOnAndroid:

    # ANDROID - use None=tkinter's or program's default fonts, to avoid crashes.
    # Pydroid 3's tkinter crashes if font family != courier/helvetica/times or synonyms.
    # Change to experiment with your own settings, and see frigcal_configs_base.py for ideas.
    # Also set your icspath and imgpath for calendars and images located elsewhere.
    # Update [3.0]: Pydroid 3's (of 2019) fixed its font crash by coercing any unknown 
    # font-family name to helvetica, though its support for italic and bold is spotty.

    daysfont = None               # text on month day-tiles: (family, size, style)
    monthnamefont = None          # text of month name at top of window
    daynamefont = None            # text of day names at top of window
    controlsfont = None           # text on buttons and toggles
    footerfont = None             # text in the footer panel
    eventdialogfont = None        # text in event view/edit dialogs


    # ANDROID [Apr1219] - preset smaller fonts to avoid truncation on smaller phones.
    # Caveat: month abbreviation (or redesign) may be warranted for very small phones.
    # The "mm/yy/dddd" input field size was also reduced, but is hardcoded in the script.
    # Note: the controlsfont preset for buttons below actually is the None default on 
    # some phones (e.g., Note 9), but is noticeably smaller on smaller devices (e.g., J7).
    # Update [3.0:] now does abbreviate month name to 3 characters to shave some hspace. 

    monthnamefont = ('times', 10, 'bold italic')    # thinner and shorter (on all tested)
    controlsfont  = ('helvetica', 6, 'normal')      # smaller buttons (on smaller phones)


    # ANDROID - preset event dialog font for readability (default is just 5 points),
    # and preset the view/edit dialog's size for fit; tailor both for your usage.
    # Note: eventdialogfont sets all text items' fonts; some differ for None=defaults.

    eventdialogfont = ('courier', 6, 'normal')
    eventdialogtextheight = 10    # number lines (None=default=5; Tk default=24)
    eventdialogtextwidth  = 80    # number characters (None=Tk default=80, prior preset)


    # ANDROID - put your custom calendars-folder path here (None = program's Calendars/).
    # In order, these are: internal storage, SD card updatable, SD card read only, and the 
    # default; yours will vary.  Also see month-images path ahead (and don't maximize).
    # Update [3.0]: month-images path is now moot because these images have been dropped.

    #icspath = '/sdcard/MY-STUFF/Code/frigcal/Calendars'
    #icspath = '/storage/6C2A-1618/Android/data/ru.iiec.pydroid3/MY-STUFF/Code/frigcal/Calendars'
    #icspath = '/storage/6C2A-1618/Android/data/com.termux/MY-STUFF/Code/frigcal/Calendars'
    icspath = None


    # ANDROID - use single-tap/click mode on smartphones for easier operation, 
    # and to avoid pointless keyboard popups on event clicks; change as desired.

    #clickmode = 'mouse'          # double-press model, with inline summary edits
    clickmode  = 'touch'          # single-press model (redendant with setting above)



#=====================================================================================
# [3.0] BUTTON NARROWING: how to narrow buttons to conserve horizontal space
#=====================================================================================

# This setting determines how horizontal padding is applied to GUI buttons.
# It can be set to values 0, 1, or 2, where 0 means the GUI library's default,
# and 1 and 2 have effects that vary by platform: try on yours to vet results.
#
# The presets below are reasonable on each platform and do not generally require 
# changes.  On Android, setting 2 shrinks buttons to conserve horizontal space 
# on narrow phones (at some cost in usability), and 0 makes buttons wider.

# presets - mod these in frigcal_configs.py

if RunningOnMacOS or RunningOnAndroid:
    buttonNarrowingFactor = 1                # moderately narrower than defaults

elif RunningOnWindows:
    buttonNarrowingFactor = 2                # more uniform widths (narrow on Android)

elif RunningOnLinux:
    buttonNarrowingFactor = 0                # no narrowing: use GUI library's defaults



#=====================================================================================
# [3.0] EMOJIS SUPPORT: minimum Tk version needed to render emojis in Frigcal
#=====================================================================================

# This is an advanced setting that should not be changed unless you're using 
# a Python whose Tk library supports emojis and is older than version 8.6.13.
#
# Before the Tk version given here, Frigcal replaces non-BMP Unicode text, 
# including emojis, with the Unicode replacement character for display, but
# propagates them to and from calendar files.  This is a config because it's
# not possible to test every Tk version to know if emoji support is present.
#
# The preset Tk 8.6.13 supports emojis and is used by Python 3.12 on PCs (and
# is embedded in standalone apps and executables), but Tk on the Android 
# Pydroid 3 app varies.  As of 10/2024, Pydroid 3 7.4's Python 3.11 uses 
# Tk 8.6.10 which lacks emojis, though this may change, and 8.6.11 and 8.6.12 
# are unknowns; change this to see if those Tks do emojis in a future Pydroid 3.
#
# To check Tk version in Pydroid 3's Interpreter (and others) run this Python:
# >>> from tkinter import *
# >>> Tcl().call('info', 'patchlevel')

minimumTkForEmojis = [8, 6, 13]   # preset means Tk 8.6.13 or later required for emojis



#=====================================================================================
# [3.0] --DEFUNCT-- FOOTER PANEL: size (start or fixed), background color, and font
#=====================================================================================

# Dropped in 3.0, because it was unusable in Android, and window-size dependent on PCs


#=====================================================================================
# [3.0] --DEFUNCT-- MONTH-IMAGES FOLDER (optional display in a popup window)
#=====================================================================================

# Dropped in 3.0, because it was gimmicky, Android unfriendly, and not know to be used


#=====================================================================================
# END OF CODE (suggestions only follow)
#=====================================================================================



"""
======================================================================================

Examples of more advanced config techniques:

# 1) Proportional window height
initwinwide = 800
initwinsize = '%dx%d' % (initwinwide, int(initwinwide * .80))  # high=80% of wide

# 2) Window size per platform/version (e.g., if this implies distinct devices)
if RunningOnWindows:
    winversion = sys.getwindowsversion()
    majorminor = (winversion.major, winversion.minor)
    if majorminor >= (6, 2):
        initwinsize = '800x600'            # Windows 8=6.2, 8.1=6.3 (tablet?)
    else:
        initwinsize = '1000x800'           # Windows 7=6.1 (laptop/desktop?)
elif RunningOnLinux:
    initwinsize = '1000x800'               # Linux laptop?
else:
    initwinsize = '1000x800'               # Mac OS X laptop?

# 3) Scale window size to actual display (caveat: this pops up a temp window);
# *this has been subsumed* by a float/tuple initwinsize giving % of full screen,
# applied in frigcal.py automatically only after root Tk() window is created;

from tkinter import Tk
root = Tk()                                # get full screen size from tkinter GUI
swide = root.winfo_screenwidth()           # in pixels: (e.g., 1920)
shigh = root.winfo_screenheight()          # in pixels: (e.g., 1080)
root.destroy()
initwinsize = '%dx%d' % (int(swide * (2/3)),            # wide=2/3 of full screen
                         int(.80 * (swide * (2/3))))    # high=80% of width

# 4) Themes: prompt for a settings set/theme name in the console window at
# startup and choose from different assignment sets in this file with an 'if'

theme = input('theme?')         # 3.x only
if theme == 'blues':
    ...
    ...settings here, plus month images path?
    ...
elif theme == 'browns':
    ...
    ...other settings here
    ...
else:
    ...default settings here?
======================================================================================
"""



[Home page] Books Code Blog Python Author Train Find ©M.Lutz