1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| #!/usr/bin/PYTHON
# -*-coding:utf-8 -*
import sqlite3
from tkinter import *
from tkinter import ttk
class Pdf:
def __init__(self):
self.root_expired_list_part = Tk()
self.root_expired_list_part.title("Parts Expired List")
self.root_expired_list_part.iconbitmap("data/logo.ico")
self.root_expired_list_part.geometry("720x350+200+100")
self.root_expired_list_part.resizable(width=FALSE, height=FALSE)
self.root_expired_list_part.grab_set()
# Treeview
self.tree_expired_list = ttk.Treeview(self.root_expired_list_part, columns=(1, 2), height=5, show="headings")
self.tree_expired_list.place(width=600, height=330)
# Scrollbar
self.vsb_exp_list = ttk.Scrollbar(self.root_expired_list_part, orient="vertical", command=self.tree_expired_list.yview)
self.vsb_exp_list.place(x=600, height=330)
self.tree_expired_list.configure(yscrollcommand=self.vsb_exp_list.set)
self.hsb_exp_list = ttk.Scrollbar(self.root_expired_list_part, orient="horizontal", command=self.tree_expired_list.xview)
self.hsb_exp_list.place(y=330, width=600)
self.tree_expired_list.configure(xscrollcommand=self.hsb_exp_list.set)
# Display database expired in treeview object
self.conn = sqlite3.connect('data/date_list.db')
self.cursor = self.conn.cursor()
self.select = self.cursor.execute("SELECT * FROM date ORDER BY date DESC")
for row in self.select:
self.tree_expired_list.insert('', END, value=row)
# Create column's name & size
# Column name
self.tree_expired_list.heading(1, text="ID")
self.tree_expired_list.heading(2, text="Date")
# Column size
self.tree_expired_list.column(1, width=40)
self.tree_expired_list.column(2, width=100)
conn.close()
# Buttons
self.button_cancel = ttk.Button(self.root_expired_list_part, text="Cancel", command=self.root_expired_list_part.destroy)
self.button_cancel.place(x=630, y=305, width=80, height=35)
self.root_expired_list_part.mainloop()
Pdf.__call__() |
Partager