def setUp(self): path = (os.path.join( os.path.abspath( os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir)), 'config.json')) settings = None with open(path, 'r') as file_: settings = json.load(file_)['options']['datasource'] self.database = database.Database(settings)
def __init__(self): self.style = ttk.Style() # self.style.theme_use("clam") #('winnative', 'clam', 'alt', 'default', 'classic', 'vista', 'xpnative') # Connecting to Database to fetch last saved theme settings db_obj = db.Database() theme_value = db_obj.get_theme_value()[1] # print(theme_value) if theme_value == "Light Mode": self.light_mode() elif theme_value == "Dark Mode": self.dark_mode()
def setUp(self): path = (os.path.join( os.path.abspath( os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir)), 'config.json')) config = None with open(path, 'r') as file_: config = utilities.read(file_) self.database = database.Database(config['options']['datasource']) core.config = config utilities.TOKENIZER = core.Tokenizer()
def validating_login(self, *args): db_obj = db.Database() # Decrypting the encrypted username & password fetched from database decrypted_username = Crypting.Decrypt(db_obj.get_login_data()[1]) decrypted_password = Crypting.Decrypt(db_obj.get_login_data()[2]) # Empty condition if self.username.get() == "" or self.password.get() == "": tk.messagebox.showwarning("Warning", "All fields are required") # Correct combination '\' below is used to continue statement in the next line elif self.username.get() == decrypted_username and \ self.password.get() == decrypted_password: tk.messagebox.showinfo("Successful", f"Welcome {self.username.get()}") self.master.switch_frame(main_menu.MainMenuWindow, self.bg_frame) # Incorrect condition else: tk.messagebox.showerror("Error", "Invalid username or password") self.username_entry.delete(0, 'end') self.password_entry.delete(0, 'end')
def save_regional_advisories(data): DB = database.Database(config.sqlite_db) tableName = "unsafe_areas" # create an an sqlite_advisory object DB.drop(tableName) DB.add_table(tableName, country_iso="country_iso", name="name", unsafe_areas="unsafe_areas") for country in data: info = data[country] country_iso = info.get('country-iso') unsafe_areas = info.get('unsafe_areas') try: DB.insert(tableName, country_iso, country, unsafe_areas) LOGGER.success(f' Saved {country} in the database.') except Exception as error_msg: LOGGER.error( f'Could not save unsafe areas for {country} in the database because of the followin error: {error_msg}' )
def __init__(self): self.renderer = web.Web() self.parameters = common.parse_parameters() self.config = common.SETTINGS self.temp_config = common.TEMP_SETTINGS self.pcl_version = common.TEMP_SETTINGS["PCL_VERSION"] self.database = database.Database(self.config) self.session = sessions.Session() if not "PCL_IN_WSGI_MODE" in os.environ: self.fields = cgi.FieldStorage(keep_blank_values=True) else: self.fields = cgi.parse_qs(os.environ["wsgi.input"], keep_blank_values=True) try: self.language = os.environ["HTTP_ACCEPT_LANGUAGE"].split("-")[0] except: self.language = "en" # By default we don't need authorization. self.set_temp_setting("AUTH_REQUIRED", False)
import lib.database db = database.Database() def printa(x): print x db.save_event('teste', {"field1": "cenas1", "field2": "outra1"}) db.save_event('teste', {"field1": "cenas2", "field2": "outra1"}) db.save_event('teste', {"field1": "cenas3", "field2": "outra2"}) db.save_event('teste', {"field1": "cenas4", "field2": "outra3"}) db.save_event('teste', {"field1": "cenas5", "field2": "outra3"}) print 'UUUUUUUUUUUUUUUUUUUUUUUUU' map(printa, db.get_events("teste")) print 'AAAAAAAAAAAAAAAAAAAAAAAAA' print db.get_distinct("teste", "field1", "field2") print 'BBBBBBBBBBBBBBBBBBBBBBBBB'
def __init__(self, master): tk.Frame.__init__(self, master) # Initializing Theme Engine ThemeEngine.__init__(self) self.db_obj = db.Database() #===== Main Background Frame / Master Frame =============== win_width, win_height = 1340, 680 bg_frame = ttk.Frame(master, width=win_width, height=win_height, style="mainframe.TFrame") bg_frame.place(x=0, y=0) #======================== Title Frame ========================== title_frame = ttk.Frame(bg_frame) title_frame.place(x=20, y=20, relwidth=0.97) # Back Button self.back_btn_img = tk.PhotoImage(file='images/back_button.png') back_btn = tk.Button(title_frame, image=self.back_btn_img, bd=0, bg=self.button_bg, activebackground=self.button_bg, command=lambda: master.switch_frame( main_menu.MainMenuWindow, bg_frame)) back_btn.pack(side="left", padx=50) # Title Label title_label = ttk.Label(title_frame, text="INVENTORY ", font="Arial 60 bold", foreground='#22d3fe') title_label.pack(side="left", padx=240) # Time Label date_string = time.strftime("%a,%d/%b/%y") time_string = time.strftime("%I:%M %p") date_label = ttk.Label(title_frame, text=date_string, font="Arial 18 bold") date_label.place(x=1030, y=15) time_label = ttk.Label(title_frame, text=time_string, font="Arial 18 bold") time_label.place(x=1060, y=50) #=============== Product List Frame / Left Frame ====================== product_list_frame = ttk.Frame(bg_frame, border=1) product_list_frame.place(x=20, y=135, width=930, height=525) # Heading Label heading_label = ttk.Label(product_list_frame, text="Product List", font="Arial 20 bold", foreground='#4eacfe', justify='left') heading_label.grid(row=0, column=0, padx=30, pady=15) # Product list Treeview self.product_list_treeview = ttk.Treeview( product_list_frame, columns=('zero', "one", "two", "three", "four", "five", "six"), selectmode='browse', show='headings') self.product_list_treeview.grid(row=1, column=0, padx=(25, 0), ipady=65) self.product_list_treeview.heading('zero', text='No') self.product_list_treeview.column('zero', minwidth=60, width=60, anchor="c", stretch=False) self.product_list_treeview.heading('one', text='Product Name') self.product_list_treeview.column('one', minwidth=255, width=255, anchor="c", stretch=False) self.product_list_treeview.heading('two', text='Category') self.product_list_treeview.column('two', minwidth=150, width=150, anchor="c", stretch=False) self.product_list_treeview.heading('three', text='Sub-Category') self.product_list_treeview.column('three', minwidth=150, width=150, anchor="c", stretch=False) self.product_list_treeview.heading('four', text='Quantity') self.product_list_treeview.column('four', minwidth=80, width=80, anchor="c", stretch=False) self.product_list_treeview.heading('five', text='Unit Price') self.product_list_treeview.column('five', minwidth=82, width=82, anchor="c", stretch=False) self.product_list_treeview.heading('six', text='Total Price') self.product_list_treeview.column('six', minwidth=83, width=83, anchor="c", stretch=False) # Adding Vertical Scrollbar verscrlbar = ttk.Scrollbar(product_list_frame, orient="vertical", command=self.product_list_treeview.yview) verscrlbar.grid(row=1, column=5, ipady=152) self.product_list_treeview.configure(yscrollcommand=verscrlbar.set) # Adding Horizontal Scrollbar horscrlbar = ttk.Scrollbar(product_list_frame, orient="horizontal", command=self.product_list_treeview.xview) horscrlbar.grid(row=3, column=0, padx=(25, 0), ipadx=405) self.product_list_treeview.configure(xscrollcommand=horscrlbar.set) # Product Name Search prod_name_label = ttk.Label(product_list_frame, text="Product Name", font="Arial 16 bold") prod_name_label.place(x=55, y=470) self.prod_search_entry = tk.Entry(product_list_frame, font="Arial 16", bg=self.entry_bg, fg=self.entry_fg, width=48, bd=0) self.prod_search_entry.place(x=230, y=470) # Binding Enter Key to Search Product self.prod_search_entry.bind("<Return>", self.search_product) # Adding line below entry widget to look modern line_label_full = tk.Label(product_list_frame, text=("_") * (115), bg=self.entry_bg, fg=self.entry_fg, bd=0) line_label_full.place(x=230, y=495) # Binding Line-Label to Focus on Entry widget when clicked upon line_label_full.bind("<Button-1>", lambda e: self.prod_search_entry.focus_set()) # Search Button self.search_btn_img = tk.PhotoImage(file='images/search.png') search_button = tk.Button(product_list_frame, image=self.search_btn_img, bd=0, bg=self.button_bg, activebackground=self.button_bg, command=self.search_product) search_button.place(x=835, y=470) # Filling Product List at start of inventory window self.search_product() #=============== ADD Prodct Frame / Middle Frame Right 1 ====================== add_product_frame = ttk.Frame(bg_frame, border=1) add_product_frame.place(x=970, y=135, width=350, height=100) self.add_product_btn_img = tk.PhotoImage(file='images/addprod_btn.png') add_product_btn = tk.Button(add_product_frame, image=self.add_product_btn_img, bd=0, bg=self.button_bg, activebackground=self.button_bg, text="Add Product", font=("Arial", 20, "bold"), command=lambda: AddProductTopWindow(self)) # add_product_btn.grid(row=0, column=0, padx=35, pady=13) add_product_btn.place(relwidth=1, relheight=1) #=============== Menu Frame / Middle Frame Right 2 ====================== product_menu_frame = ttk.Frame(bg_frame, border=1) product_menu_frame.place(x=970, y=255, width=350, height=405) # Heading Label heading_label = ttk.Label(product_menu_frame, text="Menu", font="Arial 20 bold", foreground='#4eacfe') heading_label.place(x=140, y=15) # Product Name selected_prod_name_label = ttk.Label(product_menu_frame, text="Product Name", font="Arial 16 bold") selected_prod_name_label.place(x=102, y=70) self.selected_prod_name_txt = tk.Text(product_menu_frame, font="Arial 12 bold", bg=self.entry_bg, fg=self.entry_fg, bd=0, height=2, width=33, state='disabled') self.selected_prod_name_txt.place(x=25, y=110) # Product Quantity selected_prod_qty_label = ttk.Label(product_menu_frame, text="Quantity", font="Arial 16 bold") selected_prod_qty_label.place(x=45, y=170) self.selected_prod_qty_entry = tk.Entry( product_menu_frame, font="Arial 16 bold", bg=self.entry_bg, fg=self.entry_fg, readonlybackground=self.entry_bg, bd=0, width=10, justify='center', state='readonly') self.selected_prod_qty_entry.place(x=35, y=210) # Binding Key release to Call Secure Function to allow only Integers self.selected_prod_qty_entry.bind("<KeyRelease>", self.secure_entries) # Adding Line label to make entry widget look modern line_label_half = tk.Label(product_menu_frame, text=("_") * (25), bg=self.entry_bg, fg=self.entry_fg, bd=0) line_label_half.place(x=35, y=240) # Binding Line-Label to Focus on Entry widget when clicked upon line_label_half.bind( "<Button-1>", lambda e: self.selected_prod_qty_entry.focus_set()) # Product Price selected_prod_price_label = ttk.Label(product_menu_frame, text="Price(\u20B9)", font="Arial 16 bold") selected_prod_price_label.place(x=215, y=170) self.selected_prod_price_entry = tk.Entry( product_menu_frame, font="Arial 16 bold", bg=self.entry_bg, fg=self.entry_fg, readonlybackground=self.entry_bg, bd=0, width=10, justify='center', state='readonly') self.selected_prod_price_entry.place(x=200, y=210) # Adding Line label to make entry widget look modern self.selected_prod_price_entry.bind("<KeyRelease>", self.secure_entries) # Adding Line label to make entry widget look modern line_label_half = tk.Label(product_menu_frame, text=("_") * (25), bg=self.entry_bg, fg=self.entry_fg, bd=0) line_label_half.place(x=200, y=240) # Binding Line-Label to Focus on Entry widget when clicked upon line_label_half.bind( "<Button-1>", lambda e: self.selected_prod_price_entry.focus_set()) # Function Buttons # Select Product from list self.select_product_img = tk.PhotoImage( file='images/selectprod_btn.png') select_product_btn = tk.Button(product_menu_frame, image=self.select_product_img, bd=0, bg=self.button_bg, activebackground=self.button_bg, command=self.select_product) select_product_btn.place(x=37, y=290) # View All Products in the List self.view_all_product_img = tk.PhotoImage( file='images/viewall_prod_btn.png') viewall_product_btn = tk.Button( product_menu_frame, image=self.view_all_product_img, bd=0, bg=self.button_bg, activebackground=self.button_bg, command=lambda: [self.prod_search_entry.delete(0, 'end'), self.search_product()]) viewall_product_btn.place(x=204, y=290) # Update Product values: Price and Quantity self.update_product_img = tk.PhotoImage( file='images/updateprod_btn.png') self.update_product_btn = tk.Button(product_menu_frame, image=self.update_product_img, bd=0, bg=self.button_bg, activebackground=self.button_bg, state='disabled', command=self.update_product) self.update_product_btn.place(x=37, y=350) # Delete selected product from db self.delete_product_img = tk.PhotoImage( file='images/deleteprod_btn.png') delete_product_btn = tk.Button(product_menu_frame, image=self.delete_product_img, bd=0, bg=self.button_bg, activebackground=self.button_bg, command=self.delete_product) delete_product_btn.place(x=204, y=350)
def add_to_db(self): """Checks : (1) Cat already exists in the database or not. (2) Sub-Cat already exist or not. (3) Product Name already exist or not. If All 3 exists everything is skipped. If All 3 doesn't exist new entry is added to database. If Cat and Sub-cat exists write to database is of cat, sub-cat is skipped If Prod Name exist and new Cat, Sub-cat data is written to db, both entry is deleted from db Entry in the following order : Category -> Sub-Category ->Product Tables to match Foreign Key Policy """ db_obj = db.Database() def insert_success_msg(): # Deleting all entries from Top level/ Add Product window self.nprod_name_entry.delete(0, 'end') self.nprod_catname_entry.delete(0, 'end') self.nprod_subcatname_entry.delete(0, 'end') self.nprod_price_entry.delete(0, 'end') self.nprod_qty_entry.delete(0, 'end') # Showing success message as pop-up tk.messagebox.showinfo("Successful", f"\"{self.fetch_name}\" added to database", parent=self.add_prod_win) try: # Deleting master/ inventory windows search entry box # Instant update of added product to Inventory Window Product List self.master.prod_search_entry.delete(0, 'end') self.master.search_product() except: pass # INSERTING to CATEGORY SUB-CATEGORY PRODUCT TABLES in DATABASE try: db_obj.insert_category(cat_name=self.fetch_catname) # print("1") db_obj.insert_sub_category(sub_cat_name=self.fetch_subcatname, cat_name=self.fetch_catname) # print("2") db_obj.insert_product(prod_name=self.fetch_name, prod_price=self.fetch_price, prod_quantity=self.fetch_qty, sub_cat_name=self.fetch_subcatname, cat_name=self.fetch_catname) # Cat Sub-Cat and Product doesnt exist and everything succesfull written to db insert_success_msg() # Exception to handle Foreign Key error if the Entry exist in the Cat, Sub-Cat or product table except Exception as e: # CATEGORY exists condition => Skip cat and try sub-cat, prod entries if "UNIQUE constraint failed: category.cat_name" in e.args[0]: # print(e.args[0]," <= CATEGORY EXISTS") try: # New Entry for Sub-Category and Product Table db_obj.insert_sub_category( sub_cat_name=self.fetch_subcatname, cat_name=self.fetch_catname) # print("2.1") db_obj.insert_product(prod_name=self.fetch_name, prod_price=self.fetch_price, prod_quantity=self.fetch_qty, sub_cat_name=self.fetch_subcatname, cat_name=self.fetch_catname) # print("2.3") insert_success_msg() except Exception as e: # Category and Subcategory exists condition => skip both and try product entry if "UNIQUE constraint failed: sub_category.sub_cat_name" in e.args[ 0]: # print("Sub cat also exist") try: db_obj.insert_product( prod_name=self.fetch_name, prod_price=self.fetch_price, prod_quantity=self.fetch_qty, sub_cat_name=self.fetch_subcatname, cat_name=self.fetch_catname) insert_success_msg() except Exception as e: # print(e) # Everything exists => skip all-3 entry if "UNIQUE constraint failed: product.prod_name" in e.args[ 0]: # Pop-up warning : Everything exists tk.messagebox.showwarning( "Warning", f"\"{self.fetch_name}\" already exist in the database", parent=self.add_prod_win) self.nprod_name_entry.delete(0, 'end') # print("everything exists so nothing happened") # Cat and product exists, Sub-category doesnt exist so deleting sub category from db elif "UNIQUE constraint failed: product.prod_name" in e.args[ 0]: db_obj.delete_sub_category(self.fetch_subcatname) tk.messagebox.showwarning( "Warning", f"\"{self.fetch_name}\" already exist in the database", parent=self.add_prod_win) self.nprod_name_entry.delete(0, 'end') # print("SUB dont exist but product does") # print("delete sub category") # SUB-CATEGORY exists condition => cat entered and try prod entries elif "UNIQUE constraint failed: sub_category.sub_cat_name" in e.args[ 0]: # print(e.args[0]," <= SUB-CATEGORY EXISTS") try: db_obj.insert_product(prod_name=self.fetch_name, prod_price=self.fetch_price, prod_quantity=self.fetch_qty, sub_cat_name=self.fetch_subcatname, cat_name=self.fetch_catname) insert_success_msg() # Sub-cat, Product exists so delete entered new category except Exception as e: # print(e) if "UNIQUE constraint failed: product.prod_name" in e.args[ 0]: tk.messagebox.showwarning( "Warning", f"\"{self.fetch_name}\" already exist in the database", parent=self.add_prod_win) self.nprod_name_entry.delete(0, 'end') # print("prod exists") # print("deleting cat") db_obj.delete_category(self.fetch_catname) # CATEGORY added, SUB-CATEGORY added but PRODUCT exists so delete newly added Cat Sub-Cat entries elif "UNIQUE constraint failed: product.prod_name" in e.args[0]: # print(e.args[0]," <= PRODUCT EXISTS") db_obj.delete_sub_category(self.fetch_subcatname) db_obj.delete_category(self.fetch_catname) # print("Delete SUB-Category") # print("Delete Category") tk.messagebox.showwarning( "Warning", f"\"{self.fetch_name}\" already exist in the database", parent=self.add_prod_win) self.nprod_name_entry.delete(0, 'end') # If Out of the box error occurs else: pass
def __init__(self, bot): self._bot = bot self._database = database.Database()
def __init__(self, master): ttk.Frame.__init__(self, master) # Initializing Theme Engine ThemeEngine.__init__(self) self.master = master # Setting Window Title master.title("Inventory Management System\ Extras") # Connecting to Database self.db_obj = db_obj = db.Database() #========================= Main Background Frame =====================# win_width, win_height = 1340, 680 self.bg_frame = ttk.Frame(master, width=win_width, height=win_height, style="mainframe.TFrame") self.bg_frame.place(x=0, y=0) #======================== Title Frame ===============================# title_frame = ttk.Frame(self.bg_frame) title_frame.place(x=20, y=20, relwidth=0.97) # Back Button self.back_btn_img = tk.PhotoImage(file='images/back_button.png') back_btn = tk.Button(title_frame, image=self.back_btn_img, bd=0, bg=self.button_bg, activebackground=self.button_bg, command=lambda: master.switch_frame( main_menu.MainMenuWindow, self.bg_frame)) back_btn.place(relwidth=0.15, relheight=1) # Title Label title_label = ttk.Label(title_frame, text="EXTRAS", font="Arial 60 bold", foreground='#22d3fe') title_label.pack() # Date and Time Label date_string = time.strftime("%a,%d/%b/%y") time_string = time.strftime("%I:%M %p") date_label = ttk.Label(title_frame, text=date_string, font="Arial 18 bold") date_label.place(x=1090, y=15) time_label = ttk.Label(title_frame, text=time_string, font="Arial 18 bold") time_label.place(x=1115, y=50) #=============== Password Frame / Left Frame 1 =======================# ch_pass_frame = ttk.Frame(self.bg_frame, border=1) ch_pass_frame.place(x=20, y=135, width=930, height=300) # Heading Label heading_label = ttk.Label(ch_pass_frame, text="CHANGE PASSWORD", font="Arial 20 bold", foreground='#4eacfe') heading_label.pack(side='top', pady=25) # Current Password current_password_label = ttk.Label(ch_pass_frame, text="Current Password", font="Arial 17 bold") current_password_label.place(x=90, y=100) # self.current_password_entry = tk.Entry(ch_pass_frame, font="Arial 17 bold", show="*", width=23, bg=self.entry_bg, fg=self.entry_fg, bd=0) self.current_password_entry.place(x=90, y=150) # Adding line below entry widget to look modern line_label_half = tk.Label(ch_pass_frame, text=("_") * (61), bg=self.entry_bg, fg=self.entry_fg, bd=0) line_label_half.place(x=89, y=180) # Binding Line label to focus on entry widget line_label_half.bind("<Button-1>", lambda e: self.current_password_entry.focus_set()) # New Password new_password_label = ttk.Label(ch_pass_frame, text="New Password", font="Arial 17 bold") new_password_label.place(x=530, y=100) self.new_password_entry = tk.Entry(ch_pass_frame, show="*", font="Arial 17 bold", bg=self.entry_bg, fg=self.entry_fg, bd=0, width=23) self.new_password_entry.place(x=530, y=150) # Adding line below entry widget to look modern line_label_half = tk.Label(ch_pass_frame, text=("_") * (61), bg=self.entry_bg, fg=self.entry_fg, bd=0) line_label_half.place(x=529, y=180) # Binding Line label to focus on entry widget line_label_half.bind("<Button-1>", lambda e: self.new_password_entry.focus_set()) # Change Password Button self.changepass_btn_img = tk.PhotoImage( file='images/changepass_btn.png') self.change_password_button = tk.Button( ch_pass_frame, image=self.changepass_btn_img, bd=0, bg=self.button_bg, activebackground=self.button_bg, command=self.change_password) self.change_password_button.pack(side='bottom', pady=30) #=============== THEME Frame / Right Frame 1 ====================== theme_frame = ttk.Frame(self.bg_frame, border=1) theme_frame.place(x=970, y=135, width=350, height=300) heading_label = ttk.Label(theme_frame, text="CHANGE THEME", font="Arial 20 bold", foreground='#4eacfe') heading_label.pack(side='top', pady=25) # Fetching theme value from db theme_value = db_obj.get_theme_value()[1] # print(theme_value) # If theme value fetched from is dark mode # then set button for dark theme implementation and vice-versa if theme_value == "Light Mode": theme_button_value = "Dark Mode" self.theme_btn_img = tk.PhotoImage(file='images/dark_theme.png') # print(theme_button_value) else: theme_button_value = "Light Mode" self.theme_btn_img = tk.PhotoImage(file='images/light_theme.png') # print(theme_button_value) self.change_theme_button = tk.Button(theme_frame, text=theme_button_value, image=self.theme_btn_img, bd=0, bg=self.button_bg, activebackground=self.button_bg, command=self.change_theme) self.change_theme_button.pack()
from lib import database import redis redis_server = redis.StrictRedis(host="127.0.0.1",port=6379,password='******') db = database.Database({'db':"MYSQL"})
def __init__(self, master): ttk.Frame.__init__(self, master) # Initializing Theme Engine ThemeEngine.__init__(self) self.master = master self.db_obj = db.Database() #===== Main Background Frame / Master Frame =============== win_width, win_height = 1340, 680 bg_frame = ttk.Frame(master, width=win_width, height=win_height, style="mainframe.TFrame") bg_frame.place(x=0, y=0) #======================== Title Frame ========================== title_frame = ttk.Frame(bg_frame) title_frame.place(x=20, y=20, relwidth=0.97) # Back Button self.back_btn_img = tk.PhotoImage(file='images/back_button.png') back_btn = tk.Button(title_frame, image=self.back_btn_img, bd=0, bg=self.button_bg, activebackground=self.button_bg, command=lambda: master.switch_frame(main_menu.MainMenuWindow, bg_frame)) back_btn.pack(side="left", padx=50) # Title Label title_label = ttk.Label(title_frame, text="SALES", font="Arial 60 bold", foreground='#22d3fe') title_label.pack(side="left", padx=320) # Date and Time Label date_string = time.strftime("%a,%d/%b/%y") time_string = time.strftime("%I:%M %p") date_label = ttk.Label(title_frame, text=date_string, font="Arial 18 bold") date_label.place(x=1030, y=15) time_label = ttk.Label(title_frame, text=time_string, font="Arial 18 bold") time_label.place(x=1055, y=50) #===================== Customer Details Frame / Left Frame 1 ====================== customer_details_frame = ttk.Frame(bg_frame, border=1) customer_details_frame.place(x=20, y=130, width=895, height=82) # Heading Label heading_label = ttk.Label(customer_details_frame, text="Customer Details", font="Arial 15 bold", foreground='#4eacfe') heading_label.grid(row=0, column=0, padx=30, pady=10) # Customer Name Label and Entry cname_label = ttk.Label(customer_details_frame, text="Customer Name", font="Arial 16 bold") cname_label.place(x=50, y=40) self.cname_entry = tk.Entry(customer_details_frame, font="Arial 16", width=17, bg=self.entry_bg, fg=self.entry_fg, bd=0) self.cname_entry.place(x=244,y=35) # Binding Keyrelease to check length of Name shouldnt be > 25 self.cname_entry.bind("<KeyRelease>", self.customer_validity_check) # Inserting Line label below to make entry widget look modern line_label = tk.Label(customer_details_frame, text=("_")*(38), bg=self.entry_bg, fg=self.entry_fg, bd=0) line_label.place(x=243, y=60) # Binding Line-Label to Focus on Entry widget when clicked upon line_label.bind("<Button-1>", lambda e: self.cname_entry.focus_set()) # Customer Contact Number. Label and Entry cno_label = ttk.Label(customer_details_frame, text="Contact No.", font="Arial 16 bold") cno_label.place(x=480,y=40) self.cno_entry = tk.Entry(customer_details_frame,font="Arial 16", width=17, bg=self.entry_bg, fg=self.entry_fg, bd=0) self.cno_entry.place(x=650,y=35) # Binding Keyrelease to check length of No. shouldnt be > 10 and should be Integer only self.cno_entry.bind("<KeyRelease>", self.customer_validity_check) # Inserting Line label to make entry widget look modern line_label = tk.Label(customer_details_frame, text=("_")*(38), bg=self.entry_bg, fg=self.entry_fg, bd=0) line_label.place(x=649, y=60) # Binding Line-Label to Focus on Entry widget when clicked upon line_label.bind("<Button-1>", lambda e: self.cno_entry.focus_set()) #===================== OPTIONS Frame / Right Frame 1 ====================== options_frame = ttk.Frame(bg_frame, border=1) options_frame.place(x=930, y=130, width=390, height=82) # Customer Details Heading Label heading_label = ttk.Label(options_frame, text="Options", font=("Arial", 15, "bold"), foreground='#4eacfe') heading_label.grid(row=0, column=0, padx=30, pady=10) # Clear all button # Clear All Entries, Cart, Selection => Reset everything self.clear_all_btn_img = tk.PhotoImage(file="images/clearall_btn.png") clear_all_btn = tk.Button(options_frame, image=self.clear_all_btn_img, bd=0, bg=self.button_bg, activebackground=self.button_bg, command=self.clear_all) clear_all_btn.grid(row=1, column=0) # Bill Records Button # Opens File Explorer to Show Directory in which all transaction/sales records # Records are saved in png and .txt formats self.bill_records_btn_img = tk.PhotoImage(file="images/bill_records_btn.png") bill_records_btn = tk.Button(options_frame, image=self.bill_records_btn_img, bd=0, bg=self.button_bg, activebackground=self.button_bg, command=self.bill_records) bill_records_btn.place(x=140, y=10) #=============== Product Selection Frame / Left Frame 2 ====================== selection_frame = ttk.Frame(bg_frame, border=1) selection_frame.place(x=20, y=225, width=405, height=435) # Heading Label heading_label = ttk.Label(selection_frame, text="Product Selection", font="Arial 15 bold", foreground='#4eacfe') heading_label.grid(row=0, column=0, padx=30, pady=10) # Category category_label = ttk.Label(selection_frame, text="Category", font="Arial 16 bold") category_label.grid(row=1, column=0, padx=(20,0), pady= 10, sticky="W") self.category_cb = ttk.Combobox(selection_frame, state="readonly", width=27) self.category_cb.place(x=200, y=60) # Binding mouse left click self.category_cb.bind('<Button-1>', self.get_category_values) # Sub Category sub_category_label = ttk.Label(selection_frame, text="Sub-Category", font="Arial 16 bold") sub_category_label.grid(row=2, column=0, padx=(20,0), pady=10, sticky="W") self.sub_category_cb = ttk.Combobox(selection_frame, state="readonly", width=27) self.sub_category_cb.place(x=200, y=108) # Binding mouse left click self.sub_category_cb.bind('<Button-1>', self.get_sub_category_values) # Product / Item product_label = ttk.Label(selection_frame, text="Product", font="Arial 16 bold") product_label.grid(row=3, column=0, padx=(20,0), pady=10, sticky="W") self.product_cb = ttk.Combobox(selection_frame, state='readonly', width=27) self.product_cb.place(x=200, y=156) # Binding Mouse Left Click self.product_cb.bind('<Button-1>', self.get_product_values) # Binding Selecting item calls the function self.product_cb.bind("<<ComboboxSelected>>", self.get_product_details) # Quantity qty_label = ttk.Label(selection_frame, text="Quantity", font="Arial 16 bold") qty_label.grid(row=4, column=0, padx=(20,0), pady=10, sticky="W") self.quantity = tk.StringVar() self.qty_entry = tk.Entry(selection_frame, width=30, state='readonly') self.qty_entry.place(x=200, y=204) # self.qty_entry.grid(row=3, column=1) self.qty_entry.bind("<KeyRelease>", self.get_quantity_entered) # Remaining Quantity stock_label = ttk.Label(selection_frame, text="Stock", font="Arial 16 bold") stock_label.grid(row=5, column=0, padx=(20,0), pady=10, sticky="W") self.stock_value = ttk.Label(selection_frame, font="Arial 16 bold") self.stock_value.grid(row=5, column=1, padx=15, sticky="NSEW") # self.stock_value.place(x=250, y=252) # Price Per Unit price_label = ttk.Label(selection_frame, text="Unit Price", font="Arial 16 bold") price_label.grid(row=6, column=0, padx=(20,0), pady=10, sticky="W") self.unit_price = ttk.Label(selection_frame, font="Arial 16 bold") self.unit_price.grid(row=6, column=1, pady=10, sticky="NSEW") # Total Price tprice_label = ttk.Label(selection_frame, text="Total Price", font="Arial 16 bold") tprice_label.grid(row=7, column=0, padx=(20,0), pady=10, sticky="W") self.total_price = ttk.Label(selection_frame, font="Arial 16 bold") self.total_price.grid(row=7, column=1, pady=10, sticky="NSEW") # Add to cart button self.add_to_cart_btn_img = tk.PhotoImage(file='images/add_to_cart_btn.png') self.add_to_cart_btn = tk.Button(selection_frame, state='disabled', image=self.add_to_cart_btn_img, bd=0, bg=self.button_bg, activebackground=self.button_bg, command=self.add_to_cart) self.add_to_cart_btn.place(x=210,y=390) #=================== Cart Frame / Right Frame 2 =========================== cart_frame = ttk.Frame(bg_frame, border=1) cart_frame.place(x=440, y=225, width=880, height=435) # Cart Heading Label self.add_to_cart_img = tk.PhotoImage(file='images/shopping_cart.png') heading_label = ttk.Label(cart_frame, image=self.add_to_cart_img, text="CART", font="Arial 15 bold", foreground='#4eacfe', compound='left') heading_label.grid(row=0, column=0, padx=60, pady=10, sticky='W') # Cart Treeview self.cart = ttk.Treeview(cart_frame, columns=("one","two","three","four"), selectmode ='browse', show='headings') self.cart.grid(row=1,column=0, padx=(35,0), ipady=43) self.cart.heading('one', text='Product Name') self.cart.column('one', minwidth=520, width=520, anchor="w", stretch=False) self.cart.heading('two', text='Quantity') self.cart.column('two', minwidth=90, width=90, anchor="c", stretch=False) self.cart.heading('three', text='Unit Price') self.cart.column('three', minwidth=90, width=90, anchor="c", stretch=False) self.cart.heading('four', text='Total Price') self.cart.column('four', minwidth=90, width=90, anchor="c", stretch=False) # Attaching Vertical Scrollbars verscrlbar = ttk.Scrollbar(cart_frame, orient ="vertical", command=self.cart.yview) verscrlbar.grid(row=1, column=5, ipady=130) self.cart.configure(yscrollcommand = verscrlbar.set) # Attaching Horizontal Scrollbars horscrlbar = ttk.Scrollbar(cart_frame, orient ="horizontal", command=self.cart.xview) horscrlbar.grid(row=3, column=0, padx=(35,0), ipadx=370) self.cart.configure(xscrollcommand=horscrlbar.set) # Remove from cart button self.remove_from_cart_btn_img = tk.PhotoImage(file='images/remove_selected_btn.png') self.remove_from_cart_btn = tk.Button(cart_frame, image=self.remove_from_cart_btn_img, bd=0, bg=self.button_bg, activebackground=self.button_bg, command=self.remove_from_cart) self.remove_from_cart_btn.place(x=150, y=390) self.gen_bill_btn_img = tk.PhotoImage(file='images/generate_bill_btn.png') gen_bill_btn = tk.Button(cart_frame, image=self.gen_bill_btn_img, bd=0, bg=self.button_bg, activebackground=self.button_bg, command=self.generate_bill) gen_bill_btn.place(x=570, y=390)