1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| import glob, os
import sys
import time, threading
from Tkinter import *
from tkFileDialog import askopenfilename
class App:
def __init__(self,parent):
f = Frame(parent)
f.pack(padx=15,pady=15)
self.entry = Entry(f,text="enter your choice")
self.entry.pack(side= TOP,padx=10,pady=12)
self.exit = Button(f, text="exit", command=f.quit)
self.exit.pack(side=BOTTOM,padx=10,pady=10)
self.button = Button(f, text="print bonjour",command=self.effacer_intraday)
self.button.pack(side=BOTTOM,padx=10,pady=10)
self.button = Button(f, text="print once",command=self.update_once)
self.button.pack(side=BOTTOM,padx=10,pady=10)
self.button = Button(f, text="Stop",command=self.stop_loop)
self.button.pack(side=BOTTOM,padx=10,pady=10)
self.button = Button(f, text="print each second",command=self.update_loop)
self.button.pack(side=BOTTOM,padx=10,pady=10)
def effacer_intraday(self):
print "bonjour"
def update_loop(self):
global counter_id
periode = self.entry.get()
print periode
counter_id =root.after(1000, self.update_loop)
def update_once(self):
periode = self.entry.get()
print periode
def stop_loop(self):
if counter_id:
root.after_cancel(counter_id)
root = Tk()
root.title('Tkwidgets application')
Label (text="Enter text to print:").pack(side=TOP,padx=0,pady=0)
app = App(root)
root.mainloop() |
Partager