Here is some boilerplate code for setting up a basic GUI application with ttk in Python 3.1:
#!/usr/bin/env python # Python 3 import tkinter from tkinter import ttk class Application: def __init__(self, root): self.root = root self.root.title('Hello World') ttk.Frame(self.root, width=200, height=100).pack() ttk.Label(self.root, text='Hello World').place(x=10, y=10) if __name__ == '__main__': root = tkinter.Tk() Application(root) root.mainloop()
This example shows usage of the Frame and Label widgets, and some basic layout management using pack() and place(). It renders on Ubuntu (with Gnome) like this:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0bVXhe9IqLqqYjR-llJng76ACAVDMI17q3QiKBx9xkv70WHOOLhTAabPLuuq4YHJVwtn0WVUvcH2xbZoiOOH0mv_qW8_PxbGq95D6QhC-55eb8YzwJ3GKBv1X30mICnFW62x2u2P13BM/s400/Screenshot-Hello+World.png)
1 comment:
This article just helped me get a basic idea about how to give my Python 3 programs GUI's, thank you.
Post a Comment