Skip to content

Commit

Permalink
Increased testing #216
Browse files Browse the repository at this point in the history
Basic and & focus
  • Loading branch information
jarvisteach committed Aug 27, 2017
1 parent e564996 commit b44acc1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
1 change: 1 addition & 0 deletions appJar/__init__.py
Expand Up @@ -10,3 +10,4 @@
from appJar.appjar import Separator
from appJar.appjar import Grip
from appJar.appjar import PieChart
from appJar.appjar import DraggableWidget
20 changes: 20 additions & 0 deletions examples/focus.py
@@ -0,0 +1,20 @@
import sys
sys.path.append("../")

from appJar import gui

def get(btn):
print(app.getFocus() == btn)

def press(btn):
if btn == "E1": app.setEntryFocus("e1")
if btn == "L1": app.setLabelFocus("l1")

app = gui()
e1 = app.addEntry("e1")
e1 = app.addLabel("l1")

app.addButtons(["E1", "L1"], press)
app.addButtons(["l1", "e1"], get)

app.go()
26 changes: 24 additions & 2 deletions tests/widget_test.py
Expand Up @@ -9,7 +9,7 @@


sys.path.append("../")
from appJar import gui, SelectableLabel, AutoCompleteEntry, ajScale, AjText, AjScrolledText, Meter, Properties, Link, Separator, Grip, PieChart
from appJar import gui, SelectableLabel, AutoCompleteEntry, ajScale, AjText, AjScrolledText, Meter, Properties, Link, Separator, Grip, PieChart, DraggableWidget

PY_VER = str(sys.version_info[0]) + "." + str(sys.version_info[1])

Expand Down Expand Up @@ -46,7 +46,6 @@ def test_grid_layout():
app.addLabel("lay2", TEXT_ONE, 1, 1)
app.addLabel("lay3", TEXT_ONE, 1, 1, 1)
app.addLabel("lay4", TEXT_ONE, 1, 1, 1, 1)

app.addLabel("lay5", TEXT_ONE, 2)
app.addLabel("lay6", TEXT_ONE, 2, 2)
app.addLabel("lay7", TEXT_ONE, 2, 2, 2)
Expand Down Expand Up @@ -118,6 +117,7 @@ def test_entries():
app.setAutoEntryNumRows("ae1", 5)

# quick validation check
app.addEntry("focusEnt")
app.addValidationEntry("ve1")
app.addLabelValidationEntry("lve1")
app.setEntryValid("ve1")
Expand Down Expand Up @@ -2211,7 +2211,11 @@ def dropFunc(val=None):
pass

def test_dnd():
dw = DraggableWidget(app.topLevel.canvasPane, "a", "b", [10,10])
app.addLabel("ddd", "DND TESTER")
tb = app.addTrashBin("tb")
tb.config(fg="red")
tb.dnd_commit(dw, None)
# internal drag & drop
app.setLabelDroppable("ddd", dropFunc)
app.setLabelDraggable("ddd", dragFunc)
Expand All @@ -2220,6 +2224,23 @@ def test_dnd():
app.setLabelDropTarget("ddd", dropFunc)
app.setLabelDragSource("ddd", dragFunc)

def test_focus():
print("testing focus\n")

app.addEntry("entFocus")
app.setEntryFocus("entFocus")
try: assert app.getFocus() == "entFocus"
except: pass

app.addLabel("labFocus", "text")
app.setLabelFocus("labFocus")
with pytest.raises(Exception) :
assert app.getFocus() == "labFocus"

print(" >> not implemented...")
#print("\t >> all tests complete")


app = gui()
with pytest.raises(Exception) :
app3 = gui()
Expand Down Expand Up @@ -2296,6 +2317,7 @@ def test_gui(btn=None):
if doStop == 0:
test_pop_ups()
if doStop == 2:
test_focus()
test_sets()
test_langs()
test_widget_arranging()
Expand Down

0 comments on commit b44acc1

Please sign in to comment.