#!/usr/bin/env python import sys, os import time import threading import multiprocessing from Tkinter import * ### ### class Panel ### class Panel: def __init__(self, subp='multip'): if subp == 'multip': print 'multiprocessing module to handle' # GUI process self.process1 = multiprocessing.Process(target=self.draw) self.process1.start() elif subp == 'thread': print 'threading module to handle' # GUI thread self.thread1 = threading.Thread(target=self.draw) self.thread1.start() # self.thread1.setDaemon(1) else: print 'main thread to handle' pass def draw(self): self.root = Tk() w = Button(self.root, text='Exit', command=self.root.quit) w.pack() self.root.mainloop() ### ### Main routine ### def main(): subp = 'multip' if len(sys.argv) >= 2: if not sys.argv[1] in ['multip', 'thread', 'none',]: print 'Invalid option: %s' % sys.argv[1] print "Valid options are 'multip', 'thread', 'none'" sys.exit(1) else: subp = sys.argv[1] panel = Panel(subp) if subp == 'none': panel.draw() while 1: time.sleep(1) pass if __name__ == '__main__': main()