#πŸ”’ Pickle problem?

15 messages Β· Page 1 of 1 (latest)

slow dove
#

I'm trying create a login for my gym software where it looks within the system for the pickle file to validate weather the userID and password is there howeber it isnt working for some reason even though i have a pkl file of the infomatiom

modest trailBOT
#

@slow dove

Python help channel opened

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.

slow dove
#

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")

modest trailBOT
#

Hey @slow dove!

Please edit your message to use a code block

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
slow dove
#

'''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")
'''

steady robin
#

what does "isn't working" mean?

slow dove
#

it cant find the file within my computer

olive oracle
#

Looks like an issue with the current working directory

steady robin
#

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

olive oracle
#

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

slow dove
#

Ye its working now thanks

#

all this coding stuff is still new to me😭

modest trailBOT
#
Python help channel closed

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.