Skip to content
LinuxEducation edited this page Oct 28, 2023 · 12 revisions

About Project

tesTk is based on the tkinter library. The first layer of each widget is a canvas, so you decide how the widget will look and change. You can create animations, draw your own controls, change widget shapes. You can also easily combine multiple widgets into one. Tkinter Canvas allows you to add any widgets you want: Frame, Button, Entry or Text, Images. Each pixel on the canvas, each object can be tagged by giving it a name, allowing you to change these objects or remove them.

The tesTk widgets are based on a WidgetShape or WidgetComposition object. The composition consists of multiple layers: Canvas, Shape and a Tkinter Frame object.

class WidgetComposition

from tkmodule import App
from tkinter import Button
from src.widget_composition import WidgetComposition

class MyOwnWidget(WidgetComposition):
    widgetName = 'My Own Widget'

    def __init__(self, container, **kw):
        super().__init__(container, **kw)
        self.draw_widget()
        self._insert_tkinter_frame_widget()
        self._grid_settings()
        self.insert_widget()

    def draw_widget(self) -> None:
        WidgetComposition.draw_widget(self)
        print(MyOwnWidget.widgetName, 'is draw!')

    def insert_widget(self) -> None:
        Button(self.tkinterframe, text='Tkinter Button').pack()


app = App()
MyOwnWidget(app).pack()
app.mainloop()

class WidgetShape

from tkmodule import App
from src.widget import WidgetShape, WidgetSetting

class MyOwnWidget(WidgetShape):
    widgetName = 'My Own Widget'

    def __init__(self, container, **kw):
        WidgetShape.__init__(self, container, **kw)
        self.draw_widget()

    def draw_widget(self) -> None:
        WidgetShape.draw_widget(self)
        if self.text:
            WidgetShape.insert_text(self)
        print(MyOwnWidget.widgetName, 'is draw!')


app = App()
MyOwnWidget(app, text='tesTk').pack()
app.mainloop()
Clone this wiki locally