#🔒 Button isnt functioning as it should.(my bad but ı got no clue how to fix)

46 messages · Page 1 of 1 (latest)

lime hill
#

ı made personal library code there we add new books, delete them ,borrow them, and give them back and also search them but the borrow button doesnt work as it should ı cant code it
firstly it should ask the book name which is gonna be borrowed and if it finds the book then it will ask the borrower name . it asks the book name and borrower name but it always says there isnt any book which has this name
there is also a parameter odunc_alındı_mı : 1/0 when this button works make this parameter 1 and then it should create a parameter which is named odunc_alan (borrowers name) and save those with sqlite3 but it dosent even create the parameter borrowers name
heres the full code : https://paste.pythondiscord.com/YVBA

glacial axleBOT
#

@lime hill

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.

dusky dagger
#

if I understand correctly, you think the problem is in this function?

def odunc_al(self, ad):
        isim = simpledialog.askstring('Ödünç Al', 'Kitabı Ödünç Alan Kişinin Adı:')
        if isim is None:
            messagebox.showerror('Hata', 'Kitap Adı Gerekli. Ödünç Alma İşlemi İptal Edildi.')
            return
        kitap = self.kitap_ara(ad)
        if kitap and not kitap.odunc_alindi_mi:
            kitap.odunc_alindi_mi = True
            kitap.odunc_alan = isim
            self.cursor.execute("UPDATE kitaplar SET odunc_alindi_mi=1, odunc_alan=? WHERE ad=?", (isim, ad))
            self.conn.commit()
            return f"'{ad}' başlıklı kitap ödünç alındı. {isim} isimli kişi kitabı ödünç aldı."
        elif kitap:
            return f"'{ad}' başlıklı kitap zaten ödünç alınmış."
        else:
            return f"'{ad}' başlıklı kitap bulunamadı."
lime hill
#

yes

dusky dagger
#

and specifically this condition, since you think this line isn't running?

if kitap and not kitap.odunc_alindi_mi:
lime hill
#

probably

dusky dagger
#

i'd add a print statement in that block to confirm whether or not it's executing

#

and then print kitap and kitap.odunc_alindi_mi to check what they are

#

narrow down where the problem is coming from, basically

lime hill
#

ı never thought about that seems pretty good

lime hill
dusky dagger
#

just add a print statement?

#

im not sure what you're asking

lime hill
#

nvm gimme a sec to try something

lime hill
#

this is the error even the ai isnt helping

dusky dagger
#

you're passing too many arguments to the function

#

or your function definition doesn't accept enough arguments

formal garden
lime hill
#

ok now ı returned to the start

#

help me step by step like ım literally noob

#

please guys

dusky dagger
#

wdym "returned to start"?

#

we were mid helping you

lime hill
#

at the start of text which i sent link

#

i started from that code again :D

dusky dagger
#

ok, did you figure out whether that if-block is executing like you expect it to?

lime hill
#

ı reached just this there isnt a problem

lime hill
lime hill
#

@dusky dagger yo ı found the problem

dusky dagger
#

nice

lime hill
lime hill
dusky dagger
#

sounds like that column needs to exist

lime hill
#

yeah ı see taht

#

that

#

how can ı make that column ??

#

will db browser be enough ??

#

nah it wont 😭

dusky dagger
#

that'd be something to look up in the sqlite documentation

glacial axleBOT
#
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.