Member Avatar

I'm trying to write a program in which a message box is to appear on the application window when the application is launched. The code below produces the message box, but it appears as a separate window that is not over the application window. Is there a way to fix this? Ideally I would like to make it so that the user cannot move the message box off the application window. I'm using python 2.7.6 on OSX 10.6.8. Thanks.

from Tkinter import *
import tkMessageBox

class App:

    def __init__(self):

        self.root = Tk()
        self.root.wm_resizable(0,0)
        self.frame = Frame(root, background="blue")
        self.frame.pack()

        self.cnvsHt = 800
        self.cnvsWdth = 800
        self.cnvs = Canvas(self.frame, width=self.cnvsWdth, height=self.cnvsHt, background = "#faf0e6")
        self.cnvs.pack(fill=X)


        tkMessageBox.showwarning('TEST', 'This is a test', parent =self.frame)

        self.root.mainloop()

if __name__ == '__main__':
    App()

Recommended Answers

You might want to replace the messagebox with a label of your own design.

Jump to Post

All 2 Replies

You might want to replace the messagebox with a label of your own design.

Or put it in a Toplevel which can be positioned and sized.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.