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:
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