Wrapper of tkinter giving an easier way to build a gui interface. GUI Development does not have to be difficult nor painful.
Type in terminal or cmd
git clone https://github.com/lenskikh/tkeasy.git
Run any file with name "example"
On Arch linux install tk first
python sudo pacman -S tk
On Ubuntu
python sudo apt-get install python3-tk
06/22/23
- Changed name. "file" to "image_file"
- Added option image for the button widget
- Added option transparent for a window
- Each widget supports all default widget options of TKinter. You take any parameter from the Tkinter documentation and just use it.
- Creating a second window or frame is now easier, more logical and clearer. You will be able to open a second window after closing without any problem.
- Some options are already used by default. If your row or column is zero, then you can leave it. If your program is small, consists of two widgets, for example, a temperature converter, then this approach reduces the code. Or you use one vertical column equal to zero, then you can only specify a row. Other values such as pady are None.
Since the standard library is used, there are no issues with creating an exe
from tkeasy import TKeasy
gui = TKeasy()
gui.Title("The first window")
gui.config(size="300x100", bg = "white")
gui.label(text="The first window", bg = "white")
gui.loop()
Use get_info(name)
If you use several widgets such as entry, for understand which one to take information from, you need to give a name in each widget inside the brackets. See an example below.
from tkeasy import TKeasy
gui = TKeasy()
gui.Title("Input")
def info():
gui.msg_box_warning("INFO", gui.get_info("ent1"))
gui.entry(name="ent1",width=20, padx = 5, pady =5)
gui.button(text="Button",command=info,row=1)
gui.loop()
config(size="1x2 3 4")
1 - width
2 - hight
3 - position by X
4 - postion by Y
config(size="widthxhight posX posY")
Color of background, you can use hex colors
config(bg="lightgreen")
Icon of a window
config(icon="icon.ico")
Border of a window. If you don't specify "False", it will default to the standard window border width.
config(border = "False")
from tkeasy import TKeasy
gui = TKeasy()
gui.Title("ICON")
gui.config(size="50x150 400 100")
gui.config(bg="lightgreen")
gui.config(icon="icon.ico")
gui.config(border = "False")
gui.loop()
from tkeasy import TKeasy
gui = TKeasy()
gui.Title("The first window")
gui.config(size="300x300")
gui2 = TKeasy()
gui2.Title("The second window")
gui2.config(size="300x300 300 400")
#packing the first window
gui.loop()
#packing the second window
gui2.loop()
What are frames for? Frame allows you to pack widgets at specific coordinates. A frame has own grid. The most striking example is a calculator. In the first frame, you show the screen where the numbers are displayed. In the second frame you have buttons with numbers.
How to work with frames?
First you specify the first frame, prescribe its parameters. Then you enumerate the widgets. At the end, open the second frame and list new widgets there. See example below.
from tkeasy import TKeasy
gui = TKeasy()
gui.Title("Frames")
gui.config(size="205x250",bg="white")
gui.frames (frame = "frame 1", x= 21, y = 10,
highlightthickness = 1,
highlightbackground = "black",
padx = 5,
pady = 5)
gui.label(text="the first frame", bg = "#f5dc4b")
gui.frames (frame = "frame 2", x= 21, y = 50,
highlightthickness = 1,
highlightbackground = "black",
background = "#cadb66",
padx = 5,
pady = 5)
gui.label(text="the second frame", bg = "white")
gui.loop()
The top menu is a dictionary - tabs{}
See the image below to see how it works.
Remember that on the Mac operation system, the menu is not located in the window itself. The topmenu will be on top of your screen.
from tkeasy import TKeasy
gui = TKeasy()
gui.Title("Top Menu")
gui.config(size="250x170")
tabs = {"File":{"New":"False","Open":"False"}}
gui.top_menu(tabs)
gui.loop()
from tkeasy import TKeasy
gui = TKeasy()
gui.button(text="BUTTON", command=FALSE, padx = 5, row=0, column=0)
gui.loop()
from tkeasy import TKeasy
gui = TKeasy()
gui.Title("Input")
def info():
gui.msg_box_warning("INFO", gui.get_info("ent1"))
gui.entry(name="ent1",width=20, padx = 5, pady =5)
gui.button(text="Button",command=info,row=1)
gui.loop()
from tkeasy import TKeasy
gui = TKeasy()
gui.Title("Text area")
gui.config(size="246x245", transparent = 0.9)
def show_info():
gui.msg_box_warning("FROM TEXT AREA",gui.get_info("area").strip())
image = gui.image_file("button.png")
gui.label(text="Enter some text and press button 'Show info'", sticky='nswe', pady = 5)
gui.text_area(name="area",height=10,width=30,row=1)
gui.button(text="Show Info",image=image, borderwidth=0, compound="center", command=show_info,row=2)
gui.loop()