Esempio n. 1
0
    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')
Esempio n. 2
0
    def test_dateentry_functions(self):
        widget = DateEntry(self.window,
                           width=12,
                           background='darkblue',
                           foreground='white',
                           borderwidth=2)
        widget.pack()
        self.window.update()

        widget.set_date(format_date(date(2018, 12, 31), 'short'))
        self.assertEqual(widget.get_date(), date(2018, 12, 31))
        with self.assertRaises(ValueError):
            widget.set_date("ab")
        widget.set_date(date(2015, 12, 31))
        self.assertEqual(widget.get_date(), date(2015, 12, 31))
        self.assertEqual(widget.get(), format_date(date(2015, 12, 31),
                                                   'short'))

        widget.delete(0, "end")
        widget.insert(0, "abc")
        self.window.focus_force()
        self.assertEqual(widget.get_date(), date(2015, 12, 31))

        widget._on_motion(TestEvent(x=10, y=20))
        widget._on_b1_press(TestEvent(x=10, y=20))
        widget._on_b1_press(TestEvent(x=widget.winfo_width() - 2, y=2))
        widget._on_focus_out_cal(TestEvent(x=10, y=20))

        widget.state(("disabled", ))
        self.window.update()
        self.assertIn("disabled", widget.state())

        widget.drop_down()
        self.window.update()
        widget._select()
        self.window.update()
        widget.drop_down()
        self.window.update()
        widget.drop_down()
        self.window.update()

        widget.configure(state='readonly')
        self.window.update()
        widget._select()
        self.assertIn('readonly', widget.state())
Esempio n. 3
0
    def draw_tasks(self, length, pos_x, pos_y, span_x, span_y):
        """
        draws tasks in this format Task:
            goal(string)  |  checkbox(bool)  |  target date(date)
        :parameter: length: (integer) tells how any tasks to draw

        """
        self.tasks = []
        self.label_frame_tasks = tk.LabelFrame(text="Tasks")
        self.label_frame_tasks.grid(column=pos_x,
                                    row=pos_y,
                                    columnspan=span_x,
                                    rowspan=span_y,
                                    padx=10,
                                    pady=10)
        self.task_label = tk.Label(self.label_frame_tasks, text="Tasks")
        self.task_label.grid(column=0, row=0)
        self.done_label = tk.Label(self.label_frame_tasks, text="Done")
        self.done_label.grid(column=1, row=0)
        self.task_date_label = tk.Label(self.label_frame_tasks, text="Date")
        self.task_date_label.grid(column=2, row=0)
        self.task_date_must_label = tk.Label(self.label_frame_tasks,
                                             text="Must Date")
        self.task_date_must_label.grid(column=3, row=0)
        for i in range(0, length):
            entry = tk.Entry(self.label_frame_tasks, width="75")
            entry.grid(column=0, row=i + 1)

            check = tk.BooleanVar()
            check_button = tk.Checkbutton(self.label_frame_tasks, var=check)
            check_button.grid(column=1, row=i + 1)

            date = DateEntry(self.label_frame_tasks, width="25")
            date.grid(column=2, row=i + 1)
            date.configure(state="readonly")
            date_must = DateEntry(self.label_frame_tasks, width="25")
            date_must.grid(column=3, row=i + 1)
            date_must.configure(state="readonly")
            self.tasks.append([entry, check_button, date, check, date_must])
class view_data_window:
    def print_census(self):
        self.tempdate = self.Date_Entry.get()
        self.tempvalue = self.WTable_Name_Drop2.get()
        databaseobj = Database("dental.db")
        if (self.tempvalue == "All"):
            self.absdate = databaseobj.get_word_total(self.tempdate)
            print(self.absdate)
            databaseobj.createreport(self.tempdate, self.absdate)
        if (self.tempvalue == "Department"):
            databaseobj.createdept(self.tempdate)
        if (self.tempvalue == "Dental Camp"):
            databaseobj.createcamp(self.tempdate)
        if (self.tempvalue == "Turn Over"):
            databaseobj.createturn(self.tempdate)
        if (self.tempvalue == "Satellite"):
            databaseobj.createsat(self.tempdate)

    def print_word(self):
        databaseobj = Database("dental.db")
        self.date = self.WDate_Entry.get()
        databaseobj.createword(self.date)

    def print_excel(self):
        databaseobj = Database("dental.db")
        self.fromdate = self.EFrom_Date_Entry.get()
        self.todate = self.ETo_Date_Entry.get()
        self.trvalue = self.EPatient_Type_Drop.get()
        if (self.ETable_Name_Drop.get() == "Department"
                and self.EPatient_Type_Drop.get() == "All"):
            databaseobj.createexcel("dept", self.fromdate, self.todate)
        if (self.ETable_Name_Drop.get() == "Department"
                and self.EPatient_Type_Drop.get() == "Screened"):
            databaseobj.createexcel("dept", self.fromdate, self.todate, TR=1)
        if (self.ETable_Name_Drop.get() == "Department"
                and self.EPatient_Type_Drop.get() == "Referred"):
            databaseobj.createexcel("dept", self.fromdate, self.todate, TR=2)
        if (self.ETable_Name_Drop.get() == "Department"
                and self.EPatient_Type_Drop.get() == "Treated"):
            databaseobj.createexcel("dept", self.fromdate, self.todate, TR=3)
        if (self.ETable_Name_Drop.get() == "Dental Camp"
                and self.EPatient_Type_Drop.get() == "All"):
            databaseobj.createexcel("screen", self.fromdate, self.todate)
        if (self.ETable_Name_Drop.get() == "Dental Camp"
                and self.EPatient_Type_Drop.get() == "Screened"):
            databaseobj.createexcel("screen", self.fromdate, self.todate, TR=1)
        if (self.ETable_Name_Drop.get() == "Dental Camp"
                and self.EPatient_Type_Drop.get() == "Referred"):
            databaseobj.createexcel("screen", self.fromdate, self.todate, TR=2)
        if (self.ETable_Name_Drop.get() == "Dental Camp"
                and self.EPatient_Type_Drop.get() == "Treated"):
            databaseobj.createexcel("screen", self.fromdate, self.todate, TR=3)
        if (self.ETable_Name_Drop.get() == "Turnover"
                and self.EPatient_Type_Drop.get() == "All"):
            databaseobj.createexcel("turnover", self.fromdate, self.todate)
        if (self.ETable_Name_Drop.get() == "Turnover"
                and self.EPatient_Type_Drop.get() == "Screened"):
            databaseobj.createexcel("turnover",
                                    self.fromdate,
                                    self.todate,
                                    TR=1)
        if (self.ETable_Name_Drop.get() == "Turnover"
                and self.EPatient_Type_Drop.get() == "Referred"):
            databaseobj.createexcel("turnover",
                                    self.fromdate,
                                    self.todate,
                                    TR=2)
        if (self.ETable_Name_Drop.get() == "Turnover"
                and self.EPatient_Type_Drop.get() == "Treated"):
            databaseobj.createexcel("turnover",
                                    self.fromdate,
                                    self.todate,
                                    TR=3)
        if (self.ETable_Name_Drop.get() == "Satellite"
                and self.EPatient_Type_Drop.get() == "All"):
            databaseobj.createexcel("satellite", self.fromdate, self.todate)
        if (self.ETable_Name_Drop.get() == "Satellite"
                and self.EPatient_Type_Drop.get() == "Screened"):
            databaseobj.createexcel("satellite",
                                    self.fromdate,
                                    self.todate,
                                    TR=1)
        if (self.ETable_Name_Drop.get() == "Satellite"
                and self.EPatient_Type_Drop.get() == "Referred"):
            databaseobj.createexcel("satellite",
                                    self.fromdate,
                                    self.todate,
                                    TR=2)
        if (self.ETable_Name_Drop.get() == "Satellite"
                and self.EPatient_Type_Drop.get() == "Treated"):
            databaseobj.createexcel("satellite",
                                    self.fromdate,
                                    self.todate,
                                    TR=3)

    def print_graph(self):
        databaseobj = Database("dental.db")
        self.fromdate = self.GFrom_Date_Entry.get()
        self.todate = self.GTo_Date_Entry.get()
        self.grp = self.GGroup_By_Drop.get()
        if (self.GTable_Name_Drop.get() == "All" and self.grp == 'By Month'):
            self.x1values, self.y1values = databaseobj.get_by_date(
                "dept", self.fromdate, self.todate, "m")
            plt.plot(self.x1values,
                     self.y1values,
                     color="red",
                     label="Department")
            self.x2values, self.y2values = databaseobj.get_by_date(
                "screen", self.fromdate, self.todate, "m")
            plt.plot(self.x2values,
                     self.y2values,
                     color="blue",
                     label="Dental Camp")
            self.x3values, self.y3values = databaseobj.get_by_date(
                "turnover", self.fromdate, self.todate, "m")
            plt.plot(self.x3values,
                     self.y3values,
                     color="green",
                     label="Turnover")
            self.x4values, self.y4values = databaseobj.get_by_date(
                "satellite", self.fromdate, self.todate, "m")
            plt.plot(self.x4values,
                     self.y4values,
                     color="yellow",
                     label="Satellite centres")
            plt.xlabel("Date")
            plt.ylabel("Patients")
            plt.grid()
            plt.legend(loc="lower right", title="Legend Title", frameon=False)
            plt.show()
        if (self.GTable_Name_Drop.get() == "Department"
                and self.grp == 'By Month'):
            self.xvalues, self.yvalues = databaseobj.get_by_date(
                "dept", self.fromdate, self.todate, "m")
            plt.plot(self.xvalues, self.yvalues)
            plt.xlabel("Date")
            plt.ylabel("Patients")
            plt.grid()
            plt.show()
        if (self.GTable_Name_Drop.get() == "Department"
                and self.grp == 'By Year'):
            self.xvalues, self.yvalues = databaseobj.get_by_date(
                "dept", self.fromdate, self.todate, "y")
            plt.plot(self.xvalues, self.yvalues)
            plt.xlabel("Date")
            plt.ylabel("Patients")
            plt.grid()
            plt.show()
        if (self.GTable_Name_Drop.get() == "Dental Camp"
                and self.grp == 'By Month'):
            #print("inside if of dental camp")
            self.xvalues, self.yvalues = databaseobj.get_by_date(
                "screen", self.fromdate, self.todate, "m")
            # print(self.xvalues, self.yvalues)
            plt.plot(self.xvalues, self.yvalues)
            plt.xlabel("Date")
            plt.ylabel("Patients")
            plt.grid()
            plt.show()
        if (self.GTable_Name_Drop.get() == "Dental Camp"
                and self.grp == 'By Year'):
            # print("inside if of dental camp")
            self.xvalues, self.yvalues = databaseobj.get_by_date(
                "screen", self.fromdate, self.todate, "y")
            plt.plot(self.xvalues, self.yvalues)
            plt.xlabel("Date")
            plt.ylabel("Patients")
            plt.grid()
            plt.show()
        if (self.GTable_Name_Drop.get() == "Turn Over"
                and self.grp == 'By Month'):
            self.xvalues, self.yvalues = databaseobj.get_by_date(
                "turnover", self.fromdate, self.todate, "m")
            plt.plot(self.xvalues, self.yvalues)
            plt.xlabel("Date")
            plt.ylabel("Patients")
            plt.grid()
            plt.show()
        if (self.GTable_Name_Drop.get() == "Turn Over"
                and self.grp == 'By Year'):
            self.xvalues, self.yvalues = databaseobj.get_by_date(
                "turnover", self.fromdate, self.todate, "y")
            plt.plot(self.xvalues, self.yvalues)
            plt.xlabel("Date")
            plt.ylabel("Patients")
            plt.grid()
            plt.show()
        if (self.GTable_Name_Drop.get() == "Satellite"
                and self.grp == 'By Month'):
            self.xvalues, self.yvalues = databaseobj.get_by_date(
                "satellite", self.fromdate, self.todate, "m")
            plt.plot(self.xvalues, self.yvalues)
            plt.xlabel("Date")
            plt.ylabel("Patients")
            plt.grid()
            plt.show()
        if (self.GTable_Name_Drop.get() == "Satellite"
                and self.grp == 'By Year'):
            self.xvalues, self.yvalues = databaseobj.get_by_date(
                "satellite", self.fromdate, self.todate, "y")
            plt.plot(self.xvalues, self.yvalues)
            plt.xlabel("Date")
            plt.ylabel("Patients")
            plt.grid()
            plt.show()

    def __init__(self, View_Data_Window=None):
        '''This class configures and populates the toplevel window.
           View_Data_Window is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#ececec'  # Closest X11 color: 'gray92'
        font9 = "-family {Segoe UI} -size 9 -weight normal -slant "  \
            "roman -underline 0 -overstrike 0"
        font10 = "-family {Helvatica} -size 13 -weight normal -slant " \
                "roman -underline 0 -overstrike 0"
        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)])

        View_Data_Window.geometry("1491x739+35+31")
        View_Data_Window.minsize(148, 1)
        View_Data_Window.maxsize(4112, 1330)
        View_Data_Window.resizable(1, 1)
        View_Data_Window.title("VIEW DATA")
        View_Data_Window.configure(background="#40b3a3")

        self.menubar = tk.Menu(View_Data_Window,
                               font=font9,
                               bg=_bgcolor,
                               fg=_fgcolor)
        View_Data_Window.configure(menu=self.menubar)

        self.sub_menu = tk.Menu(View_Data_Window, tearoff=0)
        self.menubar.add_cascade(menu=self.sub_menu,
                                 activebackground="#ececec",
                                 activeforeground="#000000",
                                 background="#d9d9d9",
                                 compound="left",
                                 foreground="#000000",
                                 label="File")
        self.sub_menu.add_command(
            activebackground="#ececec",
            activeforeground="#000000",
            background="#d9d9d9",
            foreground="#000000",
            label="Exit",
            command=view_data_window1_support.destroy_window)

        self.TSeparator1 = ttk.Separator(View_Data_Window)
        self.TSeparator1.place(relx=0.355, rely=0.0, relheight=1.001)
        self.TSeparator1.configure(orient="vertical")

        self.TSeparator2 = ttk.Separator(View_Data_Window)
        self.TSeparator2.place(relx=0.0, rely=0.46, relwidth=0.355)

        self.TSeparator3 = ttk.Separator(View_Data_Window)
        self.TSeparator3.place(relx=0.355, rely=0.46, relwidth=1.0)

        self.ETable_Name_Drop = ttk.Combobox(View_Data_Window)
        self.ETable_Name_Drop.place(relx=0.034,
                                    rely=0.095,
                                    relheight=0.035,
                                    relwidth=0.125)
        self.ETable_Name_Drop.configure(
            textvariable=view_data_window1_support.Ecombobox1)
        self.ETable_Name_Drop.configure(takefocus="")
        self.ETable_Name_Drop.configure(values=("All", "Department",
                                                "Dental Camp", "Turn Over",
                                                "Satellite"))

        self.EPatient_Type_Drop = ttk.Combobox(View_Data_Window)
        self.EPatient_Type_Drop.place(relx=0.181,
                                      rely=0.095,
                                      relheight=0.035,
                                      relwidth=0.125)
        self.EPatient_Type_Drop.configure(
            textvariable=view_data_window1_support.Ecombobox2)
        self.EPatient_Type_Drop.configure(takefocus="")
        self.EPatient_Type_Drop.configure(values=("All", "Treated", "Reffered",
                                                  "Screened"))

        self.Excel_Label = tk.Label(View_Data_Window)
        self.Excel_Label.place(relx=0.034,
                               rely=0.014,
                               relheight=0.062,
                               relwidth=0.276)
        self.Excel_Label.configure(background="#d9d9d9")
        self.Excel_Label.configure(font="font10")
        self.Excel_Label.configure(disabledforeground="#a3a3a3")
        self.Excel_Label.configure(foreground="#000000")
        self.Excel_Label.configure(relief="raised")
        self.Excel_Label.configure(text='''Excel View''')

        self.EFrom_Date_Label = tk.Label(View_Data_Window)
        self.EFrom_Date_Label.place(relx=0.034,
                                    rely=0.162,
                                    relheight=0.049,
                                    relwidth=0.122)
        self.EFrom_Date_Label.configure(font="font10")
        self.EFrom_Date_Label.configure(background="#d9d9d9")
        self.EFrom_Date_Label.configure(disabledforeground="#a3a3a3")
        self.EFrom_Date_Label.configure(foreground="#000000")
        self.EFrom_Date_Label.configure(text='''From Date:''')

        now = datetime.datetime.now()
        self.EFrom_Date_Entry = DateEntry(View_Data_Window,
                                          year=now.year,
                                          month=now.month,
                                          day=now.day)
        self.EFrom_Date_Entry.place(relx=0.168,
                                    rely=0.162,
                                    relheight=0.046,
                                    relwidth=0.137)
        self.EFrom_Date_Entry.configure(background="white")
        self.EFrom_Date_Entry.configure(date_pattern='y-mm-dd')
        self.EFrom_Date_Entry.configure(font="-family {Helvetica} -size 10")
        self.EFrom_Date_Entry.configure(foreground="#000000")
        self.EFrom_Date_Entry.configure(borderwidth=2)
        self.EFrom_Date_Entry.configure(width=12)

        self.ETo_Date_Label = tk.Label(View_Data_Window)
        self.ETo_Date_Label.place(relx=0.034,
                                  rely=0.23,
                                  relheight=0.049,
                                  relwidth=0.122)
        self.ETo_Date_Label.configure(activebackground="#f9f9f9")
        self.ETo_Date_Label.configure(font="font10")
        self.ETo_Date_Label.configure(activeforeground="black")
        self.ETo_Date_Label.configure(background="#d9d9d9")
        self.ETo_Date_Label.configure(disabledforeground="#a3a3a3")
        self.ETo_Date_Label.configure(foreground="#000000")
        self.ETo_Date_Label.configure(highlightbackground="#d9d9d9")
        self.ETo_Date_Label.configure(highlightcolor="black")
        self.ETo_Date_Label.configure(text='''To Date:''')

        now1 = datetime.datetime.now()
        self.ETo_Date_Entry = DateEntry(View_Data_Window,
                                        year=now1.year,
                                        month=now1.month,
                                        day=now1.day)
        self.ETo_Date_Entry.place(relx=0.168,
                                  rely=0.23,
                                  relheight=0.046,
                                  relwidth=0.137)
        self.ETo_Date_Entry.configure(background="white")
        self.ETo_Date_Entry.configure(date_pattern='y-mm-dd')
        self.ETo_Date_Entry.configure(font="-family {Helvetica} -size 10")
        self.ETo_Date_Entry.configure(foreground="#000000")
        self.ETo_Date_Entry.configure(borderwidth=2)
        self.ETo_Date_Entry.configure(width=12)

        self.Gen_Excel_Button = tk.Button(View_Data_Window)
        self.Gen_Excel_Button.place(relx=0.114,
                                    rely=0.311,
                                    relheight=0.045,
                                    relwidth=0.111)
        self.Gen_Excel_Button.configure(font="font10")
        self.Gen_Excel_Button.configure(activebackground="#ececec")
        self.Gen_Excel_Button.configure(activeforeground="#000000")
        self.Gen_Excel_Button.configure(background="#d9d9d9")
        self.Gen_Excel_Button.configure(disabledforeground="#a3a3a3")
        self.Gen_Excel_Button.configure(foreground="#000000")
        self.Gen_Excel_Button.configure(highlightbackground="#d9d9d9")
        self.Gen_Excel_Button.configure(highlightcolor="black")
        self.Gen_Excel_Button.configure(pady="0")
        self.Gen_Excel_Button.configure(text='''Generate Excel''')
        self.Gen_Excel_Button.configure(command=self.print_excel)

        self.Word_Label = tk.Label(View_Data_Window)
        self.Word_Label.place(relx=0.034,
                              rely=0.487,
                              relheight=0.062,
                              relwidth=0.276)
        self.Word_Label.configure(activebackground="#f9f9f9")
        self.Word_Label.configure(font="font10")
        self.Word_Label.configure(activeforeground="black")
        self.Word_Label.configure(background="#d9d9d9")
        self.Word_Label.configure(disabledforeground="#a3a3a3")
        self.Word_Label.configure(foreground="#000000")
        self.Word_Label.configure(highlightbackground="#d9d9d9")
        self.Word_Label.configure(highlightcolor="black")
        self.Word_Label.configure(relief="raised")
        self.Word_Label.configure(text='''Camp Report ''')

        self.WDate_Label = tk.Label(View_Data_Window)
        self.WDate_Label.place(relx=0.034,
                               rely=0.622,
                               relheight=0.049,
                               relwidth=0.122)
        self.WDate_Label.configure(activebackground="#f9f9f9")
        self.WDate_Label.configure(font="font10")
        self.WDate_Label.configure(activeforeground="black")
        self.WDate_Label.configure(background="#d9d9d9")
        self.WDate_Label.configure(disabledforeground="#a3a3a3")
        self.WDate_Label.configure(foreground="#000000")
        self.WDate_Label.configure(highlightbackground="#d9d9d9")
        self.WDate_Label.configure(highlightcolor="black")
        self.WDate_Label.configure(text='''Date:''')

        now2 = datetime.datetime.now()
        self.WDate_Entry = DateEntry(View_Data_Window,
                                     year=now2.year,
                                     month=now2.month,
                                     day=now2.day)
        self.WDate_Entry.place(relx=0.168,
                               rely=0.622,
                               relheight=0.046,
                               relwidth=0.137)
        self.WDate_Entry.configure(background="white")
        self.WDate_Entry.configure(date_pattern='y-mm-dd')
        self.WDate_Entry.configure(font="-family {Helvetica} -size 10")
        self.WDate_Entry.configure(foreground="#000000")
        self.WDate_Entry.configure(borderwidth=2)
        self.WDate_Entry.configure(width=12)

        self.Gen_Word_Button = tk.Button(View_Data_Window)
        self.Gen_Word_Button.place(relx=0.131,
                                   rely=0.785,
                                   relheight=0.045,
                                   relwidth=0.111)
        self.Gen_Word_Button.configure(activebackground="#ececec")
        self.Gen_Word_Button.configure(font="font10")
        self.Gen_Word_Button.configure(activeforeground="#000000")
        self.Gen_Word_Button.configure(background="#d9d9d9")
        self.Gen_Word_Button.configure(disabledforeground="#a3a3a3")
        self.Gen_Word_Button.configure(foreground="#000000")
        self.Gen_Word_Button.configure(highlightbackground="#d9d9d9")
        self.Gen_Word_Button.configure(highlightcolor="black")
        self.Gen_Word_Button.configure(pady="0")
        self.Gen_Word_Button.configure(text='''Generate Word''')

        self.Gen_Word_Button.configure(command=self.print_word)

        self.Graph_Label = tk.Label(View_Data_Window)
        self.Graph_Label.place(relx=0.543,
                               rely=0.014,
                               relheight=0.062,
                               relwidth=0.276)
        self.Graph_Label.configure(activebackground="#f9f9f9")
        self.Graph_Label.configure(font="font10")
        self.Graph_Label.configure(activeforeground="black")
        self.Graph_Label.configure(background="#d9d9d9")
        self.Graph_Label.configure(disabledforeground="#a3a3a3")
        self.Graph_Label.configure(foreground="#000000")
        self.Graph_Label.configure(highlightbackground="#d9d9d9")
        self.Graph_Label.configure(highlightcolor="black")
        self.Graph_Label.configure(relief="raised")
        self.Graph_Label.configure(text='''Graph View''')

        self.GTable_Name_Drop = ttk.Combobox(View_Data_Window)
        self.GTable_Name_Drop.place(relx=0.416,
                                    rely=0.122,
                                    relheight=0.035,
                                    relwidth=0.125)
        self.GTable_Name_Drop.configure(
            textvariable=view_data_window1_support.Gcombobox1)
        self.GTable_Name_Drop.configure(takefocus="")
        self.GTable_Name_Drop.configure(values=("All", "Department",
                                                "Dental Camp", "Turn Over",
                                                "Satellite"))

        self.GGroup_By_Drop = ttk.Combobox(View_Data_Window)
        self.GGroup_By_Drop.place(relx=0.805,
                                  rely=0.122,
                                  relheight=0.035,
                                  relwidth=0.125)
        self.GGroup_By_Drop.configure(
            textvariable=view_data_window1_support.Gcombobox3)
        self.GGroup_By_Drop.configure(takefocus="")
        self.GGroup_By_Drop.configure(values=("By Month", "By Year"))

        self.GFrom_Date_Label = tk.Label(View_Data_Window)
        self.GFrom_Date_Label.place(relx=0.396,
                                    rely=0.23,
                                    relheight=0.049,
                                    relwidth=0.122)
        self.GFrom_Date_Label.configure(activebackground="#f9f9f9")
        self.GFrom_Date_Label.configure(font="font10")
        self.GFrom_Date_Label.configure(activeforeground="black")
        self.GFrom_Date_Label.configure(background="#d9d9d9")
        self.GFrom_Date_Label.configure(disabledforeground="#a3a3a3")
        self.GFrom_Date_Label.configure(foreground="#000000")
        self.GFrom_Date_Label.configure(highlightbackground="#d9d9d9")
        self.GFrom_Date_Label.configure(highlightcolor="black")
        self.GFrom_Date_Label.configure(text='''From Date:''')

        self.GTo_Date_Label = tk.Label(View_Data_Window)
        self.GTo_Date_Label.place(relx=0.691,
                                  rely=0.23,
                                  relheight=0.049,
                                  relwidth=0.122)
        self.GTo_Date_Label.configure(activebackground="#f9f9f9")
        self.GTo_Date_Label.configure(font="font10")
        self.GTo_Date_Label.configure(activeforeground="black")
        self.GTo_Date_Label.configure(background="#d9d9d9")
        self.GTo_Date_Label.configure(disabledforeground="#a3a3a3")
        self.GTo_Date_Label.configure(foreground="#000000")
        self.GTo_Date_Label.configure(highlightbackground="#d9d9d9")
        self.GTo_Date_Label.configure(highlightcolor="black")
        self.GTo_Date_Label.configure(text='''To Date:''')

        now3 = datetime.datetime.now()
        self.GFrom_Date_Entry = DateEntry(View_Data_Window,
                                          year=now3.year,
                                          month=now3.month,
                                          day=now3.day)
        self.GFrom_Date_Entry.place(relx=0.53,
                                    rely=0.23,
                                    relheight=0.046,
                                    relwidth=0.137)
        self.GFrom_Date_Entry.configure(background="white")
        self.GFrom_Date_Entry.configure(date_pattern='y-mm-dd')
        self.GFrom_Date_Entry.configure(font="-family {Helvetica} -size 10")
        self.GFrom_Date_Entry.configure(foreground="#000000")
        self.GFrom_Date_Entry.configure(borderwidth=2)
        self.GFrom_Date_Entry.configure(width=12)

        now4 = datetime.datetime.now()
        self.GTo_Date_Entry = DateEntry(View_Data_Window,
                                        year=now4.year,
                                        month=now4.month,
                                        day=now4.day)
        self.GTo_Date_Entry.place(relx=0.825,
                                  rely=0.23,
                                  relheight=0.046,
                                  relwidth=0.137)
        self.GTo_Date_Entry.configure(background="white")
        self.GTo_Date_Entry.configure(date_pattern='y-mm-dd')
        self.GTo_Date_Entry.configure(font="-family {Helvetica} -size 10")
        self.GTo_Date_Entry.configure(foreground="#000000")
        self.GTo_Date_Entry.configure(borderwidth=2)
        self.GTo_Date_Entry.configure(width=12)

        self.Gen_Graph_Button = tk.Button(View_Data_Window)
        self.Gen_Graph_Button.place(relx=0.396,
                                    rely=0.352,
                                    relheight=0.045,
                                    relwidth=0.111)
        self.Gen_Graph_Button.configure(activebackground="#ececec")
        self.Gen_Graph_Button.configure(font="font10")
        self.Gen_Graph_Button.configure(activeforeground="#000000")
        self.Gen_Graph_Button.configure(background="#d9d9d9")
        self.Gen_Graph_Button.configure(disabledforeground="#a3a3a3")
        self.Gen_Graph_Button.configure(foreground="#000000")
        self.Gen_Graph_Button.configure(highlightbackground="#d9d9d9")
        self.Gen_Graph_Button.configure(highlightcolor="black")
        self.Gen_Graph_Button.configure(pady="0")
        self.Gen_Graph_Button.configure(text='''Generate Graph''')
        self.Gen_Graph_Button.configure(command=self.print_graph)

        self.Word_Label2 = tk.Label(View_Data_Window)
        self.Word_Label2.place(relx=0.543,
                               rely=0.487,
                               relheight=0.062,
                               relwidth=0.276)
        self.Word_Label2.configure(activebackground="#f9f9f9")
        self.Word_Label2.configure(font="font10")
        self.Word_Label2.configure(activeforeground="black")
        self.Word_Label2.configure(background="#d9d9d9")
        self.Word_Label2.configure(disabledforeground="#a3a3a3")
        self.Word_Label2.configure(foreground="#000000")
        self.Word_Label2.configure(highlightbackground="#d9d9d9")
        self.Word_Label2.configure(highlightcolor="black")
        self.Word_Label2.configure(relief="raised")
        self.Word_Label2.configure(text='''Sensus Report''')

        self.WTable_Name_Drop2 = ttk.Combobox(View_Data_Window)
        self.WTable_Name_Drop2.place(relx=0.416,
                                     rely=0.585,
                                     relheight=0.035,
                                     relwidth=0.125)
        self.WTable_Name_Drop2.configure(
            textvariable=view_data_window1_support.Wscombox)
        self.WTable_Name_Drop2.configure(takefocus="")
        self.WTable_Name_Drop2.configure(values=("All", "Department",
                                                 "Dental Camp", "Turn Over",
                                                 "Satellite"))

        self.WFrom_Date_Label2 = tk.Label(View_Data_Window)
        self.WFrom_Date_Label2.place(relx=0.396,
                                     rely=0.65,
                                     relheight=0.049,
                                     relwidth=0.122)
        self.WFrom_Date_Label2.configure(activebackground="#f9f9f9")
        self.WFrom_Date_Label2.configure(font="font10")
        self.WFrom_Date_Label2.configure(activeforeground="black")
        self.WFrom_Date_Label2.configure(background="#d9d9d9")
        self.WFrom_Date_Label2.configure(disabledforeground="#a3a3a3")
        self.WFrom_Date_Label2.configure(foreground="#000000")
        self.WFrom_Date_Label2.configure(highlightbackground="#d9d9d9")
        self.WFrom_Date_Label2.configure(highlightcolor="black")
        self.WFrom_Date_Label2.configure(text=''' Year:''')

        self.Date_Entry = tk.Entry(View_Data_Window)
        self.Date_Entry.place(relx=0.53,
                              rely=0.65,
                              relheight=0.046,
                              relwidth=0.137)
        self.Date_Entry.configure(background="#ffffff")
        self.Date_Entry.configure(font="font10")
        self.Date_Entry.configure(disabledforeground="#a3a3a3")
        self.Date_Entry.configure(foreground="#000000")

        self.Gen_Sensus_Button = tk.Button(View_Data_Window)
        self.Gen_Sensus_Button.place(relx=0.396,
                                     rely=0.785,
                                     relheight=0.045,
                                     relwidth=0.111)
        self.Gen_Sensus_Button.configure(activebackground="#ececec")
        self.Gen_Sensus_Button.configure(font="font10")
        self.Gen_Sensus_Button.configure(activeforeground="#000000")
        self.Gen_Sensus_Button.configure(background="#d9d9d9")
        self.Gen_Sensus_Button.configure(disabledforeground="#a3a3a3")
        self.Gen_Sensus_Button.configure(foreground="#000000")
        self.Gen_Sensus_Button.configure(highlightbackground="#d9d9d9")
        self.Gen_Sensus_Button.configure(highlightcolor="black")
        self.Gen_Sensus_Button.configure(pady="0")
        self.Gen_Sensus_Button.configure(text='''Generate Sensus''')
        self.Gen_Sensus_Button.configure(command=self.print_census)
Esempio n. 5
0
    def _make_query_frame(
        self,
        parent,
    ):
        """
        make parameter frame for queries

        Return: a frame with the controls in it
        """
        a_frame = Frame(parent,
                        width=600,
                        height=200,
                        bg=self.bkg_color,
                        relief=RAISED,
                        borderwidth=1)

        # add some more for db, different style, which do I like best?
        lrow = 0
        lcol = 0

        # some spacers might be nice -- may put back as we play with the look
        #        a_spacer  = Frame( a_frame, width=60, height=60, bg ="green", relief=RAISED, borderwidth=1 )
        #        a_spacer.grid( row = 0, column = lcol, sticky = E + W + N + S, rowspan = 2 )

        # ------------------------------------
        # !! do not need to save lables
        lrow += 1
        (lrow, lcol, self.lbl_start) = self._make_label(
            a_frame,
            lrow,
            lcol,
            "Start date and hour:",
        )
        (lrow, lcol, self.lbl_end) = self._make_label(
            a_frame,
            lrow,
            lcol,
            "End date and hour:",
        )
        #( lrow, lcol, self.lbl_db_user )   = self._make_label( a_frame, lrow, lcol, "user", )

        lrow = 0
        lcol = 2
        cal = DateEntry(
            a_frame,
            width=12,
            background='darkblue',
            foreground='white',
            borderwidth=2,
            year=2010,
            bordercolor="red",
        )

        cal.grid(row=lrow, column=lcol, sticky=E + W + N + S)
        cal.configure(date_pattern="yyyy/mm/dd")
        cal.set_date(self.parameters.graph_begin_date)
        self.cal_begin = cal

        cal = DateEntry(
            a_frame,
            width=12,
            background='darkblue',
            foreground='white',
            borderwidth=2,
            year=2010,
            bordercolor="red",
        )
        cal.grid(row=lrow + 1, column=lcol, sticky=E + W + N + S)
        cal.configure(date_pattern="yyyy/mm/dd")
        cal.set_date(self.parameters.graph_end_date)
        self.cal_end = cal  # save for later

        #-------------------------------------
        lrow = 0
        lcol = 3

        a_widget = ttk.Combobox(a_frame,
                                values=AppGlobal.dd_hours,
                                state='readonly')
        a_widget.grid(row=lrow, column=lcol, rowspan=1, sticky=E + W + N +
                      S)  # sticky=W+E+N+S  )   # relief = RAISED)
        a_widget.set(self.parameters.graph_begin_hr)
        self.time_begin = a_widget

        a_widget = ttk.Combobox(a_frame,
                                values=AppGlobal.dd_hours,
                                state='readonly')
        a_widget.grid(row=lrow + 1,
                      column=lcol,
                      rowspan=1,
                      sticky=E + W + N +
                      S)  # sticky=W+E+N+S  )   # relief = RAISED)
        a_widget.set(self.parameters.graph_end_hr)
        self.time_end = a_widget

        #------------- some of this may be added back later or not ---------------

        lrow = 0
        lcol = 4
        a_rb = Radiobutton(a_frame,
                           text="From Parms   ",
                           variable=self.rb_var,
                           value=0,
                           command=self.controller.cb_rb_select)
        a_rb.grid(row=lrow, column=lcol)

        #lrow   = 1
        lcol += 1
        a_rb = Radiobutton(a_frame,
                           text="Today",
                           variable=self.rb_var,
                           value=1,
                           command=self.controller.cb_rb_select)
        a_rb.grid(row=lrow, column=lcol)

        #lrow    = 0
        lcol += 1
        a_rb = Radiobutton(a_frame,
                           text="From Now - 1hr ",
                           variable=self.rb_var,
                           value=6,
                           command=self.controller.cb_rb_select)
        a_rb.grid(row=lrow, column=lcol)

        #  ------- ikd buttons that could come back
        #        lcol    += 1
        #        a_rb   =  Radiobutton( a_frame, text = "From Sun - 2 ",      variable = self.rb_var, value=2,  command=self.controller.cb_rb_select )
        #        a_rb.grid( row = lrow,  column = lcol )
        #
        #        lrow   = 1
        #        lcol   = 4
        #        a_rb   =  Radiobutton( a_frame, text = "From Sun - 3  ",      variable = self.rb_var, value=3,  command=self.controller.cb_rb_select )
        #        a_rb.grid( row = lrow,  column = lcol )
        #
        #        #lrow    = 0
        #        lcol    += 1
        #        a_rb   =  Radiobutton( a_frame, text = "From Sun - 4  ",      variable = self.rb_var, value=4,  command=self.controller.cb_rb_select )
        #        a_rb.grid( row = lrow,  column = lcol )
        #
        #        #lrow   = 1
        #        lcol    += 1
        #        a_rb   =  Radiobutton( a_frame, text = "From Sun - 5 ",      variable = self.rb_var, value=5,  command=self.controller.cb_rb_select )
        #        a_rb.grid( row = lrow,  column = lcol )

        #        lrow    = 0
        #        lcol    += 1
        #        a_rb   =  Radiobutton( a_frame, text = "From Now - 1hr ",      variable = self.rb_var, value=6,  command=self.controller.cb_rb_select )
        #        a_rb.grid( row = lrow,  column = lcol )

        #        lrow   = 1
        #        #lcol    += 1
        #        a_rb   =  Radiobutton( a_frame, text = "From Now - 3 ",      variable = self.rb_var, value=7,  command=self.controller.cb_rb_select )
        #        a_rb.grid( row = lrow,  column = lcol )
        #
        #        # ------------------------------
        #        lrow    = 0
        #        lcol   += 1
        #        #lrow    += 1
        #
        #        a_spacer  = Frame( a_frame, width=60, height=60, bg ="green", relief=RAISED, borderwidth=1 )
        #        a_spacer.grid( row = lrow, column = lcol, sticky = E + W + N + S, rowspan = 2 )

        # ------------------------------
        #        lrow    = 0
        #        lcol   += 1
        #
        #        if lrow >= 2:
        #                lrow   =  0
        #                lcol   += 1
        #
        #        a_label   = ( Label( a_frame, text = "status", relief = RAISED,  )  )
        #        a_label.grid( row=lrow, column=lcol, sticky=E + W + N + S )    # sticky=W+E+N+S  )   # relief = RAISED)
        #        self.lbl_db_status  = a_label
        #
        #        ( lrow, lcol, self.lbl_db_connect )   = self._make_label( a_frame, lrow, lcol, "connect", )
        #        ( lrow, lcol, self.lbl_db_host )      = self._make_label( a_frame, lrow, lcol, "host", )
        #        ( lrow, lcol, self.lbl_db_db )        = self._make_label( a_frame, lrow, lcol, "db", )
        #        ( lrow, lcol, self.lbl_db_user )      = self._make_label( a_frame, lrow, lcol, "user", )

        return a_frame
Esempio n. 6
0
class MainWindow(tk.Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.master = master
        self.master.title("Delivery Accountant")
        self.master.minsize(1440, 1080)
        self.master.resizable(True, True)
        # create_tables()
        # draws searching engine
        self.duedate_dockets()
        # additional info for dates
        self.customer_info = self.draw_info(CUSTOMER,
                                            pos_x=2,
                                            pos_y=0,
                                            span_x=2,
                                            span_y=1)
        self.vendor_info = self.draw_info(VENDOR,
                                          pos_x=2,
                                          pos_y=1,
                                          span_x=2,
                                          span_y=1)
        self.draw_dates(pos_x=4, pos_y=0, span_x=2, span_y=1)
        self.draw_notes(pos_x=4, pos_y=1, span_x=2, span_y=2)
        self.draw_tasks(12, pos_x=2, pos_y=4, span_x=4, span_y=2)

        self.delivery_info(pos_x=6, pos_y=0, span_x=1, span_y=1)

        self.draw_menu()
        self.update_customer_combobox()
        self.update_vendor_combobox()
        # the only button for now in this app
        self.btn_submit = ttk.Button(text="submit")
        self.btn_submit.grid(column=0,
                             row=11,
                             columnspan=2,
                             rowspan=2,
                             sticky="NESW")

    def duedate_dockets(self):
        # search engine UI
        self.label_frame_search = tk.LabelFrame(text="Search")
        self.label_frame_search.grid(column=0,
                                     row=0,
                                     columnspan=2,
                                     rowspan=6,
                                     pady=10,
                                     padx=10,
                                     sticky="NESW")
        self.search_entry = tk.Entry(self.label_frame_search,
                                     bg=BASECOLOR,
                                     font=ENTRYFONT)
        self.search_entry.bind("<Return>", self.update_dockets_list)
        self.search_entry.grid(column=0, row=0)
        data = request_recent()
        self.list_dockets(data=data)

    def draw_menu(self):
        """Creates menue in the app"""
        self.menubar = tk.Menu(self.master)

        self.editmenu = tk.Menu(self.menubar, tearoff=0)
        self.editmenu.add_command(label="New Customer",
                                  command=lambda: self.new_partner(CUSTOMER))
        self.editmenu.add_command(label="New Vendor",
                                  command=lambda: self.new_partner(VENDOR))
        self.editmenu.add_command(label="New Delivery",
                                  command=self.new_delivery)

        self.menubar.add_cascade(label="Edit", menu=self.editmenu)

        # self.menubar.add_command(label="Report", command=report_open_tasks)
        self.menubar.add_command(label="Test database", command=self.db_test)
        self.master.config(menu=self.menubar)

    # UI labels with dockets
    def db_test(self):

        create_tables()

    def update_dockets_list(self, event):
        num = self.search_entry.get()
        self.update_by_docket(event, docket=int(num))
        self.list_dockets(data=request_recent())

    def new_delivery(self):
        self.set_active()
        self.clear_entries()
        self.clear_by_partner(CUSTOMER)
        self.clear_by_partner(VENDOR)
        self.btn_submit.configure(command=self.read_delivery_entries)

    def list_dockets(self, data=None, dockets=None):
        """
        parameter: data(list) includes list of strings to show
        """
        """if data is None:
            data = []
            for i in range(0, LENGTH_DOCKETS):
                data.append("Max and Co. \n # 30041")
        """
        # dont forget that there maybe less data than dockets!

        self.docket_labels = []
        font_list = None
        for i, obj in enumerate(data):
            if i % 2 == 0:
                font_list = SECONDARYCOLOR
            else:
                font_list = BASECOLOR
            # concatincates dict wit empty string
            text = ""
            for k, v in obj.items():
                text = text + str(k) + " : " + str(v) + "\n"
            label = tk.Label(self.label_frame_search, text=text, bg=font_list)
            label.grid(column=0, row=i + 1, sticky="NESW")
            label.bind("<Double-Button-1>", self.update_by_docket)
            self.docket_labels.append(label)

            # creates the label with data and packs it with grid

    def delivery_info(self, pos_x, pos_y, span_x, span_y):
        """
        draws delivery information of the form
        """
        self.label_frame_delivery = tk.LabelFrame(self.master,
                                                  text="Delivery Info")
        self.label_frame_delivery.grid(column=pos_x,
                                       row=pos_y,
                                       columnspan=2,
                                       sticky="NEW",
                                       padx=10,
                                       pady=10)
        self.deliver_address = tk.Label(self.label_frame_delivery,
                                        text="Delivery Address")
        self.deliver_address.grid(column=0, row=0)
        self.entry_del_address = tk.Entry(self.label_frame_delivery, width=30)
        self.entry_del_address.grid(column=1, row=0)

    def draw_info(self, name, pos_x, pos_y, span_x, span_y):
        """
        :parameter: labels: (bool) show the requirement of label of entry
        :parameter: name: whos info is going to showed up
        :return: (list) returns two lists that have information about state
        """
        label_frame = tk.LabelFrame(self.master, text="{} Info".format(name))
        label_frame.grid(column=pos_x,
                         row=pos_y,
                         columnspan=span_x,
                         rowspan=span_y,
                         pady=10,
                         padx=10,
                         sticky="NESW")

        # TODO backend method that returns all customers
        combobox = ttk.Combobox(label_frame, values=[], font=ENTRYFONT)
        combobox.grid(column=0, row=0, sticky="NESW")
        if name == CUSTOMER:
            combobox.bind("<<ComboboxSelected>>", self.update_customer_info)
        elif name == VENDOR:
            combobox.bind("<<ComboboxSelected>>", self.update_vendor_info)
        name_label = tk.Label(label_frame,
                              text="{} Name".format(name),
                              font=BASICFONT)
        name_label.grid(column=0, row=1, sticky="W")

        address_label = tk.Label(label_frame, text="Address", font=BASICFONT)
        address_label.grid(column=0, row=2, sticky="W")

        phone_label = tk.Label(label_frame, text="Phone", font=BASICFONT)
        phone_label.grid(column=0, row=3, sticky="W")

        contact_label = tk.Label(label_frame, text="Contact", font=BASICFONT)
        contact_label.grid(column=0, row=4, sticky="W")

        # if need lbels than it is going to draw labels, if not draw entries

        name = tk.Entry(label_frame, width=30)
        name.grid(column=1, row=1, sticky="NESW")

        address = tk.Entry(label_frame, width=30)
        address.grid(column=1, row=2, sticky="NESW")

        phone = tk.Entry(label_frame, width=30)
        phone.grid(column=1, row=3, sticky="NESW")

        contact = tk.Entry(label_frame, width=30)
        contact.grid(column=1, row=4, sticky="NESW")

        return [[name_label, address_label, phone_label, contact_label],
                [combobox, name, address, phone, contact]]

    def draw_dates(self, pos_x, pos_y, span_x, span_y):
        # ui for date widget
        self.label_frame_dates = tk.LabelFrame(text="About Dates")
        self.label_frame_dates.grid(column=pos_x,
                                    row=pos_y,
                                    columnspan=span_x,
                                    rowspan=span_y,
                                    padx=10,
                                    pady=10,
                                    sticky="NEW")

        # date labels

        self.date_client = tk.Label(self.label_frame_dates,
                                    text="Client",
                                    font=BASICFONT)
        self.date_client.grid(column=0, row=0, sticky="W")
        self.date_required = tk.Label(self.label_frame_dates,
                                      text="Requested",
                                      font=BASICFONT)
        self.date_required.grid(column=0, row=1, sticky="w")
        self.date_ship = tk.Label(self.label_frame_dates,
                                  text="Shipment",
                                  font=BASICFONT)
        self.date_ship.grid(column=0, row=2, sticky="w")

        self.entry_client = DateEntry(self.label_frame_dates, font=ENTRYFONT)
        self.entry_client.grid(column=1, row=0, sticky="w")

        self.entry_required = DateEntry(self.label_frame_dates, font=ENTRYFONT)
        self.entry_required.grid(column=1, row=1, sticky="w")

        self.entry_ship = DateEntry(self.label_frame_dates, font=ENTRYFONT)
        self.entry_ship.grid(column=1, row=2, sticky="w")

    def draw_tasks(self, length, pos_x, pos_y, span_x, span_y):
        """
        draws tasks in this format Task:
            goal(string)  |  checkbox(bool)  |  target date(date)
        :parameter: length: (integer) tells how any tasks to draw

        """
        self.tasks = []
        self.label_frame_tasks = tk.LabelFrame(text="Tasks")
        self.label_frame_tasks.grid(column=pos_x,
                                    row=pos_y,
                                    columnspan=span_x,
                                    rowspan=span_y,
                                    padx=10,
                                    pady=10)
        self.task_label = tk.Label(self.label_frame_tasks, text="Tasks")
        self.task_label.grid(column=0, row=0)
        self.done_label = tk.Label(self.label_frame_tasks, text="Done")
        self.done_label.grid(column=1, row=0)
        self.task_date_label = tk.Label(self.label_frame_tasks, text="Date")
        self.task_date_label.grid(column=2, row=0)
        self.task_date_must_label = tk.Label(self.label_frame_tasks,
                                             text="Must Date")
        self.task_date_must_label.grid(column=3, row=0)
        for i in range(0, length):
            entry = tk.Entry(self.label_frame_tasks, width="75")
            entry.grid(column=0, row=i + 1)

            check = tk.BooleanVar()
            check_button = tk.Checkbutton(self.label_frame_tasks, var=check)
            check_button.grid(column=1, row=i + 1)

            date = DateEntry(self.label_frame_tasks, width="25")
            date.grid(column=2, row=i + 1)
            date.configure(state="readonly")
            date_must = DateEntry(self.label_frame_tasks, width="25")
            date_must.grid(column=3, row=i + 1)
            date_must.configure(state="readonly")
            self.tasks.append([entry, check_button, date, check, date_must])

    def draw_notes(self, pos_x, pos_y, span_x, span_y):

        self.notes_frame = tk.LabelFrame(text="Notes")
        self.notes_frame.grid(column=pos_x,
                              row=pos_y,
                              columnspan=span_x,
                              rowspan=span_y,
                              sticky="NESW")
        self.notes = tk.Text(self.notes_frame,
                             height=9,
                             width=35,
                             font=ENTRYFONT)

        self.notes.grid(column=0, row=0)

    def update_customer_info(self, event):
        data = request_partner_info(CUSTOMER_DB,
                                    self.customer_info[1][0].get())
        if data is None:
            pass
        else:
            self.activate_info_entries(CUSTOMER)
            for n, d in data:
                self.customer_info[1][n + 1].delete(0, tk.END)
                self.customer_info[1][n + 1].insert(0, str(d))
            self.deactivate_info_entries(CUSTOMER, include=False)
            # return [[name_label, address_label, phone_label, contact_label],
            # [combobox, name, address, phone, contact]]

    def update_customer_combobox(self):
        """
        updates info on customer frame
        """
        tmp = []
        for i in request_partners(CUSTOMER_DB):
            tmp.append(i["name"])
        self.customer_info[1][0].configure(values=tmp)

    def update_vendor_combobox(self):
        tmp = []
        for i in request_partners(VENDOR_DB):
            tmp.append(i["name"])
        self.vendor_info[1][0].configure(values=tmp)

    def update_vendor_info(self, event):
        data = request_partner_info(VENDOR_DB, self.vendor_info[1][0].get())
        if data is None:
            pass
        else:
            self.activate_info_entries(VENDOR)
            for n, d in enumerate(data):
                self.vendor_info[1][n + 1].delete(0, tk.END)
                self.vendor_info[1][n + 1].insert(1, str(d))
            self.deactivate_info_entries(VENDOR, include=False)

    def update_by_docket(self, event, docket=None):
        # this method parses widget text because of the explained below
        """
            found intersting bug(probably just the thing that not all people know) in python
            if you bind label(may work with other widgets) in a loop(which uses range(0,somenumber))
            with the callback the last value of i or other iterator will be passed to function!
        """

        self.set_active()
        self.clear_tasks()

        # docket, customer, vendor, completed_tasks, date_client, date_require,
        # date_shipment, tasks, note, delivery address
        data = None
        if docket is None:
            docket = int(event.widget["text"].split("\n")[0].split(" ")[2])
            data = request_by_docket(docket)
        else:
            data = request_by_docket(docket)
        if data is None:
            # create a message that will say that something wrong was inputed
            self.clear_entries()
            self.clear_by_partner(CUSTOMER)
            self.clear_by_partner(VENDOR)
            self.clear_tasks()

        else:
            print(data)
            func = lambda: update_docket(docket, self.read_tasks())
            self.btn_submit.configure(command=func)
            # fields in dictionary are the same as fields in docket
            # update customer info
            self.customer_info[1][0].current(
                self.customer_info[1][0]["values"].index((data["customer"])))
            self.update_customer_info(None)
            # none instead of event as update does
            # not depend on event variables
            # update vendor info
            self.vendor_info[1][0].current(
                self.vendor_info[1][0]["values"].index((data["vendor"])))
            self.update_vendor_info(None)
            # update dates

            self.insert_dates([
                data["date_client"], data["date_request"], data["date_shipmet"]
            ])

            # update tasks dont forget that
            # at some point it should turn from bytes -> tuple -> string

            self.update_tasks(data["tasks"])
            # update notes
            self.update_notes(data["note"])
            # update delivery address
            self.update_delivery_address(data["delivery_address"])
        self.readonly_mode()

    def update_notes(self, text):
        self.notes.delete(1.0, tk.END)
        self.notes.insert(1.0, text)

    def update_delivery_address(self, text):
        self.entry_del_address.delete(0, tk.END)
        self.entry_del_address.insert(0, text)

    def readonly_mode(self):
        self.deactivate_info_entries(CUSTOMER)
        self.deactivate_info_entries(VENDOR)
        self.entry_client.configure(state="disabled")
        self.entry_del_address.configure(state="readonly")
        self.entry_required.configure(state="disabled")
        self.entry_ship.configure(state="disabled")
        for i in self.tasks:
            if not i[0].get() and not i[0].get().isspace() and i[0].get(
            ) is not None:
                i[0].configure(state="normal")
                i[2].configure(state="readonly")
                i[1].configure(state="normal")
            else:
                if i[1] == 1:
                    i[1].configure(state="disabled")
                else:
                    i[0].configure(state="normal")
                i[0].configure(state="disabled")
                i[2].configure(state="disabled")

        self.notes.configure(state="disabled")

    def read_tasks(self):
        done_tasks = True
        tasks = ""
        for task, done, date, check, date_must in self.tasks:

            if task.get() and not task.get().isspace() and not (task.get() is
                                                                None):

                if not check.get():
                    done_tasks = False

                if check.get():
                    check = 1
                else:
                    check = 0
                tasks = tasks + "" + task.get() + "|" + str(
                    check) + "|" + date.get() + "|" + date_must.get()
        return [tasks, done_tasks]

    def read_delivery_entries(self):
        # self.update_dockets_list()
        self.btn_submit.configure(command=None)
        self.set_active()
        data = []
        data.append(self.customer_info[1][0].get())
        data.append(self.vendor_info[1][0].get())
        tasks, done = self.read_tasks()
        data.append(done)
        data.append(time_format(self.entry_client.get()))
        data.append(time_format(self.entry_required.get()))
        data.append(time_format(self.entry_ship.get()))
        data.append(tasks)
        data.append(self.notes.get(1.0, tk.END))
        data.append(self.entry_del_address.get())
        self.readonly_mode()
        submit_delivery(data)

    def after_action_update(self):
        self.update_customer_combobox()
        self.update_vendor_combobox()

    def insert_dates(self, dates):
        self.entry_client.delete(0, tk.END)
        self.entry_ship.delete(0, tk.END)
        self.entry_required.delete(0, tk.END)

        self.entry_client.insert(0, dates[0])
        self.entry_required.insert(0, dates[1])
        self.entry_ship.insert(0, dates[2])

    def clear_tasks(self):
        for i in self.tasks:
            i[0].delete(0, tk.END)
            i[1].deselect()
            i[2].delete(0, tk.END)

    def clear_entries(self):
        self.insert_dates([0, 0, 0])
        self.entry_client.delete(0, tk.END)
        self.entry_del_address.delete(0, tk.END)
        self.entry_required.delete(0, tk.END)
        self.entry_ship.delete(0, tk.END)
        self.clear_tasks()
        self.notes.delete(1.0, tk.END)
        self.vendor_info[1][0].current(0)
        self.customer_info[1][0].current(0)

    def clear_by_partner(self, partner):
        if partner == CUSTOMER:
            for i in self.vendor_info[1]:
                i.delete(0, tk.END)
        if partner == VENDOR:
            for i in self.customer_info[1]:
                i.delete(0, tk.END)

    def set_active(self):
        self.activate_info_entries(CUSTOMER)
        self.activate_info_entries(VENDOR)
        self.entry_client.configure(state="readonly")
        self.entry_del_address.configure(state="normal")
        self.entry_required.configure(state="readonly")
        self.entry_ship.configure(state="readonly")
        for i in self.tasks:
            i[0].configure(state="normal")
            i[1].configure(state="normal")
            i[2].configure(state="readonly")
        self.notes.configure(state="normal")

    def activate_info_entries(self, partner):
        if partner == CUSTOMER:
            data = self.customer_info[1]
        elif partner == VENDOR:
            data = self.vendor_info[1]
        for i in data[1:]:
            i.configure(state="normal")
        data[0].configure(state="readonly")

    def deactivate_info_entries(self, partner, include=True):
        """
        CHANGE SIMILAR SSTATEMENTS ON THIS
        IF .... CUSOTMER:
            DATA = SELF.CUSTOMER
        FOR I IN DATA:
            ....
        """
        if include:
            if partner == CUSTOMER:
                data = self.customer_info[1]
            elif partner == VENDOR:
                data = self.vendor_info[1]
            for i in data[1:]:
                i.configure(state="disabled")

            data[0].configure(state="disabled")

    def update_tasks(self, text):
        if text is None:
            return None
        text = text.split("\n")
        #text.remove("")
        self.clear_tasks()
        for num, obj in enumerate(text):
            obj = obj.split("|")
            self.tasks[num][0].delete(0, tk.END)
            self.tasks[num][0].insert(0, obj[0])
            self.tasks[num][3].set(int(obj[1]))
            self.tasks[num][2].delete(0, tk.END)
            self.tasks[num][2].insert(0, obj[2])
            self.tasks[num][4].delete(0, tk.END)
            self.tasks[num][4].insert(0, obj[3])

    def read_partner(self, partner):
        self.btn_submit.configure(command=None)
        data = None
        if partner == CUSTOMER:
            data = self.customer_info[1]
        elif partner == VENDOR:
            data = self.vendor_info[1]
        submit_data = []
        for i in data[1:]:
            submit_data.append(str(i.get()))
        submit_partner(submit_data, partner)
        self.clear_entries()
        self.update_customer_combobox()
        self.update_vendor_combobox()

    def new_partner(self, partner):
        self.set_active()
        self.clear_entries()
        self.readonly_mode()
        self.activate_info_entries(VENDOR)
        self.activate_info_entries(CUSTOMER)

        self.clear_by_partner(VENDOR)
        self.clear_by_partner(CUSTOMER)
        if partner == VENDOR:
            self.deactivate_info_entries(CUSTOMER)
        elif partner == CUSTOMER:
            self.deactivate_info_entries(VENDOR)
        self.btn_submit.configure(command=lambda: self.read_partner(partner))
class Department_Outpatient:
    def __init__(self, Department_Window=None):
        '''This class configures and populates the toplevel window.
           Department_Window is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#ececec'  # Closest X11 color: 'gray92'
        font10 = "-family {Helvetica} -size 10 -weight normal -slant"  \
            " roman -underline 0 -overstrike 0"
        font11 = "-family {Helvetica} -size 13 -weight normal -slant "  \
            "roman -underline 0 -overstrike 0"
        font9 = "-family {Segoe UI} -size 9 -weight normal -slant "  \
            "roman -underline 0 -overstrike 0"
        self.style = ttk.Style()
        self.data = Database("dental.db")
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.', background=_bgcolor)
        self.style.configure('.', foreground=_fgcolor)
        self.style.map('.',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])

        Department_Window.geometry("1491x739+35+31")
        Department_Window.minsize(148, 1)
        Department_Window.maxsize(4112, 1030)
        Department_Window.resizable(1, 1)
        Department_Window.title("DEPARTMENT OUT-PATIENT")
        Department_Window.configure(background="#40b3a3")
        Department_Window.configure(highlightbackground="#d9d9d9")
        Department_Window.configure(highlightcolor="black")

        self.menubar = tk.Menu(Department_Window,
                               font=font9,
                               bg=_bgcolor,
                               fg=_fgcolor)
        Department_Window.configure(menu=self.menubar)

        self.File = tk.Menu(Department_Window, tearoff=0)
        self.menubar.add_cascade(
            menu=self.File,
            activebackground="#ececec",
            activeforeground="#000000",
            background="#d9d9d9",
            font=
            ('-family {Segoe UI} -size 9 -weight normal -slant roman -underline 0 -overstrike 0'
             ),
            foreground="#000000",
            label="File")
        self.File.add_command(
            activebackground="#ececec",
            activeforeground="#000000",
            background="#d9d9d9",
            font=
            ('-family {Segoe UI} -size 9 -weight normal -slant roman -underline 0 -overstrike 0'
             ),
            foreground="#000000",
            label="Exit",
            command=department_window_support.destroy_window)

        self.Department_Label = tk.Label(Department_Window)
        self.Department_Label.place(relx=0.241,
                                    rely=0.027,
                                    relwidth=0.518,
                                    relheight=0.084)

        self.Department_Label.configure(activebackground="#f9f9f9")
        self.Department_Label.configure(activeforeground="black")
        self.Department_Label.configure(background="#d9d9d9")
        self.Department_Label.configure(disabledforeground="#a3a3a3")
        self.Department_Label.configure(
            font="-family {Helvetica} -size 18 -weight normal")
        self.Department_Label.configure(foreground="#000000")
        self.Department_Label.configure(highlightbackground="#d9d9d9")
        self.Department_Label.configure(highlightcolor="black")
        self.Department_Label.configure(relief="raised")
        self.Department_Label.configure(text='''Department Out Patient''')

        self.on_radio = tk.IntVar(None, 1)
        self.Old_Patient_Radio = tk.Radiobutton(Department_Window)
        self.Old_Patient_Radio.place(relx=0.013,
                                     rely=0.124,
                                     relheight=0.042,
                                     relwidth=0.18)
        self.Old_Patient_Radio.configure(activebackground="#ececec")
        self.Old_Patient_Radio.configure(activeforeground="#000000")
        self.Old_Patient_Radio.configure(background="#d9d9d9")
        self.Old_Patient_Radio.configure(disabledforeground="#a3a3a3")
        self.Old_Patient_Radio.configure(font=font11)
        self.Old_Patient_Radio.configure(foreground="#000000")
        self.Old_Patient_Radio.configure(highlightbackground="#d9d9d9")
        self.Old_Patient_Radio.configure(highlightcolor="black")
        self.Old_Patient_Radio.configure(justify='left')
        self.Old_Patient_Radio.configure(text='''Old Patient''')
        self.Old_Patient_Radio.configure(value=1)
        self.Old_Patient_Radio.configure(variable=self.on_radio)

        self.New_Patient_Radio = tk.Radiobutton(Department_Window)
        self.New_Patient_Radio.place(relx=0.213,
                                     rely=0.124,
                                     relheight=0.042,
                                     relwidth=0.18)
        self.New_Patient_Radio.configure(activebackground="#ececec")
        self.New_Patient_Radio.configure(activeforeground="#000000")
        self.New_Patient_Radio.configure(background="#d9d9d9")
        self.New_Patient_Radio.configure(disabledforeground="#a3a3a3")
        self.New_Patient_Radio.configure(font=font11)
        self.New_Patient_Radio.configure(foreground="#000000")
        self.New_Patient_Radio.configure(highlightbackground="#d9d9d9")
        self.New_Patient_Radio.configure(highlightcolor="black")
        self.New_Patient_Radio.configure(justify='left')
        self.New_Patient_Radio.configure(text='''New Patient''')
        self.New_Patient_Radio.configure(value=2)
        self.New_Patient_Radio.configure(variable=self.on_radio)

        self.Health_Label = tk.Label(Department_Window)
        self.Health_Label.place(relx=0.410,
                                rely=0.124,
                                relwidth=0.169,
                                relheight=0.05)
        self.Health_Label.configure(activebackground="#f9f9f9")
        self.Health_Label.configure(activeforeground="black")
        self.Health_Label.configure(background="#d9d9d9")
        self.Health_Label.configure(disabledforeground="#a3a3a3")
        self.Health_Label.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Health_Label.configure(foreground="#000000")
        self.Health_Label.configure(highlightbackground="#d9d9d9")
        self.Health_Label.configure(highlightcolor="black")
        self.Health_Label.configure(text='''Health Education''')

        self.Health_Entry = tk.Entry(Department_Window)
        self.Health_Entry.place(relx=0.599,
                                rely=0.124,
                                relheight=0.048,
                                relwidth=0.137)
        self.Health_Entry.configure(background="white")
        self.Health_Entry.configure(disabledforeground="#a3a3a3")
        self.Health_Entry.configure(font="-family {Helvetica} -size 10")
        self.Health_Entry.configure(foreground="#000000")
        self.Health_Entry.configure(highlightbackground="#d9d9d9")
        self.Health_Entry.configure(highlightcolor="black")
        self.Health_Entry.configure(insertbackground="black")
        self.Health_Entry.configure(selectbackground="#c4c4c4")
        self.Health_Entry.configure(selectforeground="black")

        self.Incharge_Label = tk.Label(Department_Window)
        self.Incharge_Label.place(relx=0.013,
                                  rely=0.189,
                                  relwidth=0.169,
                                  relheight=0.05)
        self.Incharge_Label.configure(activebackground="#f9f9f9")
        self.Incharge_Label.configure(activeforeground="black")
        self.Incharge_Label.configure(background="#d9d9d9")
        self.Incharge_Label.configure(disabledforeground="#a3a3a3")
        self.Incharge_Label.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Incharge_Label.configure(foreground="#000000")
        self.Incharge_Label.configure(highlightbackground="#d9d9d9")
        self.Incharge_Label.configure(highlightcolor="black")
        self.Incharge_Label.configure(text='''Incharge''')

        self.Incharge_Entry = tk.Entry(Department_Window)
        self.Incharge_Entry.place(relx=0.188,
                                  rely=0.189,
                                  relheight=0.048,
                                  relwidth=0.137)
        self.Incharge_Entry.configure(background="white")
        self.Incharge_Entry.configure(disabledforeground="#a3a3a3")
        self.Incharge_Entry.configure(font="-family {Helvetica} -size 10")
        self.Incharge_Entry.configure(foreground="#000000")
        self.Incharge_Entry.configure(highlightbackground="#d9d9d9")
        self.Incharge_Entry.configure(highlightcolor="black")
        self.Incharge_Entry.configure(insertbackground="black")
        self.Incharge_Entry.configure(selectbackground="#c4c4c4")
        self.Incharge_Entry.configure(selectforeground="black")

        self.Phone_Label = tk.Label(Department_Window)
        self.Phone_Label.place(relx=0.335,
                               rely=0.189,
                               relwidth=0.162,
                               relheight=0.05)
        self.Phone_Label.configure(activebackground="#f9f9f9")
        self.Phone_Label.configure(activeforeground="black")
        self.Phone_Label.configure(background="#d9d9d9")
        self.Phone_Label.configure(disabledforeground="#a3a3a3")
        self.Phone_Label.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Phone_Label.configure(foreground="#000000")
        self.Phone_Label.configure(highlightbackground="#d9d9d9")
        self.Phone_Label.configure(highlightcolor="black")
        self.Phone_Label.configure(text='''Phone''')

        self.Phone_Entry = tk.Entry(Department_Window)
        self.Phone_Entry.place(relx=0.51,
                               rely=0.189,
                               relheight=0.048,
                               relwidth=0.137)
        self.Phone_Entry.configure(background="white")
        self.Phone_Entry.configure(disabledforeground="#a3a3a3")
        self.Phone_Entry.configure(font="-family {Helvetica} -size 10")
        self.Phone_Entry.configure(foreground="#000000")
        self.Phone_Entry.configure(highlightbackground="#d9d9d9")
        self.Phone_Entry.configure(highlightcolor="black")
        self.Phone_Entry.configure(insertbackground="black")
        self.Phone_Entry.configure(selectbackground="#c4c4c4")
        self.Phone_Entry.configure(selectforeground="black")

        self.Date_Label = tk.Label(Department_Window)
        self.Date_Label.place(relx=0.664,
                              rely=0.189,
                              relwidth=0.122,
                              relheight=0.05)
        self.Date_Label.configure(activebackground="#f9f9f9")
        self.Date_Label.configure(activeforeground="black")
        self.Date_Label.configure(background="#d9d9d9")
        self.Date_Label.configure(disabledforeground="#a3a3a3")
        self.Date_Label.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Date_Label.configure(foreground="#000000")
        self.Date_Label.configure(highlightbackground="#d9d9d9")
        self.Date_Label.configure(highlightcolor="black")
        self.Date_Label.configure(text='''Date\nYYYY-MM-DD''')

        now = datetime.datetime.now()
        self.Date_Entry = DateEntry(Department_Window,
                                    year=now.year,
                                    month=now.month,
                                    day=now.day)
        self.Date_Entry.place(relx=0.791,
                              rely=0.189,
                              relheight=0.048,
                              relwidth=0.137)
        self.Date_Entry.configure(background="white")
        self.Date_Entry.configure(date_pattern='y/mm/dd')
        self.Date_Entry.configure(font="-family {Helvetica} -size 10")
        self.Date_Entry.configure(foreground="#000000")
        self.Date_Entry.configure(borderwidth=2)
        self.Date_Entry.configure(width=12)

        # self.Date_Entry = tk.Entry(Department_Window)
        # self.Date_Entry.place(relx=0.791, rely=0.189,relheight = 0.048, relwidth=0.137)
        # self.Date_Entry.configure(background="white")
        # self.Date_Entry.configure(disabledforeground="#a3a3a3")
        # self.Date_Entry.configure(font="-family {Helvetica} -size 10")
        # self.Date_Entry.configure(foreground="#000000")
        # self.Date_Entry.configure(highlightbackground="#d9d9d9")
        # self.Date_Entry.configure(highlightcolor="black")
        # self.Date_Entry.configure(insertbackground="black")
        # self.Date_Entry.configure(selectbackground="#c4c4c4")
        # self.Date_Entry.configure(selectforeground="black")

        self.From_Label = tk.Label(Department_Window)
        self.From_Label.place(relx=0.013,
                              rely=0.311,
                              relwidth=0.162,
                              relheight=0.05)
        self.From_Label.configure(activebackground="#f9f9f9")
        self.From_Label.configure(activeforeground="black")
        self.From_Label.configure(background="#d9d9d9")
        self.From_Label.configure(disabledforeground="#a3a3a3")
        self.From_Label.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.From_Label.configure(foreground="#000000")
        self.From_Label.configure(highlightbackground="#d9d9d9")
        self.From_Label.configure(highlightcolor="black")
        self.From_Label.configure(text='''ID From''')

        self.From_Entry = tk.Entry(Department_Window)
        self.From_Entry.place(relx=0.188,
                              rely=0.311,
                              relwidth=0.137,
                              relheight=0.048)
        self.From_Entry.configure(background="white")
        self.From_Entry.configure(disabledforeground="#a3a3a3")
        self.From_Entry.configure(font="-family {Helvetica} -size 10")
        self.From_Entry.configure(foreground="#000000")
        self.From_Entry.configure(highlightbackground="#d9d9d9")
        self.From_Entry.configure(highlightcolor="black")
        self.From_Entry.configure(insertbackground="black")
        self.From_Entry.configure(selectbackground="#c4c4c4")
        self.From_Entry.configure(selectforeground="black")

        self.To_Label = tk.Label(Department_Window)
        self.To_Label.place(relx=0.335,
                            rely=0.311,
                            relwidth=0.162,
                            relheight=0.05)
        self.To_Label.configure(activebackground="#f9f9f9")
        self.To_Label.configure(activeforeground="black")
        self.To_Label.configure(background="#d9d9d9")
        self.To_Label.configure(disabledforeground="#a3a3a3")
        self.To_Label.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.To_Label.configure(foreground="#000000")
        self.To_Label.configure(highlightbackground="#d9d9d9")
        self.To_Label.configure(highlightcolor="black")
        self.To_Label.configure(text='''ID To''')

        self.To_Entry = tk.Entry(Department_Window)
        self.To_Entry.place(relx=0.51,
                            rely=0.311,
                            relwidth=0.137,
                            relheight=0.048)
        self.To_Entry.configure(background="white")
        self.To_Entry.configure(disabledforeground="#a3a3a3")
        self.To_Entry.configure(font="-family {Helvetica} -size 10")
        self.To_Entry.configure(foreground="#000000")
        self.To_Entry.configure(highlightbackground="#d9d9d9")
        self.To_Entry.configure(highlightcolor="black")
        self.To_Entry.configure(insertbackground="black")
        self.To_Entry.configure(selectbackground="#c4c4c4")
        self.To_Entry.configure(selectforeground="black")

        self.Endodontics_Label = tk.Label(Department_Window)
        self.Endodontics_Label.place(relx=0.013,
                                     rely=0.379,
                                     relwidth=0.162,
                                     relheight=0.05)
        self.Endodontics_Label.configure(activebackground="#f9f9f9")
        self.Endodontics_Label.configure(activeforeground="black")
        self.Endodontics_Label.configure(background="#d9d9d9")
        self.Endodontics_Label.configure(disabledforeground="#a3a3a3")
        self.Endodontics_Label.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Endodontics_Label.configure(foreground="#000000")
        self.Endodontics_Label.configure(highlightbackground="#d9d9d9")
        self.Endodontics_Label.configure(highlightcolor="black")
        self.Endodontics_Label.configure(text='''Endodontics''')

        self.Periodont_Label = tk.Label(Department_Window)
        self.Periodont_Label.place(relx=0.013,
                                   rely=0.447,
                                   relwidth=0.162,
                                   relheight=0.05)
        self.Periodont_Label.configure(activebackground="#f9f9f9")
        self.Periodont_Label.configure(activeforeground="black")
        self.Periodont_Label.configure(background="#d9d9d9")
        self.Periodont_Label.configure(disabledforeground="#a3a3a3")
        self.Periodont_Label.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Periodont_Label.configure(foreground="#000000")
        self.Periodont_Label.configure(highlightbackground="#d9d9d9")
        self.Periodont_Label.configure(highlightcolor="black")
        self.Periodont_Label.configure(text='''Periodont''')

        self.Orthodontics_Label = tk.Label(Department_Window)
        self.Orthodontics_Label.place(relx=0.013,
                                      rely=0.514,
                                      relwidth=0.162,
                                      relheight=0.05)
        self.Orthodontics_Label.configure(activebackground="#f9f9f9")
        self.Orthodontics_Label.configure(activeforeground="black")
        self.Orthodontics_Label.configure(background="#d9d9d9")
        self.Orthodontics_Label.configure(disabledforeground="#a3a3a3")
        self.Orthodontics_Label.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Orthodontics_Label.configure(foreground="#000000")
        self.Orthodontics_Label.configure(highlightbackground="#d9d9d9")
        self.Orthodontics_Label.configure(highlightcolor="black")
        self.Orthodontics_Label.configure(text='''Orthodontics''')

        self.Surgery_Label = tk.Label(Department_Window)
        self.Surgery_Label.place(relx=0.013,
                                 rely=0.582,
                                 relwidth=0.162,
                                 relheight=0.05)
        self.Surgery_Label.configure(activebackground="#f9f9f9")
        self.Surgery_Label.configure(activeforeground="black")
        self.Surgery_Label.configure(background="#d9d9d9")
        self.Surgery_Label.configure(disabledforeground="#a3a3a3")
        self.Surgery_Label.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Surgery_Label.configure(foreground="#000000")
        self.Surgery_Label.configure(highlightbackground="#d9d9d9")
        self.Surgery_Label.configure(highlightcolor="black")
        self.Surgery_Label.configure(text='''Surgery''')

        self.Pedodont_Label = tk.Label(Department_Window)
        self.Pedodont_Label.place(relx=0.013,
                                  rely=0.65,
                                  relwidth=0.162,
                                  relheight=0.05)
        self.Pedodont_Label.configure(activebackground="#f9f9f9")
        self.Pedodont_Label.configure(activeforeground="black")
        self.Pedodont_Label.configure(background="#d9d9d9")
        self.Pedodont_Label.configure(disabledforeground="#a3a3a3")
        self.Pedodont_Label.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Pedodont_Label.configure(foreground="#000000")
        self.Pedodont_Label.configure(highlightbackground="#d9d9d9")
        self.Pedodont_Label.configure(highlightcolor="black")
        self.Pedodont_Label.configure(text='''Pedodont''')

        self.Oralpatho_Label = tk.Label(Department_Window)
        self.Oralpatho_Label.place(relx=0.335,
                                   rely=0.379,
                                   relwidth=0.162,
                                   relheight=0.05)
        self.Oralpatho_Label.configure(activebackground="#f9f9f9")
        self.Oralpatho_Label.configure(activeforeground="black")
        self.Oralpatho_Label.configure(background="#d9d9d9")
        self.Oralpatho_Label.configure(disabledforeground="#a3a3a3")
        self.Oralpatho_Label.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Oralpatho_Label.configure(foreground="#000000")
        self.Oralpatho_Label.configure(highlightbackground="#d9d9d9")
        self.Oralpatho_Label.configure(highlightcolor="black")
        self.Oralpatho_Label.configure(text='''Oralpatho''')

        self.Public_Health_Label = tk.Label(Department_Window)
        self.Public_Health_Label.place(relx=0.335,
                                       rely=0.447,
                                       relwidth=0.162,
                                       relheight=0.05)
        self.Public_Health_Label.configure(activebackground="#f9f9f9")
        self.Public_Health_Label.configure(activeforeground="black")
        self.Public_Health_Label.configure(background="#d9d9d9")
        self.Public_Health_Label.configure(disabledforeground="#a3a3a3")
        self.Public_Health_Label.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Public_Health_Label.configure(foreground="#000000")
        self.Public_Health_Label.configure(highlightbackground="#d9d9d9")
        self.Public_Health_Label.configure(highlightcolor="black")
        self.Public_Health_Label.configure(text='''Public Health''')

        self.Oral_Mea_Label = tk.Label(Department_Window)
        self.Oral_Mea_Label.place(relx=0.335,
                                  rely=0.514,
                                  relwidth=0.162,
                                  relheight=0.05)
        self.Oral_Mea_Label.configure(activebackground="#f9f9f9")
        self.Oral_Mea_Label.configure(activeforeground="black")
        self.Oral_Mea_Label.configure(background="#d9d9d9")
        self.Oral_Mea_Label.configure(disabledforeground="#a3a3a3")
        self.Oral_Mea_Label.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Oral_Mea_Label.configure(foreground="#000000")
        self.Oral_Mea_Label.configure(highlightbackground="#d9d9d9")
        self.Oral_Mea_Label.configure(highlightcolor="black")
        self.Oral_Mea_Label.configure(text='''Oral mea''')

        self.Ping_Thread_Label = tk.Label(Department_Window)
        self.Ping_Thread_Label.place(relx=0.335,
                                     rely=0.582,
                                     relwidth=0.162,
                                     relheight=0.05)
        self.Ping_Thread_Label.configure(activebackground="#f9f9f9")
        self.Ping_Thread_Label.configure(activeforeground="black")
        self.Ping_Thread_Label.configure(background="#d9d9d9")
        self.Ping_Thread_Label.configure(disabledforeground="#a3a3a3")
        self.Ping_Thread_Label.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Ping_Thread_Label.configure(foreground="#000000")
        self.Ping_Thread_Label.configure(highlightbackground="#d9d9d9")
        self.Ping_Thread_Label.configure(highlightcolor="black")
        self.Ping_Thread_Label.configure(text='''Prostho''')

        self.Grand_Total_Label = tk.Label(Department_Window)
        self.Grand_Total_Label.place(relx=0.335,
                                     rely=0.65,
                                     relwidth=0.162,
                                     relheight=0.05)

        self.Grand_Total_Label.configure(activebackground="#f9f9f9")
        self.Grand_Total_Label.configure(activeforeground="black")
        self.Grand_Total_Label.configure(background="#d9d9d9")
        self.Grand_Total_Label.configure(disabledforeground="#a3a3a3")
        self.Grand_Total_Label.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Grand_Total_Label.configure(foreground="#000000")
        self.Grand_Total_Label.configure(highlightbackground="#d9d9d9")
        self.Grand_Total_Label.configure(highlightcolor="black")
        self.Grand_Total_Label.configure(text='''Grand Total''')

        #Defining the entries

        self.Endodontics_Entry = tk.Entry(Department_Window)
        self.Endodontics_Entry.place(relx=0.188,
                                     rely=0.379,
                                     relwidth=0.137,
                                     relheight=0.048)
        self.Endodontics_Entry.configure(background="white")
        self.Endodontics_Entry.configure(disabledforeground="#a3a3a3")
        self.Endodontics_Entry.configure(font="-family {Helvetica} -size 10")
        self.Endodontics_Entry.configure(foreground="#000000")
        self.Endodontics_Entry.configure(highlightbackground="#d9d9d9")
        self.Endodontics_Entry.configure(highlightcolor="black")
        self.Endodontics_Entry.configure(insertbackground="black")
        self.Endodontics_Entry.configure(selectbackground="#c4c4c4")
        self.Endodontics_Entry.configure(selectforeground="black")

        self.Periodont_Entry = tk.Entry(Department_Window)
        self.Periodont_Entry.place(relx=0.188,
                                   rely=0.447,
                                   relwidth=0.137,
                                   relheight=0.048)
        self.Periodont_Entry.configure(background="white")
        self.Periodont_Entry.configure(disabledforeground="#a3a3a3")
        self.Periodont_Entry.configure(font="-family {Helvetica} -size 10")
        self.Periodont_Entry.configure(foreground="#000000")
        self.Periodont_Entry.configure(highlightbackground="#d9d9d9")
        self.Periodont_Entry.configure(highlightcolor="black")
        self.Periodont_Entry.configure(insertbackground="black")
        self.Periodont_Entry.configure(selectbackground="#c4c4c4")
        self.Periodont_Entry.configure(selectforeground="black")

        self.Orthodontics_Entry = tk.Entry(Department_Window)
        self.Orthodontics_Entry.place(relx=0.188,
                                      rely=0.514,
                                      relwidth=0.137,
                                      relheight=0.048)
        self.Orthodontics_Entry.configure(background="white")
        self.Orthodontics_Entry.configure(disabledforeground="#a3a3a3")
        self.Orthodontics_Entry.configure(font="-family {Helvetica} -size 10")
        self.Orthodontics_Entry.configure(foreground="#000000")
        self.Orthodontics_Entry.configure(highlightbackground="#d9d9d9")
        self.Orthodontics_Entry.configure(highlightcolor="black")
        self.Orthodontics_Entry.configure(insertbackground="black")
        self.Orthodontics_Entry.configure(selectbackground="#c4c4c4")
        self.Orthodontics_Entry.configure(selectforeground="black")

        self.Surgery_Entry = tk.Entry(Department_Window)
        self.Surgery_Entry.place(relx=0.188,
                                 rely=0.582,
                                 relwidth=0.137,
                                 relheight=0.048)
        self.Surgery_Entry.configure(background="white")
        self.Surgery_Entry.configure(disabledforeground="#a3a3a3")
        self.Surgery_Entry.configure(font="-family {Helvetica} -size 10")
        self.Surgery_Entry.configure(foreground="#000000")
        self.Surgery_Entry.configure(highlightbackground="#d9d9d9")
        self.Surgery_Entry.configure(highlightcolor="black")
        self.Surgery_Entry.configure(insertbackground="black")
        self.Surgery_Entry.configure(selectbackground="#c4c4c4")
        self.Surgery_Entry.configure(selectforeground="black")

        self.Pedodont_Entry = tk.Entry(Department_Window)
        self.Pedodont_Entry.place(relx=0.188,
                                  rely=0.65,
                                  relwidth=0.137,
                                  relheight=0.048)
        self.Pedodont_Entry.configure(background="white")
        self.Pedodont_Entry.configure(disabledforeground="#a3a3a3")
        self.Pedodont_Entry.configure(font="-family {Helvetica} -size 10")
        self.Pedodont_Entry.configure(foreground="#000000")
        self.Pedodont_Entry.configure(highlightbackground="#d9d9d9")
        self.Pedodont_Entry.configure(highlightcolor="black")
        self.Pedodont_Entry.configure(insertbackground="black")
        self.Pedodont_Entry.configure(selectbackground="#c4c4c4")
        self.Pedodont_Entry.configure(selectforeground="black")

        self.Oralpatho_Entry = tk.Entry(Department_Window)
        self.Oralpatho_Entry.place(relx=0.51,
                                   rely=0.379,
                                   relwidth=0.137,
                                   relheight=0.048)
        self.Oralpatho_Entry.configure(background="white")
        self.Oralpatho_Entry.configure(disabledforeground="#a3a3a3")
        self.Oralpatho_Entry.configure(font="-family {Helvetica} -size 10")
        self.Oralpatho_Entry.configure(foreground="#000000")
        self.Oralpatho_Entry.configure(highlightbackground="#d9d9d9")
        self.Oralpatho_Entry.configure(highlightcolor="black")
        self.Oralpatho_Entry.configure(insertbackground="black")
        self.Oralpatho_Entry.configure(selectbackground="#c4c4c4")
        self.Oralpatho_Entry.configure(selectforeground="black")

        self.Public_Health_Entry = tk.Entry(Department_Window)
        self.Public_Health_Entry.place(relx=0.51,
                                       rely=0.447,
                                       relwidth=0.137,
                                       relheight=0.048)
        self.Public_Health_Entry.configure(background="white")
        self.Public_Health_Entry.configure(disabledforeground="#a3a3a3")
        self.Public_Health_Entry.configure(font="-family {Helvetica} -size 10")
        self.Public_Health_Entry.configure(foreground="#000000")
        self.Public_Health_Entry.configure(highlightbackground="#d9d9d9")
        self.Public_Health_Entry.configure(highlightcolor="black")
        self.Public_Health_Entry.configure(insertbackground="black")
        self.Public_Health_Entry.configure(selectbackground="#c4c4c4")
        self.Public_Health_Entry.configure(selectforeground="black")

        self.Oral_Mea_Entry = tk.Entry(Department_Window)
        self.Oral_Mea_Entry.place(relx=0.51,
                                  rely=0.514,
                                  relwidth=0.137,
                                  relheight=0.048)
        self.Oral_Mea_Entry.configure(background="white")
        self.Oral_Mea_Entry.configure(disabledforeground="#a3a3a3")
        self.Oral_Mea_Entry.configure(font="-family {Helvetica} -size 10")
        self.Oral_Mea_Entry.configure(foreground="#000000")
        self.Oral_Mea_Entry.configure(highlightbackground="#d9d9d9")
        self.Oral_Mea_Entry.configure(highlightcolor="black")
        self.Oral_Mea_Entry.configure(insertbackground="black")
        self.Oral_Mea_Entry.configure(selectbackground="#c4c4c4")
        self.Oral_Mea_Entry.configure(selectforeground="black")

        self.Ping_Thread_Entry = tk.Entry(Department_Window)
        self.Ping_Thread_Entry.place(relx=0.51,
                                     rely=0.582,
                                     relwidth=0.137,
                                     relheight=0.048)
        self.Ping_Thread_Entry.configure(background="white")
        self.Ping_Thread_Entry.configure(disabledforeground="#a3a3a3")
        self.Ping_Thread_Entry.configure(font="-family {Helvetica} -size 10")
        self.Ping_Thread_Entry.configure(foreground="#000000")
        self.Ping_Thread_Entry.configure(highlightbackground="#d9d9d9")
        self.Ping_Thread_Entry.configure(highlightcolor="black")
        self.Ping_Thread_Entry.configure(insertbackground="black")
        self.Ping_Thread_Entry.configure(selectbackground="#c4c4c4")
        self.Ping_Thread_Entry.configure(selectforeground="black")

        self.Grand_Total_Entry = tk.Entry(Department_Window)
        self.Grand_Total_Entry.place(relx=0.51,
                                     rely=0.65,
                                     relwidth=0.137,
                                     relheight=0.048)
        self.Grand_Total_Entry.configure(background="white")
        self.Grand_Total_Entry.configure(disabledforeground="#a3a3a3")
        self.Grand_Total_Entry.configure(font="-family {Helvetica} -size 10")
        self.Grand_Total_Entry.configure(foreground="#000000")
        self.Grand_Total_Entry.configure(highlightbackground="#d9d9d9")
        self.Grand_Total_Entry.configure(highlightcolor="black")
        self.Grand_Total_Entry.configure(insertbackground="black")
        self.Grand_Total_Entry.configure(selectbackground="#c4c4c4")
        self.Grand_Total_Entry.configure(selectforeground="black")

        self.Add_Button_ = tk.Button(Department_Window)
        self.Add_Button_.place(relx=0.798,
                               rely=0.311,
                               relwidth=0.078,
                               relheight=0.06)
        self.Add_Button_.configure(activebackground="#ececec")
        self.Add_Button_.configure(activeforeground="#000000")
        self.Add_Button_.configure(background="#d9d9d9")
        self.Add_Button_.configure(disabledforeground="#a3a3a3")
        self.Add_Button_.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Add_Button_.configure(foreground="#000000")
        self.Add_Button_.configure(highlightbackground="#d9d9d9")
        self.Add_Button_.configure(highlightcolor="black")
        self.Add_Button_.configure(pady="0")
        self.Add_Button_.configure(text='''ADD''', command=self.add_item)

        self.Delete_Button = tk.Button(Department_Window)
        self.Delete_Button.place(relx=0.798,
                                 rely=0.392,
                                 relwidth=0.078,
                                 relheight=0.06)
        self.Delete_Button.configure(activebackground="#ececec")
        self.Delete_Button.configure(activeforeground="#000000")
        self.Delete_Button.configure(background="#d9d9d9")
        self.Delete_Button.configure(disabledforeground="#a3a3a3")
        self.Delete_Button.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Delete_Button.configure(foreground="#000000")
        self.Delete_Button.configure(highlightbackground="#d9d9d9")
        self.Delete_Button.configure(highlightcolor="black")
        self.Delete_Button.configure(pady="0")
        self.Delete_Button.configure(text='''DELETE''',
                                     command=self.remove_item)

        self.Update_Button = tk.Button(Department_Window)
        self.Update_Button.place(relx=0.798,
                                 rely=0.474,
                                 relwidth=0.078,
                                 relheight=0.06)
        self.Update_Button.configure(activebackground="#ececec")
        self.Update_Button.configure(activeforeground="#000000")
        self.Update_Button.configure(background="#d9d9d9")
        self.Update_Button.configure(disabledforeground="#a3a3a3")
        self.Update_Button.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Update_Button.configure(foreground="#000000")
        self.Update_Button.configure(highlightbackground="#d9d9d9")
        self.Update_Button.configure(highlightcolor="black")
        self.Update_Button.configure(pady="0")
        self.Update_Button.configure(text='''UPDATE''',
                                     command=self.update_item)

        self.Clear_Button = tk.Button(Department_Window)
        self.Clear_Button.place(relx=0.798,
                                rely=0.555,
                                relwidth=0.078,
                                relheight=0.06)
        self.Clear_Button.configure(activebackground="#ececec")
        self.Clear_Button.configure(activeforeground="#000000")
        self.Clear_Button.configure(background="#d9d9d9")
        self.Clear_Button.configure(disabledforeground="#a3a3a3")
        self.Clear_Button.configure(
            font="-family {Helvetica} -size 13 -weight normal")
        self.Clear_Button.configure(foreground="#000000")
        self.Clear_Button.configure(highlightbackground="#d9d9d9")
        self.Clear_Button.configure(highlightcolor="black")
        self.Clear_Button.configure(pady="0")
        self.Clear_Button.configure(text='''CLEAR''', command=self.clear_text)

        self.Scrolledlistbox3 = ScrolledListBox(Department_Window)
        self.Scrolledlistbox3.place(relx=0.02,
                                    rely=0.717,
                                    relheight=0.253,
                                    relwidth=0.969)
        self.Scrolledlistbox3.configure(background="white")
        self.Scrolledlistbox3.configure(disabledforeground="#a3a3a3")
        self.Scrolledlistbox3.configure(font=font10)
        self.Scrolledlistbox3.configure(foreground="black")
        self.Scrolledlistbox3.configure(highlightbackground="#d9d9d9")
        self.Scrolledlistbox3.configure(highlightcolor="#d9d9d9")
        self.Scrolledlistbox3.configure(selectbackground="#c4c4c4")
        self.Scrolledlistbox3.configure(selectforeground="black")

        self.tr_radio = tk.IntVar(None, 1)
        self.Treated_Radio = tk.Radiobutton(Department_Window)
        self.Treated_Radio.place(relx=0.013,
                                 rely=0.257,
                                 relheight=0.042,
                                 relwidth=0.18)
        self.Treated_Radio.configure(activebackground="#ececec")
        self.Treated_Radio.configure(activeforeground="#000000")
        self.Treated_Radio.configure(background="#d9d9d9")
        self.Treated_Radio.configure(disabledforeground="#a3a3a3")
        self.Treated_Radio.configure(font=font11)
        self.Treated_Radio.configure(foreground="#000000")
        self.Treated_Radio.configure(highlightbackground="#d9d9d9")
        self.Treated_Radio.configure(highlightcolor="black")
        self.Treated_Radio.configure(justify='left')
        self.Treated_Radio.configure(text='''Treated''')
        self.Treated_Radio.configure(value=1)
        self.Treated_Radio.configure(variable=self.tr_radio)

        self.Reffered_Radio = tk.Radiobutton(Department_Window)
        self.Reffered_Radio.place(relx=0.208,
                                  rely=0.257,
                                  relheight=0.042,
                                  relwidth=0.18)
        self.Reffered_Radio.configure(activebackground="#ececec")
        self.Reffered_Radio.configure(activeforeground="#000000")
        self.Reffered_Radio.configure(background="#d9d9d9")
        self.Reffered_Radio.configure(disabledforeground="#a3a3a3")
        self.Reffered_Radio.configure(font=font11)
        self.Reffered_Radio.configure(foreground="#000000")
        self.Reffered_Radio.configure(highlightbackground="#d9d9d9")
        self.Reffered_Radio.configure(highlightcolor="black")
        self.Reffered_Radio.configure(justify='left')
        self.Reffered_Radio.configure(text='''Reffered''')
        self.Reffered_Radio.configure(value=2)
        self.Reffered_Radio.configure(variable=self.tr_radio)

        self.Screened_Radio = tk.Radiobutton(Department_Window)
        self.Screened_Radio.place(relx=0.408,
                                  rely=0.257,
                                  relheight=0.042,
                                  relwidth=0.18)
        self.Screened_Radio.configure(activebackground="#ececec")
        self.Screened_Radio.configure(activeforeground="#000000")
        self.Screened_Radio.configure(background="#d9d9d9")
        self.Screened_Radio.configure(disabledforeground="#a3a3a3")
        self.Screened_Radio.configure(font=font11)
        self.Screened_Radio.configure(foreground="#000000")
        self.Screened_Radio.configure(highlightbackground="#d9d9d9")
        self.Screened_Radio.configure(highlightcolor="black")
        self.Screened_Radio.configure(justify='left')
        self.Screened_Radio.configure(text='''Screened''')
        self.Screened_Radio.configure(value=3)
        self.Screened_Radio.configure(variable=self.tr_radio)

        self.populate_list()

    # Returns the list of all the entries in the window
    def get_entry_object(self):
        entries = [
            self.Date_Entry, self.on_radio, self.Health_Entry, self.From_Entry,
            self.To_Entry, self.Incharge_Entry, self.Phone_Entry,
            self.Endodontics_Entry, self.Periodont_Entry,
            self.Orthodontics_Entry, self.Surgery_Entry, self.Pedodont_Entry,
            self.Oralpatho_Entry, self.Public_Health_Entry,
            self.Oral_Mea_Entry, self.Ping_Thread_Entry, self.tr_radio,
            self.Grand_Total_Entry
        ]
        return entries

    # Adds a row to the database' respective table by getting inputs from entries
    def add_item(self):
        # Getting the values entered in each Entry box objects
        entries = self.get_entry_object()
        for i in range(0, len(entries)):
            entries[i] = entries[i].get()
        self.data.insert("dept", entries)
        self.clear_text()
        self.populate_list()
        print("1 row added")

    # Clears all the data entered in the entries
    def clear_text(self):
        entries = self.get_entry_object()
        for i in range(0, len(entries)):
            try:
                entries[i].delete(0, tk.END)
            except AttributeError:
                pass

    # Returns the item selected in the listbox
    def select_item(self):
        index = self.Scrolledlistbox3.curselection()[0]
        selected_item = self.Scrolledlistbox3.get(index)
        return selected_item

    # Removes the item selected in the listbox
    def remove_item(self):
        selected = self.select_item()
        print(selected[0])
        self.data.remove("dept", selected[0])
        self.populate_list()
        print("Selected Item deleted")

    # Updates the item selected in list box with the values entered in Entry boxes
    def update_item(self):
        selected = self.select_item()
        values = self.get_entry_object()
        # id of new_values is as same as the old value
        new_values = [selected[0]]
        for val in values[1:]:
            new_values.append(val.get())
        self.data.update("dept", new_values)
        self.clear_text()
        self.populate_list()
        print("Selected Item Updated")

    # Updates the list box with the current content of the table
    def populate_list(self):
        self.Scrolledlistbox3.delete(0, tk.END)
        for row in self.data.fetch("dept"):
            self.Scrolledlistbox3.insert(tk.END, row)
        self.count = self.data.get_count("dept")
