Skip to content

Commit

Permalink
Add ability to tweak font-sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
dougmassay committed Dec 9, 2018
1 parent b50560d commit 814794d
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 11 deletions.
57 changes: 57 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -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+)?/

10 changes: 7 additions & 3 deletions dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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])
Expand All @@ -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)
Expand Down
28 changes: 21 additions & 7 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
'attrs' : 0,
}

font_tweaks = {
'font_family' : 'Helvetica',
'font_size' : '10',
}

miscellaneous_settings = {
'windowGeometry' : None,
}
Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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'''
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<description>Manipulate Spans, Divs and other tags.</description>
<engine>python3.4</engine>
<engine>python2.7</engine>
<version>0.4.4</version>
<version>0.4.5</version>
<oslist>osx,unx,win</oslist>
<autostart>true</autostart>
<autoclose>true</autoclose>
Expand Down

0 comments on commit 814794d

Please sign in to comment.