#π Pickle problem?
15 messages Β· Page 1 of 1 (latest)
@slow dove
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
import tkinter as tk
from tkinter import messagebox
import pickle
class Staff:
def init(self, userid, username, password, fname, sname, phone, email, dob):
self.userid = userid
self.username = username
self.password = password
self.fname = fname
self.sname = sname
self.phone = phone
self.email = email
self.dob = dob
Load staff data from pickle file
with open('my_staff.pkl', 'rb') as f:
staff_data = pickle.load(f)
def validate_login():
userid = username_entry.get()
password = password_entry.get()
for staff in staff_data:
if staff.userid == userid and staff.password == password:
messagebox.showinfo("Login Successful", "Welcome " + staff.sname + "!")
return
messagebox.showerror("Login Error", "Incorrect Username or Password")
Main window
root = tk.Tk()
root.title("Gym System Login")
Hey @slow dove!
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
'''py
import tkinter as tk
from tkinter import messagebox
import pickle
class Staff:
def init(self, userid, username, password, fname, sname, phone, email, dob):
self.userid = userid
self.username = username
self.password = password
self.fname = fname
self.sname = sname
self.phone = phone
self.email = email
self.dob = dob
Load staff data from pickle file
with open('my_staff.pkl', 'rb') as f:
staff_data = pickle.load(f)
def validate_login():
userid = username_entry.get()
password = password_entry.get()
for staff in staff_data:
if staff.userid == userid and staff.password == password:
messagebox.showinfo("Login Successful", "Welcome " + staff.sname + "!")
return
messagebox.showerror("Login Error", "Incorrect Username or Password")
Main window
root = tk.Tk()
root.title("Gym System Login")
'''
what does "isn't working" mean?
it cant find the file within my computer
Looks like an issue with the current working directory
yeah, if python is raising a FileNotFound error, and if you're using a relative path (i.e., one that doesnt' start with / or C:/) to look for it, that's the problem
I can see that the cwd is Users/email in the image, but the pickle file is in a folder named Coding Projects
If you open that folder in vscode it should work fine
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.