Skip to content

Commit

Permalink
getXXXBg() Function #373
Browse files Browse the repository at this point in the history
Added new function for getting the BG of a widget, and use it in
accessibility #328
  • Loading branch information
jarvisteach committed Feb 13, 2018
1 parent 42725bc commit 9ce9946
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions appJar/appjar.py
Expand Up @@ -2741,6 +2741,9 @@ def getWidget(self, kind, name, val=None):
if val is not None: name+= "-" + val
return self.widgetManager.get(kind, name)

def _getWidgetBg(self, kind, name, val=None):
return self.getWidget(kind, name, val).cget("bg")

def addWidget(self, title, widg, row=None, column=0, colspan=0, rowspan=0):
self.widgetManager.verify(self.Widgets.Widget, title)
self._positionWidget(widg, row, column, colspan, rowspan)
Expand Down Expand Up @@ -3253,6 +3256,11 @@ def _buildConfigFuncs(self):
str(k) + ", name, val)")
exec("gui.get" + v + "Widget=get" + v + "Widget")

exec( "def get" + v +
"Bg(self, name, val=None): return self._getWidgetBg(" +
str(k) + ", name, val)")
exec("gui.get" + v + "Bg=get" + v + "Bg")

#####################################
#  FUNCTION to hide/show/remove widgets
#####################################
Expand Down
8 changes: 4 additions & 4 deletions examples/issues/issue328.py
Expand Up @@ -3,8 +3,8 @@
from appJar import gui

def close(): app.hideSubWindow("Accessibility")
def changeFg(): app.label("fg", bg=app.colourBox(app.getLabelWidget("fg").cget("bg")))
def changeBg(): app.label("bg", bg=app.colourBox(app.getLabelWidget("bg").cget("bg")))
def changeFg(): app.label("fg", bg=app.colourBox(app.getLabelBg("fg")))
def changeBg(): app.label("bg", bg=app.colourBox(app.getLabelBg("bg")))

def settings():
font = {"underline":app.check("Underline"), "overstrike":app.check("Overstrike")}
Expand All @@ -15,8 +15,8 @@ def settings():
if app.option("Size:") is not None: font["size"] = app.option("Size:")

app.font = font
app.bg = app.getLabelWidget("bg").cget("bg")
app.fg = app.getLabelWidget("fg").cget("bg")
app.bg = app.getLabelBg("bg")
app.fg = app.getLabelBg("fg")

with gui("COLOUR TEST", "400x400") as app:
app.label("Some text")
Expand Down

0 comments on commit 9ce9946

Please sign in to comment.