Note that there are some explanatory texts on larger screens.

plurals
  1. POThe best way to call multiple values in a function from another function in Python
    primarykey
    data
    text
    <p>As I working with the Python tkinter GUI and sqlite 3 recently to build a project, I discovered a lots of questions in Python programming. One of the questions is <strong><em>what would be the best way of calling multiple values in a function from another function in python?</em></strong> Meanwhile, I've done some research about retuning and calling value in function, and I know that in python function it can allows to return multiple value, however, when it comes to calling and I want it to call specifically the value I return e.g <code>return (x,y,z)</code>, I really not sure how could I call it. </p> <p>Here are some code that are in my project, please feel free to give me any suggestion about my code and the question that I ask above</p> <p><p>First function</p> <pre><code>def taskUpdateB(): conn = sqlite3.connect("zzzsqlite.db") booking = conn.cursor() index = sOLB.curselection() selTask = sOLB.get(index) bookinID = selTask[-2] getBookID = booking.execute('''SELECT bookingID FROM booking WHERE bookingID=?''', (bookinID,)) taUp = Toplevel() taUp.title("Task Update") taskLabel = Label(taUp, text ="Task Update", font=('Times', 20)) taskLabel.grid(row=0) showLabel = Label(taUp, text ="Please Select and Enter Infomation Below", font=('Times', 18)) showLabel.grid(row=1) var = IntVar() var = 0 fullRadio = Radiobutton(taUp, text="Fully", variable=var, value=1, command = taskUpdCom) fullRadio.grid(row=2, sticky=W) partRadio = Radiobutton(taUp, text="Partly", variable=var, value=2, command = taskUpdCom) partRadio.grid(row=3, sticky=W) notRadio = Radiobutton(taUp, text="Unable", variable=var, value=3, command = taskUpdCom) notRadio.grid(row=4, sticky=W) noteLabel = Label(taUp, text ="Note:", font=('Times', 16)) noteLabel.grid(row=5, sticky=W) noteBox = Text(taUp, width=30, height =20, font=('Arial', 12,), highlightbackground='black') noteBox.grid(row=6) comButton = Button(taUp, text ="Task Complete and Send Invoice", command = taskUpdCom) comButton.grid(row =7) booking.close() return (var, noteBox, showLabel, bookinID) </code></pre> <p>Second function </p> <pre><code> def taskUpdCom(): a = taskUpdateB #get the data from the update list var = taskUpdateB.var() noteBox = taskUpdateB.noteBox() showLabel = taskUpdateB.showLabel() bookinID = taskUpdateB.bookinID() selProg = str(var.get()) if selProg == 0: showLabel["text"] = ("***Please Select Task Progress Below***") elif noteBox.get() == "": showLabel["text"] = ("***Please Enter Task Note Below***") else: conn = sqlite3.connect("zzzsqlite.db") update = conn.cursor() wriUpda = zzzsqliteTable.addUpdate(bookinID, selProg, noteBox) conn.commit() updata.close() taskUpdateB.noteBox.delete(0, END) tkinter.messagebox.showinfo("Notification","Your task has been updated and removed from the list") try: deIndex = taskUpdateB.index()#The item selected from task update delete it from the list.... will still in the database. sOLB.delete(deIndex) except IndexError: pass </code></pre> <p><p> Please forgive my code has not been fully complete yet, and kind of messy... <p> Thanks for your help :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload