From 814794dab15fbc13dd9112ac57cd85eadce7a989 Mon Sep 17 00:00:00 2001 From: Doug Massay Date: Sun, 9 Dec 2018 11:13:12 -0500 Subject: [PATCH] Add ability to tweak font-sizes --- appveyor.yml | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ dialogs.py | 10 ++++++--- plugin.py | 28 +++++++++++++++++++------- plugin.xml | 2 +- 4 files changed, 86 insertions(+), 11 deletions(-) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..262d09b --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,57 @@ + +branches: + only: + - master + - /v\d+\.\d+\.\d+(-\d+)?/ + +clone_folder: c:\project\tagmechanic + +image: +- Visual Studio 2017 + +configuration: Release + +platform: x64 + + +init: + # Configure the AppVeyor build version to ${branch-name}-${git-revision}-${timestamp} + - ps: $commit = $env:appveyor_repo_commit.SubString(0,7) + - ps: $timestamp = $env:appveyor_repo_commit_timestamp.SubString(0,10) + - ps: Update-AppveyorBuild -Version ("{0}-{1}-{2}" -f $env:appveyor_repo_branch, $commit, $timestamp) + + +environment: + global: + PYTHON: C:\Python37-x64 + + +before_build: +- cmd: |- + set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH% +# python -m pip install --upgrade pip +# pip3.7 install six + + +build_script: +- cmd: |- + set PATH=%PYTHON%;%PATH% + python buildplugin + + +artifacts: + - path: '*.zip' + name: plugin + +deploy: + - provider: GitHub + auth_token: + secure: QM747yzK0qkUTP1k/zQXGbxvvWK97YQpC5+6oAX6FTCPI+jYlB2zf4mzdcFj/uPL + release: TagMechanic $(APPVEYOR_REPO_BRANCH) + tag: $(APPVEYOR_REPO_BRANCH) + description: '[Replace this text]' + artifact: plugin + draft: true + on: + branch: /v\d+\.\d+\.\d+(-\d+)?/ + diff --git a/dialogs.py b/dialogs.py index fa4bb87..29c4601 100644 --- a/dialogs.py +++ b/dialogs.py @@ -12,10 +12,12 @@ if PY2: import Tkinter as tkinter import Tkconstants as tkinter_constants + import tkFont range = xrange else: import tkinter import tkinter.constants as tkinter_constants + import tkinter.font as tkFont def remove_dupes(values): @@ -32,11 +34,13 @@ def remove_dupes(values): return output class guiConfig(tkinter.Toplevel): - def __init__(self, parent, defaults): + def __init__(self, parent, defaults, font_tweaks): tkinter.Toplevel.__init__(self, parent, border=5) self.resizable(False, False) self.title('Plugin Customization') self.maingui = parent + # define a bold font based on font_tweaks for labels + self.label_font = tkFont.Font(family=font_tweaks['font_family'], size=int(font_tweaks['font_size']), weight=tkFont.BOLD) # Copy taglist, combox values and their original defaults from main plugin.py self.taglist = self.maingui.taglist self.temp_values = self.maingui.combobox_values @@ -84,7 +88,7 @@ def initUI(self): # Add label and text entry widget to current column. entry_frame = tkinter.Frame(column[curr_col], pady=5) lbl = tkinter.Label(entry_frame, text='Choices to change "{}" elements to:'.format(tag), - font='Helvetica -12 bold') + font=self.label_font) lbl.pack(side=tkinter_constants.TOP, fill=tkinter_constants.X) self.tkinter_vars[tag] = tkinter.StringVar() self.tkentry_widgets[tag] = tkinter.Entry(entry_frame, textvariable=self.tkinter_vars[tag]) @@ -95,7 +99,7 @@ def initUI(self): # Create the label/text-entry widget for the html attributes list attrs_frame = tkinter.Frame(body, pady=10) attrs_label = tkinter.Label(attrs_frame, text='HTML attributes available to search for:', - font='Helvetica -12 bold') + font=self.label_font) attrs_label.pack(side=tkinter_constants.TOP, fill=tkinter_constants.X) self.attrs_value = tkinter.StringVar() self.attrs_value_entry = tkinter.Entry(attrs_frame, textvariable=self.attrs_value) diff --git a/plugin.py b/plugin.py index ee9e68c..03e7b9b 100644 --- a/plugin.py +++ b/plugin.py @@ -38,6 +38,11 @@ 'attrs' : 0, } +font_tweaks = { + 'font_family' : 'Helvetica', + 'font_size' : '10', +} + miscellaneous_settings = { 'windowGeometry' : None, } @@ -122,6 +127,7 @@ def __init__(self, parent, bk): # Edit Plugin container object self.bk = bk # Handy prefs groupings + self.font_tweaks = prefs['font_tweaks'] self.gui_prefs = prefs['gui_selections'] self.misc_prefs = prefs['miscellaneous_settings'] self.update_prefs = prefs['update_settings'] @@ -481,7 +487,7 @@ def check_for_update(self): def showConfig(self): ''' Launch Customization Dialog ''' - guiConfig(self, combobox_defaults) + guiConfig(self, combobox_defaults, self.font_tweaks) def quitApp(self): '''Clean up and close Widget''' @@ -509,10 +515,13 @@ def clear_box(self): def showCmdOutput(self, msg, tag='nochange'): '''Write messages to the scrolling textbox.''' - normalFont = tkFont.Font(size=9, weight=tkFont.NORMAL) - boldBigFont = tkFont.Font(size=10, weight=tkFont.BOLD) - boldFont = tkFont.Font(size=9, weight=tkFont.BOLD) - summaryFont = tkFont.Font(size=9, weight=tkFont.BOLD, underline=True) + normalFont = tkFont.Font(family=self.font_tweaks['font_family'], size=int(self.font_tweaks['font_size']), weight=tkFont.NORMAL) + if int(self.font_tweaks['font_size']) < 0: + boldBigFont = tkFont.Font(family=self.font_tweaks['font_family'], size=int(self.font_tweaks['font_size'])-1, weight=tkFont.BOLD) + else: + boldBigFont = tkFont.Font(family=self.font_tweaks['font_family'], size=int(self.font_tweaks['font_size'])+1, weight=tkFont.BOLD) + boldFont = tkFont.Font(family=self.font_tweaks['font_family'], size=int(self.font_tweaks['font_size']), weight=tkFont.BOLD) + summaryFont = tkFont.Font(family=self.font_tweaks['font_family'], size=int(self.font_tweaks['font_size']), weight=tkFont.BOLD, underline=True) self.results.tag_config('nochange', lmargin1=10, lmargin2=30, spacing1=3, font=normalFont) self.results.tag_config('header', spacing1=5, spacing3=5, font=boldBigFont) @@ -543,9 +552,13 @@ def run(bk): global prefs prefs = bk.getPrefs() + if 'font_tweaks' not in prefs: + prefs['font_tweaks'] = font_tweaks + else: # otherwise, use the piecemeal method in case new prefs have been added since json creation. + check_for_new_prefs(prefs['font_tweaks'], font_tweaks) if 'gui_selections' not in prefs: # If the json doesn't exist yet, assign wholesale defaults. prefs['gui_selections'] = gui_selections - else: # otherwise, use the piecemeal method in case new prefs have been added since json creation. + else: check_for_new_prefs(prefs['gui_selections'], gui_selections) if 'miscellaneous_settings' not in prefs: prefs['miscellaneous_settings']= miscellaneous_settings @@ -565,7 +578,8 @@ def run(bk): root.title('') root.resizable(True, True) root.minsize(420, 325) - root.option_add('*font', 'Arial -12') + default_font = tkFont.Font(family=prefs['font_tweaks']['font_family'], size=int(prefs['font_tweaks']['font_size'])) + root.option_add('*font', default_font) if not sys.platform.startswith('darwin'): img = tkinter.Image('photo', file=os.path.join(bk._w.plugin_dir, bk._w.plugin_name, 'images/icon.png')) root.tk.call('wm','iconphoto',root._w,img) diff --git a/plugin.xml b/plugin.xml index 750772d..949966f 100644 --- a/plugin.xml +++ b/plugin.xml @@ -6,7 +6,7 @@ Manipulate Spans, Divs and other tags. python3.4 python2.7 -0.4.4 +0.4.5 osx,unx,win true true