Python Forum
[Tkinter] <function notes_counter at 0x0000024E06FC51F0
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] <function notes_counter at 0x0000024E06FC51F0
#1
I have a little problem, if I set the global variable sys_note the results into sys_notes Label are printed in tuple format (3,).  I want to have a plane number without brackets, however, when I use the function I'm getting an error: <function notes_counter at 0x0000024E06FC51F0> 
I'm a beginner with Python Cry

# Global Variable
sys_note = cur.execute("SELECT count(*) FROM notes").fetchone()


# With fucntion
def notes_counter():
    sys_note = cur.execute("SELECT count(*) FROM notes").fetchone()
 
 
# Label Statistic - System Notes
self.sys_notes = Label(self.footer, text = ' |  Notes: ' + str(notes_counter), fg = '#b3b3b3', bg = '#333', font = 'Helvetica 10 bold')
self.sys_notes.grid(row = 0, column = 3)
Reply
#2
It is not an error, the function notes_counter has not been called you need to do notes_counter() to call the function, then you will need to add return to the function otherwise it will return None.
Reply
#3
(Oct-14-2020, 05:20 AM)Yoriz Wrote: It is not an error, the function notes_counter has not been called you need to do notes_counter() to call the function, then you will need to add return to the function otherwise it will return None.
I appreciate your help and effort. I added 'return' to the function and the function is called into the label but i'm still getting None value.  

def notes_counter():
    sys_note = cur.execute("SELECT count(*) FROM notes").fetchone()
    return


class Application(object):
......

        # Label Statistic - System Notes

        self.sys_notes = Label(self.footer, text = ' |  Notes: ' + str(notes_counter()), fg = '#b3b3b3', bg = '#333', font = 'Helvetica 10 bold')
        self.sys_notes.grid(row = 0, column = 3)
....
Reply
#4
The function returns None because you haven't told it what to return.  Do you want it to return the value of your sys_note variable?  If so, your return statement should be "return sys_note" instead of just "return" (which, as you have seen, returns None by default).
Reply
#5
(Oct-14-2020, 11:10 AM)GOTO10 Wrote: The function returns None because you haven't told it what to return.  Do you want it to return the value of your sys_note variable?  If so, your return statement should be "return sys_note" instead of just "return" (which, as you have seen, returns None by default).

Thank you for your feedback! I learned something new today!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020