More tkinter : Add entry and text box
This code adds a box to our application, a box can serve either as a text output box OR a text entry box.
Note I have included the whole program here. I have also defined the size of our application.
While the window is bigger and the boxes are at the top, the idea is that it just displays those boxes. We can tidy things up later.
#!/usr/bin/env python
import Tkinter # note use of caps
from Tkinter import *
window = Tk()
window.title('GUI Tkinter 1')
window.geometry("300x250") # w x h
window.resizable(0,0)
#define entry box
circleVar = StringVar()
circletext = Entry(window, textvariable=circleVar)
#define out box
circleVar2 = StringVar()
circletext2 = Entry(window, textvariable=circleVar2)
circleVar2 = StringVar()
circletext2 = Entry(window, textvariable=circleVar2)
#display boxes
circletext.grid(row = 1, column = 2,)
circletext2.grid(row = 2, column = 2,)
window.mainloop()
We get:
#tkinter,#python,#gui,#programming.
Mastodon | Peertube | Join Mastodon |
AI statement : Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity. Consent CANNOT be assumed, it has to be granted.