|
Post by Trey Brown on Jul 8, 2014 20:51:13 GMT -5
Ok, lets start off with that you should know a bit of lingo before you even think about looking at this tutorial. I will use it, and I won't explain it. As well as I will be using Python 2.7. Lets get started. Tkinter is simply a python extension used for GUI programming, it's fairly simple. It's basically a bunch of functions put together that you need to set out strategically to get your program to run properly. Let's get started... First you want to import the extension. The syntax to do so is as follows: from Tkinter import * import sys
I assume that you have learned import statements from another tutorial, but I will explain it anyways. The "from" grabs a library and the "import" pulls something to be used in the code from that library. The "*" signals that we will be grabbing all of the contents of the library. Now we want to assign a variable for our root, which will be our window. root = Tk()
This is pretty self explanatory. We just took the main function and called it. Now we will set the title of the window. root.title('Hello World')
Here we called the "title" function and called it to our "root". Our last line will just run the rest of the program through a loop. root.mainloop()
This takes our "root" and runs it through the "mainloop". This is what you should see when you run this program by double-clicking it. Final product: from Tkinter import * import sys
root = Tk() root.title('Hello World') root.mainloop()
|
|