I want to create a program in which the output currently on screen is stored in the file and when required, can be read and printed on the screen as it is.
I want to use it to create a program in turbo c++.
Actually, I have an assignment from school in which i have to simulate the functioning of a dialog box in dos.
What does this assignment have to do with capturing screen-display into a file? Your program knows what it displayed on the screen previously, just re-display that when you're finished with your simulated dialog box. Depending on the details of which compiler you're using for school, you may be able to use
as a non-portable way to clear the screen before drawing the dialog box, and after "closing" it and re-displaying what was there previously. Once you have more basic stuff done, you may want to look into a "curses" library for better control over where text is displayed in your terminal window, but that sounds more advanced than you really need. Not to mention trying to go back and scrape the current contents of your window into a file, and then read that file back and re-populate your window from it.
root = tkinter.Tk()
buttons=[i for i in range(10)]
#If specific button is pressed, output "YES"
for num in buttons: