OK, here is a litting script I wrote (admittedly with some help from http://www.pythonware.com/library/tkinter/introduction/hello-again.htm)that will allow me to cloak in with ease here at work. Only.... since I sometimes log into the computer multiple times in the day, I wanted to use Tkinter to give me a yes/no button. But.... I was having trouble getting it to close the tkinter box afterwards. If I select "Don't clock in", the button is depressed, but the box is still there, and I have to end it manually. I'm still a bit cloudy about some of the things that are happening in the program, but I can't see why it doesn't work quite right.

# File: clockin.py

from Tkinter import *
from win32com.client import Dispatch
import time

class App:

def __init__(self, master):

frame = Frame(master)

self.button = Button(frame, text="Don't clock in", command=frame.quit)

self.hi_there = Button(frame, text="Clock in", command=self.clock_in)

def clock_in(self):
xlApp = Dispatch("Excel.Application")
logfile = r"h:\hourslog.xlsx"
date = time.strftime("%a %m/%d/%y", time.localtime())
r = 1


while True:
if xlApp.ActiveWorkbook.ActiveSheet.Cells(r,1).Value == None:
xlApp.ActiveWorkbook.ActiveSheet.Cells(r,1).Value = date
xlApp.ActiveWorkbook.ActiveSheet.Cells(r,2).Value = time.strftime("%H:%M:%S", time.localtime())
elif xlApp.ActiveWorkbook.ActiveSheet.Cells(r,1).Value == date:
xlApp.ActiveWorkbook.ActiveSheet.Cells(r,3).Value = time.strftime("%H:%M:%S", time.localtime())
r = r + 1

#xlApp.Visible = 0

root = Tk()

app = App(root)


Nevemind, found the issue myself after playing around with it even more.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.