Beginner's help with a GUI window

One such instance of a thread I’ve read would be this one:

I tried strategically placing the code into my project, but it does not work. I’m sure there are multiple reasons why, and I’m trying to get to the bottom of this.