How to use the ttkwidgets.ItemsCanvas function in ttkwidgets

To help you get started, we’ve selected a few ttkwidgets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TkinterEP / ttkwidgets / tests / test_itemscanvas.py View on Github external
def test_itemscanvas_init(self):
        canvas = ItemsCanvas(self.window)
        canvas.pack()
        self.window.update()
github TkinterEP / ttkwidgets / tests / test_itemscanvas.py View on Github external
def test_itemscanvas_items(self):
        canvas = ItemsCanvas(callback_del=lambda *args: args)
        canvas.add_item(text="Item", backgroundcolor="red", textcolor="green", highlightcolor="#ffffff",
                        font=("default", 15, "italic"))
        canvas.current = 1
        canvas.del_item()
        self.window.update()
github TkinterEP / ttkwidgets / tests / test_itemscanvas.py View on Github external
def test_itemscanvas_background(self):
        canvas = ItemsCanvas()
        path = os.path.join(get_assets_directory(), "open.png")
        img = ImageTk.PhotoImage(Image.open(path))
        canvas.set_background(image=img)
        self.window.update()
        canvas.set_background(path=path)
        self.window.update()
        self.assertRaises(ValueError, lambda: canvas.set_background(image=img, path=path))
        self.assertRaises(ValueError, canvas.set_background)
        self.assertRaises(ValueError, canvas.set_background, path=1)
        self.assertRaises(ValueError, canvas.set_background, path="/path/not/existing")
        self.assertRaises(ValueError, canvas.set_background, image=1)
github TkinterEP / ttkwidgets / tests / test_itemscanvas.py View on Github external
def test_itemscanvas_menu(self):
        canvas = ItemsCanvas()
        canvas.pack()
        self.window.wm_geometry("+0+0")
        self.window.update()
        mouse_controller = Controller()
        mouse_controller.position = (0, 0)
        mouse_controller.move(30, 40)
        self.window.update()
        mouse_controller.press(Button.right)
        self.window.update()
        mouse_controller.release(Button.right)
        self.window.update()
github TkinterEP / ttkwidgets / tests / test_itemscanvas.py View on Github external
def test_itemscanvas_config(self):
        canvas = ItemsCanvas()
        canvas.config(canvaswidth=1024, canvasheight=1024)
github TkinterEP / ttkwidgets / tests / test_itemscanvas.py View on Github external
def test_items_canvas_get_options(self):
        canvas = ItemsCanvas()
        keys = ["canvaswidth", "canvasheight", "function_new", "callback_add", "callback_del", "callback_move", "width"]
        for key in keys:
            canvas.cget(key)
            self.assertTrue(key in canvas.keys())
github TkinterEP / ttkwidgets / tests / test_itemscanvas.py View on Github external
def test_itemscanvas_getsetitem(self):
        canvas = ItemsCanvas()
        value = canvas["canvaswidth"]
        self.assertIsInstance(value, int)
        canvas["canvaswidth"] = 20
github TkinterEP / ttkwidgets / tests / test_itemscanvas.py View on Github external
def test_itemscanvas_drag(self):
        canvas = ItemsCanvas(self.window)
        canvas.pack()
        canvas.add_item("item", font=("default", 16))
        self.window.wm_geometry("+0+0")
        self.window.update()
        mouse_controller = Controller()
        mouse_controller.position = (30, 40)
        self.window.update()
        mouse_controller.press(Button.left)
        self.window.update()
        mouse_controller.move(100, 100)
        self.window.update()
        mouse_controller.release(Button.left)
        self.window.update()
github TkinterEP / ttkwidgets / tests / test_itemscanvas.py View on Github external
def test_itemscanvas_select(self):
        canvas = ItemsCanvas()
        canvas.pack()
        canvas.add_item("item", font=("default", 16))
        self.window.wm_geometry("+0+0")
        self.window.update()
        mouse_controller = Controller()
        mouse_controller.position = (30, 40)
        self.window.update()
        mouse_controller.press(Button.left)
        self.window.update()
        mouse_controller.release(Button.left)
        self.window.update()
github TkinterEP / ttkwidgets / examples / example_itemscanvas.py View on Github external
# -*- coding: utf-8 -*-

# Copyright (c) RedFantom 2017
# For license see LICENSE
from ttkwidgets import ItemsCanvas
import tkinter as tk
from tkinter import ttk


root = tk.Tk()

canvas = ItemsCanvas(root)
canvas.pack()

canvas.add_item("Example", font=("default", 13, "italic"), backgroundcolor="green", textcolor="darkblue",
                highlightcolor="blue")

root.mainloop()