from tkinter import *
from sqlite3 import *
def center(toplevel): #Run outside the Class definition
toplevel.update_idletasks()
w = toplevel.winfo_screenwidth()
h = toplevel.winfo_screenheight()
size = tuple(int(_) for _ in toplevel.geometry().split('+')[0].split('x'))
x = w/2 - size[0]/2
y = h/2 - size[1]/2
toplevel.geometry("%dx%d+%d+%d" % (size + (x, y)))
class Earnings():
def __init__(self):
print("About to go to self.connect_database")
self.conn = self.connect_database(self)
def connect_database(self):
#create a database connection
print("About to go to self.create_connection")
def main():
root = Tk()
root.geometry("1250x650")
root.title("The Ryall Family Earnings")
center(root)
App = Earnings()
root.mainloop()
if __name__ == '__main__':
main()
Why do I keep getting the following message when I only enter the "self" parm when I go to self.connect_database(self)
Error:
Traceback (most recent call last):
File "D:/Code/New/test_class.py", line 32, in <module>
main()
File "D:/Code/New/test_class.py", line 28, in main
App = Earnings()
File "D:/Code/New/test_class.py", line 17, in __init__
self.conn = self.connect_database(self)
TypeError: connect_database() takes 1 positional argument but 2 were given