Esempio n. 8
0
    def __init__(self, main):

        #Janela Principal:
        #fundo branco, 1400x800
        self.main = main
        self.main.config(bg="#FFFFFF")
        self.main.geometry("1400x800")
        self.main.resizable(width=False, height=False)

        #Janela lateral aonde ficara os botoes
        #350x800 | fundo "cinza" | posicionado no lado esquerdo superior
        self.lateral = tk.Frame(self.main, width=300, height=800)
        self.lateral.config(bg="#808080")
        self.lateral.grid(sticky="NW")
        self.lateral.grid_propagate(0)

        #Janela no qual estarao os dados dos produtos
        #1050x490 | fundo cinza claro
        self.tableFrame = tk.Frame(self.main, width=1050, height=490)
        self.tableFrame.config(bg="white")
        self.tableFrame.place(x=843, y=250, anchor="center")

        tabela = pgm.VisualizaTabela(self.tableFrame)

        # Frame para visualizar os outputs e mensagens do sistema
        # 985x220 | fundo cinza claro | desabilitado | e tipo flat
        self.outPutBox = tk.Text(self.main,
                                 background="#F0F0F0",
                                 relief="flat",
                                 font=minhaFont)
        self.outPutBox.place(x=810,
                             y=685,
                             anchor="center",
                             width=985,
                             height=200)

        # Entrys e Labels dos Campos
        entryProduto = tk.Entry(
            self.main,
            fg="#333333",
            bg="#F0F0F0",
            highlightthickness=0,
            bd=0,
            font=pgm.textoEntry,
            width=20,
        )
        entryProduto.insert(0, "Produto")

        # Campo de input de Setor
        entrySetor = ttk.Combobox(
            self.main,
            values=[
                "Biscoitos", "Cereais", "Enlatados", "Farinhas", "Laticinios",
                "Oleos", "Bebidas", "Gelados", "Outros"
            ],
            font=pgm.textoEntry,
        )
        entrySetor.current(0)

        # Campo de input para a data de validade
        entryValidade = DateEntry(self.main, font=pgm.textoEntry)

        # Campo de input para o Id

        idString = tk.StringVar()
        idString.set("ID")

        entryId = tk.Entry(self.main,
                           fg="#333333",
                           bg="#F0F0F0",
                           highlightthickness=0,
                           bd=0,
                           font=pgm.textoEntry,
                           justify="right",
                           textvariable=idString)
        entryId.configure(state="readonly", readonlybackground="#F0F0F0")

        # Estilo do entry Setor
        setorStyle = ttk.Style(self.main)
        setorStyle.map("TCombobox", fieldbackground=[("readonly", "#F0F0F0")])
        setorStyle.configure(
            "my.TCombobox",
            foreground="#333333",
            borderwidth=0,
            relief="flat",
        )

        entrySetor.configure(style="my.TCombobox", state="readonly")

        # Estilo do entry validade
        validadeStyle = ttk.Style(self.main)
        validadeStyle.configure("my.DateEntry",
                                fieldbackground="#F0F0F0",
                                foreground="#333333",
                                borderwidth=0,
                                relief="flat")
        entryValidade.configure(style="my.DateEntry")

        # Posicionamentos dos entries e redimensao das suas propriedades
        entryProduto.place(x=320, y=525, anchor="nw", width=250, height=30)
        entrySetor.place(x=583, y=525, anchor="nw", width=200, height=30)
        entryValidade.place(x=795, y=525, anchor="nw", width=200, height=30)
        entryId.place(x=1008, y=525, anchor="nw", width=80, height=30)

        #Config dos botoes laterais

        largura = 18
        altura = 2

        #--- BotOes do menu Principal ---

        self.btnProcuraArquivo = tk.Button(
            self.lateral,
            text="Abrir Arquivo",
            width=largura,
            height=altura,
            borderwidth=0,
            font=minhaFont,
            bg="white",
            fg="#262626",
            command=lambda: pgm.IniciaArquivo(self.main, tabela))
        self.btnProcuraArquivo.place(relx=0.5, rely=0.55, anchor="center")

        #Adicionar a Imagem para editar item
        imagemLapis = tk.PhotoImage(file="perdasGui/assets/Lapis.png")

        #botao para editar remessa
        self.editarBtn = tk.Button(
            self.main,
            image=imagemLapis,
            relief="flat",
            highlightthickness=0,
            command=lambda: [
                pgm.queryExecuter(operacao=1,
                                  entryProduto=entryProduto,
                                  entrySetor=entrySetor,
                                  entryValidade=entryValidade,
                                  identEntry=entryId),
                pgm.resetaDados(entryProduto, entrySetor, idString, tabela)
            ])
        self.editarBtn.image = imagemLapis
        self.editarBtn.place(x=1185, y=515, anchor="nw", width=50, height=50)

        #Adicionar a Imagem para Excluir o item
        imagemLixo = tk.PhotoImage(file="perdasGui/assets/lixeira1.png")

        self.excluirBtn = tk.Button(
            self.main,
            image=imagemLixo,
            relief="flat",
            highlightthickness=0,
            activebackground="#F2695E",
            bg="#e55a58",
            command=lambda: [
                pgm.queryExecuter(operacao=2,
                                  entryProduto=entryProduto,
                                  entrySetor=entrySetor,
                                  entryValidade=entryValidade,
                                  identEntry=entryId),
                pgm.resetaDados(entryProduto, entrySetor, idString, tabela)
            ])
        self.excluirBtn.image = imagemLixo
        self.excluirBtn.place(x=1243, y=515, anchor="nw", width=50, height=50)

        # Adicionar Imagem de Inserimento de item
        imagemAdicao = tk.PhotoImage(file="perdasGui/assets/sum1.png")

        self.InserirBtn = tk.Button(
            self.main,
            image=imagemAdicao,
            relief="flat",
            highlightthickness=0,
            activebackground="#9AF598",
            bg="#92e891",
            command=lambda: [
                pgm.queryExecuter(0, entryProduto, entrySetor, entryValidade),
                pgm.resetaDados(entryProduto, entrySetor, idString, tabela)
            ])
        self.InserirBtn.image = imagemAdicao
        self.InserirBtn.place(x=1125, y=515, anchor="nw", width=50, height=50)

        # Adicionar a Imagem de logo no corpo lateral
        imagemLogo = Image.open("perdasGui/assets/logo.png")
        logo = ImageTk.PhotoImage(imagemLogo)

        self.labelLogo = tk.Label(self.lateral, image=logo, borderwidth=0)
        self.labelLogo.image = logo

        self.labelLogo.place(relx=0.49, rely=0.3, anchor="center")

        tabela.bind(
            "<Double-1>",
            lambda event: pgm.selecionaItem(event,
                                            entryProduto=entryProduto,
                                            entrySetor=entrySetor,
                                            entryValidade=entryValidade,
                                            idVar=idString))
