コード例 #1
0
    def test_FrameListView(self):
        win = tk.Tk()
        constructor = TestFrame
        args = ("1", "2", "3")
        view = FrameListView(win)
        view.Load(constructor, args, "X")
        view.pack(anchor='n', fill=tk.BOTH, expand=True, side='left')

        #tk.mainloop()
        win.destroy()
コード例 #2
0
    def test_FrameListViewSelectMode(self):
        win = tk.Tk()
        constructor = TestFrame
        args = ("1", "2", "3")
        view = FrameListView(win, selectMode = True)
        view.Load(constructor, args, "X")
        view.pack(anchor='n', fill=tk.BOTH, expand=True, side='left')

        #tk.mainloop()
        result = [p.Text.get() for p in view.GetSelected()]
        print(result)
        win.destroy()
コード例 #3
0
 def test_FrameListViewMoves(self):
     win = tk.Tk()
     constructor = TestFrame
     args = ("1", "2", "3")
     view = FrameListView(win)
     view.Load(constructor, args, "X")
     view.pack(anchor='n', fill=tk.BOTH, expand=True, side='left')
     view.Insert(2, FrameListViewItem(view, TestFrame, "A"))
     view.Insert(3, FrameListViewItem(view, TestFrame, "B"))
     view.Insert(4, FrameListViewItem(view, TestFrame, "C"))
     actual = [item.Item.Text.get() for item in view.Items]
     expected = ['1', '2', 'A', 'B', 'C', '3']
     self.assertEqual(str(actual), str(expected), "Insert of items mid list failed")
     view.MovingObject = view.Items[2]
     view.MoveOrCreate(view.Items[0])
     actual = [item.Item.Text.get() for item in view.Items]
     expected = ['A', '1', '2', 'B', 'C', '3']
     self.assertEqual(str(actual), str(expected), "Move of item to start of list failed")
     view.MovingObject = view.Items[0]
     view.MoveOrCreate(view.Items[5])
     actual = [item.Item.Text.get() for item in view.Items]
     expected = ['1', '2', 'B', 'C', 'A', '3']
     self.assertEqual(str(actual), str(expected), "Move of item to before end of list failed")
     view.MovingObject = view.Items[4]
     view.MoveOrCreate(view.Items[5], True)
     actual = [item.Item.Text.get() for item in view.Items]
     expected = ['1', '2', 'B', 'C', '3', 'A']
     self.assertEqual(str(actual), str(expected), "Move of item to end of list failed")
     view.MovingObject = view.Items[-1]
     view.MoveOrCreate(view.Items[4])
     actual = [item.Item.Text.get() for item in view.Items]
     expected = ['1', '2', 'B', 'C', 'A', '3']
     self.assertEqual(str(actual), str(expected), "Move of item to middle of list failed")
     view.MovingObject = None
     view.MoveOrCreate(view.Items[-1], True)
     actual = [item.Item.Text.get() for item in view.Items]
     expected = ['1', '2', 'B', 'C', 'A', '3', 'X']
     self.assertEqual(str(actual), str(expected), "Add of item to end of list failed")
     view.Remove(view.Items[-1])
     view.Remove(view.Items[4])
     view.Remove(view.Items[3])
     view.Remove(view.Items[2])
     actual = [item.Item.Text.get() for item in view.Items]
     expected = ['1', '2', '3']
     self.assertEqual(str(actual), str(expected), "Removing items failed")
     win.destroy()