Skip to content

Commit

Permalink
ContainerFonts now used #385
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvisteach committed Feb 17, 2018
1 parent 7c407c1 commit 2ec2e42
Showing 1 changed file with 37 additions and 36 deletions.
73 changes: 37 additions & 36 deletions appJar/appjar.py
Expand Up @@ -629,7 +629,7 @@ def _configBg(self, container):
# properly

if not self.ttkFlag:
self.bgLabel = Label(container, anchor=CENTER, font=self._outputFont, background=self._getContainerBg())
self.bgLabel = Label(container, anchor=CENTER, font=self._getContainerProperty('outputFont'), background=self._getContainerBg())
else:
self.bgLabel = ttk.Label(container)
self.bgLabel.place(x=0, y=0, relwidth=1, relheight=1)
Expand Down Expand Up @@ -2366,6 +2366,7 @@ def configure(self, **kwargs):

if fg is not None: self.fg = fg
if bg is not None: self.bg = bg

if font is not None: self.font = font
if outputFont is not None: self.outputFont = outputFont
if buttonFont is not None: self.buttonFont = buttonFont
Expand Down Expand Up @@ -2482,7 +2483,7 @@ def setFont(self, *args, **kwargs):
self.setButtonFont(*args, **kwargs)

def getFont(self):
return self._outputFont.actual()
return self._getContainerProperty('outputFont').actual()

font = property(getFont, setFont)

Expand All @@ -2496,10 +2497,10 @@ def setInputFont(self, *args, **kwargs):
gui.warn("Unable to set input fonts using Font class")
return

self._inputFont.config(**kwargs)
self._getContainerProperty('inputFont').config(**kwargs)

def getInputFont(self):
return self._inputFont.actual()
return self._getContainerProperty('inputFont').actual()

inputFont = property(getInputFont, setInputFont)

Expand All @@ -2513,10 +2514,10 @@ def setButtonFont(self, *args, **kwargs):
gui.warn("Unable to set command fonts using Font class")
return

self._buttonFont.config(**kwargs)
self._getContainerProperty('buttonFont').config(**kwargs)

def getButtonFont(self):
return self._buttonFont.actual()
return self._getContainerProperty('buttonFont').actual()

buttonFont = property(getButtonFont, setButtonFont)

Expand All @@ -2530,7 +2531,7 @@ def setOutputFont(self, *args, **kwargs):
gui.warn("Unable to set output fonts using Font class")
return

self._outputFont.config(**kwargs)
self._getContainerProperty('outputFont').config(**kwargs)
self.tableFont.config(**kwargs)

# need better way to register font change events on tables
Expand All @@ -2542,7 +2543,7 @@ def setOutputFont(self, *args, **kwargs):
self.linkFont.config(**kwargs)

def getOutputFont(self):
return self._outputFont.actual()
return self._getContainerProperty('outputFont').actual()

outputFont = property(getOutputFont, setOutputFont)

