Skip to content

How to create Message Box? #30

Answered by ObaraEmmanuel
ewwink asked this question in Q&A
Discussion options

You must be logged in to vote

There is no way to directly do this on the designer yet. However, you can easily do this on the code side. You will need to attach a command to the button like so:

Note the name show_message.

You can then call the dialog in your code

from formation.loader import AppBuilder
from tkinter.messagebox import askyesno


class App(AppBuilder):

    def __init__(self):
        super().__init__(path="test.xml")
        self.connect_callbacks(self)

    def show_message(self):
        result = askyesno("Test", "This is a test message box")
        print(result)


if __name__ == "__main__":
    App().mainloop()

The name of the method show_message must match the name you provided in the command option.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ewwink
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants