-
Notifications
You must be signed in to change notification settings - Fork 0
Home
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 the WidgetShape or WidgetComposition object. The composition consists of multiple layers: Canvas, Shape and the Tkinter Frame object. tesTk allows you to easily create your own widgets. All you have to do is put the widgets in the frame and show them to the world.
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.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()
'''A place for your code
'''
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!')
'''A place for your code
'''
app = App()
MyOwnWidget(app, text='tesTk').pack()
app.mainloop()
This is tesWidgetBox. I created it based on the WidgetComposition class. I created it so you can see how easy it is to create your own widgets. You can set the title, maximum width and maximum height of the widget and place all other widgets in it. Very importantly, the size of this widget changes.
tesWidgetBox class object
from tkmodule import App
from widgets import tesWidgetBox, tesText, tesLabel, tesButton
app = App()
box = tesWidgetBox(app, width_max=300, height_max=600, separator=None) ; box.pack()
tesText(box.tkinterframe, text='default').pack(side='top')
tesLabel(box.tkinterframe, text='tesTk is Tkinter's modern widgets design').pack(side='left')
tesButton(box.tkinterframe, icon='./image/tesTk.png').pack(side='right')
app.mainloop()