Expand Down Expand Up @@ -3914,7 +3915,7 @@ def startContainer(self, fType, title, row=None, column=0, colspan=0, rowspan=0,
self.widgetManager.verify(self.Widgets.LabelFrame, title)
if not self.ttkFlag:
container = LabelFrame(self.getContainer(), text=name, relief="groove")
container.config(background=self._getContainerBg(), font=self._outputFont)
container.config(background=self._getContainerBg(), font=self._getContainerProperty('outputFont'))
else:
container = ttk.LabelFrame(self.getContainer(), text=name, relief="groove")

Expand Down Expand Up @@ -3955,7 +3956,7 @@ def startContainer(self, fType, title, row=None, column=0, colspan=0, rowspan=0,
return container
elif fType == self.Widgets.TabbedFrame:
self.widgetManager.verify(self.Widgets.TabbedFrame, title)
tabbedFrame = self._tabbedFrameMaker(self.getContainer(), self.ttkFlag, font=self._outputFont)
tabbedFrame = self._tabbedFrameMaker(self.getContainer(), self.ttkFlag, font=self._getContainerProperty('outputFont'))
if not self.ttkFlag:
tabbedFrame.config(bg=self._getContainerBg())
# tabbedFrame.isContainer = True
Expand Down Expand Up @@ -4060,7 +4061,7 @@ def startContainer(self, fType, title, row=None, column=0, colspan=0, rowspan=0,
elif fType == self.Widgets.ToggleFrame:
self.widgetManager.verify(self.Widgets.ToggleFrame, title)
toggleFrame = ToggleFrame(self.getContainer(), title=title, bg=self._getContainerBg())
toggleFrame.configure(font=self._outputFont)
toggleFrame.configure(font=self._getContainerProperty('outputFont'))
toggleFrame.isContainer = True
self._positionWidget(
toggleFrame,
Expand All @@ -4074,7 +4075,7 @@ def startContainer(self, fType, title, row=None, column=0, colspan=0, rowspan=0,
return toggleFrame
elif fType == self.Widgets.PagedWindow:
# create the paged window
pagedWindow = PagedWindow(self.getContainer(), title=title, bg=self._getContainerBg(), width=200, height=400, buttonFont=self._buttonFont, titleFont=self._outputFont)
pagedWindow = PagedWindow(self.getContainer(), title=title, bg=self._getContainerBg(), width=200, height=400, buttonFont=self._getContainerProperty('buttonFont'), titleFont=self._getContainerProperty('outputFont'))
# bind events
self.topLevel.bind("<Left>", pagedWindow.showPrev)
self.topLevel.bind("<Control-Left>", pagedWindow.showFirst)
Expand Down Expand Up @@ -4666,7 +4667,7 @@ def addTable(self, title, data, row=None, column=0, colspan=0, rowspan=0, action
grid = SimpleTable(self.getContainer(), title, data,
action, addRow,
actionHeading, actionButton, addButton,
showMenu, buttonFont=self._buttonFont)
showMenu, buttonFont=self._getContainerProperty('buttonFont'))
if not self.ttkFlag:
grid.config(font=self.tableFont, background=self._getContainerBg())
self._positionWidget(grid, row, column, colspan, rowspan, N+E+S+W)
Expand Down Expand Up @@ -5392,7 +5393,7 @@ def addCheckBox(self, title, row=None, column=0, colspan=0, rowspan=0, name=None
if not self.ttkFlag:
cb = Checkbutton(self.getContainer(), text=name, variable=var)
cb.config(
font=self._outputFont,
font=self._getContainerProperty('outputFont'),
background=self._getContainerBg(),
activebackground=self._getContainerBg(),
anchor=W)
Expand Down Expand Up @@ -5488,7 +5489,7 @@ def _buildScale(self, title, frame):
self.widgetManager.verify(self.Widgets.Scale, title)
var = DoubleVar(self.topLevel)
if not self.ttkFlag:
scale = self._makeAjScale()(frame, increment=10, variable=var, repeatinterval=10, orient=HORIZONTAL, font=self._inputFont)
scale = self._makeAjScale()(frame, increment=10, variable=var, repeatinterval=10, orient=HORIZONTAL, font=self._getContainerProperty('inputFont'))
scale.config(digits=1, showvalue=False, highlightthickness=1)
else:
scale = self._makeAjScale()(frame, increment=10, variable=var, orient=HORIZONTAL)
Expand Down Expand Up @@ -5669,7 +5670,7 @@ def _buildOptionBox(self, frame, title, options, kind="normal"):

option.config(
justify=LEFT,
font=self._inputFont,
font=self._getContainerProperty('inputFont'),
# background=self._getContainerBg(),
highlightthickness=0,
width=maxSize,
Expand Down Expand Up @@ -6288,7 +6289,7 @@ def addProperties(self, title, values=None, row=None, column=0, colspan=0, rowsp
haveTitle = False

props = Properties(self.getContainer(), title, values, haveTitle,
font=self._outputFont, background=self._getContainerBg())
font=self._getContainerProperty('outputFont'), background=self._getContainerBg())
self._positionWidget(props, row, column, colspan, rowspan)
self.widgetManager.add(self.Widgets.Properties, title, props)
return props
Expand Down Expand Up @@ -6387,7 +6388,7 @@ def _buildSpinBox(self, frame, title, vals):
spin = Spinbox(frame)
spin.inContainer = False
spin.isRange = False
spin.config(font=self._inputFont, highlightthickness=0)
spin.config(font=self._getContainerProperty('inputFont'), highlightthickness=0)

# adds bg colour under spinners
# if self.platform == self.MAC:
Expand Down Expand Up @@ -6875,7 +6876,7 @@ def _populateImage(self, name, image, internal=False):

label.image.animating = False
label.config(image=image)
label.config(anchor=CENTER, font=self._outputFont)
label.config(anchor=CENTER, font=self._getContainerProperty('outputFont'))
if not self.ttkFlag:
label.config(background=self._getContainerBg())
label.image = image # keep a reference!
Expand Down Expand Up @@ -6952,7 +6953,7 @@ def _addImageObj(self, name, img, row=None, column=0, colspan=0, rowspan=0, comp
else:
label = ttk.Label(self.getContainer())

label.config(anchor=CENTER, font=self._outputFont,image=img)
label.config(anchor=CENTER, font=self._getContainerProperty('outputFont'),image=img)
label.image = img # keep a reference!

if compound is not None:
Expand Down Expand Up @@ -6992,7 +6993,7 @@ def shrinkImage(self, name, x, y=''):
image = label.image.subsample(x, y)

label.config(image=image)
label.config(anchor=CENTER, font=self._outputFont)
label.config(anchor=CENTER, font=self._getContainerProperty('outputFont'))

if not self.ttkFlag:
label.config(background=self._getContainerBg())
Expand All @@ -7006,7 +7007,7 @@ def growImage(self, name, x, y=''):
image = label.image.zoom(x, y)

label.config(image=image)
label.config(anchor=CENTER, font=self._outputFont)
label.config(anchor=CENTER, font=self._getContainerProperty('outputFont'))

if not self.ttkFlag:
label.config(background=self._getContainerBg())
Expand Down Expand Up @@ -7233,7 +7234,7 @@ def addRadioButton(self, title, name, row=None, column=0, colspan=0, rowspan=0):
if not self.ttkFlag:
rb = Radiobutton(self.getContainer(), text=name, variable=var, value=name)
rb.config(anchor=W, background=self._getContainerBg(), indicatoron=1,
activebackground=self._getContainerBg(), font=self._outputFont
activebackground=self._getContainerBg(), font=self._getContainerProperty('outputFont')
)
else:
rb = ttk.Radiobutton(self.getContainer(), text=name, variable=var, value=name)
Expand Down Expand Up @@ -7344,7 +7345,7 @@ def addListBox(self, name, values=None, row=None, column=0, colspan=0, rowspan=0
vscrollbar.config(command=container.lb.yview)
hscrollbar.config(command=container.lb.xview)

container.lb.config(font=self._inputFont)
container.lb.config(font=self._getContainerProperty('inputFont'))
self.widgetManager.add(self.Widgets.ListBox, name, container.lb)

container.lb.DEFAULT_TEXT=""
Expand Down Expand Up @@ -7627,7 +7628,7 @@ def _buildButton(self, title, func, frame, name=None):
self.widgetManager.verify(self.Widgets.Button, title)
if not self.ttkFlag:
but = Button(frame, text=name)
but.config(font=self._buttonFont)
but.config(font=self._getContainerProperty('buttonFont'))
if self.platform in [self.MAC, self.LINUX]:
but.config(highlightbackground=self._getContainerBg())
else:
Expand Down Expand Up @@ -8295,13 +8296,13 @@ def addLabel(self, title, text=None, row=None, column=0, colspan=0, rowspan=0, s
if not selectable:
if not self.ttkFlag:
lab = Label(self.getContainer(), text=text)
lab.config(justify=LEFT, font=self._outputFont, background=self._getContainerBg())
lab.config(justify=LEFT, font=self._getContainerProperty('outputFont'), background=self._getContainerBg())
lab.origBg = self._getContainerBg()
else:
lab = ttk.Label(self.getContainer(), text=text)
else:
lab = SelectableLabel(self.getContainer(), text=text)
lab.config(justify=CENTER, font=self._outputFont, background=self._getContainerBg())
lab.config(justify=CENTER, font=self._getContainerProperty('outputFont'), background=self._getContainerBg())
lab.origBg = self._getContainerBg()

lab.inContainer = False
Expand All @@ -8324,7 +8325,7 @@ def addLabels(self, names, row=None, colspan=0, rowspan=0):
self.widgetManager.verify(self.Widgets.Label, names[i])
if not self.ttkFlag:
lab = Label(frame, text=names[i])
lab.config(font=self._outputFont, justify=LEFT, background=self._getContainerBg())
lab.config(font=self._getContainerProperty('outputFont'), justify=LEFT, background=self._getContainerBg())
else:
lab = ttk.Label(frame, text=names[i])
lab.DEFAULT_TEXT = names[i]
Expand Down Expand Up @@ -8397,7 +8398,7 @@ def _buildTextArea(self, title, frame, scrollable=False):
text = AjScrolledText(frame)
else:
text = AjText(frame)
text.config(font=self._inputFont, width=20, height=10, undo=True, wrap=WORD)
text.config(font=self._getContainerProperty('inputFont'), width=20, height=10, undo=True, wrap=WORD)

if not self.ttkFlag:
if self.platform in [self.MAC, self.LINUX]:
Expand Down Expand Up @@ -8665,7 +8666,7 @@ def addMessage(self, title, text=None, row=None, column=0, colspan=0, rowspan=0)
gui.trace("Not specifying text for messages (%s) now uses the title for the text. If you want an empty message, pass an empty string ''", title)
mess = Message(self.getContainer())
mess.config(text=text)
mess.config(font=self._inputFont)
mess.config(font=self._getContainerProperty('outputFont'))
mess.config(justify=LEFT, background=self._getContainerBg())
mess.DEFAULT_TEXT = text

Expand Down Expand Up @@ -8876,7 +8877,7 @@ def suppress(event):
ent.bind("<Key>", suppress)

if not self.ttkFlag:
ent.config(font=self._inputFont)
ent.config(font=self._getContainerProperty('inputFont'))
if self.platform in [self.MAC, self.LINUX]:
ent.config(highlightbackground=self._getContainerBg())

Expand Down Expand Up @@ -8935,7 +8936,7 @@ def _buildFileEntry(self, title, frame, selectFile=True):
vFrame.theWidget.bind("<Button-1>", click_command, "+")

if not self.ttkFlag:
vFrame.theButton = Button(vFrame, font=self._buttonFont)
vFrame.theButton = Button(vFrame, font=self._getContainerProperty('buttonFont'))
else:
vFrame.theButton = ttk.Button(vFrame)

Expand Down Expand Up @@ -8965,7 +8966,7 @@ def _buildValidationEntry(self, title, frame, secret):

lab = labelBase(vFrame)
lab.pack(side=RIGHT, fill=Y)
lab.config(font=self._outputFont)
lab.config(font=self._getContainerProperty('outputFont'))
if not self.ttkFlag:
lab.config(background=self._getContainerBg())
lab.inContainer = True
Expand Down Expand Up @@ -9343,11 +9344,11 @@ def _addMeter(self, name, kind="METER", row=None, column=0, colspan=0, rowspan=0
self.widgetManager.verify(self.Widgets.Meter, name)

if kind == "SPLIT":
meter = SplitMeter(self.getContainer(), font=self._outputFont)
meter = SplitMeter(self.getContainer(), font=self._getContainerProperty('outputFont'))
elif kind == "DUAL":
meter = DualMeter(self.getContainer(), font=self._outputFont)
meter = DualMeter(self.getContainer(), font=self._getContainerProperty('outputFont'))
else:
meter = Meter(self.getContainer(), font=self._outputFont)
meter = Meter(self.getContainer(), font=self._getContainerProperty('outputFont'))

self.widgetManager.add(self.Widgets.Meter, name, meter)
self._positionWidget(meter, row, column, colspan, rowspan)
Expand Down

0 comments on commit 2ec2e42

Please sign in to comment.