Esempio n. 9
0
    def __init__(self, schemaobject, cb, *args, **kwargs):
        """edit view/dialog for schema object

        Args:
            schemaobject (schema object or class): If it's object, then it populated edit field of that object. If it's class, then values are set to default.
            cb (function): callback function to be called when object is read for modify/insert
        """

        super().__init__(*args, **kwargs)

        self.cb = cb

        self.frame_container = tk.Frame(self)

        self.binded_vars = {}

        if (inspect.isclass(schemaobject)):
            self.originalobject = None
            self.schemaobject = schemaobject()
            self.title('Novi objekt')
        else:
            self.originalobject = schemaobject
            self.schemaobject = copy.deepcopy(schemaobject)
            self.title('Objekt {}'.format(
                schemaobject.getPKfield().getValueSQL()))

        for i, (field_name, mstype) in enumerate(schemaobject.fields.items()):
            entry_label = tk.Label(self.frame_container,
                                   text="{} [{}]".format(
                                       field_name, mstype.DESCRIPTOR))
            self.binded_vars[field_name] = {'type': mstype}

            if (type(mstype) in (MSInt, MSBigInt, MSBit)):
                binded_var = tk.IntVar()
            else:
                binded_var = tk.StringVar()

            self.binded_vars[field_name]['var'] = binded_var

            if (mstype.getValue() is not None):
                binded_var.set(mstype.getValue())

            main_entry = tk.Entry(self.frame_container,
                                  textvariable=binded_var)

            if (isinstance(mstype, MSDatetime)):
                main_entry = DateEntry(self.frame_container,
                                       width=12,
                                       background='darkblue',
                                       foreground='white',
                                       borderwidth=2,
                                       state="readonly")
                date_val = mstype.getValue()
                if (date_val is not None):
                    main_entry.set_date(date_val)
                self.binded_vars[field_name]['var'] = main_entry

            elif (isinstance(mstype, MSBit)):
                main_entry = tk.Checkbutton(self.frame_container)
                if (binded_var.get() == 1):
                    main_entry.select()
                main_entry.configure(variable=binded_var)

            self.binded_vars[field_name]['control'] = main_entry

            entry_label.grid(row=i, column=0)
            main_entry.grid(row=i, column=1)

            if (mstype.isNull):
                isnullvar = tk.IntVar()
                self.binded_vars[field_name]['null'] = isnullvar

                checkboxbtn = tk.Checkbutton(
                    self.frame_container,
                    text='NULL',
                    command=lambda main_entry=main_entry, isnullvar=isnullvar:
                    toggleMe(isnullvar, main_entry))
                if (mstype.getValue() is None):
                    isnullvar.set(1)
                    checkboxbtn.select()
                    toggleMe(isnullvar, main_entry)
                checkboxbtn.configure(variable=isnullvar)
                checkboxbtn.grid(row=i, column=2)

        if (self.originalobject is None):
            button_text = "Kreiraj"
        else:
            button_text = "Shrani"

        tk.Button(self.frame_container,
                  text=button_text,
                  command=self.parseObject).grid(row=i + 1,
                                                 columnspan=3,
                                                 ipadx=20,
                                                 pady=10)

        self.frame_container.pack()
