Home > Software design >  What is the function of body ( ) parameter in Tkinter simpledialog?
What is the function of body ( ) parameter in Tkinter simpledialog?

Time:10-11

I am trying to customize my simpledialogbox in Tkinter in order to fit my text into the box. When I read the document, I did not detail info about it. How can I do that?

CodePudding user response:

So the documentation may be a bit confusing, especially for beginners? I don't know, but at least one way to use body is this:

from tkinter import Tk, Label
from tkinter.simpledialog import Dialog


class MyDialog(Dialog):
    def __init__(self, master, title=None):
        super().__init__(master, title)

    def body(self, master):
        Label(master, text='some text here').pack()


root = Tk()
root.withdraw()

MyDialog(root, title='some title here')
  • Related