Wednesday, November 17, 2010

Python - GUI programming script - Tkinter

This is a sample script which is used to create a label and display it in a window. The script uses Tkinter library for GUI programming. There are several other GUI tools that are available, you can use anything that suits your needs, but this small script is to understand the basics of what python GUI is all about. I will be writing more scripts on GUI with Python,

import Tkinter
from Tkinter import *

def create_label(caption):
    widget = Label(text=caption)
    return widget

def main():
    root = Tk()
    labelfont = ('times', 24, 'italic')
    widget = Label(root, text='Eat At JOES')
    widget.config(bg='black', fg='red')
    widget.pack(expand=YES, fill=BOTH)
    root.mainloop( )

if __name__ == '__main__':
    main()

No comments:

Post a Comment