MCPcopy Create free account
hub / github.com/ndleah/python-mini-project / __init__

Method __init__

Sqlite-crud/main.py:12–52  ·  view source on GitHub ↗
(self, window)

Source from the content-addressed store, hash-verified

10 db_name = 'database.db'
11
12 def __init__(self, window):
13 # Initializations
14 self.wind = window
15 self.wind.title('Products Application')
16
17 # Creating a Frame Container
18 frame = LabelFrame(self.wind, text = 'Register new Product')
19 frame.grid(row = 0, column = 0, columnspan = 3, pady = 20)
20
21 # Name Input
22 Label(frame, text = 'Name: ').grid(row = 1, column = 0)
23 self.name = Entry(frame)
24 self.name.focus()
25 self.name.grid(row = 1, column = 1)
26
27 # Price Input
28 Label(frame, text = 'Price: ').grid(row = 2, column = 0)
29 self.price = Entry(frame)
30 self.price.grid(row = 2, column = 1)
31
32 # Button Add Product
33 ttk.Button(frame, text = 'Save Product', command = self.add_product).grid(row = 3, columnspan = 2, sticky = W + E)
34
35 # Output Messages
36 self.message = Label(text = '', fg = 'red')
37 self.message.grid(row = 3, column = 0, columnspan = 2, sticky = W + E)
38
39 # Table
40 self.tree = ttk.Treeview(height = 10, columns = 2)
41 self.tree.grid(row = 4, column = 0, columnspan = 2)
42 self.tree.heading('#0', text = 'Name', anchor = CENTER)
43 self.tree.heading('#1', text = 'Price', anchor = CENTER)
44
45 # Buttons
46 ttk.Button(text = 'DELETE', command = self.delete_product).grid(row = 5, column = 0, sticky = W + E)
47 ttk.Button(text = 'EDIT', command = self.edit_product).grid(row = 5, column = 1, sticky = W + E)
48
49 self.exits_db_file()
50
51 # Filling the Rows
52 self.get_products()
53
54 # Function to verify if already exist the table in database
55 # Else create the table

Callers

nothing calls this directly

Calls 2

exits_db_fileMethod · 0.95
get_productsMethod · 0.95

Tested by

no test coverage detected