Esempio n. 1
0
def test_Lock_Unlock_History():
    from mglutil.gui.BasicWidgets.Tk.TreeWidget.tree import TreeView
    tv = TreeView()
    tv.addNode('protein_1')
    tv.addNode('residue_11', parent='protein_1')
    tv.addNode('AminoAcid', parent='protein_1|residue_11')
    tv.addNode('A', parent='protein_1|residue_11|AminoAcid')
    tv.addNode('H', parent='protein_1|residue_11|AminoAcid')
    tv.addNode('protein_2')

    tv.Select("protein_1|residue_11|AminoAcid|A")
    tv.AddToHistoryList()
    tv.Select("protein_2")
    tv.AddToHistoryList()
    tv.Select("protein_1|residue_11")
    tv.AddToHistoryList()
    tv.Select("protein_1|residue_11|AminoAcid|H")
    tv.AddToHistoryList()

    # lock
    tv.LockHistoryItem(2)
    tv.LockHistoryItem(3)
    # unlock
    tv.UnLockHistoryItem(2)

    tv.destroy()
Esempio n. 2
0
def test_Delete_from_History():
    from mglutil.gui.BasicWidgets.Tk.TreeWidget.tree import TreeView
    tv = TreeView()
    tv.addNode('protein_1')
    tv.addNode('residue_11', parent='protein_1')
    tv.addNode('AminoAcid', parent='protein_1|residue_11')
    tv.addNode('A', parent='protein_1|residue_11|AminoAcid')
    tv.addNode('H', parent='protein_1|residue_11|AminoAcid')
    tv.addNode('protein_2')

    tv.Select("protein_1|residue_11|AminoAcid|A")
    tv.AddToHistoryList()

    tv.Select("protein_2")
    tv.AddToHistoryList()

    tv.Select("protein_1|residue_11")
    tv.AddToHistoryList()

    tv.Select("protein_1|residue_11|AminoAcid|H")
    tv.AddToHistoryList()

    # delete
    tv.DeleteFromHistoryList(2)
    list = [0, 2]
    tv.historyList.Delete_multi(list)
    tv.destroy()
Esempio n. 3
0
def test_NoHistory():
    """ Test the crateion of a TreeView with no history Pane """

    tv = TreeView(nohistory=True)
    # paint canvas red so we see it disappear when distroyed
    tv.canvas.configure(bg='red')

    tv.addNode('protein_1')
    tv.addNode('residue_11', parent='protein_1')
    tv.addNode('AminoAcid', parent='protein_1|residue_11')
    tv.addNode('A', parent='protein_1|residue_11|AminoAcid')
    tv.addNode('H', parent='protein_1|residue_11|AminoAcid')
    tv.addNode('protein_2')

    tv.Select("protein_1|residue_11|AminoAcid|A")

    selection = tv.GetSelected()
    if selection:
        print "Adding", selection.name, "to the history list"
    else:
        print "Nothing is selected"

    # add the current selected node to the list
    tv.AddToHistoryList()

    #tv.topFrame.master.update()
    pause(0.2)
    tv.destroy()
Esempio n. 4
0
def test_SelectNode_deSelectNode():
    from mglutil.gui.BasicWidgets.Tk.TreeWidget.tree import TreeView
    tv = TreeView()
    #Add some nodes
    tv.addNode('protein_1')
    node = tv.addNode('residue_11', parent='protein_1')
    tv.addNode('AminoAcid', parent='protein_1|residue_11')
    tv.addNode('A', parent='protein_1|residue_11|AminoAcid')
    tv.addNode('H', parent='protein_1|residue_11|AminoAcid')
    tv.addNode('protein_2')

    selection = tv.GetSelected()
    if selection:
        print "Now", selection.name, "is selected"
    else:
        print "Nothing is selected"

    # Now select a node
    tv.Select("protein_1|residue_11|AminoAcid|A")

    selection = tv.GetSelected()
    if selection:
        print "***", selection.name, "is selected ***"
    else:
        print "Nothing is selected"

    tv.destroy()
Esempio n. 5
0
def test_SetAction():
    from mglutil.gui.BasicWidgets.Tk.TreeWidget.tree import TreeView
    tv = TreeView()
    tv.addNode('protein_1')
    tv.addNode('residue_11', parent='protein_1')
    tv.addNode('AminoAcid', parent='protein_1|residue_11')

    #Set what to do after an action here.
    tv.setAction(event='select', function=foo)
    tv.Select("protein_1")

    tv.destroy()
Esempio n. 6
0
def test_Add_to_History():
    from mglutil.gui.BasicWidgets.Tk.TreeWidget.tree import TreeView
    tv = TreeView()
    tv.addNode('protein_1')
    tv.addNode('residue_11', parent='protein_1')
    tv.addNode('AminoAcid', parent='protein_1|residue_11')
    tv.addNode('A', parent='protein_1|residue_11|AminoAcid')
    tv.addNode('H', parent='protein_1|residue_11|AminoAcid')
    tv.addNode('protein_2')

    tv.Select("protein_1|residue_11|AminoAcid|A")

    selection = tv.GetSelected()
    if selection:
        print "Adding", selection.name, "to the history list"
    else:
        print "Nothing is selected"

    # add the current selected node to the list
    tv.AddToHistoryList()

    tv.destroy()
Esempio n. 7
0
def test_obj2Node():
    """ Test the creation of a TreeView with obj2Node == false
    In that case there is not  1to 1 relation between object and node
    tv.objToNode should stay empty.
    """

    tv = TreeView(obj2Node=False)
    # paint canvas red so we see it disappear when distroyed
    tv.canvas.configure(bg='red')

    tv.addNode('protein_1')
    tv.addNode('residue_11', parent='protein_1')
    tv.addNode('AminoAcid', parent='protein_1|residue_11')
    tv.addNode('A', parent='protein_1|residue_11|AminoAcid')
    tv.addNode('H', parent='protein_1|residue_11|AminoAcid')
    tv.addNode('protein_2')

    tv.Select("protein_1|residue_11|AminoAcid|A")

    assert tv.objToNode == {}

    #tv.topFrame.master.update()
    pause(0.2)
    tv.destroy()