Placing a button in the middle of text areas and anywhere. (Tkinter, Python)

by - 2:54 AM

This might sound a little bit flashy because no one ever thought of creating a software with the button right in front of the your text area or somewhere in the middle of an image label, where the nose of the person in the image is clickeable. You can make some silly game out of this, or a cool one if you want to.
Again, you can tank me later for that. :)

You should create canvas so that the button can depend on it as a parent or root and then use the place manager to place it anywhere you want within the realm of possibilities.

Here's the code. You figure the rest out...

from Tkinter import *
window = Tk()
frame = Frame(window).pack()
canvas = Canvas(frame).pack(side = LEFT)
text = Text(frame,wrap = WORD)
text.insert(END,"THIS IS THE TEXT AREA AND WE ARE PLACING THE BUTTON IN THE MIDDLE");
text.pack()
framec = Frame(canvas).pack()
button = Button(framec, text = "Button").place(x = 500,y=12)
window.mainloop()

Here's a screenshot of what the code basically does.



Please do not hesitate to contact and ask me anything you want. Especially, in Python and Java. I will try to assist.

Comment below if you have any questions or comments.

Thank you!

You May Also Like

0 comments