Author: Dan Shafer

# Scrolled Message Dialog

## Creating the Dialog

Create a Scrolled Message Dialog by calling dialog.scrolledMessageDialog with the three arguments shown in the following table.

Argument | Data type/notes
self | the window (background) that is the parent for the dialog
message | quoted string containing the text to be displayed in the scrolling dialog by default
title | quoted string containing the text to appear in the dialog's title bar

Most often, this dialog is used not with an explicit string passed as the second argument but rather with the contents of a file. The source code for this sample shows you how you can evaluate the third argument to the constructor method and, if it contains a valid file name, open that file and read its contents into the message variable for display.
Example:
Above dialog was created with this line of code:
`result = dialog.scrolledMessageDialog(self, message, filename)`
In the sample code that launches and handles the above dialog, you will find the following lines of code which determine what will be displayed. Here, the name of the file "dialogs.py" is hard coded into the program for simplicity's sake but it is easy to see how you would handle the parsing of the file name in the first line of this fragment if it were supplied as a string in the third argument of the constructor, for example.
`base, ext = os.path.splitext(os.path.split(sys.argv[0])[-1])
filename = base + ".py"
if os.path.exists(filename):
f = open(filename, "r")
msg = f.read()
else:
msg = "Can't find the file dialogs.py"`

## Interacting With the Dialog

You will not likely have much interaction with the scrolledMessageDialog component because it merely displays information to the user, supplies only an OK button, and returns no value in the result variable. It returns "accepted" but since there is no real difference between the user clicking the OK button (in which case accepted has a value of True) or the window's close button (in which case accepted has a value of False), it is of little value.
Example:
The sample dialog shown at the top of this page returns the following results if the user clicks the "OK" button to dismiss it.
result:
accepted: True