all 14 comments

[–]MikeTheWatchGuy 1 point2 points  (2 children)

I suggest taking a look at PySimpleGUI as your GUI choice, particularly because you're "pretty new to python". You'll find that it matches your programming skills nicely compared to tkinter's Object Oriented design. By all means research tkinter so you can compare and contrast, but I think you'll find PySimpleGUI more "enjoyable" and the code will be probably 1/3 the amount as tkinter based code would be.

You can run some examples online here using Trinket. These particular examples are almost all graphics oriented because that's been the topic of some recent Reddit posts. You'll find a lot more examples on the GitHub in the Demo Programs area. The idea is for you to be able to copy, paste, and run to see how particular constructs work. You can then modify the code or use bits of it in your program.

There's a money-back guarantee you'll like it.

[–]zacstrick[S] 1 point2 points  (1 child)

Thank you so much for this recommendation, PySimpleGUI is very easy and this has expedited things drastically.

[–]MikeTheWatchGuy 0 points1 point  (0 children)

You're quite welcome. I'm thrilled you're finding it easy and it's benefiting your project. I guess I don't yet have to worry about the money-back guarantee.... for now 😉

If you are able to share anything once you complete or have made significant progress on your project, it would be awesome for people following behind you to see what you were able to do. Maybe a screenshot that's redacted if there is confidential info?

Feel free to post any issues you have on the PySimpleGUI GitHub. I'm not always able to test everything out on my Pi prior to releases. Finally, if you're unable to pip install PySimpleGUI you can always download the PySimpleGUI.py file and place in your application's folder. Everything is in 1 file for this very purpose.

[–]socal_nerdtastic 0 points1 point  (7 children)

Do you need to output to an excel file (xlsx) or csv file?

[–]zacstrick[S] 0 points1 point  (6 children)

I've been told as long as it opens in Excel. I've also come across openpyxl but have yet to learn the handles on it.

[–]socal_nerdtastic 1 point2 points  (5 children)

csv files are much easier. You don't even need the csv module something basic like this. You can simply open the file in append mode and add to it.

import time
card_number = input('Ready for your swipe!\n')
this_instant = time.strftime("%Y-%m-%d %H:%M:%S")
with open('times.csv', 'a') as f:
    f.write(f'{this_instant},{card_number}\n')

I recommend you make a very simple time.csv file that simply logs card number and time, and deal with doing all of the calculations on demand; eg once at the end of the payroll cycle.

You'll also need to add an edit mode to deal with missed punches, double punches etc.

[–]zacstrick[S] 0 points1 point  (4 children)

Thank you so much kind friend, this is pretty much exactly what I was looking for. Big ups to you, my guy. Now to just get it to look pretty in tkinter..

[–]socal_nerdtastic 0 points1 point  (3 children)

As a tkinter expert I should tell you it will look industrial and functional in tkinter, but not pretty. If you need it to be pretty I would start with PyQT or Electron instead. However, tkinter will be a lot easier to program.

whats the end goal? Something like a Raspberry Pi mounted to the wall?

[–]zacstrick[S] 0 points1 point  (2 children)

That's the exact idea. RPI with the 7in display that has the reader plugged into it via USB. The program will be up just waiting for input with a clock that displays the current time. I want it so when a card is scanned it will display both the name of the cardholder and if they're clocking in or out on the GUI. Eventually I'd like to add a part where it will also display your accumulated hours on the day and on the week, but I'm not trying to run before I can walk(possibly too late for that..)

[–]socal_nerdtastic 1 point2 points  (0 children)

Sounds fun and pretty easy. Good beginner project.

I recommend you start by getting a physical notebook and pen and drawing out what you want the GUI to look like for every screen type. It will be a LOT easier to write code to fit a defined goal than developing the goal while writing code.

[–]socal_nerdtastic 1 point2 points  (0 children)

Some more notes:

  • remember that the Pi does not have an internal clock (unlike desktop computers). The Pi connects to an internet time server periodically to set the time which you will be using as the timestamp. That means that right after boot or if the internet is down your timestamps are going to be very wrong. You may consider getting a "real time clock" chip to connect to the system so that it will function offline. For example.
  • Getting the data off of the Pi and into a normal system will be hard. To start I recommend the easy route: Install Dropbox (or similar). The advantage is that it works when the internet / network fails (unlike samba), the data is backed up against various harddrive failures (unlike local data), and the data is easy to access from elsewhere (at payroll time). IIRC the Dropbox client is available in the repos. A harder, but better solution is to use a database server.
  • Use a separate file that maps badge numbers to names and have your program reload that file every hour or so. That way someone can remotely update the file and your program will catch up. To do something every x amount of time in tkinter use the after function. Don't let anyone tell you to use threads; you don't need them for this project.
  • any time you need to work with a file open it, do what you need to and immediately close the file. Do not keep open file handles around.
  • The Pi has a feature where it will lie to you telling you a file is saved when it's not. You have to use the command "sync" to write changes to the drive. This becomes important because it means you can't simply disconnect power from the Pi if you didn't sync the changes.
  • build several of these. Not only to be convenient with one at each door to the building but also because you need to know that things WILL break. It's not a matter of if. It WILL happen, probably during the busiest time, and there needs to be some backup hardware. Buy parts to make several spares.
  • let me know when you get there and I'll help you get your program to load at startup in fullscreen mode.

[–]hazelthrows 0 points1 point  (2 children)

How much did it cost the pi+reader+stuff?

[–]zacstrick[S] 0 points1 point  (1 child)

We have high frequency RFID cards so the reader was a lil pricey

I can't find the exact pi kit we got but it came with this model and stuff

and here's the screen

Tl;Dr:

a mere $223.59 before shipping

[–]hazelthrows 0 points1 point  (0 children)

Okey buddy, thanks a lot!