def one_way(): Label(info,text="From",font=('Arial',10),width=20,bg='paleturquoise').place(x=70,y=20) departurecityvar.set("Select city") departurecity = OptionMenu(info,departurecityvar,*airportlst) departurecity.place(x=170,y=50) departurecity.config(width=10) Label(info,text="To",font=('Arial',10),width=20,bg='paleturquoise').place(x=300,y=20) arrivalcityvar.set("Select city") arrivalcity = OptionMenu(info,arrivalcityvar,*airportlst) arrivalcity.place(x=400,y=50) arrivalcity.config(width=10) #---------------\\-------Date--------------------------------# Label(info,text="Date of Departure",font=('Arial',10),width=20,bg='paleturquoise').place(x=70,y=120) datedep = DateEntry(info,width=20,date_pattern='dd/mm/yyyy',textvariable=vardep).place(x=150,y=150) lblret=Label(info,text="Date of Return",font=('Arial',10),width=20,bg='paleturquoise') lblret.place(x=340,y=120) lblret.config(state='disabled') datearr = DateEntry(info,width=20,date_pattern='dd/mm/yyyy') datearr.place(x=420,y=150) datearr.config(state='disabled') #----------------\\------Passengers------------------------------# Label(info,text="Passenger(s)",width=10,bg='paleturquoise').place(x=200,y=200) varpass.set(1) passmenu = OptionMenu(info,varpass,*passengerlst).place(x=280,y=200) Label(info,text="~ Maximum 7 passengers allowed",font=('arial',9,'italic'),bg='paleturquoise').place(x=350,y=220)
def test_dateentry_get_set(self): widget = DateEntry(self.window, width=12, background='darkblue', foreground='white', borderwidth=2, font='Arial 9') widget.pack() self.window.update() keys = [ 'exportselection', 'invalidcommand', 'justify', 'show', 'cursor', 'style', 'state', 'takefocus', 'textvariable', 'validate', 'validatecommand', 'width', 'xscrollcommand' ] keys.extend(widget._calendar.keys()) self.assertEqual(sorted(list(set(keys))), sorted(widget.keys())) self.assertEqual(widget["background"], 'darkblue') self.assertEqual(widget.cget("width"), 12) widget["borderwidth"] = 5 self.window.update() self.assertEqual(widget["borderwidth"], 5) widget.config(font="Arial 20 bold") self.window.update() self.assertEqual(widget["font"], "Arial 20 bold") widget.config(style="my.TEntry") self.window.update() self.assertEqual(widget["style"], "my.TEntry")
class Main: def __init__(self): self.tk = Tk() #it is used to pick the date from the claender self.dob = DateEntry(self.tk,font=('Comic Sans MS',13), bg='darkblue', fg='white', borderwidth=2) self.dob.place(x=0,y=0) self.dob.config(width=31) self.tk.mainloop()
def create_datepicker(self, label, filter_key, column): tk.Label(self, text=label).grid(row=0, column=column, sticky="W") container = tk.Frame(self) date_picker = DateEntry(container, date_pattern=Filters.DATE_PATTERN) date_picker.config(validate='none') date_picker.bind('<<DateEntrySelected>>', self.on_date_pick(filter_key)) date_picker.delete(0, tk.END) date_picker.grid(row=0, column=0) clear_btn = tk.Button( container, text="x", command=self.on_clear_date_click(date_picker, filter_key), ) clear_btn.grid(row=0, column=1, sticky="N") container.grid(row=1, column=column)
def test_dateentry_get_set(self): widget = DateEntry(self.window, width=12, background='darkblue', locale='en_US', foreground='white', borderwidth=2, font='Arial 9', year=2019, month=7, day=3) widget.pack() self.window.update() keys = ['exportselection', 'invalidcommand', 'justify', 'show', 'cursor', 'calendar_cursor', 'style', 'state', 'takefocus', 'textvariable', 'validate', 'validatecommand', 'width', 'xscrollcommand'] keys.extend(widget._calendar.keys()) self.assertEqual(sorted(list(set(keys))), sorted(widget.keys())) self.assertEqual(widget["background"], 'darkblue') self.assertEqual(widget.cget("width"), 12) widget["borderwidth"] = 5 self.window.update() self.assertEqual(widget["borderwidth"], 5) widget.configure({'foreground': 'cyan', 'font': 'FreeMono 10', 'background': 'green'}, background="blue", borderwidth=4, font="Arial 20 bold", justify='center') self.window.update() self.assertEqual(widget["foreground"], "cyan") self.assertEqual(widget["background"], "blue") self.assertEqual(widget["borderwidth"], 4) self.assertEqual(widget["font"], "Arial 20 bold") self.assertEqual(widget["justify"], "center") widget.config(font="Arial 20 bold") self.window.update() self.assertEqual(widget["font"], "Arial 20 bold") widget.config(style="my.TEntry") self.window.update() self.assertEqual(widget["style"], "my.TEntry") style = ttk.Style(self.window) style.theme_use('clam') self.assertEqual(widget["locale"], "en_US") self.assertEqual(widget.get(), '7/3/19') widget.config(locale="fr_FR") self.window.update() self.assertEqual(widget["locale"], "fr_FR") self.assertEqual(widget.get(), '03/07/2019')
class Edit: def __init__(self, master, type): # build ui self.master = master self.type = type self.frame_1 = ttk.Frame(self.master) self.frame_4 = ttk.Frame(self.frame_1) self.treeview_1 = ttk.Treeview(self.frame_4) self.treeview_1.pack(side='left') self.frame_4.configure(height='200', width='200') self.frame_4.pack(expand='true', fill='x', padx='10', pady='10', side='top') self.frame_5 = ttk.Frame(self.frame_4) self.label_1 = ttk.Label(self.frame_5) self.label_1.configure(text='Dział', width='15') self.label_1.pack(padx='5', pady='5', side='left') self.combobox_1 = ttk.Combobox(self.frame_5, state="readonly") self.combobox_1.pack(expand='true', fill='x', side='left') self.combobox_1.bind('<<ComboboxSelected>>', self.fill_combobox2) self.frame_5.configure(height='200', width='200') self.frame_5.pack(expand='true', fill='x', side='top') self.frame_6 = ttk.Frame(self.frame_4) self.label_2 = ttk.Label(self.frame_6) self.label_2.configure(text='Nazwa', width='15') self.label_2.pack(padx='5', pady='5', side='left') self.combobox_2 = ttk.Combobox(self.frame_6, state="readonly") self.combobox_2.pack(expand='true', fill='x', side='left') self.frame_6.configure(height='200', width='200') self.frame_6.pack(expand='true', fill='x', side='top') self.frame_7 = ttk.Frame(self.frame_4) self.label_3 = ttk.Label(self.frame_7) self.label_3.configure(text='Cena hurtowa', width='15') self.label_3.pack(padx='3', pady='3', side='left') self.entry_5 = ttk.Entry(self.frame_7) self.entry_5.pack(expand='true', fill='x', side='left') self.frame_7.configure(height='200', width='200') self.frame_7.pack(expand='true', fill='x', side='top') self.frame_8 = ttk.Frame(self.frame_4) self.label_4 = ttk.Label(self.frame_8) self.label_4.configure(text='Ilość', width='15') self.label_4.pack(padx='3', pady='3', side='left') self.entry_6 = ttk.Entry(self.frame_8) self.entry_6.pack(expand='true', fill='x', side='left') self.frame_8.configure(height='200', width='200') self.frame_8.pack(expand='true', fill='x', side='top') self.frame_9 = ttk.Frame(self.frame_4) self.label_5 = ttk.Label(self.frame_9) self.label_5.configure(text='Cena netto', width='15') self.label_5.pack(padx='3', pady='3', side='left') self.entry_7 = ttk.Entry(self.frame_9) self.entry_7.pack(expand='true', fill='x', side='left') self.frame_9.configure(height='200', width='200') self.frame_9.pack(expand='true', fill='x', side='top') self.frame_10 = ttk.Frame(self.frame_4) self.label_6 = ttk.Label(self.frame_10) self.label_6.configure(text='Procent VAT', width='15') self.label_6.pack(padx='3', pady='3', side='left') self.entry_8 = ttk.Entry(self.frame_10) self.entry_8.pack(expand='true', fill='x', side='left') self.frame_10.configure(height='200', width='200') self.frame_10.pack(expand='true', fill='x', side='top') self.frame_11 = ttk.Frame(self.frame_4) self.label_7 = ttk.Label(self.frame_11) self.label_7.configure(text='Data', width='15') self.label_7.pack(padx='3', pady='3', side='left') self.dateEntry = DateEntry(self.frame_11, width=12, background='darkblue', locale="pl_PL", date_pattern="yyyy-mm-dd", foreground='white', borderwidth=2) self.dateEntry.delete(0, END) self.dateEntry.pack(expand='true', fill='x', side='left') self.frame_11.configure(height='200', width='200') self.frame_11.pack(expand='true', fill='x', side='top') self.frame_12 = ttk.Frame(self.frame_4) self.button_3 = ttk.Button(self.frame_12) self.button_3.configure(text='Filtruj') self.button_3.bind('<Button>', self.filter) self.button_3.pack(expand='true', fill='x', side='left') self.button_4 = ttk.Button(self.frame_12) self.button_4.configure(text='Wyczyść') self.button_4.bind('<Button>', self.clear) self.button_4.pack(expand='true', fill='x', side='left') self.frame_12.configure(height='200', width='200') self.frame_12.pack(expand='true', fill='x', side='top', padx='3') self.frame_1.configure(height='200', width='200') self.frame_1.pack(side='top') self.id = None if self.type == 0: self.treeview_1['columns'] = ('ID', 'Nazwa', 'Cena netto', 'Procent VAT', 'Dział') self.treeview_1.column("#0", width=0) self.treeview_1.column('ID', width=30) self.treeview_1.column('Nazwa', width=130) self.treeview_1.column('Cena netto', width=80) self.treeview_1.column('Procent VAT', width=80) self.treeview_1.column('Dział', width=150) self.treeview_1.heading("#0", text='', anchor="w") self.treeview_1.heading('ID', text='ID') self.treeview_1.heading('Nazwa', text='Nazwa') self.treeview_1.heading('Cena netto', text='Cena netto') self.treeview_1.heading('Procent VAT', text='Procent VAT') self.treeview_1.heading('Dział', text='Dział') self.add_items(DB_Connection.select_products()) self.treeview_1.bind('<<TreeviewSelect>>', self.on_select_products) self.entry_5.config(state='disabled') self.entry_6.config(state='disabled') self.dateEntry.config(state='disabled') self.frame_2 = ttk.Frame(self.frame_1) self.entry_1 = ttk.Entry(self.frame_2) self.entry_1.pack(expand='true', fill='x', ipadx='8', ipady='8', padx='2', pady='2', side='left') self.entry_2 = ttk.Entry(self.frame_2) self.entry_2.pack(expand='true', fill='x', ipadx='8', ipady='8', padx='2', pady='2', side='left') self.entry_3 = ttk.Entry(self.frame_2) self.entry_3.pack(expand='true', fill='x', ipadx='8', ipady='8', padx='2', pady='2', side='left') self.entry_4 = ttk.Entry(self.frame_2) self.entry_4.pack(expand='true', fill='x', ipadx='8', ipady='8', padx='2', pady='2', side='left') self.frame_2.configure(height='200', width='200') self.frame_2.pack(fill='x', side='top') elif self.type == 1: self.treeview_1['columns'] = ('ID', 'Data', 'Nazwa', 'Cena hurtowa', 'Ilość', 'Dział') self.treeview_1.column("#0", width=0) self.treeview_1.column('ID', width=30) self.treeview_1.column('Data', width=80) self.treeview_1.column('Nazwa', width=130) self.treeview_1.column('Cena hurtowa', width=100) self.treeview_1.column('Ilość', width=80) self.treeview_1.column('Dział', width=150) self.treeview_1.heading("#0", text='', anchor="w") self.treeview_1.heading('ID', text='ID') self.treeview_1.heading('Data', text='Data') self.treeview_1.heading('Nazwa', text='Nazwa') self.treeview_1.heading('Cena hurtowa', text='Cena hurtowa') self.treeview_1.heading('Ilość', text='Ilość') self.treeview_1.heading('Dział', text='Dział') self.add_items(DB_Connection.select_supplies()) self.treeview_1.bind('<<TreeviewSelect>>', self.on_select_supplies) self.entry_7.config(state='disabled') self.entry_8.config(state='disabled') self.frame_2 = ttk.Frame(self.frame_1) self.entry_1 = ttk.Entry(self.frame_2) self.entry_1.pack(expand='true', fill='x', ipadx='8', ipady='8', padx='2', pady='2', side='left') self.entry_2 = ttk.Entry(self.frame_2) self.entry_2.pack(expand='true', fill='x', ipadx='8', ipady='8', padx='2', pady='2', side='left') self.frame_2.configure(height='200', width='200') self.frame_2.pack(fill='x', side='top') elif self.type == 2: self.treeview_1['columns'] = ('ID', 'Data', 'Nazwa', 'Ilość', 'Dział') self.treeview_1.column("#0", width=0) self.treeview_1.column('ID', width=30) self.treeview_1.column('Data', width=80) self.treeview_1.column('Nazwa', width=130) self.treeview_1.column('Ilość', width=80) self.treeview_1.column('Dział', width=150) self.treeview_1.heading("#0", text='', anchor="w") self.treeview_1.heading('ID', text='ID') self.treeview_1.heading('Data', text='Data') self.treeview_1.heading('Nazwa', text='Nazwa') self.treeview_1.heading('Ilość', text='Ilość') self.treeview_1.heading('Dział', text='Dział') self.add_items(DB_Connection.select_sales()) self.treeview_1.bind('<<TreeviewSelect>>', self.on_select_sales) self.entry_5.config(state='disabled') self.entry_7.config(state='disabled') self.entry_8.config(state='disabled') self.frame_2 = ttk.Frame(self.frame_1) self.entry_1 = ttk.Entry(self.frame_2) self.entry_1.pack(expand='true', fill='x', ipadx='8', ipady='8', padx='2', pady='2', side='left') self.frame_2.configure(height='200', width='200') self.frame_2.pack(fill='x', side='top') self.frame_3 = ttk.Frame(self.frame_1) self.button_1 = ttk.Button(self.frame_3) self.button_1.configure(text='Edytuj') self.button_1.pack(expand='true', fill='x', ipadx='3', ipady='3', side='top') self.button_1.bind('<Button>', self.edit) self.button_2 = ttk.Button(self.frame_3) self.button_2.configure(text='Usuń') self.button_2.pack(expand='true', fill='x', ipadx='3', ipady='3', side='top') self.button_2.bind('<Button>', self.delete) self.frame_3.configure(height='200', width='200') self.frame_3.pack(fill='x', side='top') self.frame_1.configure(height='200', padding='8', width='200') self.frame_1.pack(side='top') # Main widget self.mainwindow = self.frame_1 if self.type == 0: a, b = 720, 349 elif self.type == 1: a, b = 839, 346 else: a, b = 739, 346 x = self.master.winfo_screenwidth() // 2 - a // 2 - 10 y = self.master.winfo_screenheight() // 2 - b // 2 - 10 self.master.geometry(f'+{x}+{y}') self.master.title('Edytuj') def fill_combobox1(self): self.combobox_1['values'] = DB_Connection.get_sections() def fill_combobox2(self, event): self.combobox_2['values'] = DB_Connection.get_products( self.combobox_1['values'][self.combobox_1.current()]) def filter(self, event): params = {} params['Products.section'], params['Products.name'], params['Data.quantity_price'], params['Data.amount'], params['Products.netto_price'], params['Products.vat_percentage'], params['Data.date'] = \ self.combobox_1.get(), self.combobox_2.get(), self.entry_5.get(), self.entry_6.get(), self.entry_7.get(), self.entry_8.get(), self.dateEntry.get_date().strftime('%Y-%m-%d') if self.dateEntry._validate_date() else "" print(params) filtered_grid = DB_Connection.select_with_filters(self.type, params) print(filtered_grid) self.treeview_1.delete(*self.treeview_1.get_children()) self.add_items(filtered_grid) def clear(self, event): self.combobox_1.set('') self.combobox_2.set('') self.entry_5.delete(0, END) self.entry_6.delete(0, END) self.entry_7.delete(0, END) self.entry_8.delete(0, END) self.dateEntry.delete(0, END) def add_items(self, records): for r in records: self.treeview_1.insert("", "end", values=r) def edit(self, event): if self.id is not None and self.treeview_1.selection() != (): import Product as P pr = P.Product(*DB_Connection.get_settings()) if self.type == 0: pr.Name = (self.entry_1.get(), self.master) pr.Netto_price = (self.entry_2.get(), self.master) pr.Vat_percentage = (self.entry_3.get(), self.master) pr.Section = (self.entry_4.get(), self.master) if pr.final_prod_check( [pr.Section, pr.Name, pr.Netto_price, pr.Vat_percentage]): DB_Connection.edit_product(self.master, pr, self.id) focused = self.treeview_1.focus() self.treeview_1.insert( "", str(focused)[1:], values=(self.id, pr.Name, pr.Netto_price, pr.Vat_percentage, pr.Section)) self.treeview_1.delete(focused) elif self.type == 1: pr.Quantity_price = (self.entry_1.get(), self.master) pr.Amount = (self.entry_2.get(), self.master) if pr.final_prod_check([pr.Quantity_price, pr.Amount]): DB_Connection.edit_supply(self.master, pr, self.id) focused = self.treeview_1.focus() item = self.treeview_1.item(focused)['values'] self.treeview_1.insert("", str(focused)[1:], values=(self.id, item[1], item[2], pr.Quantity_price, pr.Amount, item[5])) self.treeview_1.delete(focused) else: pr.Amount = (self.entry_1.get(), self.master) if pr.final_prod_check([pr.Amount]): DB_Connection.edit_sale(self.master, pr, self.id) focused = self.treeview_1.focus() item = self.treeview_1.item(focused)['values'] self.treeview_1.insert("", str(focused)[1:], values=(self.id, item[1], item[2], pr.Amount, item[4])) self.treeview_1.delete(focused) else: messagebox.showerror( parent=self.master, title='Błąd', message='Zaznacz element, który chcesz edytować') def delete(self, event): if self.id is not None and self.treeview_1.selection() != (): if self.type == 0: DB_Connection.delete_product(self.id) else: DB_Connection.delete_supply_or_sale(self.id) focused = self.treeview_1.focus() self.treeview_1.delete(focused) else: messagebox.showerror( parent=self.master, title='Błąd', message='Zaznacz element, który chcesz usunąć') def on_select_products(self, event): selected = event.widget.focus() self.entry_1.delete(0, END) self.entry_2.delete(0, END) self.entry_3.delete(0, END) self.entry_4.delete(0, END) item = self.treeview_1.item(selected)['values'] self.id = item[0] self.entry_1.insert(0, item[1]) self.entry_2.insert(0, item[2]) self.entry_3.insert(0, item[3]) self.entry_4.insert(0, item[4]) def on_select_supplies(self, event): selected = event.widget.focus() self.entry_1.delete(0, END) self.entry_2.delete(0, END) item = self.treeview_1.item(selected)['values'] self.id = item[0] self.entry_1.insert(0, item[3]) self.entry_2.insert(0, item[4]) def on_select_sales(self, event): selected = event.widget.focus() self.entry_1.delete(0, END) item = self.treeview_1.item(selected)['values'] self.id = item[0] self.entry_1.insert(0, item[3]) def run(self): self.mainwindow.mainloop()
class main: def __init__(self, n_): print(n_) self.n = n_ ob = database_queries.database() re = ob.get_appoint_byn(n_) print(re) self.tk = Toplevel() self.frame = Frame(self.tk, height=700, width=700) self.frame.place(x=0, y=0) height = self.tk.winfo_screenheight() width = self.tk.winfo_screenwidth() y = (height - 700) // 2 x = (width - 700) // 2 self.tk.geometry('700x700+' + str(x) + '+' + str(y)) self.tk.resizable(height=False, width=False) self.can = Canvas(self.frame, height="700", width="700") self.can.pack() self.img = PhotoImage(file="./images/img2.gif") self.can.create_image(0, 0, image=self.img, anchor=NW) self.can.create_text(360, 100, text="Edit appointment ", fill="powder blue", font=('Cooper Black', 35)) self.pn = StringVar(self.tk) self.pn.set(re[2]) self.can.create_text(175, 220, text="Patient Name", fill="sandybrown", font=('Cooper Black', 25)) self.e1 = Entry(self.frame, font=('Cooper Black', 18), borderwidth="2", textvariable=self.pn) self.e1.place(x=310, y=210) self.t = StringVar(self.tk) self.t.set(re[3]) self.can.create_text(175, 280, text="Timing", fill="sandybrown", font=('Cooper Black', 25)) self.e2 = Entry(self.frame, font=('Cooper Black', 18), borderwidth="2", textvariable=self.t) self.e2.place(x=310, y=260) self.date = StringVar(self.tk) self.date.set(re[4]) self.can.create_text(175, 330, text="Date", fill="sandybrown", font=('Cooper Black', 25)) self.dob = DateEntry(self.can, font=('cooper balck', 12), bg='darkblue', fg='white', borderwidth="2", textvariable=self.date) self.dob.place(x=310, y=310) self.dob.config(width=30) self.des = StringVar(self.tk) self.des.set(re[5]) self.can.create_text(175, 380, text="Description", fill="sandybrown", font=('Cooper Black', 25)) self.e4 = Entry(self.frame, font=('Cooper Black', 18), borderwidth="2", textvariable=self.des) self.e4.place(x=310, y=360) self.btn = Button(self.frame, text="Update", fg="powder blue", bg="black", font=('Cooper Black', 22), command=self.update) self.btn.place(x=310, y=450) self.tk.mainloop() def update(self): data = [ self.e1.get(), self.e2.get(), self.dob.get(), self.des.get(), self.n ] t = database_queries.database() t.update_appoint(data)
class lHome: def __init__(self, sal, logName,tID): self.sal = sal self.logName = logName self.tID = tID global libHome libHome = Toplevel() libHome.title("Library Home") libHome.geometry("400x470") self.gui_1() libHome.mainloop() def issueFinal(self): sName = self.sName1.get() sId = self.sId1.get() bId = self.bId1.get() iDate = self.cal1.get() rDate = self.cal2.get() remarks = self.rem1.get() # check if student name and ID is matches if connection.is_connected(): mycursor = connection.cursor(buffered=True) sql = 'SELECT * from students where S_name = "{}" and S_ID = "{}"'.format(sName,sId) mycursor.execute(sql) sRece = mycursor.fetchall() mycursor.close() if not sRece: messagebox.showinfo("Field Error", "Student not found in database, please enter proper data", parent=isBook) else: # check if 3 books already issued mycursor = connection.cursor(buffered=True) sql = 'SELECT BookName, BookID, Student_ID from booksissued where Student_ID = "{}" '.format(sId) mycursor.execute(sql) noOfIssued = mycursor.rowcount if noOfIssued > 3: messagebox.showerror("Error", "You have already issued 3 books", parent=isBook) else: mycursor = connection.cursor(buffered=True) sql = 'SELECT BookName, BookID from books where BookID = "{}" '.format(bId) mycursor.execute(sql) bRece = mycursor.fetchall() if not bRece: messagebox.showinfo("Field Error", "Book not found in database.", parent=isBook) else: # write in to sql a = bRece[0] bName = a[0] mySql_insert_query = 'INSERT INTO booksIssued VALUES ("{}","{}","{}","{}","{}","{}","{}")' \ .format(bName, bId, sName, sId, iDate, rDate, remarks) cursor = connection.cursor() cursor.execute(mySql_insert_query) connection.commit() messagebox.showinfo("Book Issued", "Book issue has been registered", parent=isBook) isBook.destroy() else: messagebox.showerror("DBMS error", "Database has been disconnected.") def issueBook1(self): global isBook isBook = Toplevel() isBook.geometry("380x300") isBook.title("Issue Book") # header isBookHeader = Label(isBook, text="Issue Book", bg=libColour, fg='white', font=("Sans serif", 18, "bold"), pady=8) # text add isBookHeader.pack(fill=X) # pack is a must x1, x2 = 20, 130 y1, gapY = 70, 30 width1 = 200 # Name self.sNameLbl = Label(isBook, text="Student Name: ", font=("Sans Serif", 11)) self.sNameLbl.pack() self.sNameLbl.place(x=x1, y=y1) # USN self.sIdLbl = Label(isBook, text="Student ID: ", font=("Sans Serif", 11)) self.sIdLbl.pack() self.sIdLbl.place(x=x1, y=y1 + gapY) # Book ID self.bIdLbl = Label(isBook, text="Book ID: ", font=("Sans Serif", 11)) self.bIdLbl.pack() self.bIdLbl.place(x=x1, y=y1 + 2 * gapY) # Issue Date LBl self.iIsDateLbl = Label(isBook, text="Issue Date: ", font=("Sans Serif", 11)) self.iIsDateLbl.pack() self.iIsDateLbl.place(x=x1, y=y1 + 3 * gapY) # Return date LBL self.iReDateLbl = Label(isBook, text="Return Date: ", font=("Sans Serif", 11)) self.iReDateLbl.pack() self.iReDateLbl.place(x=x1, y=y1 + 4 * gapY) # Remarks date LBL self.remarksLbl = Label(isBook, text="Remarks: ", font=("Sans Serif", 11)) self.remarksLbl.pack() self.remarksLbl.place(x=x1, y=y1 + 5 * gapY) # Name text field self.sName1 = Entry(isBook) self.sName1.pack() self.sName1.place(x=x2, y=y1, width=width1) # sID text field self.sId1 = Entry(isBook) self.sId1.pack() self.sId1.place(x=x2, y=y1 + gapY, width=width1) # BID text field self.bId1 = Entry(isBook) self.bId1.pack() self.bId1.place(x=x2, y=y1 + 2 * gapY, width=width1) # Issue Date d = datetime.date.today() self.cal1 = DateEntry(isBook, width=12, year=d.year, month=d.month, day=d.day, background=libColour, foreground='white', borderwidth=2) self.cal1.pack() self.cal1.config(date_pattern='yyyy/mm/dd') self.cal1.place(x=x2, y=y1 + 3 * gapY) # return Date d = datetime.date.today() self.cal2 = DateEntry(isBook, width=12, year=d.year, month=d.month, day=d.day + 15, background=libColour, foreground='white', borderwidth=2) self.cal2.pack() self.cal2.config(date_pattern='yyyy/mm/dd') self.cal2.place(x=x2, y=y1 + 4 * gapY) # ID text field self.rem1 = Entry(isBook) self.rem1.pack() self.rem1.place(x=x2, y=y1 + 5 * gapY, width=width1) # submit btn self.submitBtn = PhotoImage(file="button_submitLib.png") self.submitButton = Button(isBook, image=self.submitBtn, borderwidth=0, command=self.issueFinal) self.submitButton.pack() self.submitButton.place(x=x2, y=y1 + 5 * gapY + 30) isBook.mainloop() def retFinal(self): self.bID = self.bID1.get() self.sName = self.sNameRet1.get() self.sId = self.sIdRet1.get() # SQL CODE if connection.is_connected(): mycursor = connection.cursor() sql = 'DELETE from booksissued where Student_name = "{}" and Student_ID = "{}" and BookID = "{}"'.format( self.sName, self.sId, self.bID) mycursor.execute(sql) connection.commit() delRowCount = mycursor.rowcount if delRowCount == 0: messagebox.showerror("Entry Error", "Book Issue not found in database, please enter proper data", parent=retBook) else: messagebox.showinfo("Completed", "Book has been returned.",parent=retBook) retBook.destroy() def returnBook1(self): global retBook retBook = Toplevel() retBook.title("Return Book") retBook.geometry('350x210') # header retBookHeader = Label(retBook, text="Return Book", bg=libColour, fg='white', font=("Sans serif", 16, "bold"), pady=7) # text add retBookHeader.pack(fill=X) # pack is a must x1, x2 = 20, 130 y1, gapY = 70, 30 width1 = 200 # Book ID self.bIdLbl = Label(retBook, text="Book ID: ", font=("Sans Serif", 11)) self.bIdLbl.pack() self.bIdLbl.place(x=x1, y=y1) # USN self.sNameLbl = Label(retBook, text="Student Name: ", font=("Sans Serif", 11)) self.sNameLbl.pack() self.sNameLbl.place(x=x1, y=y1 + gapY) # USN self.sIdLbl = Label(retBook, text="Student ID: ", font=("Sans Serif", 11)) self.sIdLbl.pack() self.sIdLbl.place(x=x1, y=y1 + 2 * gapY) # B_ID text field self.bID1 = Entry(retBook) self.bID1.pack() self.bID1.place(x=x2, y=y1, width=width1) # Name text field self.sNameRet1 = Entry(retBook) self.sNameRet1.pack() self.sNameRet1.place(x=x2, y=y1 + gapY, width=width1) # USN text field self.sIdRet1 = Entry(retBook) self.sIdRet1.pack() self.sIdRet1.place(x=x2, y=y1 + 2 * gapY, width=width1) # submit button self.retSubmit = PhotoImage(file='button_submitLib.png') self.retSubmitBtn = Button(retBook, image=self.retSubmit, borderwidth=0, command=self.retFinal) self.retSubmitBtn.pack() self.retSubmitBtn.place(x=x2, y=y1 + 2 * gapY + 25) retBook.mainloop() def delBook(self): self.delBookID = self.id1.get() #sql code sql = 'DELETE FROM books WHERE BookID = "{}" '.format( self.delBookID) cursor = connection.cursor() cursor.execute(sql) connection.commit() cursor.close() delRowCount = cursor.rowcount if delRowCount == 0: messagebox.showerror("Error", "Book not found in database.", parent=listBDB) else: messagebox.showinfo("Book Deleted", "Book has been deleted from database", parent=listBDB) def viewAllIsdBk(self): # sql global listIsBook listIsBook = Toplevel() listIsBook.geometry('1100x500') listIsBook.title("Books Issued") listIsBook.resizable(width=FALSE, height=FALSE) # frame1 frame1 = Frame(listIsBook) frame1.pack(side=TOP, fill=X) # DB header dbHeader = Label(frame1, text="Books Issued", bg=libColour, fg='white', font=("Sans serif", 20, "bold"), pady=10) # text add dbHeader.pack(fill=X) # pack is a must # frame1 frame2 = Frame(listIsBook) frame2.pack(fill=X) frame2.place(y=100) # DB SQL conn = connection.cursor() sql = 'SELECT * FROM booksIssued ' res = conn.execute(sql) ww = conn.fetchall() i = 1 totalBooksIssued = len(ww) details = ["BookName", "BookID", "Student_Name", "Student_ID", "Issue_date", "Return_Date", "Remarks"] # display total books if totalBooksIssued == 0: listIsBook.destroy() messagebox.showerror("Error", "No books have been issued", parent=libHome) else: totBooksLbl = Label(listIsBook, text='Total Books Issued: ' + str(totalBooksIssued), font=('bold', 15)) totBooksLbl.pack() totBooksLbl.place(x=10, y=65) i = 0 width1 = ["50", "15", "30", "15", "15", "15", "50"] # creating headings for j in range(len(details)): e = Entry(frame2, width=width1[j], bg=libColour) e.grid(row=i, column=j) e.insert(END, details[j]) i += 1 # inserting datas j = 0 for books in ww: for j in range(len(books)): e = Entry(frame2, width=width1[j], bg='white') e.grid(row=i, column=j) e.insert(END, books[j]) i += 1 listIsBook.mainloop() def listDB(self): global listBDB listBDB = Toplevel() listBDB.geometry('650x400') listBDB.title("Books") # frame1 frame1 = Frame(listBDB) frame1.pack(side=TOP, fill=X) # DB header dbHeader = Label(frame1, text="Books Database", bg=libColour, fg='white', font=("Sans serif", 20, "bold"), pady=12) # text add dbHeader.pack(fill=X) # pack is a must # frame1 frame2 = Frame(listBDB) frame2.pack(fill=X) frame2.place(y=150) # DB SQL conn = connection.cursor() sql = 'SELECT * FROM books' res = conn.execute(sql) ww = conn.fetchall() i = 1 totalBooks = len(ww) details = ["BookName", "BookID", "Author", "Edition"] # display total books totBooksLbl = Label(listBDB, text='Total Books: ' + str(totalBooks), font=('bold', 15)) totBooksLbl.pack() totBooksLbl.place(x=10, y=65) i = 0 width1 = ["50", "15", "30", "10"] # creating headings for j in range(len(details)): e = Entry(frame2, width=width1[j], bg=libColour) e.grid(row=i, column=j) e.insert(END, details[j]) i += 1 # inserting datas for books in ww: for j in range(len(books)): e = Entry(frame2, width=width1[j], bg='white') e.grid(row=i, column=j) e.insert(END, books[j]) i += 1 # bookID Lbl self.nameLbl = Label(listBDB, text="Book ID: ", font=("Sans Serif", 12,'bold')) self.nameLbl.pack() self.nameLbl.place(x=10,y=110) # Book ID entry field self.id1 = Entry(listBDB) self.id1.pack() self.id1.place (x=100,y=110,width=150) #del Book button self.delBookIcn =PhotoImage(file = "button_deleteBookLibrary.png") self.delBookIcnBtn =Button(listBDB, image = self.delBookIcn,borderwidth = 0,command = self.delBook) self.delBookIcnBtn.pack() self.delBookIcnBtn.place(x=270,y=107) #view all issued button self.viewAlIssuedIcn =PhotoImage(file = "button_allBookIssued.png") self.viewAlIssuedIcnBtn =Button(listBDB, image = self.viewAlIssuedIcn,borderwidth = 0,command = self.viewAllIsdBk) self.viewAlIssuedIcnBtn.pack() self.viewAlIssuedIcnBtn.place(x=470,y=107) listBDB.mainloop() def addFinal(self): adBookID = self.adBookId1.get() bName = self.bName1.get() bAuthor = self.bAuthor1.get() bEdition = self.bEdition1.get() if adBookID and bName and bAuthor and bEdition: if connection.is_connected(): mycursor = connection.cursor() sql = 'SELECT * from books where BookID = "{}" '.format(adBookID) mycursor.execute(sql) bRece = mycursor.fetchall() if bRece: messagebox.showinfo("Error", "Book already registered in database.", parent=adBook) else: mycursor = connection.cursor() sql = 'INSERT INTO books VALUES ("{}","{}","{}","{}")' \ .format(adBookID, bName, bAuthor, bEdition) mycursor.execute(sql) connection.commit() messagebox.showinfo("Book Registered", 'Book has been added to the database.', parent=adBook) adBook.destroy() else: print("DBMS not connected") else: messagebox.showerror("Error", "Please enter all data.", parent=adBook) def addBook1(self): global adBook adBook = Toplevel() adBook.title("Add Book") adBook.geometry("450x280") x1, x2 = 40, 130 y1, gapY = 80, 35 width1 = 250 # Add book header adBookHeader = Label(adBook, text="Add Book", bg=libColour, fg='white', font=("Sans serif", 20, "bold"), pady=8) # text add adBookHeader.pack(fill=X) # pack is a must # book ID text field self.adBookId1 = Entry(adBook) self.adBookId1.pack() self.adBookId1.place(x=x2, y=y1, width=width1) # Book Name text field self.bName1 = Entry(adBook) self.bName1.pack() self.bName1.place(x=x2, y=y1 + gapY, width=width1) # Author text field self.bAuthor1 = Entry(adBook) self.bAuthor1.pack() self.bAuthor1.place(x=x2, y=y1 + 2 * gapY, width=width1) # Edition text field self.bEdition1 = Entry(adBook) self.bEdition1.pack() self.bEdition1.place(x=x2, y=y1 + 3 * gapY, width=width1) # Book ID Lbl self.bIdLbl = Label(adBook, text="Book ID: ", font=("Sans Serif", 11)) self.bIdLbl.pack() self.bIdLbl.place(x=x1, y=y1) # Book name Lbl self.bAdNameLbl = Label(adBook, text="Book Name: ", font=("Sans Serif", 11)) self.bAdNameLbl.pack() self.bAdNameLbl.place(x=x1, y=y1 + gapY) # Book Author Lbl self.bAuthorLbl = Label(adBook, text="Author(s): ", font=("Sans Serif", 11)) self.bAuthorLbl.pack() self.bAuthorLbl.place(x=x1, y=y1 + 2 * gapY) # Book Edition Lbl self.bEditionLbl = Label(adBook, text="Edition: ", font=("Sans Serif", 11)) self.bEditionLbl.pack() self.bEditionLbl.place(x=x1, y=y1 + 3 * gapY) # submit btn self.adBookSubmit = PhotoImage(file='button_submitLib.png') self.adBookSubmitBtn = Button(adBook, image=self.adBookSubmit, borderwidth=0, command=self.addFinal) self.adBookSubmitBtn.pack() self.adBookSubmitBtn.place(x=x2, y=y1 + 3 * gapY + 30) adBook.mainloop() def settingsOpen(self): s1= settingsLibrary(self.sal,self.logName,self.tID) s1 def gui_1(self): # header textDis = 'Welcome ' + self.sal + " " + self.logName self.tHeader = Label(libHome, text=textDis, bg=libColour, fg='white', font=("Sans serif", 16, "bold"), pady=10) # text add self.tHeader.pack(fill=X) # pack is a must # issue Book image self.issueBook = PhotoImage(file='icon_bookIssue.png') self.issueBookLbl = Label(libHome, image=self.issueBook) self.issueBookLbl.pack() self.issueBookLbl.place(x=50, y=70) # return Book image self.returnBook = PhotoImage(file='icon_bookReturn.png') self.returnBookLbl = Label(libHome, image=self.returnBook) self.returnBookLbl.pack() self.returnBookLbl.place(x=230, y=70) # add Book image self.addBook = PhotoImage(file='icon_bookAdd.png') self.addBookLbl = Label(libHome, image=self.addBook) self.addBookLbl.pack() self.addBookLbl.place(x=50, y=265) # BookDb image self.bookDb = PhotoImage(file='icon_bookDb.png') self.bookDbLbl = Label(libHome, image=self.bookDb) self.bookDbLbl.pack() self.bookDbLbl.place(x=230, y=265) x1Btn, gapX = 42, 180 y1Btn, gapY = 210, 190 # issue book button self.issueBookBtn = PhotoImage(file='button_issueBook.png') self.issueBookBtnLbl = Button(libHome, image=self.issueBookBtn, borderwidth=0, command=self.issueBook1) self.issueBookBtnLbl.pack() self.issueBookBtnLbl.place(x=x1Btn, y=y1Btn) # return book button self.returnBookBtn = PhotoImage(file='button_returnBook.png') self.returnBookBtnLbl = Button(libHome, image=self.returnBookBtn, borderwidth=0, command=self.returnBook1) self.returnBookBtnLbl.pack() self.returnBookBtnLbl.place(x=x1Btn + gapX, y=y1Btn) # add book button self.addBookBtn = PhotoImage(file='button_addBook.png') self.addBookBtnLbl = Button(libHome, image=self.addBookBtn, borderwidth=0, command=self.addBook1) self.addBookBtnLbl.pack() self.addBookBtnLbl.place(x=x1Btn, y=y1Btn + gapY) # bookDB button self.bookDbBtn = PhotoImage(file='button_bookDatabase.png') self.bookDbBtnLbl = Button(libHome, image=self.bookDbBtn, borderwidth=0, command=self.listDB) self.bookDbBtnLbl.pack() self.bookDbBtnLbl.place(x=x1Btn + gapX, y=y1Btn + gapY) # settings button self.settingsBtnIcon = PhotoImage(file ="button_settingsTeacher.png") self.settingsBtn = Button(libHome, image = self.settingsBtnIcon, borderwidth = 0,command = self.settingsOpen) self.settingsBtn.pack() self.settingsBtn.place(x='350',y= '50')
class bookingpage(tk.Tk): def __init__(self,id, *args, **kwargs): # __init__ function for class Tk tk.Tk.__init__(self, *args, **kwargs) self.title("Booking") self.geometry("900x500") self.config(background="black", pady=10) lbs = tk.Label(self, text="Booking", bg="black", fg="white", font=20) lbs.place(x=110, y=5) self.id=id self.details() def details(self): lb2_name = tk.Label(self, text="Name - ", bg="black", fg="white") self.name = tk.Entry(self) lb2_name.place(x=10, y=40) self.name.place(x=110, y=40) lb2_guest = tk.Label(self, text="No of Guest ", bg="black", fg="white") self.guest = tk.Entry(self) lb2_guest.place(x=10, y=80) self.guest.place(x=110, y=80) self.tkvar = tk.StringVar(self) # Dictionary with options choice = {'Standard', 'Deluxe', 'Luxury'} self.tkvar.set('Select') # set the default option popupMenu = tk.OptionMenu(self, self.tkvar, *choice,command=self.check_acc) tk.Label(self, text="Room Type",bg="black", fg="white").place(x=10, y=120) popupMenu.place(x=110, y=120) lb2_room = tk.Label(self, text="No Of Room - ", bg="black", fg="white") self.room = tk.Entry(self) lb2_room.place(x=10, y=160) self.room.place(x=110, y=160) # lb2_s = tk.Label(self, text="Email - ", bg="black", fg="white") # self.lb2_s2 = tk.Entry(self) # lb2_s.place(x=10, y=200) # self.lb2_s2.place(x=110, y=200) current_date = date.today() self.cur_date=current_date tomorrow = date.today() + timedelta(1) label1 = tk.Label(self, text='Check In Date',bg="black", fg="white") label1.place(x='10', y='200') self.cal = DateEntry(self, width=12, year=current_date.year, month=current_date.month, day=current_date.day, mindate=current_date, date_pattern='y-mm-dd', background='darkblue', foreground='white', borderwidth=2) self.cal.place(x='110', y='200') label2 = tk.Label(self, text='Check out Date',bg="black", fg="white") label2.place(x='240', y='200') self.cal.bind("<<DateEntrySelected>>", self.callback) date_time_obj = datetime.datetime.strptime(self.cal.get(), '%Y-%m-%d') # print(type(date_time_obj)) # if self.cal.get(): # min_date=self.cal.get() # else: # min_date=tomorrow lb2_s = tk.Label(self, text="Price - ", bg="black", fg="white") self.price = tk.Label(self,bg="black", fg="white") lb2_s.place(x=10, y=240) self.price.place(x=110, y=240) self.cal1 = DateEntry(self, width=12, year=tomorrow.year, month=tomorrow.month, day=tomorrow.day, mindate=tomorrow, date_pattern='y-mm-dd', background='darkblue', foreground='white', borderwidth=2) self.cal1.place(x='380', y='200') # reg = self.register(self.callback) # # self.cal1.config(validate="key", # validatecommand=(reg, '% P')) # button = tk.Button(self, text='Search', command=self.search) # button.place(x='150', y='120') try: mycursor = mydb.cursor() mycursor.execute("SELECT * FROM hotel_name where id=%s"%self.id) self.myresult = mycursor.fetchall() print(self.myresult) im = Image.open(r"%s" % self.myresult[0][5]) image = im self.background_image = ImageTk.PhotoImage(im) lb_hotel = tk.Label(self, text=self.myresult[0][1], bg="black", fg="white", font=20) lb_hotel.place(x=400, y=40) row = 50 lb_img = tk.Label(self,image=self.background_image,height=50,width=50) lb_img.place(x=400, y=80) lb_img.photo=self.background_image except: print("No result") button = tk.Button(self, text="book", command=self.book) button.place(x='120', y='280') def callback(self,input): w = input.widget date = w.get_date()+timedelta(1) self.cal1.config(mindate=date) def book(self): try: mycursor = mydb.cursor() sql = "INSERT INTO booking (name,no_guest,room_type,checkin,checkout,hot_name,book_date,total) VALUES (%s, %s,%s,%s,%s,%s,%s,%s)" val = ( self.name.get(), self.guest.get(), self.tkvar.get(), self.cal.get(), self.cal1.get(), self.myresult[0][1],self.cur_date,(self.p*int(self.room.get()))) mycursor.execute(sql, val) mydb.commit() print(mycursor.rowcount, "record inserted.") self.display=tk.Label(self) self.display2.config(bg="green", fg="white", text="Saved Success") self.display2.place(x=20, y=1) except: self.display = tk.Label(self) self.display2.config(bg="red", fg="white", text="Not Saved") self.display2.place(x=20, y=1) def check_acc(self,event): selected = self.tkvar.get() self.dic={'Standard':7,'Deluxe':8,'Luxury':9} self.dic2 = {'Standard': 2, 'Deluxe': 3, 'Luxury': 4} if(self.myresult[0][self.dic2[selected]]==0): lab=tk.Label(self,text="Room Full") lab.place(x=200,y=120) else: if (len(selected) != 0): self.price.config(text=self.myresult[0][self.dic[selected]], bg="black", fg="white") self.p=self.myresult[0][self.dic[selected]]
class asmt1: def __init__(self, logName,tID): self.logName = logName self.tID = tID global asst asst = Toplevel() asst.title('Assignment') asst.geometry("550x320") asst.resizable(width=FALSE,height=FALSE) self.gui_1() asst.mainloop() def asmtFinal(self): astSub = self.subject1.get() astName = self.sName1.get() astSec = self.sec1.get() astLink = self.astLk1.get() astDate = self.cal1.get_date() astRem = self.rem1.get() astTeacher = self.logName if connection.is_connected(): mycursor = connection.cursor() sql = 'SELECT * from teachersubject where Teacher_name = "{}" and Teacher_ID = "{}" and Subject_Code = "{}"'.format(self.logName, self.tID,astSub) mycursor.execute(sql) wName = mycursor.fetchall() if not wName: messagebox.showinfo("Error", "You have not registered for this subject", parent=asst) else: if astSub and astName and astSec and astLink and astDate and astRem and astTeacher: if connection.is_connected(): conn = connection.cursor() sql = 'INSERT INTO assignment values("{}","{}","{}","{}","{}","{}","{}")'.format(astSub,astName,astSec,astLink,astDate,astRem,astTeacher) conn.execute(sql) connection.commit() messagebox.showinfo("Done","Assignment updated.",parent = asst) else: messagebox.showerror("Error","Please enter all fields.", parent = asst) def endAsmt(self): endSub = self.delSubject1.get() endDate = self.cal1.get_date() conn = connection.cursor() sql = 'SELECT * FROM assignment WHERE Assignment_Subject = "{}" and Asst_Sub_Date = "{}"'.format( endSub,endDate) res = conn.execute(sql) asstAll = conn.fetchall() if not asstAll: messagebox.showerror("Error","Please enter correct data.",parent=asstView) else: conn = connection.cursor() sql = 'DELETE FROM assignment where Assignment_Subject = "{}" and Asst_Sub_Date = "{}"'.format(endSub,endDate) conn.execute(sql) connection.commit() messagebox.showinfo("Done", "Assignment submission ended.", parent=asstView) def viewAsmt(self): conn = connection.cursor() sql = 'SELECT * FROM assignment WHERE Teacher = "{}"'.format( self.logName) res = conn.execute(sql) asstAll = conn.fetchall() if asstAll: global asstView asstView = Toplevel() asstView.title('Assignment View') asstView.geometry("930x400") # frame self.frame1 = Frame(asstView) self.frame1.pack(side=TOP, fill=X) # header self.tHeader = Label(self.frame1, text="Assignment View", bg=teacherColour, fg='white', font=("Sans serif", 16, "bold"), pady=6) # text add self.tHeader.pack(fill=X) # pack is a must # btm frame btmFrame = Frame(asstView) btmFrame.pack(fill=X) btmFrame.place(y=50) # list assignments details = ["Subject", "Name", "Section", "Link", "Due_Date", "Remarks", "Teacher"] i = 0 width1 = ["15", "25", "10", "35", "15", "30", "20"] # creating headings for j in range(len(details)): e = Entry(btmFrame, width=width1[j], bg=teacherColour) e.grid(row=i, column=j) e.insert(END, details[j]) i += 1 # inserting datasframe1 for asstOne in asstAll: for j in range(len(asstOne)): e = Entry(btmFrame, width=width1[j], bg='white') e.grid(row=i, column=j) e.insert(END, asstOne[j]) i += 1 # bottom frame btmFrame = Frame(asstView) btmFrame.pack(side= BOTTOM) ipa1=30 # subject lbl self.subLbl = Label(btmFrame, text="Subject Code: ", font=("Sans Serif", 11)) self.subLbl.grid(row =1,column = 1) # due date lbl self.dueDateLbl = Label(btmFrame, text="Due date:", font=("Sans Serif", 11)) self.dueDateLbl.grid(row =2,column = 1) #self.dueDateLbl.place(x=400) #end submission btn self.endAsmtBtn = PhotoImage(file="button_endSubmission.png") self.endBtnLbl = Button(btmFrame, image=self.endAsmtBtn, borderwidth=0, command=self.endAsmt) self.endBtnLbl.grid(row =3,column=2) # subject Entry self.delSubject1 = Entry(btmFrame) self.delSubject1.grid(row=1, column =2) # date Entry d = datetime.date.today() self.cal1 = DateEntry(btmFrame, width=12, year=d.year, month=d.month, day=d.day, background=teacherColour, foreground='white', borderwidth=2) self.cal1.grid(row=2,column =2,pady=10) self.cal1.config(date_pattern='yyyy-mm-dd') asstView.mainloop() else: messagebox.showerror("Not found","You have not given any assignments",parent = asst) def gui_1(self): # header self.tHeader = Label(asst, text="Assignment", bg=teacherColour, fg='white', font=("Sans serif", 16, "bold"), pady=6) # text add self.tHeader.pack(fill=X) # pack is a must x1, x2 = 20, 160 y1, gap = 60, 30 width1 = 200 # subject lbl self.subLbl = Label(asst, text="Subject Code: ", font=("Sans Serif", 11)) self.subLbl.pack() self.subLbl.place(x=x1, y=y1) # name lbl self.nameLbl = Label(asst, text="Assignment Name: ", font=("Sans Serif", 11)) self.nameLbl.pack() self.nameLbl.place(x=x1, y=y1+gap) # section lbl self.sectionLbl = Label(asst, text="Section: ", font=("Sans Serif", 11)) self.sectionLbl.pack() self.sectionLbl.place(x=x1, y=y1+2*gap) # assignment link lbl self.astLkLbl = Label(asst, text="Assignment Link: ", font=("Sans Serif", 11)) self.astLkLbl.pack() self.astLkLbl.place(x=x1, y=y1 + 3 * gap) # due date lbl self.dueDateLbl = Label(asst, text="Due date:", font=("Sans Serif", 11)) self.dueDateLbl.pack() self.dueDateLbl.place(x=x1, y=y1+4*gap) # remarks lbl self.reamarksLbl = Label(asst, text="Remarks", font=("Sans Serif", 11)) self.reamarksLbl.pack() self.reamarksLbl.place(x=x1, y=y1+5*gap) #subjct Entry self.subject1 = Entry(asst) self.subject1.pack() self.subject1.place(x=x2,y=y1,width = width1) #name Entry self.sName1 = Entry(asst) self.sName1.pack() self.sName1.place(x=x2,y=y1+gap,width = width1) #section Entry self.sec1 = Entry(asst) self.sec1.pack() self.sec1.place(x=x2,y=y1+2*gap,width = width1) #asst link Entry self.astLk1 = Entry(asst) self.astLk1.pack() self.astLk1.place(x=x2,y=y1+3*gap,width = width1) # date entry d = datetime.date.today() self.cal1 = DateEntry(asst, width=12, year=d.year, month=d.month, day=d.day, background=teacherColour, foreground='white', borderwidth=2) self.cal1.pack() self.cal1.config(date_pattern='yyyy-mm-dd') self.cal1.place(x=x2, y=y1 + 4 * gap) #remarks Entry self.rem1 = Entry(asst) self.rem1.pack() self.rem1.place(x=x2,y=y1+5*gap,width = width1) #submit button self.submitBtn = PhotoImage(file = "button_submitTeacherSmall.png") self.submitBtnLbl =Button(asst, image = self.submitBtn, borderwidth = 0,command = self.asmtFinal) self.submitBtnLbl.pack() self.submitBtnLbl.place(x=x2,y=y1+6*gap) #viewAllAsst button self.viewAllAsmtBtn = PhotoImage(file = "button_viewYourAssignments.png") self.submitBtnLbl =Button(asst, image = self.viewAllAsmtBtn, borderwidth = 0,command = self.viewAsmt) self.submitBtnLbl.pack() self.submitBtnLbl.place(x=2*x2,y=y1+7*gap+10)
def __init__(self, root, connection, master): """FormNewRepair init.""" super().__init__(root=root, connection=connection) self.root.state('zoomed') self.master = master self.root['bg'] = 'black' self.client_selected = tk.StringVar() self.vehicle_selected = tk.StringVar() self.client_id = tk.StringVar() self.name = tk.StringVar() self.last_name = tk.StringVar() self.identity_card = tk.StringVar() self.email = tk.StringVar() self.phone_1 = tk.StringVar() self.phone_2 = tk.StringVar() self.address = tk.StringVar() self.vehicle_id = tk.StringVar() self.vehicle_identity = tk.StringVar() self.color = tk.StringVar() self.brand = tk.StringVar() self.model = tk.StringVar() self.year = tk.StringVar() self.status_selected = tk.StringVar() self.mileage = tk.StringVar() self.client_obs = tk.StringVar() self.mechanical_obs = tk.StringVar() self.final_obs = tk.StringVar() self.price = tk.StringVar() self.date_entry = tk.StringVar() self.date_exit = tk.StringVar() # Frame Search clients frame_search_client = tk.LabelFrame(self.root, text="Buscar cliente", bg="black", foreground="white", font='Helvetica 12 bold') frame_search_client.pack(side="top", padx=5, pady=5, fill='x') self.client_selected.trace_add("write", self.callback_client) self.client_chosen = ttk.Combobox(frame_search_client, width=20, font='Helvetica 12 bold', state="readonly", textvariable=self.client_selected) self.client_chosen["values"] = self.get_clients() self.client_chosen.pack(side="top", padx=5, pady=5, fill='x', expand=True) # Frame Details Clients frame_details_client = tk.LabelFrame(self.root, text="Datos del cliente", bg="black", foreground="white", font='Helvetica 12 bold') frame_details_client.pack(side="top", padx=5, pady=5, fill='x') frame_details_client_1 = tk.Frame(frame_details_client, bg="black") frame_details_client_1.pack(side="top", fill='x') frame_details_client_2 = tk.Frame(frame_details_client_1, bg="black") frame_details_client_2.pack(side="left", fill='x', expand=True) frame_details_client_3 = tk.Frame(frame_details_client_1, bg="black") frame_details_client_3.pack(side="left", fill='x', expand=True) frame_details_client_4 = tk.Frame(frame_details_client_1, bg="black") frame_details_client_4.pack(side="left", fill='x', expand=True) frame_details_client_5 = tk.Frame(frame_details_client_1, bg="black") frame_details_client_5.pack(side="left", fill='x', expand=True) frame_details_client_6 = tk.Frame(frame_details_client, bg="black") frame_details_client_6.pack(side="top", fill='x') frame_details_client_7 = tk.Frame(frame_details_client_6, bg="black") frame_details_client_7.pack(side="left", fill='x') frame_details_client_8 = tk.Frame(frame_details_client_6, bg="black") frame_details_client_8.pack(side="left", fill='x', expand=True) name_label = tk.Label(frame_details_client_2, text="Nombre", font='Helvetica 12 bold', anchor='w', foreground="gold2", bg="black") name_label.pack(padx=5, pady=5, fill='both') name_entry = tk.Entry(frame_details_client_3, font="Helvetica 12", textvariable=self.name) name_entry.config(state='readonly') name_entry.pack(padx=5, pady=5, fill='both') last_name_label = tk.Label(frame_details_client_4, text="Apellido", font='Helvetica 12 bold', anchor='w', foreground="gold2", bg="black") last_name_label.pack(padx=5, pady=5, fill='both') last_name_entry = tk.Entry(frame_details_client_5, font="Helvetica 12", textvariable=self.last_name) last_name_entry.config(state='readonly') last_name_entry.pack(padx=5, pady=5, fill='both') identity_card_label = tk.Label(frame_details_client_2, text="Cedula", font='Helvetica 12 bold', anchor='w', foreground="gold2", bg="black") identity_card_label.pack(padx=5, pady=5, fill='both') identity_card_entry = tk.Entry(frame_details_client_3, font="Helvetica 12", textvariable=self.identity_card) identity_card_entry.config(state='readonly') identity_card_entry.pack(padx=5, pady=5, fill='both') email_label = tk.Label(frame_details_client_4, text="Email", font='Helvetica 12 bold', anchor='w', foreground="gold2", bg="black") email_label.pack(padx=5, pady=5, fill='both') email_entry = tk.Entry(frame_details_client_5, font="Helvetica 12", textvariable=self.email) email_entry.config(state='readonly') email_entry.pack(padx=5, pady=5, fill='both') phone_1_label = tk.Label(frame_details_client_2, text="Telefono fijo", font='Helvetica 12 bold', anchor='w', foreground="gold2", bg="black") phone_1_label.pack(padx=5, pady=5, fill='both') phone_1_entry = tk.Entry(frame_details_client_3, font="Helvetica 12", textvariable=self.phone_1) phone_1_entry.config(state='readonly') phone_1_entry.pack(padx=5, pady=5, fill='both') phone_2_label = tk.Label(frame_details_client_4, text="Celular", font='Helvetica 12 bold', anchor='w', foreground="gold2", bg="black") phone_2_label.pack(padx=5, pady=5, fill='both') phone_2_entry = tk.Entry(frame_details_client_5, font="Helvetica 12", textvariable=self.phone_2) phone_2_entry.config(state='readonly') phone_2_entry.pack(padx=5, pady=5, fill='both') address_label = tk.Label(frame_details_client_7, text="Direccion", font='Helvetica 12 bold', anchor='w', foreground="gold2", bg="black") address_label.pack(padx=5, pady=5, fill='both') address_entry = tk.Entry(frame_details_client_8, font="Helvetica 12", textvariable=self.address) address_entry.config(state='readonly') address_entry.pack(padx=5, pady=5, fill='both') # Frame Search vehicle frame_search_vehicle = tk.LabelFrame(self.root, text="Buscar vehiculo", bg="black", foreground="white", font='Helvetica 12 bold') frame_search_vehicle.pack(side="top", padx=5, pady=5, fill='x') self.vehicle_selected.trace_add("write", self.callback_vehicle) self.vehicle_chosen = ttk.Combobox(frame_search_vehicle, width=20, font='Helvetica 12 bold', state="readonly", textvariable=self.vehicle_selected) self.vehicle_chosen.pack(side="top", padx=5, pady=5, fill='x', expand=True) # Frame Vehicle details frame_details_vehicle = tk.LabelFrame(self.root, text="Datos del vehiculo", bg="black", foreground="white", font='Helvetica 12 bold') frame_details_vehicle.pack(side="top", padx=5, pady=5, fill='x') frame_details_vehicle_1 = tk.Frame(frame_details_vehicle, bg="black") frame_details_vehicle_1.pack(side="left", fill='both', padx=5, pady=5, expand=True) frame_details_vehicle_2 = tk.Frame(frame_details_vehicle, bg="black") frame_details_vehicle_2.pack(side="left", fill='both', padx=5, pady=5, expand=True) frame_details_vehicle_3 = tk.Frame(frame_details_vehicle, bg="black") frame_details_vehicle_3.pack(side="left", fill='both', padx=5, pady=5, expand=True) frame_details_vehicle_4 = tk.Frame(frame_details_vehicle, bg="black") frame_details_vehicle_4.pack(side="left", fill='both', padx=5, pady=5, expand=True) self.vehicle_identity.trace_add("write", self.callback_vehicle) self.color.trace_add("write", self.callback_vehicle) self.brand.trace_add("write", self.callback_vehicle) self.model.trace_add("write", self.callback_vehicle) self.year.trace_add("write", self.callback_vehicle) vehicle_identity_label = tk.Label(frame_details_vehicle_1, text="Placa", font='Helvetica 12 bold', anchor='w', foreground="gold2", bg="black") vehicle_identity_label.pack(padx=5, pady=5, fill='both') vehicle_identity_entry = tk.Entry(frame_details_vehicle_2, font="Helvetica 12", textvariable=self.vehicle_identity) vehicle_identity_entry.config(state='readonly') vehicle_identity_entry.pack(padx=5, pady=5, fill='both') color_label = tk.Label(frame_details_vehicle_3, text="Color", font='Helvetica 12 bold', anchor='w', foreground="gold2", bg="black") color_label.pack(padx=5, pady=5, fill='both') color_entry = tk.Entry(frame_details_vehicle_4, font="Helvetica 12", textvariable=self.color) color_entry.config(state='readonly') color_entry.pack(padx=5, pady=5, fill='both') vehicle_type_label = tk.Label(frame_details_vehicle_1, text="Tipo de Vehiculo", font='Helvetica 12 bold', anchor='w') vehicle_type_label.pack(padx=5, pady=5, fill='both') brand_entry = tk.Entry(frame_details_vehicle_2, font="Helvetica 12", textvariable=self.brand) brand_entry.config(state='readonly') brand_entry.pack(padx=5, pady=5, fill='both') model_entry = tk.Entry(frame_details_vehicle_3, font="Helvetica 12", textvariable=self.model) model_entry.config(state='readonly') model_entry.pack(padx=5, pady=5, fill='both') year_entry = tk.Entry(frame_details_vehicle_4, font="Helvetica 12", textvariable=self.year) year_entry.config(state='readonly') year_entry.pack(padx=5, pady=5, fill='both') mileage_label = tk.Label(frame_details_vehicle_1, text="Kilometraje", font='Helvetica 12 bold', anchor='w', foreground="gold2", bg="black") mileage_label.pack(padx=5, pady=5, fill='both') mileage_entry = tk.Entry(frame_details_vehicle_2, font="Helvetica 12", textvariable=self.mileage) mileage_entry.pack(padx=5, pady=5, fill='both') # Repair details frame_details_repair = tk.LabelFrame(self.root, text="Detalles de la Reparación", foreground="white", font='Helvetica 12 bold', bg="black") frame_details_repair.pack(side="top", padx=5, pady=5, fill='both') frame_details_repair_1 = tk.Frame(frame_details_repair, bg="black") frame_details_repair_1.pack(side="top", fill='x', expand=True) frame_details_repair_1_a = tk.Frame(frame_details_repair_1, bg="black") frame_details_repair_1_a.pack(side="left", padx=5, pady=5, fill='x', expand=True) frame_details_repair_1_a_a = tk.Frame(frame_details_repair_1_a, bg="black") frame_details_repair_1_a_a.pack(side="top", fill='x', expand=True) frame_details_repair_1_b = tk.Frame(frame_details_repair_1, bg="black") frame_details_repair_1_b.pack(side="left", fill='x', expand=True) frame_details_repair_1_b_a = tk.Frame(frame_details_repair_1_b, bg="black") frame_details_repair_1_b_a.pack(side="top", fill='x', expand=True) frame_details_repair_2 = tk.Frame(frame_details_repair, bg="black") frame_details_repair_2.pack(side="top", fill='x', expand=True) frame_details_repair_2_a = tk.Frame(frame_details_repair_2, bg="black") frame_details_repair_2_a.pack(side="left", fill='x', expand=True) frame_details_repair_2_a_a = tk.Frame(frame_details_repair_2_a, bg="black") frame_details_repair_2_a_a.pack(side="top", padx=5, pady=5, fill='x', expand=True) frame_details_repair_2_b = tk.Frame(frame_details_repair_2, bg="black") frame_details_repair_2_b.pack(side="left", fill='x', expand=True) frame_details_repair_2_b_a = tk.Frame(frame_details_repair_2_b, bg="black") frame_details_repair_2_b_a.pack(side="top", fill='x', expand=True) frame_details_repair_3 = tk.Frame(frame_details_repair, bg="black") frame_details_repair_3.pack(side="top", fill='x', expand=True) frame_details_repair_3_a = tk.Frame(frame_details_repair_3, bg="black") frame_details_repair_3_a.pack(side="left", padx=5, pady=5, fill='x', expand=True) # Date Entry date_entry_label = tk.Label(frame_details_repair_1_a_a, text="Fecha de entrada:", font='Helvetica 12 bold', anchor='w', foreground="gold2", bg="black") date_entry_label.pack(side="left", padx=5, pady=5, fill='x') date_entry = DateEntry(frame_details_repair_1_a_a, width=10, background='darkblue', foreground='white', borderwidth=1, date_pattern='dd/mm/y', font='Helvetica 12 bold', textvariable=self.date_entry) date_entry.pack(side="left", padx=5, pady=5, fill='x') # Client observations client_obs_label = tk.Label(frame_details_repair_1_a, text="Observaciones del Cliente:", font='Helvetica 12 bold', anchor='w', foreground="gold2", bg="black") client_obs_label.pack(side="top", fill='x', expand=True) self.client_obs = tk.Text(frame_details_repair_1_a, height=4) self.client_obs.pack(side="left", fill="x", expand=True) scrollbar_client = tk.Scrollbar(frame_details_repair_1_a) scrollbar_client.pack(side="left", fill="y") scrollbar_client.config(command=self.client_obs.yview) self.client_obs.config(yscrollcommand=scrollbar_client.set) # Status status_label = tk.Label(frame_details_repair_2_a_a, text="Estado:", font='Helvetica 12 bold', anchor='w', foreground="gold2", bg="black") status_label.pack(side="left", padx=5, pady=5, fill='x') self.status_chosen = ttk.Combobox(frame_details_repair_2_a_a, width=12, font='Helvetica 12 bold', state="readonly", textvariable=self.status_selected) self.status_chosen["values"] = ["EN TALLER"] self.status_chosen.current(0) self.status_chosen.pack(side="left", padx=5, pady=5, fill='x') # Date Exit date_exit_label = tk.Label(frame_details_repair_1_b_a, text="Fecha de salida:", font='Helvetica 12 bold', anchor='w', foreground="gold2", bg="black") date_exit_label.pack(side="left", padx=5, pady=5, fill='x') date_exit = DateEntry(frame_details_repair_1_b_a, width=10, background='darkblue', foreground='white', borderwidth=1, date_pattern='dd/mm/y', font='Helvetica 12 bold', textvariable=self.date_exit) date_exit.delete(0, "end") date_exit.config(state="disabled") date_exit.pack(side="left", padx=5, pady=5, fill='x') # Mechanical observations mechanical_obs_label = tk.Label(frame_details_repair_1_b, text="Observaciones del Mecánico:", font='Helvetica 12 bold', anchor='w', foreground="gold2", bg="black") mechanical_obs_label.pack(side="top", fill='x', expand=True) scrollbar_mechanical = tk.Scrollbar(frame_details_repair_1_b) self.mechanical_obs = tk.Text(frame_details_repair_1_b, height=4) self.mechanical_obs.pack(side="left", fill="x", expand=True) scrollbar_mechanical.pack(side="left", fill="y") scrollbar_mechanical.config(command=self.mechanical_obs.yview) self.mechanical_obs.config(yscrollcommand=scrollbar_mechanical.set) # Price price_label = tk.Label(frame_details_repair_2_b_a, text="Precio:", font='Helvetica 12 bold', foreground="gold2", bg="black") price_label.pack(side="left", padx=5, pady=5) price_entry = tk.Entry(frame_details_repair_2_b_a, font="Helvetica 12 bold", textvariable=self.price) price_entry.pack(side="left", padx=5, pady=5, fill='x', expand=True) # Final observations final_obs_label = tk.Label(frame_details_repair_3_a, text="Observación final:", font='Helvetica 12 bold', anchor='w', foreground="gold2", bg="black") final_obs_label.pack(side="top", fill='x', expand=True) self.final_obs = tk.Text(frame_details_repair_3_a, height=3) self.final_obs.configure(state='disabled') self.final_obs.pack(side="left", fill="x", expand=True) scrollbar_final = tk.Scrollbar(frame_details_repair_3_a) scrollbar_final.pack(side="left", fill="y") scrollbar_final.config(command=self.client_obs.yview) self.final_obs.config(yscrollcommand=scrollbar_client.set) # Buttons frame_buttons = tk.Frame(self.root, bg="black") frame_buttons.pack(side="bottom", fill='x') button_1 = tk.Button(frame_buttons, text="Crear", font='Helvetica 12 bold', width=15, bg="gold2", command=self.create_repair) button_1.pack(side='right', fil='x', padx=5, pady=5) button_2 = tk.Button(frame_buttons, text="Regresar", font='Helvetica 12 bold', width=15, bg="gold2", command=self.go_back) button_2.pack(side='right', fil='x', padx=5, pady=5) self.root.mainloop()
class rsearch(tk.Tk): def __init__(self, *args, **kwargs): # __init__ function for class Tk tk.Tk.__init__(self, *args, **kwargs) # self = Tk() current_date = date.today() tomorrow = date.today() + timedelta(1) print(type(tomorrow)) self.title("Search") self.geometry("900x500") self.config(background="black", pady=10) label1 = tk.Label(self, text='Check In Date') label1.place(x='60', y='40') self.cal = DateEntry(self, width=12, year=current_date.year, month=current_date.month, day=current_date.day, mindate=current_date, date_pattern='y-mm-dd', background='darkblue', foreground='white', borderwidth=2) self.cal.place(x='60', y='80') label2 = tk.Label(self, text='Check out Date') label2.place(x='200', y='40') self.cal.bind("<<DateEntrySelected>>", self.callback) date_time_obj = datetime.datetime.strptime(self.cal.get(), '%Y-%m-%d') print(type(date_time_obj)) # if self.cal.get(): # min_date=self.cal.get() # else: # min_date=tomorrow self.cal1 = DateEntry(self, width=12, year=tomorrow.year, month=tomorrow.month, day=tomorrow.day, mindate=tomorrow, date_pattern='y-mm-dd', background='darkblue', foreground='white', borderwidth=2) self.cal1.place(x='200', y='80') # reg = self.register(self.callback) # # self.cal1.config(validate="key", # validatecommand=(reg, '% P')) button = tk.Button(self, text='Search', command=self.search) button.place(x='150', y='120') def search(self): print(self.cal.get()) print(self.cal1.get()) self.destroy() bpage = booking() def callback(self, input): w = input.widget date = w.get_date() + timedelta(1) self.cal1.config(mindate=date)
class Toplevel1: def __init__(self, top=None): '''This class configures and populates the toplevel window. top is the toplevel containing window.''' _bgcolor = '#40e0d0' # X11 color: 'gray85' _fgcolor = '#000000' # X11 color: 'black' _compcolor = '#40e0d0' # X11 color: 'gray85' _ana1color = '#40e0d0' # X11 color: 'gray85' _ana2color = '#ececec' # Closest X11 color: 'gray92' self.style = ttk.Style() if sys.platform == "win32": self.style.theme_use('winnative') self.style.configure('.', background=_bgcolor) self.style.configure('.', foreground=_fgcolor) self.style.configure('.', font="TkDefaultFont") self.style.map('.', background=[ ('selected', _compcolor), ('active', _ana2color)]) self.db = DataBase() top.geometry("1300x760+20+20") top.minsize(800, 500) top.maxsize(1500, 750) top.resizable(0, 0) top.title("New Toplevel") top.configure(background="#78909C") top.configure(highlightbackground="#d9d9d9") top.configure(highlightcolor="black") self.Gid_10 = tk.Label(top) self.Gid_10.place(relx=0.427, rely=0.021, height=38, width=209) self.Gid_10.configure(activebackground="#f9f9f9") self.Gid_10.configure(activeforeground="black") self.Gid_10.configure(background="#d9d9d9") self.Gid_10.configure(disabledforeground="#a3a3a3") self.Gid_10.configure(font="-family {Segoe UI} -size 20 -weight bold") self.Gid_10.configure(foreground="#000000") self.Gid_10.configure(highlightbackground="#d9d9d9") self.Gid_10.configure(highlightcolor="black") self.Gid_10.configure(text='''ADD GOAT''') self.isBornOrBought = IntVar(None, 0) self.Rbtnborn = tk.Radiobutton(top, command=self.disableVaccination) self.Rbtnborn.place(relx=0.427, rely=0.095, relheight=0.034, relwidth=0.075) self.Rbtnborn.configure(activebackground="#ececec") self.Rbtnborn.configure(activeforeground="#000000") self.Rbtnborn.configure(background="#d9d9d9") self.Rbtnborn.configure(disabledforeground="#a3a3a3") self.Rbtnborn.configure(foreground="#000000") self.Rbtnborn.configure(highlightbackground="#d9d9d9") self.Rbtnborn.configure(highlightcolor="black") self.Rbtnborn.configure(justify='left') self.Rbtnborn.configure(text='''BORN''') self.Rbtnborn.configure(value=0) self.Rbtnborn.configure(variable=self.isBornOrBought) self.Rbtnbought = tk.Radiobutton(top, command=self.disableMotherId) self.Rbtnbought.place(relx=0.513, rely=0.095, relheight=0.034, relwidth=0.075) self.Rbtnbought.configure(activebackground="#ececec") self.Rbtnbought.configure(activeforeground="#000000") self.Rbtnbought.configure(background="#d9d9d9") self.Rbtnbought.configure(disabledforeground="#a3a3a3") self.Rbtnbought.configure(foreground="#000000") self.Rbtnbought.configure(highlightbackground="#d9d9d9") self.Rbtnbought.configure(highlightcolor="black") self.Rbtnbought.configure(justify='left') self.Rbtnbought.configure(text='''BOUGHT''') self.Rbtnbought.configure(value=1) self.Rbtnbought.configure(variable=self.isBornOrBought) self.gdetails = tk.Label(top) self.gdetails.place(x=130,y=100, height=35, width=130) self.gdetails.configure(activebackground="#f9f9f9") self.gdetails.configure(activeforeground="black") self.gdetails.configure(background="#d9d9d9") self.gdetails.configure(disabledforeground="#a3a3a3") self.gdetails.configure(font="-family {Segoe UI} -size 13") self.gdetails.configure(foreground="#000000") self.gdetails.configure(highlightbackground="#d9d9d9") self.gdetails.configure(highlightcolor="black") self.gdetails.configure(text='''GOAT DETAILS''') self.Gid = tk.Label(top) self.Gid.place(x=80,y=155, height=35, width=98) self.Gid.configure(activebackground="#f9f9f9") self.Gid.configure(activeforeground="black") self.Gid.configure(background="#d9d9d9") self.Gid.configure(disabledforeground="#a3a3a3") self.Gid.configure(foreground="#000000") self.Gid.configure(highlightbackground="#d9d9d9") self.Gid.configure(highlightcolor="black") self.Gid.configure(text='''Goat ID''') self.TEntry1 = ttk.Entry(top) self.TEntry1.place(x=250,y=155, height=35, width=140) self.TEntry1.configure(takefocus="") self.breed = tk.Label(top) self.breed.place(x=80,y=200, height=35, width=98) self.breed.configure(activebackground="#f9f9f9") self.breed.configure(activeforeground="black") self.breed.configure(background="#d9d9d9") self.breed.configure(disabledforeground="#a3a3a3") self.breed.configure(foreground="#000000") self.breed.configure(highlightbackground="#d9d9d9") self.breed.configure(highlightcolor="black") self.breed.configure(text='''Breed''') self.TEntry1_22 = ttk.Entry(top) self.TEntry1_22.place(x=250,y=200,height=35, width=140) self.TEntry1_22.configure(takefocus="") self.DOB = tk.Label(top) self.DOB.place(x=80,y=245, height=35, width=98) self.DOB.configure(activebackground="#f9f9f9") self.DOB.configure(activeforeground="black") self.DOB.configure(background="#d9d9d9") self.DOB.configure(disabledforeground="#a3a3a3") self.DOB.configure(foreground="#000000") self.DOB.configure(highlightbackground="#d9d9d9") self.DOB.configure(highlightcolor="black") self.DOB.configure(text='''DOB''') self.goatDob = DateEntry(top, width=12, year=2019, month=6, day=22, background='darkblue', foreground='white', borderwidth=2) self.goatDob.place(x=250,y=245, height=35, width=140) self.mother_id = tk.Label(top) self.mother_id.place(x=80,y=290, height=35, width=98) self.mother_id.configure(activebackground="#f9f9f9") self.mother_id.configure(activeforeground="black") self.mother_id.configure(background="#d9d9d9") self.mother_id.configure(disabledforeground="#a3a3a3") self.mother_id.configure(foreground="#000000") self.mother_id.configure(highlightbackground="#d9d9d9") self.mother_id.configure(highlightcolor="black") self.mother_id.configure(text='''Mother ID''') self.TEntry1_24 = ttk.Entry(top) self.TEntry1_24.place(x=250,y=335,height=35, width=140) self.TEntry1_24.configure(takefocus="") self.weight = tk.Label(top) self.weight.place(x=80,y=335, height=35, width=98) self.weight.configure(activebackground="#f9f9f9") self.weight.configure(activeforeground="black") self.weight.configure(background="#d9d9d9") self.weight.configure(disabledforeground="#a3a3a3") self.weight.configure(foreground="#000000") self.weight.configure(highlightbackground="#d9d9d9") self.weight.configure(highlightcolor="black") self.weight.configure(text='''Weight''') self.TEntry1_25 = ttk.Entry(top) self.TEntry1_25.place(x=250,y=290,height=35, width=140) self.TEntry1_25.configure(takefocus="") self.gender = tk.Label(top) self.gender.place(x=80,y=395, height=40, width=98) self.gender.configure(activebackground="#f9f9f9") self.gender.configure(activeforeground="black") self.gender.configure(background="#d9d9d9") self.gender.configure(disabledforeground="#a3a3a3") self.gender.configure(foreground="#000000") self.gender.configure(highlightbackground="#d9d9d9") self.gender.configure(highlightcolor="black") self.gender.configure(text='''Gender''') self.genderVal = IntVar() self.RbtnMale = tk.Radiobutton(top) self.RbtnMale.place(x=250,y=380,height=30,width=80) self.RbtnMale.configure(activebackground="#ececec") self.RbtnMale.configure(activeforeground="#000000") self.RbtnMale.configure(background="#d9d9d9") self.RbtnMale.configure(disabledforeground="#a3a3a3") self.RbtnMale.configure(foreground="#000000") self.RbtnMale.configure(highlightbackground="#d9d9d9") self.RbtnMale.configure(highlightcolor="black") self.RbtnMale.configure(justify='left') self.RbtnMale.configure(text='''MALE''') self.RbtnMale.configure(value=0) self.RbtnMale.configure(variable=self.genderVal) self.RbtnFemale = tk.Radiobutton(top) self.RbtnFemale.place(x=250,y=420,height=30,width=80) self.RbtnFemale.configure(activebackground="#ececec") self.RbtnFemale.configure(activeforeground="#000000") self.RbtnFemale.configure(background="#d9d9d9") self.RbtnFemale.configure(disabledforeground="#a3a3a3") self.RbtnFemale.configure(foreground="#000000") self.RbtnFemale.configure(highlightbackground="#d9d9d9") self.RbtnFemale.configure(highlightcolor="black") self.RbtnFemale.configure(justify='left') self.RbtnFemale.configure(text='''FEMALE''') self.RbtnFemale.configure(value=1) self.RbtnFemale.configure(variable=self.genderVal) self.health = tk.Label(top) self.health.place(x=890,y=100, height=35, width=150) self.health.configure(activebackground="#f9f9f9") self.health.configure(activeforeground="black") self.health.configure(background="#d9d9d9") self.health.configure(disabledforeground="#a3a3a3") self.health.configure(font="-family {Segoe UI} -size 12") self.health.configure(foreground="#000000") self.health.configure(highlightbackground="#d9d9d9") self.health.configure(highlightcolor="black") self.health.configure(text='''LAST VACCINATED''') self.v1 = tk.Label(top) self.v1.place(x=800,y=155, height=35, width=98) self.v1.configure(activebackground="#f9f9f9") self.v1.configure(activeforeground="black") self.v1.configure(background="#d9d9d9") self.v1.configure(disabledforeground="#a3a3a3") self.v1.configure(foreground="#000000") self.v1.configure(highlightbackground="#d9d9d9") self.v1.configure(highlightcolor="black") self.v1.configure(text='''V1''') self.cal1 = DateEntry(top, width=12, year=2020, month=6, day=22, background='darkblue', foreground='white', borderwidth=2) self.cal1.place(x=1000,y=155, height=35, width=98) self.v2 = tk.Label(top) self.v2.place(x=800,y=200, height=35, width=98) self.v2.configure(activebackground="#f9f9f9") self.v2.configure(activeforeground="black") self.v2.configure(background="#d9d9d9") self.v2.configure(disabledforeground="#a3a3a3") self.v2.configure(foreground="#000000") self.v2.configure(highlightbackground="#d9d9d9") self.v2.configure(highlightcolor="black") self.v2.configure(text='''V2''') self.cal2 = DateEntry(top, width=12, year=2019, month=6, day=22, background='darkblue', foreground='white', borderwidth=2) self.cal2.place(x=1000,y=200, height=35, width=98) self.v3 = tk.Label(top) self.v3.place(x=800,y=245, height=35, width=98) self.v3.configure(activebackground="#f9f9f9") self.v3.configure(activeforeground="black") self.v3.configure(background="#d9d9d9") self.v3.configure(disabledforeground="#a3a3a3") self.v3.configure(foreground="#000000") self.v3.configure(highlightbackground="#d9d9d9") self.v3.configure(highlightcolor="black") self.v3.configure(text='''V3''') self.cal3 = DateEntry(top, width=12, year=2019, month=6, day=22, background='darkblue', foreground='white', borderwidth=2) self.cal3.place(x=1000,y=245, height=35, width=98) self.v4 = tk.Label(top) self.v4.place(x=800,y=290, height=35, width=98) self.v4.configure(activebackground="#f9f9f9") self.v4.configure(activeforeground="black") self.v4.configure(background="#d9d9d9") self.v4.configure(disabledforeground="#a3a3a3") self.v4.configure(foreground="#000000") self.v4.configure(highlightbackground="#d9d9d9") self.v4.configure(highlightcolor="black") self.v4.configure(text='''V4''') self.cal4 = DateEntry(top, width=12, year=2019, month=6, day=22, background='darkblue', foreground='white', borderwidth=2) self.cal4.place(x=1000,y=290, height=35, width=98) self.v5 = tk.Label(top) self.v5.place(x=800,y=335, height=35, width=98) self.v5.configure(activebackground="#f9f9f9") self.v5.configure(activeforeground="black") self.v5.configure(background="#d9d9d9") self.v5.configure(disabledforeground="#a3a3a3") self.v5.configure(foreground="#000000") self.v5.configure(highlightbackground="#d9d9d9") self.v5.configure(highlightcolor="black") self.v5.configure(text='''V5''') self.cal5 = DateEntry(top, width=12, year=2019, month=6, day=22, background='darkblue', foreground='white', borderwidth=2) self.cal5.place(x=1000,y=335, height=35, width=98) self.v6 = tk.Label(top) self.v6.place(x=800,y=380, height=35, width=98) self.v6.configure(activebackground="#f9f9f9") self.v6.configure(activeforeground="black") self.v6.configure(background="#d9d9d9") self.v6.configure(disabledforeground="#a3a3a3") self.v6.configure(foreground="#000000") self.v6.configure(highlightbackground="#d9d9d9") self.v6.configure(highlightcolor="black") self.v6.configure(text='''V6''') self.cal6 = DateEntry(top, width=12, year=2019, month=6, day=22, background='darkblue', foreground='white', borderwidth=2) self.cal6.place(x=1000,y=380, height=35, width=98) self.v7 = tk.Label(top) self.v7.place(x=800,y=425, height=35, width=98) self.v7.configure(activebackground="#f9f9f9") self.v7.configure(activeforeground="black") self.v7.configure(background="#d9d9d9") self.v7.configure(disabledforeground="#a3a3a3") self.v7.configure(foreground="#000000") self.v7.configure(highlightbackground="#d9d9d9") self.v7.configure(highlightcolor="black") self.v7.configure(text='''V7''') self.cal7 = DateEntry(top, width=12, year=2019, month=6, day=22, background='darkblue', foreground='white', borderwidth=2) self.cal7.place(x=1000,y=425, height=35, width=98) self.v8 = tk.Label(top) self.v8.place(x=800,y=470, height=35, width=98) self.v8.configure(activebackground="#f9f9f9") self.v8.configure(activeforeground="black") self.v8.configure(background="#d9d9d9") self.v8.configure(disabledforeground="#a3a3a3") self.v8.configure(foreground="#000000") self.v8.configure(highlightbackground="#d9d9d9") self.v8.configure(highlightcolor="black") self.v8.configure(text='''V8''') self.cal8 = DateEntry(top, width=12, year=2019, month=6, day=22, background='darkblue', foreground='white', borderwidth=2) self.cal8.place(x=1000,y=470, height=35, width=98) self.Submit = tk.Button(top, command=self.acceptValues) self.Submit.place(relx=0.550, rely=0.842, height=30, width=59) self.Submit.configure(activebackground="#ececec") self.Submit.configure(activeforeground="#000000") self.Submit.configure(background="#d9d9d9") self.Submit.configure(disabledforeground="#a3a3a3") self.Submit.configure(foreground="#000000") self.Submit.configure(highlightbackground="#d9d9d9") self.Submit.configure(highlightcolor="black") self.Submit.configure(pady="0") self.Submit.configure(text='''SUBMIT''') self.Cancel = tk.Button(top, command=lambda: addGoat_support.destroy_window()) self.Cancel.place(relx=0.430, rely=0.842, height=30, width=59) self.Cancel.configure(activebackground="#ececec") self.Cancel.configure(activeforeground="#000000") self.Cancel.configure(background="#d9d9d9") self.Cancel.configure(disabledforeground="#a3a3a3") self.Cancel.configure(foreground="#000000") self.Cancel.configure(highlightbackground="#d9d9d9") self.Cancel.configure(highlightcolor="black") self.Cancel.configure(pady="0") self.Cancel.configure(text='''CANCEL''') self.goatDob.set_date(datetime.date(datetime.now())) self.cal1.set_date(datetime.date(datetime.now())) self.cal2.set_date(datetime.date(datetime.now())) self.cal3.set_date(datetime.date(datetime.now())) self.cal4.set_date(datetime.date(datetime.now())) self.cal5.set_date(datetime.date(datetime.now())) self.cal6.set_date(datetime.date(datetime.now())) self.cal7.set_date(datetime.date(datetime.now())) self.cal8.set_date(datetime.date(datetime.now())) self.disableVaccination() def acceptValues(self): try: goat_id = int(self.TEntry1.get()) g_breed = self.TEntry1_22.get() g_dob = self.goatDob.get_date() g_weight = int(self.TEntry1_24.get()) g_motherId = self.TEntry1_25.get() g_gender = 'm' if int(self.genderVal.get()) == 0 else 'f' g_isBornOrBought = self.isBornOrBought.get() v1Date = self.cal1.get_date() v2Date = self.cal2.get_date() v3Date = self.cal3.get_date() v4Date = self.cal4.get_date() v5Date = self.cal5.get_date() v6Date = self.cal6.get_date() v7Date = self.cal7.get_date() v8Date = self.cal8.get_date() # born = 0 print(g_isBornOrBought) addGoatData = {'goat_id': goat_id, 'breed': g_breed, 'date_of_birth': g_dob, 'weight': g_weight, 'gender': g_gender, 'pregnant': 'No', 'v1': str(v1Date), 'v2': str(v2Date), 'v3': str(v3Date), 'v4': str(v4Date), 'v5': str(v5Date), 'v6': str(v6Date), 'v7': str(v7Date), 'v8': str(v8Date), 'curdate': datetime.date(datetime.now())} if g_gender == 'f' and g_isBornOrBought == 0: self.db.insertGoatRecord(addGoatData, mother_id=g_motherId) elif g_gender == 'f' and g_isBornOrBought == 1: self.db.insertGoatRecord(addGoatData, mother_id='null') elif g_gender == 'm' and g_isBornOrBought == 0: self.db.insertGoatRecord(addGoatData, mother_id=g_motherId) elif g_gender == 'm' and g_isBornOrBought == 1: self.db.insertGoatRecord(addGoatData, mother_id='null') except: self.errorMsg() else: self.showSuccess() print({'goat_id': goat_id, 'breed': g_breed, 'date_of_birth': g_dob, 'weight': g_weight, 'gender': g_gender, 'pregnant': 'No', 'v1': str(v1Date), 'v2': str(v2Date), 'v3': str(v3Date), 'v4': str(v4Date), 'v5': str(v5Date), 'v6': str(v6Date), 'v7': str(v6Date), 'v8': str(v6Date)}) addGoat_support.destroy_window() def disableVaccination(self): self.TEntry1_25.config(state=NORMAL) self.cal1.config(state=DISABLED) self.cal2.config(state=DISABLED) self.cal3.config(state=DISABLED) self.cal4.config(state=DISABLED) self.cal5.config(state=DISABLED) self.cal6.config(state=DISABLED) self.cal7.config(state=DISABLED) self.cal8.config(state=DISABLED) def disableMotherId(self): self.TEntry1_25.config(state=DISABLED) self.cal1.config(state=NORMAL) self.cal2.config(state=NORMAL) self.cal3.config(state=NORMAL) self.cal4.config(state=NORMAL) self.cal5.config(state=NORMAL) self.cal6.config(state=NORMAL) self.cal7.config(state=NORMAL) self.cal8.config(state=NORMAL) def errorMsg(self): tk.messagebox.showerror("Input Error","Incorrect Data!") def showSuccess(self): tk.messagebox.showinfo("Success","Successfully Inserted")
class teacherReg: def __init__(self): global tReg tReg = Toplevel() tReg.geometry("500x550") tReg.resizable(width=FALSE, height=FALSE) tReg.title("Teacher Registration") self.gui_1() tReg.mainloop() def sqlRegisterTchr(self): pwd3 = self.pwd1.get() pwd4 = self.pwd2.get() if pwd3 == pwd4: sal = self.salLbl1.get() name = self.name1.get() id = self.id1.get() dept = self.dept1.get() dob = self.cal.get() cno = self.cno1.get() addr = self.addr1.get() email = self.email1.get() if not (sal and name and id and dept and dob and cno and addr and email): messagebox.showwarning("Fields Empty", "Please enter all the fields.") else: ###SQL COMMAND HERE mySql_insert_query = 'INSERT INTO teachers VALUES ("{}","{}","{}","{}","{}","{}","{}","{}","{}","{}")' \ .format(sal, name, id, dept, "None", dob, cno, addr, email, pwd4) cursor = connection.cursor() cursor.execute(mySql_insert_query) connection.commit() tReg.destroy() messagebox.showinfo("Registration Complete", "Thank you for your registration!") else: messagebox.showinfo("Password Error", "Passwords do not match!") def gui_1(self): # registration header text self.regHeader = Label(tReg, text="Teacher/Staff Registration", bg=teacherColour, fg='white', font=("Sans serif", 18, "bold"), pady=8) # text add self.regHeader.pack(fill=X) # pack is a must width1 = 240 x1, x2 = 45, 165 y1 = 160 gap = 35 fsizeLbl = 11 # Prompt self.nameLbl = Label(tReg, text="Please enter your basic details. ", font=("Sans Serif", 18)) self.nameLbl.pack() self.nameLbl.place(x=85, y=65) # Salutanion Lbl self.nameLbl = Label(tReg, text="Salutation: ", font=("Sans Serif", 10)) self.nameLbl.pack() self.nameLbl.place(x=x1, y=132) # Name Lbl self.nameLbl = Label(tReg, text="Name: ", font=("Sans Serif", fsizeLbl)) self.nameLbl.pack() self.nameLbl.place(x=x1, y=y1) # Teacher ID self.tIdLbl = Label(tReg, text="Teacher ID: ", font=("Sans Serif", fsizeLbl)) self.tIdLbl.pack() self.tIdLbl.place(x=x1, y=y1 + gap) # Department set as list self.deptLbl = Label(tReg, text="Department: ", font=("Sans Serif", fsizeLbl)) self.deptLbl.pack() self.deptLbl.place(x=x1, y=y1 + 2 * gap) # DOB self.dobLbl = Label(tReg, text="Date of Birth: ", font=("Sans Serif", fsizeLbl)) self.dobLbl.pack() self.dobLbl.place(x=x1, y=y1 + 3 * gap) # Contact No self.cnoLbl = Label(tReg, text="Contact No: ", font=("Sans Serif", fsizeLbl)) self.cnoLbl.pack() self.cnoLbl.place(x=x1, y=y1 + 4 * gap) # Address self.addrLbl = Label(tReg, text="Address: ", font=("Sans Serif", fsizeLbl)) self.addrLbl.pack() self.addrLbl.place(x=x1, y=y1 + 5 * gap) # email Lbl self.emailLbl = Label(tReg, text="Email: ", font=("Sans Serif", fsizeLbl)) self.emailLbl.pack() self.emailLbl.place(x=x1, y=y1 + 6 * gap) # Pwd1 Lbl self.pwdLbl1 = Label(tReg, text="Password: "******"Sans Serif", fsizeLbl)) self.pwdLbl1.pack() self.pwdLbl1.place(x=x1, y=y1 + 7 * gap) # Pwd2 Lbl self.pwdLbl2 = Label(tReg, text="Re-enter Password: "******"Sans Serif", 9)) self.pwdLbl2.pack() self.pwdLbl2.place(x=x1, y=y1 + 8 * gap) # salutaion list self.salLbl1 = StringVar() self.salLbl1.set("Mrs.") self.sal1 = ttk.Combobox(tReg, textvariable=self.salLbl1) self.sal1['values'] = ('Mrs.', 'Mr.', 'Ms.', 'Dr.') self.sal1.pack() self.sal1.place(x=x2, y=130, width=50) # Name text field self.name1 = Entry(tReg) self.name1.pack() self.name1.place(x=x2, y=y1, width=width1) # Teacher ID text field self.id1 = Entry(tReg) self.id1.pack() self.id1.place(x=x2, y=y1 + gap, width=width1) # Dept list field self.deptLbl1 = StringVar() self.deptLbl1.set("CSE") self.dept1 = ttk.Combobox(tReg, textvariable=self.deptLbl1) self.dept1['values'] = ('CSE', 'ISE', 'ECE', 'ME', 'EE', 'Library') self.dept1.pack() self.dept1.place(x=x2, y=y1 + 2 * gap, width=70) # DOB field d = datetime.date.today() self.cal = DateEntry(tReg, width=12, year=2000, month=d.month, day=d.day, background=teacherColour, foreground='white', borderwidth=2) self.cal.pack() self.cal.config(date_pattern='dd/mm/yyyy') self.cal.place(x=x2, y=y1 + 3 * gap) # Contact no text field self.cno1 = Entry(tReg) self.cno1.pack() self.cno1.place(x=x2, y=y1 + 4 * gap, width=width1) # Addr text field self.addr1 = Entry(tReg) self.addr1.pack() self.addr1.place(x=x2, y=y1 + 5 * gap, width=width1) # Email text field self.email1 = Entry(tReg) self.email1.pack() self.email1.place(x=x2, y=y1 + 6 * gap, width=width1) def showHideState(): if var1.get(): self.pwd1.config(show="") self.pwd2.config(show="") else: self.pwd1.config(show="*") self.pwd2.config(show="*") # Password text field self.pwd1 = Entry(tReg, show="*") self.pwd1.pack() self.pwd1.place(x=x2, y=y1 + 7 * gap, width=width1) # Password text field self.pwd2 = Entry(tReg, show="*") self.pwd2.pack() self.pwd2.place(x=x2, y=y1 + 8 * gap, width=width1) # showPassword Box var1 = IntVar() chk = Checkbutton(tReg, text="Show", variable=var1, command=showHideState) chk.pack() chk.place(x=x2 + width1 + 10, y=y1 + 7 * gap) # teacher register button teacherRegisterBtn = PhotoImage(file='button_confRegTeacher.png') self.teacherRegisterButton = Button(tReg, image=teacherRegisterBtn, borderwidth=0, command=self.sqlRegisterTchr) self.teacherRegisterButton.pack() self.teacherRegisterButton.place(x=x2, y=470) tReg.mainloop()
def ifazSesion(self, idPacienteSel, *kargs): #Comprobamos si se seleccionó alguna sesion if (kargs and kargs[0] == ''): messagebox.showinfo("Error", "No se seleccionó ningúna sesion") return fechaActual = datetime.datetime.now() horaActual = fechaActual.time().strftime("%H:%M:%S") fechaActualMasUnaHora = fechaActual + datetime.timedelta(0, 3600) horaMasUna = fechaActualMasUnaHora.strftime("%H:%M:%S") self.habilitado = 0 #Ocultamos la ventanaPrincipal mientras esta el dialogo abierto self.dlgIfzSesiones.withdraw() #Creamos una ventana self.dlgIfazSesion = Toplevel() #Hacemos que el protocolo de cierre de dialogo llame al metodo CerrarDialogo self.dlgIfazSesion.protocol( "WM_DELETE_WINDOW", lambda: self.cerrarDialogo( self.dlgIfazSesion, self.dlgIfzSesiones)) self.dlgIfazSesion.resizable(0, 0) self.dlgIfazSesion.iconbitmap('APPsico.ico') self.FrmIfazSesion = ttk.LabelFrame(self.dlgIfazSesion, text="Nueva Sesion") self.FrmIfazSesion.pack(expand=True, fill=BOTH) ttk.Label(self.FrmIfazSesion, text='Inicio: ').grid(row=0, column=0, pady=5, padx=1, sticky="e") try: fechaInicio = DateEntry( self.FrmIfazSesion, width=12, background='green', foreground='white', borderwidth=2, year=int(fechaActual.date().strftime("%Y")), month=int(fechaActual.date().strftime("%m")), day=int(fechaActual.date().strftime("%d"))) fechaInicio.grid(row=0, column=1, pady=5, padx=1) except ValueError: print("Error UTF-8") spinboxHoraInicio = ttk.Spinbox(self.FrmIfazSesion, from_=00, to=23, width=5) spinboxHoraInicio.grid(row=0, column=2, pady=5, padx=1, sticky="w") spinboxHoraInicio.set(horaActual[0:2]) ttk.Label(self.FrmIfazSesion, text=":").grid(row=0, column=2, pady=5, padx=1) spinboxMinInicio = ttk.Spinbox(self.FrmIfazSesion, from_=00, to=59, width=5) spinboxMinInicio.grid(row=0, column=2, pady=5, padx=1, sticky="e") spinboxMinInicio.set(horaActual[3:5]) ttk.Label(self.FrmIfazSesion, text='Fin: ').grid(row=1, column=0, pady=5, padx=1, sticky="e") try: fechaFin = DateEntry( self.FrmIfazSesion, width=12, background='green', foreground='white', borderwidth=2, year=int(fechaActualMasUnaHora.date().strftime("%Y")), month=int(fechaActualMasUnaHora.date().strftime("%m")), day=int(fechaActualMasUnaHora.date().strftime("%d"))) fechaFin.grid(row=1, column=1, pady=5, padx=1) except ValueError: print("Error UTF-8") spinboxHoraFin = ttk.Spinbox(self.FrmIfazSesion, from_=00, to=23, width=5) spinboxHoraFin.grid(row=1, column=2, pady=5, padx=1, sticky="w") spinboxHoraFin.set(horaMasUna[0:2]) ttk.Label(self.FrmIfazSesion, text=":").grid(row=1, column=2, pady=5, padx=1) spinboxMinFin = ttk.Spinbox(self.FrmIfazSesion, from_=00, to=59, width=5) spinboxMinFin.grid(row=1, column=2, pady=5, padx=1, sticky="e") spinboxMinFin.set(horaMasUna[3:5]) lblComentarios = Label(self.FrmIfazSesion, text="Notas: ") lblComentarios.grid(row=2, column=0, pady=5, padx=1, sticky="e") txtComentarios = st.ScrolledText(self.FrmIfazSesion, height=15, width=60) txtComentarios.bind('<Button-3>', clickDerecho, add='') txtComentarios.grid(row=2, column=1, columnspan=4, sticky="nsew", pady=5, padx=1) btnGuardar = ttk.Button( self.FrmIfazSesion, text="Guardar", command=lambda: self.nuevaSesion( fechaInicio.get_date(), spinboxHoraInicio.get(), spinboxMinInicio.get(), fechaFin.get_date(), spinboxHoraFin.get(), spinboxMinFin.get(), txtComentarios.get("1.0", 'end-1c'), idPacienteSel)) btnGuardar.grid(row=5, column=0, sticky="e") btnSalir = ttk.Button(self.FrmIfazSesion, text='Cerrar', command=lambda: self.cerrarDialogo( self.dlgIfazSesion, self.dlgIfzSesiones)) btnSalir.grid(row=5, column=1, sticky="w") def habilitarModificacion(): if (self.habilitado == 0): self.FrmIfazSesion.config(text="Modificar Sesion") spinboxHoraFin.config(state='normal') spinboxMinFin.config(state='normal') spinboxHoraInicio.config(state='normal') spinboxMinInicio.config(state='normal') fechaInicio.config(state='normal') fechaFin.config(state='normal') txtComentarios.config(state='normal') btnGuardar.config(state='normal') btnEliminarSesion.config(state='enabled') btnModificarSesion.config(state='enabled') btnModificarSesion.config(text="Visualizar") self.habilitado = 1 else: self.FrmIfazSesion.config(text="Visualizar Sesion") spinboxHoraFin.config(state='disabled') spinboxMinFin.config(state='disabled') spinboxHoraInicio.config(state='disabled') spinboxMinInicio.config(state='disabled') fechaInicio.config(state='disabled') fechaFin.config(state='disabled') txtComentarios.config(state='disabled') btnGuardar.config(state='disabled') btnEliminarSesion.config(state='disabled') btnModificarSesion.config(text="Modificar") self.habilitado = 0 if (kargs): idSesionSel = kargs[0] sesion_sel = query("SELECT * FROM sesiones WHERE id_sesion='" + str(idSesionSel) + "';").fetchall()[0] fInicio = date(int(sesion_sel[2][0:4]), int(sesion_sel[2][5:7]), int(sesion_sel[2][8:10])) fFin = date(int(sesion_sel[3][0:4]), int(sesion_sel[3][5:7]), int(sesion_sel[3][8:10])) spinboxHoraFin.set(int(sesion_sel[3][11:13])) spinboxMinFin.set(int(sesion_sel[3][14:16])) spinboxHoraInicio.set(int(sesion_sel[2][11:13])) spinboxMinInicio.set(int(sesion_sel[2][14:16])) fechaInicio.set_date(fInicio) fechaFin.set_date(fFin) txtComentarios.insert("insert", sesion_sel[1]) #Cambio el titulo del frame self.FrmIfazSesion.config(text="Visualizar Sesion") spinboxHoraFin.config(state='disabled') spinboxMinFin.config(state='disabled') spinboxHoraInicio.config(state='disabled') spinboxMinInicio.config(state='disabled') fechaInicio.config(state='disabled') fechaFin.config(state='disabled') txtComentarios.config(state='disabled') btnGuardar.config(state='disabled') #Boton Eliminar Paciente btnEliminarSesion = ttk.Button(self.FrmIfazSesion, text='Eliminar Sesion', command=lambda: self.eliminarSesion( idSesionSel, idPacienteSel)) btnEliminarSesion.grid(row=5, column=3, sticky="ew") btnEliminarSesion.config(state='disabled') #Boton habilitar modificacion btnModificarSesion = ttk.Button(self.FrmIfazSesion, text='Modificar', command=habilitarModificacion) btnModificarSesion.grid(row=5, column=2, sticky="ew") #para modificar el boton guardar btnGuardar.config(command=lambda: self.modificarSesion( fechaInicio.get_date(), spinboxHoraInicio.get(), spinboxMinInicio.get(), fechaFin.get_date(), spinboxHoraFin.get(), spinboxMinFin.get(), txtComentarios.get("1.0", 'end-1c'), idSesionSel, idPacienteSel )) btnGuardar.config(state='disabled')
class checkout: def __init__(self, frame): self.mywindow = Toplevel(frame) self.mywindow.wm_title("Check Out") self.mywindow.geometry("800x300") t1 = Label(self.mywindow, text="Customer ID ") t2 = Label(self.mywindow, text="Customer Name ") t3 = Label(self.mywindow, text="Date of Check In ") t4 = Label(self.mywindow, text="Date of Check Out ") t5 = Label(self.mywindow, text="Resturant Balance ") t6 = Label(self.mywindow, text="Room Rent ") t7 = Label(self.mywindow, text="Mode of Payemt ") t8 = Label(self.mywindow, text="Advance Received ") t9 = Label(self.mywindow, text="Total Payable Amount ") self.e1 = Entry(self.mywindow) #Customer id self.e2 = Entry(self.mywindow) #Customer Name self.e3 = DateEntry(self.mywindow) #d Check in self.e4 = DateEntry(self.mywindow) #d check out self.e5 = Entry(self.mywindow) #resturant bill self.e6 = Entry(self.mywindow) # room bill self.e7 = Entry(self.mywindow) # Adv payment self.e8 = Entry(self.mywindow) # payable amt self.mop = StringVar() self.c1 = ttk.Combobox(self.mywindow, values=("Cash", "Cheque", "Debit Card", "Paytm"), textvariable=self.mop, state="readonly") self.c1.set(" Mode Of Payment") t1.place(x=50, y=50) t2.place(x=350, y=50) t3.place(x=50, y=80) t4.place(x=350, y=80) t5.place(x=50, y=110) t6.place(x=350, y=110) t7.place(x=50, y=140) t8.place(x=350, y=140) self.e1.place(x=180, y=50) self.e2.place(x=500, y=50) self.e3.place(x=180, y=80) self.e4.place(x=500, y=80) self.e5.place(x=180, y=110) self.e6.place(x=500, y=110) self.c1.place(x=180, y=140) self.e7.place(x=500, y=140) self.frame() self.e1.bind("<FocusIn>", lambda e: self.foucsin()) self.e1.bind("<FocusOut>", lambda e: self.getcustomerdetails()) self.c1.bind("<<ComboboxSelected>>", lambda e: self.get_items()) def get_items(self): # print(self.mop.get()) self.totalpayableamt = (float(self.e5.get()) + float(self.e6.get())) - float(self.e7.get()) if self.mop.get() in ("Debit Card", "Paytm"): disscount = self.totalpayableamt * 0.15 self.totalpayableamt -= disscount # print(str(totalpayableamt)) if self.mop.get() not in ("Debit Card", "Paytm"): print(str(self.totalpayableamt)) self.ttlamtframe() def getcustomerdetails(self): try: mydb = pymysql.connect(host='localhost', user='******', password='', db='hotelmanagementdb') with mydb.cursor() as myconn: myroomhistory = [] myconn.execute( "select room_type,customer_name,check_in,check_out,advance_payment,room_no,price_per_day from room_history where customer_id=%s", (self.e1.get())) mydb.commit() myroomhistory = myconn.fetchone() # print(type(myroomhistory)) # print(myroomhistory) self.roomtype = myroomhistory[0] self.e2.insert(0, myroomhistory[1]) self.e3.set_date(myroomhistory[2]) self.e4.set_date(myroomhistory[3]) self.e7.insert(0, myroomhistory[4]) self.myroomno = myroomhistory[5] self.myroomprice = myroomhistory[6] # print("Room rent: "+str(int(self.myroomprice))) self.calcroomrent() del myroomhistory myconn.execute( "select payable_amt from resturant_acc where customer_id=%s", (self.e1.get())) mydb.commit() myroomhistory = myconn.fetchone() print(type(myroomhistory)) print(myroomhistory) if myroomhistory is None: self.e5.insert(0, 0) else: self.e5.insert(0, myroomhistory[0]) self.e2.config(state="readonly") self.e3.config(state="readonly") self.e5.config(state="readonly") self.e7.config(state="readonly") except Exception as e: messagebox.showerror("DataBase Error ", "Error Occured Due to : " + str(e)) def update_room_status(self): try: mydb = pymysql.connect(host='localhost', user='******', password='', db='hotelmanagementdb') with mydb.cursor() as myconn: myconn.execute( "update room set status=%s where room_no=%s and room_type=%s", ("Available", self.myroomno, self.roomtype)) mydb.commit() except Exception as e: messagebox.showerror("DataBase Error ", "Error Occured Due to : " + str(e)) def update_customer_status(self): try: mydb = pymysql.connect(host='localhost', user='******', password='', db='hotelmanagementdb') with mydb.cursor() as mycon: mycon.execute( "update customer set status=%s where customer_id=%s", ("out", self.e1.get())) mydb.commit() except Exception as e: messagebox.showerror("Database Error", "Error Occured Due to " + str(e)) def calcroomrent(self): roomrent = 0 dayz = self.e4.get_date() - self.e3.get_date() stayday = str(dayz) index = stayday.find("day") # print(type(stayday)) # print("Stay days : "+stayday) # print("Days : "+stayday[0:index]) # print(self.roomtype) # print(self.myroomprice) # roomrent=int(stayday[0:index-1])*(int(self.myroomprice)) print("Room rent : " + str(int(self.myroomprice))) self.e6.insert(0, str((int(self.myroomprice)))) if self.roomtype == "Double": roomrent = int(stayday[0:index - 1]) * self.myroomprice self.e6.insert(0, str(roomrent)) # if self.roomtype == "Triple": # roomrent = int(stayday[0:index - 1]) * 750 # self.e6.insert(0, str(roomrent)) # if self.roomtype == "Quad": # roomrent = int(stayday[0:index - 1]) * 800 # self.e6.insert(0, str(roomrent)) self.e6.config(state="readonly") def frame(self): note = Frame(self.mywindow, border=2, relief=RAISED) t1 = Label( note, text= "get 15% discount on Every Transaction with Debit Card / Paytm", font=(32)) t1.pack() note.place(x=180, y=250) def ttlamtframe(self): self.note = Frame(self.mywindow, border=5, relief=RAISED) t1 = Label(self.note, text="Total Payable Amount is : ₹ " + str(self.totalpayableamt), font=(28)) t1.pack() self.note.place(x=250, y=180) self.note.bind("<Enter>", lambda e: self.enter(self.note)) self.note.bind("<Leave>", lambda e: self.leave(self.note)) t1.bind("<Button-1>", lambda e: self.billpaid()) def billpaid(self): try: billingdate = ("{}/{}/{}".format(datetime.datetime.now().year, datetime.datetime.now().month, datetime.datetime.now().day)) mydb = pymysql.connect(host='localhost', user='******', password='', db='hotelmanagementdb') with mydb.cursor() as myconn: myconn.execute( "insert into billpaid (customer_id,customer_name,date_of_payment,amt_pay) values (%s,%s,%s,%s)", (self.e1.get(), self.e2.get(), billingdate, str(self.totalpayableamt))) mydb.commit() self.clear_rec() messagebox.showinfo("Bill Payment", "Thank You \n Visit Again ", parent=self.mywindow) self.update_room_status() self.update_customer_status() except Exception as e: messagebox.showinfo("Database Error ", "Occured due to " + str(e), parent=self.mywindow) self.clear() def enter(event, obj): obj.config(bg="Blue") def leave(event, obj): obj.config(bg="red") def foucsin(self): print("in") self.e2.config(state="normal") self.e3.config(state="normal") self.e4.config(state="normal") self.e5.config(state="normal") self.e6.config(state="normal") self.e7.config(state="normal") self.e2.delete(0, END) self.e3.delete(0, END) self.e4.delete(0, END) self.e5.delete(0, END) self.e6.delete(0, END) self.e7.delete(0, END) self.c1.set("Mode Of Payment") def clear_rec(self): try: mydb = pymysql.connect(host='localhost', user='******', password='', db='hotelmanagementdb') with mydb.cursor() as myconn: myconn.execute("delete from room_history where customer_id=%s", (self.e1.get())) myconn.execute( "delete from resturant_acc where customer_id=%s", (self.e1.get())) mydb.commit() except Exception as e: messagebox.showerror("DataBase Error", "Error occured due to : " + str(e)) def clear(self): self.e2.config(state="normal") self.e3.config(state="normal") self.e4.config(state="normal") self.e5.config(state="normal") self.e6.config(state="normal") self.e7.config(state="normal") self.e1.delete(0, END) self.e2.delete(0, END) self.e3.delete(0, END) self.e4.delete(0, END) self.e5.delete(0, END) self.e6.delete(0, END) self.e7.delete(0, END) self.c1.set("Mode Of Payment")
class main: def __init__(self): self.tk = Toplevel() self.frame = Frame(self.tk, height=700, width=700) self.frame.place(x=0, y=0) height = self.tk.winfo_screenheight() width = self.tk.winfo_screenwidth() y = (height - 700) // 2 x = (width - 700) // 2 self.tk.geometry('700x700+' + str(x) + '+' + str(y)) self.tk.resizable(height=False, width=False) self.can = Canvas(self.frame, height="700", width="700") self.can.pack() self.img = PhotoImage(file="./images/img2.gif") self.can.create_image(0, 0, image=self.img, anchor=NW) self.can.create_text(360, 100, text="Add appointment ", fill="#FF9933", font=('Cooper Black', 35)) self.can.create_text(175, 220, text="Patient Name", fill="#99ccff", font=('Cooper Black', 25)) self.e1 = Entry(self.frame, font=('Cooper Black', 18), borderwidth="2") self.e1.place(x=310, y=210) self.can.create_text(175, 280, text="Timing", fill="#99ccff", font=('Cooper Black', 25)) self.e2 = Entry(self.frame, font=('Cooper Black', 18), borderwidth="2") self.e2.place(x=310, y=260) self.can.create_text(175, 330, text="Date", fill="#99ccff", font=('Cooper Black', 25)) '''self.e3=Entry(self.frame,font=('Cooper Black',18),borderwidth="2") self.e3.place(x=310,y=310)''' self.dob = DateEntry(self.can, font=('cooper balck', 12), bg='darkblue', fg='white', borderwidth=2) self.dob.place(x=310, y=310) self.dob.config(width=30) self.can.create_text(175, 380, text="Description", fill="#99ccff", font=('Cooper Black', 25)) self.e4 = Entry(self.frame, font=('Cooper Black', 18), borderwidth="2") self.e4.place(x=310, y=360) self.btn = Button(self.frame, text="Submit", fg="#FF9933", bg="black", font=('Cooper Black', 22), command=self.add) self.btn.place(x=310, y=450) self.tk.mainloop() def add(self): data = ( self.e1.get(), self.e2.get(), self.dob.get(), self.e4.get(), ) if (self.e1.get() != "" and self.e1.get() != 0 and self.e2.get() != 0 and self.dob.get() != 0 and self.e4.get() != 0): y = database_queries.database() y.add_appoint(data) else: print("Please enter all fields")