Esempio n. 10
0
class student:
    def __init__(self, win):
        self.win = win
        self.win.title("Registro Estudiante")
        self.win.resizable(0, 0)  #Quitar el rezisable

        ################## Menu Bar ################
        self.menu_bar = tk.Menu(win)
        self.my_dropdown_menu = tk.Menu(self.menu_bar, tearoff=1)
        ### Clear option
        self.my_dropdown_menu.add_command(label="New")
        self.menu_bar.add_cascade(label='File', menu=self.my_dropdown_menu)
        self.win.configure(menu=self.menu_bar)
        ################## Labels ################## ipadx=genera espaciamiento entre el elemento X
        tk.Label(win, text="Carrera: ").grid(row=1,
                                             column=2,
                                             sticky='W',
                                             ipadx=5)
        #tk.Label(win,text='Código: ').grid(row=1,column=0,sticky='W',ipadx=5)
        tk.Label(win, text='Nombres: ').grid(row=1,
                                             column=0,
                                             sticky='W',
                                             ipadx=5)
        tk.Label(win, text='Apellidos: ').grid(row=2,
                                               column=0,
                                               sticky='W',
                                               ipadx=5)
        tk.Label(win, text='DNI: ').grid(row=3, column=0, sticky='W', ipadx=5)
        tk.Label(win, text='Fecha.Nac: ').grid(row=4,
                                               column=0,
                                               sticky='W',
                                               ipadx=5)
        tk.Label(win, text="Facultad: ").grid(row=2,
                                              column=2,
                                              sticky='W',
                                              ipadx=5)
        tk.Label(win, text="Ciclo: ").grid(row=3,
                                           column=2,
                                           sticky='W',
                                           ipadx=5)

        ################# TextBoxes ####################
        self.read = "readonly"
        self.normal = "normal"
        #self.codigo = tk.Entry(win)
        # self.codigo.grid(row=1,column=1,sticky="W")
        self.nombre = tk.Entry(win, state=self.read)  #Nombres
        self.nombre.grid(row=1, column=1, sticky="W")
        self.apell = tk.Entry(win, state=self.read)  #Apellidos
        self.apell.grid(row=2, column=1, sticky="W")
        self.dni = tk.Entry(win, state=self.read)
        self.dni.grid(row=3, column=1, sticky="W")
        self.cboCarrera = ttk.Combobox(win,
                                       width=17,
                                       state="disabled",
                                       values=("Select..", "Ing.Sistemas",
                                               "Ing.Mecatronica", "Ing.Civil",
                                               "Arquitectura", "Periodismo"))
        self.cboCarrera.current(0)
        self.cboCarrera.grid(row=1, column=3, sticky="W")
        self.cboCarrera.bind("<<ComboboxSelected>>", self.news_election)

        self.facultad = tk.Entry(win, bg="#cdcdcd", state=self.read)
        self.facultad.grid(row=2, column=3, sticky="W")  #Facultad

        self.ciclo = tk.Spinbox(from_=1, to=10, width=5, state=self.read)
        self.ciclo.grid(row=3, column=3, sticky="W")

        self.fec_nac = DateEntry(win,
                                 width=17,
                                 background='darkblue',
                                 foreground='white',
                                 borderwidth=2,
                                 date_pattern="dd/MM/yyyy",
                                 state="disabled")
        self.fec_nac.grid(row=4, column=1, sticky="W")
        #self.fec_nac.get_date()
        #print(str(date).split("-"))

        ############# TABLE ##################
        #### "browse" permite solo seleccionar 1 fila, "extended" permite seleccionar múltiples, "none" no permite seleccionar ninguna fila
        self.tree = ttk.Treeview(win,
                                 selectmode="browse",
                                 columns=(0, 1, 2, 3, 4, 5, 6))
        #self.tree.grid(row=7,column=0,columnspan=35,padx=10,sticky="W")
        ###### SCROLL BAR VERTICAL && HORIZONTAL ######
        self.vsb = ttk.Scrollbar(win,
                                 orient="vertical",
                                 command=self.tree.yview)
        self.vsb.grid(row=7, column=5, sticky="NS", pady=10)
        self.hsb = ttk.Scrollbar(win,
                                 orient="horizontal",
                                 command=self.tree.xview)
        self.hsb.grid(row=9, column=0, columnspan=5, sticky="EW")

        self.tree.configure(yscrollcommand=self.vsb.set, xscroll=self.hsb.set)
        self.tree.grid(row=7, column=0, columnspan=5, pady=10, padx=5)

        ###### COLUMNS ######
        self.tree.heading('#0', text='Codigo',
                          anchor="center")  #Posicionar el centro el contenido
        self.tree.column('#0',
                         minwidth=0,
                         width=60,
                         stretch=tk.NO,
                         anchor="center")
        ######
        self.tree.heading('#1', text='Nombres', anchor="center")
        self.tree.column('#1',
                         minwidth=0,
                         width=100,
                         stretch="NO",
                         anchor="center")
        ######
        self.tree.heading('#2', text='Apellidos', anchor="center")
        self.tree.column('#2',
                         minwidth=0,
                         width=100,
                         stretch="NO",
                         anchor="center")
        ######
        self.tree.heading('#3', text='DNI', anchor="center")
        self.tree.column('#3',
                         minwidth=0,
                         width=100,
                         stretch="NO",
                         anchor="center")
        ######
        self.tree.heading('#4', text='Fec.Nac', anchor="center")
        self.tree.column('#4',
                         minwidth=0,
                         width=80,
                         stretch="NO",
                         anchor="center")
        ######
        self.tree.heading('#5', text='Carrera', anchor="center")
        self.tree.column('#5',
                         minwidth=0,
                         width=100,
                         stretch="NO",
                         anchor="center")
        ######
        self.tree.heading('#6', text='Facultad', anchor=tk.CENTER)
        self.tree.column('#6',
                         minwidth=0,
                         width=100,
                         stretch="NO",
                         anchor="center")
        ######
        self.tree.heading('#7', text='Ciclo', anchor="center")
        self.tree.column('#7',
                         minwidth=0,
                         width=60,
                         stretch="NO",
                         anchor="center")
        ######

        ############### BUTTONS ############### (ipadx genera alargamiento horizontal del elemento)
        ttk.Button(win, text="Nuevo",
                   command=self.unlocking_boxes).grid(row=1,
                                                      column=4,
                                                      ipadx=50,
                                                      sticky=tk.W + tk.E)
        ttk.Button(win, text="Grabar",
                   command=self.insert_data).grid(row=2,
                                                  column=4,
                                                  sticky=tk.W + tk.E)
        ttk.Button(win, text="Editar",
                   command=self.update_student).grid(row=3,
                                                     column=4,
                                                     sticky=tk.W + tk.E)
        ttk.Button(win, text="Eliminar",
                   command=self.delete_student).grid(row=4,
                                                     column=4,
                                                     sticky=tk.W + tk.E)

    def news_election(self, event):
        response = str(event.widget.get())
        if response.startswith("Ing."):
            self.facultad.delete(0, tk.END)
            self.facultad.insert(0, "Ingenieria")
            #self.new_faculty.insert(0,"Ingenieria")
        elif response.startswith("Arquitectura"):
            self.facultad.delete(0, tk.END)
            self.facultad.insert(0, "Arquitectura")
            #self.new_faculty.insert(0,"Arquitectura")
        elif response.startswith("Periodismo"):
            self.facultad.delete(0, tk.END)
            self.facultad.insert(0, "Comunicaciones")
            #self.new_faculty.insert(0,"Comunicaciones")
        #print('selected:', event.widget.get())

    def unlocking_boxes(self):
        # if self.cboCarrera.current()==0:
        #     self.facultad.configure(text="Seleccionado")
        return self.nombre.configure(state=self.normal), self.apell.configure(
            state=self.normal), self.dni.configure(
                state=self.normal), self.fec_nac.configure(
                    state=self.normal), self.cboCarrera.configure(
                        state=self.normal), self.facultad.configure(
                            state=self.normal), self.ciclo.configure(
                                state=self.normal), self.fec_nac.configure(
                                    state=self.normal)

    def locking_boxes(self):
        return self.nombre.configure(state=self.read), self.apell.configure(
            state=self.read), self.dni.configure(
                state=self.read), self.fec_nac.configure(
                    state="disabled"), self.cboCarrera.configure(
                        state="disabled"), self.facultad.configure(
                            state=self.read), self.ciclo.configure(
                                state=self.read)

    # def create_table():
    #     try:
    #         sql = '''CREATE TABLE ESTUDIANTE(        id_est int NOT NULL AUTOINCREMENT
    #                                                 ,nombres varchar(30)
    #                                                 ,apell varchar(30)
    #                                                 ,dni varchar(8)
    #                                                 ,fech_nac date
    #                                                 ,carrera varchar(20)
    #                                                 ,facultad varchar(20)
    #                                                 ,ciclo int
    #                                                 ,PRIMARY KEY(id_est))'''
    #         run_query(sql)
    #     except Exception as e:
    #         print(e)

    def clear_boxes(self):
        #self.codigo.delete(0,tk.END)
        self.nombre.delete(0, tk.END)
        self.apell.delete(0, tk.END)
        self.dni.delete(0, tk.END)
        self.cboCarrera.delete(0, tk.END)
        self.facultad.delete(0, tk.END)
        self.ciclo.delete(0, tk.END)

    def insert_data(self):
        sql = '''
                            INSERT INTO ESTUDIANTE(nombres,apell,dni,fech_nac,carrera,facultad,ciclo) values(?,?,?,?,?,?,?)
                        '''
        data = (self.nombre.get(), self.apell.get(), self.dni.get(),
                self.fec_nac.get_date(), self.cboCarrera.get(),
                self.facultad.get(), self.ciclo.get())
        try:
            self.run_query(sql, data)
            print("Student added successfully")
            self.clear_boxes()
            self.list_students()
            self.locking_boxes()
        except Exception as e:
            print(e)

    def db_connect(self):
        try:
            myConnection = sqlite3.connect('data.db')
            return myConnection
        except Exception as e:
            tk.messagebox(e)

    def run_query(self, query, parameters=()):
        with sqlite3.connect('data.db') as myConnection:
            myCursor = myConnection.cursor()
            result = myCursor.execute(query, parameters)
            myConnection.commit()
        return result

    def list_students(self):
        records = self.tree.get_children()
        #Cleaning table
        for element in records:
            self.tree.delete(element)
        #Querying data
        sql = "SELECT * FROM ESTUDIANTE"
        tb_rows = self.run_query(sql)
        # myCursor.execute(sql)
        # students = myCursor.fetchall()
        for row in tb_rows:
            self.tree.insert(
                '', 0, text=row[0], values=row[1:]
            )  #Comienza del elem 0, luego aplica apartir del primer campo hasta el final

    # def search_student(self,cod):
    #     sql = f"SELECT * FROM ESTUDIANTE WHERE id_est = {cod}"
    #     myCursor.execute(sql)
    #     student = myCursor.fetchall()
    #     myConnection.commit()
    #     print(student)

    def update_student(self):

        row = self.tree.item(self.tree.selection())['text']
        old_name = self.tree.item(self.tree.selection())['values'][0]
        old_lastname = self.tree.item(self.tree.selection())['values'][1]
        old_dni = self.tree.item(self.tree.selection())['values'][2]
        old_fec_nac = self.tree.item(self.tree.selection())['values'][3]
        old_career = self.tree.item(self.tree.selection())['values'][4]
        old_faculty = self.tree.item(self.tree.selection())['values'][5]
        old_term = self.tree.item(self.tree.selection())['values'][6]
        self.edit_wind = tk.Toplevel()
        self.edit_wind.title("Modifying Student")

        #### OLD ####
        tk.Label(self.edit_wind, text="Old Name: ").grid(row=0, column=1)
        tk.Entry(self.edit_wind,
                 textvariable=tk.StringVar(self.edit_wind, value=old_name),
                 state="readonly").grid(row=0, column=2)
        tk.Label(self.edit_wind, text="Old Last Name: ").grid(row=1, column=1)
        tk.Entry(self.edit_wind,
                 textvariable=tk.StringVar(self.edit_wind, value=old_lastname),
                 state="readonly").grid(row=1, column=2)
        tk.Label(self.edit_wind, text="Old DNI: ").grid(row=2, column=1)
        tk.Entry(self.edit_wind,
                 textvariable=tk.StringVar(self.edit_wind, value=old_dni),
                 state="readonly").grid(row=2, column=2)
        tk.Label(self.edit_wind, text="Old Birth Date: ").grid(row=3, column=1)
        tk.Entry(self.edit_wind,
                 textvariable=tk.StringVar(self.edit_wind, value=old_fec_nac),
                 state="readonly").grid(row=3, column=2)
        tk.Label(self.edit_wind, text="Old Career: ").grid(row=4, column=1)
        tk.Entry(self.edit_wind,
                 textvariable=tk.StringVar(self.edit_wind, value=old_career),
                 state="readonly").grid(row=4, column=2)
        tk.Label(self.edit_wind, text="Old Faculty: ").grid(row=5, column=1)
        tk.Entry(self.edit_wind,
                 textvariable=tk.StringVar(self.edit_wind, value=old_faculty),
                 state="readonly").grid(row=5, column=2)
        tk.Label(self.edit_wind, text="Old Term: ").grid(row=6, column=1)
        tk.Entry(self.edit_wind,
                 textvariable=tk.StringVar(self.edit_wind, value=old_term),
                 state="readonly").grid(row=6, column=2)

        #### NEW ONE ####
        tk.Label(self.edit_wind, text="New Name: ").grid(row=0, column=3)
        new_name = tk.Entry(self.edit_wind)
        new_name.grid(row=0, column=4)
        #######
        tk.Label(self.edit_wind, text="New Last Name: ").grid(row=1, column=3)
        new_lastname = tk.Entry(self.edit_wind)
        new_lastname.grid(row=1, column=4)
        #######
        tk.Label(self.edit_wind, text="New DNI: ").grid(row=2, column=3)
        new_dni = tk.Entry(self.edit_wind)
        new_dni.grid(row=2, column=4)
        #######
        tk.Label(self.edit_wind, text="New Fec.Nac: ").grid(row=3, column=3)
        new_fec_nac = DateEntry(self.edit_wind,
                                width=17,
                                background='darkblue',
                                foreground='white',
                                borderwidth=2,
                                date_pattern="dd/MM/yyyy")
        new_fec_nac.grid(row=3, column=4)

        def news_election_edit(event):
            response = str(event.widget.get())
            if response.startswith("Ing."):
                new_faculty.delete(0, tk.END)
                new_faculty.insert(0, "Ingenieria")
            elif response.startswith("Arquitectura"):
                new_faculty.delete(0, tk.END)
                new_faculty.insert(0, "Arquitectura")
            elif response.startswith("Periodismo"):
                new_faculty.delete(0, tk.END)
                new_faculty.insert(0, "Comunicaciones")

        #######
        tk.Label(self.edit_wind, text="New Career: ").grid(row=4, column=3)
        new_career = ttk.Combobox(self.edit_wind,
                                  width=17,
                                  values=('Select...', 'Ing.Sistemas',
                                          'Ing.Mecatronica', 'Ing.Civil',
                                          'Arquitectura', 'Periodismo'))
        new_career.current(0)
        new_career.grid(row=4, column=4)
        new_career.bind("<<ComboboxSelected>>", news_election_edit)
        #######
        tk.Label(self.edit_wind, text="New Faculty: ").grid(row=5, column=3)
        new_faculty = tk.Entry(self.edit_wind, bg="#cdcdcd")
        new_faculty.grid(row=5, column=4)
        #######
        tk.Label(self.edit_wind, text="New Term: ").grid(row=6, column=3)
        new_term = tk.Spinbox(self.edit_wind, from_=1, to=10, width=5)
        new_term.grid(row=6, column=4)

        ####### BUTTONS #######
        tk.Button(
            self.edit_wind,
            text="Save",
            command=lambda: self.edit_records(
                new_name.get(), old_name, new_lastname.get(), old_lastname,
                new_dni.get(), old_dni, new_fec_nac.get_date(), old_fec_nac,
                new_career.get(), old_career, new_faculty.get(), old_faculty,
                new_term.get(), old_term)).grid(row=7,
                                                column=0,
                                                columnspan=3,
                                                sticky=tk.E + tk.W)
        tk.Button(self.edit_wind,
                  text="Cancel",
                  command=lambda: self.edit_wind.destroy()).grid(row=7,
                                                                 column=3,
                                                                 columnspan=2,
                                                                 sticky=tk.E +
                                                                 tk.W)
        # sql = f"UPDATE ESTUDIANTE SET dni={dni} WHERE id_est={cod}"
        # try:
        #     myCursor.execute(sql)
        #     myConnection.commit()
        #     print("Student was updated successfully!")
        #     listStudents()
        # except Exception as e:
        #     print(e)
    def edit_records(self, new_name, nombres, new_lastname, apell, new_dni,
                     dni, new_fec_nac, fech_nac, new_career, carrera,
                     new_faculty, facultad, new_term, ciclo):
        sql = "UPDATE ESTUDIANTE SET nombres = ?,apell = ?,dni = ?, fech_nac = ?, carrera = ?, facultad = ?, ciclo = ? WHERE nombres = ? AND apell = ? AND dni = ? AND fech_nac = ? AND carrera = ? AND facultad = ? AND ciclo = ?"
        parameters = (new_name, new_lastname, new_dni, new_fec_nac, new_career,
                      new_faculty, new_term, nombres, apell, dni, fech_nac,
                      carrera, facultad, ciclo)
        self.run_query(sql, parameters)
        self.edit_wind.destroy()
        tk.messagebox.showinfo(title=None,
                               message="Student updated successfully")
        self.list_students()

    def delete_student(self):
        try:
            row = self.tree.item(self.tree.selection())['text']
            sql = f"DELETE FROM ESTUDIANTE WHERE id_est = ?"
            self.run_query(sql, (row, ))
            #tk.messagebox.showinfo(title=None, message="Student deleted successfully")
            self.list_students()
        except:
            tk.messagebox.showinfo(title=None, message="Error")