Skip to content

Commit

Permalink
new function to set all tree colours (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvisteach committed Apr 8, 2017
1 parent 3b3a989 commit 88bcb8b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
12 changes: 12 additions & 0 deletions appJar/appjar.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,14 @@ def setFgHColour(self, colour):
self.fgHColour = colour
self.__doUpdateColour()

def setAllColours(self, bg, fg, bgH, fgH):
self.canvas.config(background=bg)
self.bgColour = bg
self.fgColour = fg
self.bgHColour = bgH
self.fgHColour = fgH
self.__doUpdateColour()

def __doUpdateColour(self):
self.__updateColours(
self.bgColour,
Expand Down Expand Up @@ -5359,6 +5367,10 @@ def setTreeHighlightFg(self, title, colour):
tree = self.__verifyItem(self.n_trees, title)
tree.setFgHColour(colour)

def setTreeColours(self, title, fg, bg, fgH, bgH):
tree = self.__verifyItem(self.n_trees, title)
tree.setAllColours(bg, fg, bgH, fgH)

def setTreeDoubleClickFunction(self, title, func):
if func is not None:
tree = self.__verifyItem(self.n_trees, title)
Expand Down
4 changes: 3 additions & 1 deletion docs/mkdocs/docs/pythonDevWidgets.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Widget to emulate a [MicroBit](http://microbit.org)
* ```.addMicroBit(title)```
Will create a 5x5 grid emulating the MicroBit LEDs.

###Set MicroBits
####Set MicroBits
* ```.setMicroBitImage(title, image)```
This sets each pixel to the specified brightness (0 to 9).
Each set of 5 digits represents a row of pixels, from top to bottom.
Expand Down Expand Up @@ -89,6 +89,8 @@ app.go()
Register a function to call when an item is edited
* `.setTreeEditable(title, value)`
Set whether the tree can be edited
* `.setTreeColours(title, fg, bg, fgH, bgH)`
Set the fg/bg/fg highlight/bg highlight colours of the tree
* `.setTreeBg(title, colour)`
Set the background colour of the tree
* `.setTreeFg(title, colour)`
Expand Down
1 change: 1 addition & 0 deletions docs/mkdocs/docs/whatsNew.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* [#101](https://github.com/jarvisteach/appJar/issues/101) - Drag n'Drop supported between applications
* [#92](https://github.com/jarvisteach/appJar/issues/92) - Function to [get all entries](/pythonWidgets/#entry)
* [#46](https://github.com/jarvisteach/appJar/issues/46) - Added version details to about box
* [#33](https://github.com/jarvisteach/appJar/issues/33) - Added convenience function to [setTreeColours](/pythonDevWidgets/#tree)

---
## Version (0.052)
Expand Down
9 changes: 5 additions & 4 deletions examples/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ def col(btn):
canEdit = not canEdit
app.setTreeEditable("t1", canEdit)
app.setBg("black")
app.setTreeBg("t1", "red")
app.setTreeFg("t1", "yellow")
app.setTreeHighlightBg("t1", "yellow")
app.setTreeHighlightFg("t1", "red")
# app.setTreeBg("t1", "red")
# app.setTreeFg("t1", "yellow")
# app.setTreeHighlightBg("t1", "yellow")
# app.setTreeHighlightFg("t1", "red")
app.setTreeColours("t1", "yellow", "red", "red", "yellow")
def dClick(btn):
print("DBL CLICK:", app.getTreeSelected(btn))

Expand Down
2 changes: 2 additions & 0 deletions tests/widget_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,8 @@ def test_trees():
app.getTreeSelected("t1")
app.getTreeSelectedXML("t1")

app.setTreeColours("t1", "red", "yellow", "yellow", "red")

# call generic setter functions
test_setters("Tree", "t1")

Expand Down

0 comments on commit 88bcb8b

Please sign in to comment.