""" A program that stores this book information Title, Author Year, ISBN User can: View all records Search an entry Add entry Update entry Delete Close """ from tkinter import * from backend import Database database = Database("db.lite") window = Tk() window.wm_title("BookStore") def popupmsg(msg): FONT = ("VERDANA", 12) popup = Tk() popup.wm_title("!") label = Label(popup, text=msg, font=FONT) label.pack(side="top", fill="x", pady=10) b1 = Button(popup, text="Okay", command=popup.destroy) b1.pack() popup.mainloop()
#! python3 from tkinter import * from backend import Database database = Database('books.db') def get_selected_row(event): global selected_tuple try: index = list1.curselection()[0] selected_tuple = list1.get(index) e1.delete(0, END) e1.insert(END, selected_tuple[1]) e2.delete(0, END) e2.insert(END, selected_tuple[2]) e3.delete(0, END) e3.insert(END, selected_tuple[3]) e4.delete(0, END) e4.insert(END, selected_tuple[4]) except IndexError: pass def view_command(): list1.delete(0, END) for row in database.view(): list1.insert(END, row) def search_command():
from tkinter import * from backend import Database database = Database() def get_selected_row(event): global selected_tuple index def view_command(): list1.delete(0, END) for row in backend.view(): list1.insert(END, row) def search_command(): list1.delete(0, END) for row in backend.search(title_text.get(), author_text.get(), year_text.get(), isbn_text.get()): list1.insert(END, row) def add_command(): backend.insert(title_text.get(), author_text.get(), year_text.get(), isbn_text.get()) list1.delete(0, END) list1.insert(END, (title_text.get(), author_text.get(), year_text.get(), isbn_text.get()))
import tkinter as tk import tkinter.ttk as ttk from backend import Database database = Database("db1.db") window = tk.Tk() window.title("Asset Manager") window.geometry("850x520") menu = tk.Menu(window) menu.add_command(label="Addition", command=lambda: addition_frame()) menu.add_command(label="Search", command=lambda: switch_frame(search_frame)) menu.add_command(label="Records", command=lambda: switch_frame(records_frame)) menu.add_command(label="Order", command=lambda: switch_frame(order_frame)) window.configure(menu=menu) def switch_frame(frame): new_frame = frame() if frame is not None: frame = tk.Frame.destroy() new_frame = frame() new_frame.pack() def addition_frame(): options = ("COMPUTERS", "FURNITURES", "SERVERS", "OFFICE_EQUIPMENTS") description = tk.StringVar() tag_number = tk.StringVar() serial_number = tk.StringVar() category = tk.StringVar()
# Location of 'hosts' file and redirect address host_path = "C:\\Windows\\System32\\drivers\\etc\\hosts" redirect = "127.0.0.1" selected_tuple = () website_list = [] # Flag of clearing the entry field check = 1 # Working hours of the program begin = 8 end = 18 # Class of database from 'backend.py' db = Database("sites.db") # Regular expressions for checking the correct site name pattern1 = "^w{3}\.\w+\.[a-z]+$" pattern2 = "^[^w]{3}\w+\.[a-z]+$" def get_selected_row( event): # Put the selected site from the listbox into the entry field try: global selected_tuple, check check += 1 index = list1.curselection()[0] selected_tuple = list1.get(index) e1.delete(0, END) e1.insert(END, selected_tuple[1])
class MyGrid(Widget): loc = ObjectProperty(None) time = ObjectProperty(None) numOfRec = ObjectProperty(None) def __init__(self, **kwargs): super().__init__(**kwargs) self.database = Database() def submit_btn_handler(self): """ submit button handler this function collect the data from the user input and send it to the backend side :return: None if the input is invalid """ loc = self.loc.text time = self.time.text nor = self.numOfRec.text print("location: ", loc, "time: ", time, "Recommendation number: ", nor) valid_input = self.validate_input(loc, time, nor) if not valid_input: return recommendation_list = self.database.recommend(loc, time, nor) popup = MyPopup() popup.set_title("System Recommendation") popup.set_msg("We Recommend you to travel to:\n" + "\n".join(recommendation_list)) popup.open() self.loc.text = "" self.time.text = "" self.numOfRec.text = "" def validate_input(self, location, d_time, rec_number): """ This function validate the input of the user for date validate that d_time is fro the form of DD/MM/YYYY for location must be exist in the database for rec_number must be a integer number :param location: string location to check :param d_time: string duration time to check :param rec_number: recommendation number to check :return: True if all the variable satisfied the constraints False otherwise """ popup = MyPopup() popup.set_title("Input Error") """validate if location exist in the DB""" if not self.database.is_location_exist(location): popup.set_msg("location cant be found") popup.open() return False """check if duration time is an integer number""" try: int(d_time) except: popup.set_msg("time must be an integer number") popup.open() return False try: int(rec_number) except: popup.set_msg( "number of recommendation\nmust be an integer number") popup.open() return False return True
class Frontend: def __init__(self): self.database = Database("lite.db") def get_selected_row(self, event): title.delete(0, END) author.delete(0, END) year.delete(0, END) isbn.delete(0, END) global currentItem list_size = listbox.size() if list_size != 0: index = listbox.curselection() currentItem = listbox.get(index) title.insert(0, currentItem[1]) author.insert(0, currentItem[2]) year.insert(0, currentItem[3]) isbn.insert(0, currentItem[4]) def view_command(self): listbox.delete(0, END) for row in self.database.view(): listbox.insert(END, row) def search_command(self): listbox.delete(0, END) author = get_close_matches(author_text.get(), self.database.view_authors(), n=10, cutoff=0.3) title = get_close_matches(title_text.get(), self.database.view_titles(), n=10, cutoff=0.2) isbn = get_close_matches(isbn_text.get(), self.database.view_isbn(), n=10, cutoff=0.2) #combinations of queries #get author's book from specific year if author != [] and year_text.get() != "": for row in self.database.search(title_text.get(), author[0], year_text.get(), isbn_text.get()): listbox.insert(END, row) elif title != []: for row in self.database.search(title[0], "", "", ""): listbox.insert(END, row) elif author != []: for row in self.database.search("", author[0], "", ""): listbox.insert(END, row) elif isbn != []: for row in self.database.search("", "", "", isbn[0]): listbox.insert(END, row) elif year_text.get() != "": for row in self.database.search(title_text.get(), author_text.get(), year_text.get(), isbn_text.get()): listbox.insert(END, row) def add_command(self): self.database.insert(title_text.get(), author_text.get(), year_text.get(), isbn_text.get()) #show added book self.search_command() title.delete(0, END) author.delete(0, END) year.delete(0, END) isbn.delete(0, END) def delete_command(self): self.database.delete(currentItem[0]) self.view_command() def update_command(self): self.database.update(currentItem[0], title_text.get(), author_text.get(), year_text.get(), isbn_text.get()) self.view_command()
from tkinter import * from backend import Database database = Database("bookstore.db") #Function for Listbox Select Event def get_selected_row(event): try: global selected_row index = list1.curselection()[0] selected_row = list1.get(index) e1.delete(0, END) e1.insert(END, selected_row[1]) e2.delete(0, END) e2.insert(END, selected_row[2]) e3.delete(0, END) e3.insert(END, selected_row[3]) e4.delete(0, END) e4.insert(END, selected_row[4]) except IndexError: pass #Backend Function Wrapper def view_command(): list1.delete(0, END) for row in database.view(): list1.insert(END, row)
from tkinter import * from backend import Database db = Database('books.db') class Window(object): def __init__(self, window): self.window = window self.window.title("Book Store Management") l1 = Label(window, text="Title") l1.grid(row=0, column=0) l2 = Label(window, text="Author") l2.grid(row=0, column=2) l3 = Label(window, text="Year") l3.grid(row=1, column=0) l4 = Label(window, text="ISBN") l4.grid(row=1, column=2) self.title_text = StringVar() self.e1 = Entry(window, textvariable=self.title_text) self.e1.grid(row=0, column=1) self.author_text = StringVar() self.e2 = Entry(window, textvariable=self.author_text)
from tkinter import * from backend import Database database = Database("bookinventory.db") def get_selected_row(event): global selected_row try: index = list1.curselection()[0] selected_row = list1.get(index) e1.delete(0, END) e1.insert(END, selected_row[1]) e2.delete(0, END) e2.insert(END, selected_row[2]) e3.delete(0, END) e3.insert(END, selected_row[3]) e4.delete(0, END) e4.insert(END, selected_row[4]) except IndexError: pass def view_command(): list1.delete(0, END) for row in database.view_all(): list1.insert(END, row) def search_command(): list1.delete(0, END)
""" A program that creates a Desktop Application widget that stores contact information inside database """ import tkinter as tk from backend import Database database = Database("contacts.db") class Window: """Window class that creates the PhoneBook Widget, formats the display and calls the instance methods when buttons are clicked """ def __init__(self, window): """Initializer / Instance Attributes""" self.window = window self.window.wm_title("PhoneBook Widget") first = tk.Label(window, text="First") first.grid(row=0, column=0) last = tk.Label(window, text="Last") last.grid(row=0, column=2) cell = tk.Label(window, text="Cell") cell.grid(row=1, column=0) email = tk.Label(window, text="Email") email.grid(row=1, column=2)
from tkinter import * from backend import Database database = Database("Books.db") def get_selected_row(event): global selected_tuple index = list1.curselection()[0] selected_tuple = list1.get(index) e1.delete(0, END) e1.insert(END, selected_tuple[1]) e3.delete(0, END) e3.insert(END, selected_tuple[2]) e2.delete(0, END) e2.insert(END, selected_tuple[3]) e4.delete(0, END) e4.insert(END, selected_tuple[4]) def view_command(): list1.delete(0, END) for row in database.view(): list1.insert(END, row) def search_command(): list1.delete(0, END) for row in database.search(title_text.get(), author_text.get(), year_text.get(), isbn_text.get()): list1.insert(END, row)
# \\\ | √ ensure refresh happens after each action # /// | - begin window with a view_command() so that the list appears. # \\\ | - make adding duplicates impossible by running a search and erroring # /// | - test that scrollbar actually works # \\\ | - make standalone and make db save itself # /// | - make update print out name of updated item # \\\ | - make the frontend OOP # /// | # \\\ | ------------------------------------- # /// from tkinter import * # import (no longer used) from backend import Database database = Database("books.db") print("Frontend initialized.") database.view() # ============================================ # ======= F U N C T I O N S ################## # ============================================ def get_selected_row(event): # index=list1.curselection() # print("the current selection is: ") # print(index) # needs to change to a selected Tuple,
from tkinter import Label, StringVar, Entry, Button, messagebox from backend import Database database = Database("bank.db") class CreateAccount: def __init__(self, create_account): self.create_account = create_account self.create_account.wm_title('Ajeet Bank') self.create_account.resizable(0, 0) name_lbl = Label(create_account, text="Name") name_lbl.grid(row=0, column=0) bal_lbl = Label(create_account, text="Balance") bal_lbl.grid(row=0, column=2) account_lbl = Label(create_account, text='Account No.') account_lbl.grid(row=1, column=0) address_lbl = Label(create_account, text="Address") address_lbl.grid(row=1, column=2) name_value = StringVar() self.name_entry = Entry(create_account, textvariable=name_value) self.name_entry.grid(row=0, column=1) self.name_entry.focus() self.name_entry.bind('<Return>', lambda func1: self.balance_entry.focus()) balance_value = StringVar() self.balance_entry = Entry(create_account, textvariable=balance_value) self.balance_entry.grid(row=0, column=3) self.balance_entry.bind('<Return>', lambda func1: self.account_entry.focus())
from tkinter import * from student import Student from backend import Database from major import Major from courses import Courses from course import Course database = Database("StudentPortal") class Window(): """ This class creates the GUI. It pops up to the user, some screens in order to insert and list data """ def __init__(self, window): self.window = window self.window.wm_title("Student portal") b1 = Button(window, text="Insert student", command=self.add_student) b1.grid(row=0, column=0) b2 = Button(window, text="List all students", command=self.list_student) b2.grid(row=1, column=0) b3 = Button(window, text="Insert major", command=self.add_major) b3.grid(row=0, column=1) b4 = Button(window, text="List all majors", command=self.list_major) b4.grid(row=1, column=1) b5 = Button(window,
from tkinter import * from backend import Database #Frontend classes/objects database=Database("book.db") def get_selected_row(event): global selected_tuple index.list1.curselection() selected_tuple=list1.get(index) e1.delete(0,END) e1.insert(END,selected_tuple[1]) e2.delete(0,END) e2.insert(END,selected_tuple[2]) e3.delete(0,END) e3.insert(END,selected_tuple[3]) e4.delete(0,END) e4.insert(END,selected_tuple[4]) def view_command(): list1.delete(0,END) for row in database.view(): list1.insert(END,row) def search_command(): list1.delete(0,END) for row in database.search(title_text.get(),author_text.get(),year_text.get(),isbn_text.get()): list1.insert(END,row) def add_command():
from tkinter import * from backend import Database database = Database("reminder.db") class Window(object): def __init__(self, window): self.window = window self.window.wm_title("Reminder") l1 = Label(window, text="Title") l1.grid(row=0, column=0) l2 = Label(window, text="Description") l2.grid(row=0, column=2) l3 = Label(window, text="Time") l3.grid(row=1, column=0) l4 = Label(window, text="status") l4.grid(row=1, column=2) self.title_text = StringVar() self.e1 = Entry(window, textvariable=self.title_text) self.e1.grid(row=0, column=1) self.description_text = StringVar() self.e2 = Entry(window, textvariable=self.description_text)
from datetime import datetime from random import shuffle import tkinter from tkinter import messagebox from backend import Database database = Database('multi-13-runs.db') class Interface: """tk interface for Multi-13.""" def __init__(self): self.time_start = None self.time_stop = None self.RECORDS = [] # Collect data from each completed row. self.MULTIPLE = 13 # Highest multiple to use. self.CURRENT = 1 self.window = tkinter.Tk() self.window.wm_title("Multi-Thirteen") self.menu_bar = tkinter.Menu(self.window) self.file_menu = tkinter.Menu(self.menu_bar, tearoff=0) self.file_menu.add_command(label='Records', accelerator='Ctrl+O', command=self.cmd_see_records) self.file_menu.add_command(label='Quit', accelerator='Ctrl+Q', command=self.window.destroy) self.menu_bar.add_cascade(label='File', menu=self.file_menu) self.help_menu = tkinter.Menu(self.menu_bar, tearoff=0) self.help_menu.add_command(label="About", command=self.cmd_about) self.menu_bar.add_cascade(label="Help", menu=self.help_menu) self.window.config(menu=self.menu_bar)
def __init__(self, **kwargs): super().__init__(**kwargs) self.database = Database()
try: from tkinter import * except ImportError: from Tkinter import * from backend import Database database = Database("projs.db") class Window(object): def __init__(self, window): self.window = window self.window.wm_title("Project List") l1 = Label(window, text="Title") l1.grid(row=0, column=0) l2 = Label(window, text="Date") l2.grid(row=2, column=0) l3 = Label(window, text="Skills") l3.grid(row=4, column=0) l4 = Label(window, text="Details") l4.grid(row=6, column=0) self.title_text = StringVar() self.e1 = Entry(window, textvariable=self.title_text) self.e1.grid(row=0, column=1) self.date_text = StringVar()
def __init__(self): self.database = Database("lite.db")
Year, ISBN User can: View all records Search an entry Add entry Update entr Delete Close program """ import tkinter as tk from backend import Database # importing the Database class from the backend.py script database=Database() # create an object called database from the Database class class Commands(): def __init__(self): pass def get_selected_row(self,event): # the event parameter is a flag to highlight that this function is binded to an event and is necessary. #global selected_tuple index=list1.curselection()[0] # get the index of the selected row in the listbox which is a tuple. The [0] extracts just the number which is the first item in the tuple. self.selected_tuple=list1.get(index) # from the listbox, retrieve the row which corresponds to the obtained index from the event of clicking. e1.delete(0,tk.END) # clear e1 e1.insert(tk.END,self.selected_tuple[1]) # insert title when the row is selected e2.delete(0,tk.END) # clear e2 e2.insert(tk.END,self.selected_tuple[2]) # insert author in author entry widget when row is selected e3.delete(0,tk.END) # clear e3
# The front end from tkinter import * from backend import Database database = Database("store.db") class Window: def __init__(self, window): self.window = window self.window.wm_title("Inventory Management Application") # Label objects l1 = Label(window, text="Name") l1.grid(row=0, column=0) l2 = Label(window, text="Manufacturer") l2.grid(row=0, column=2) l3 = Label(window, text="Serial") l3.grid(row=1, column=0) l4 = Label(window, text="Year") l4.grid(row=1, column=2) # Entry objects self.name_text = StringVar() self.e1 = Entry(window, textvariable=self.name_text) self.e1.grid(row=0, column=1) self.manufacturer_text = StringVar() self.e2 = Entry(window, textvariable=self.manufacturer_text) self.e2.grid(row=0, column=3)
from datetime import datetime from collections import * import matplotlib import matplotlib.pyplot as plt matplotlib.use('tkAgg') from backend import Database database = Database("newDbook.db") class graph: def __init__(self): print("in init") def graph_data_sold_book(self): # Connect to database book_name = [] quantity = [] quantity_in_per = [] rows = database.graph_attr() for row in rows: book_name.append(row[1]) quantity.append(row[0]) max_sold_book = max(quantity) for qty in quantity: per_qty = (qty * 100) / max_sold_book quantity_in_per.append(per_qty) plt.bar(book_name, quantity_in_per, width=0.5, color=['red', 'green'])
# ------------------------------------------------------------------- # FIBROSUR ARGENTINA # Creado por Erik Bianco Vera, Ezequiel Palladino, y Tomás Yaciura # para la Técnica 4, Programación en Python # -------------------------------------------------------------------- from tkinter import * from backend import Database database = Database("productos.db") class Window(object): def __init__(self, window): self.window = window self.window.wm_title("FibroSur Argentina") l1 = Label(window, text="Nombre del Producto") l1.grid(row=0, column=0) l2 = Label(window, text="Descripción") l2.grid(row=0, column=2) l3 = Label(window, text="Link a Mercado Libre") l3.grid(row=1, column=0) l4 = Label(window, text="Precio") l4.grid(row=1, column=2) l5 = Label(window, text="Link a imágen") l5.grid(row=2, column=0)
from tkinter import * from backend import Database # instantiate Database db = Database() def view_command(): list1.delete(0, END) for row in db.view(): list1.insert(END, row) def search_command(): list1.delete(0, END) for row in db.search(title_value.get(), author_value.get(), year_value.get(), isbn_value.get()): list1.insert(END, row) def add_command(): db.insert(title_value.get(), author_value.get(), year_value.get(), isbn_value.get()) list1.delete(0, END) list1.insert(END, (title_value.get(), author_value.get(), year_value.get(), isbn_value.get())) def get_selected_row(event): try: global selected_tuple index = list1.curselection()[0] selected_tuple = list1.get(index)
try: from PySide2.QtWidgets import QWidget, QLabel, QLineEdit, QPushButton, QComboBox, QVBoxLayout, \ QFormLayout, QFrame, QMessageBox, QHBoxLayout, QSpacerItem, QSizePolicy from PySide2.QtGui import QIcon, QPixmap from PySide2.QtCore import Qt, Slot except: from PyQt.QtWidgets import QWidget, QLabel, QLineEdit, QPushButton, QComboBox, QVBoxLayout, \ QFormLayout, QFrame, QMessageBox from PyQt.QtGui import QIcon, QPixmap from PyQt.QtCore import Qt from backend import Database db = Database("sr-data.db") class DisplayPerson(QWidget): def __init__(self, parent): QWidget.__init__(self) self.setWindowTitle("View person") self.setWindowIcon(QIcon("assets/icons/logo-dark.png")) self.setGeometry(450, 150, 450, 650) self.Parent = parent self.UI() self.show() def UI(self): self.personDetails() self.widgets()
def login(): db = Database() formData = request.form.to_dict() if formData and db.verify_user(formData['uname'], formData['psw']): return render_template('dashboard.html', title='Dashboard') return render_template('login.html', title='Login')
from tkinter import * from backend import Database database = Database("books.db") class Window(object): def __init__(self, window): self.window = window self.window.wm_title("BookStore") l1 = Label(window, text="Title") l1.grid(row=0, column=0) l2 = Label(window, text="Author") l2.grid(row=0, column=2) l3 = Label(window, text="Year") l3.grid(row=1, column=0) l4 = Label(window, text="ISBN") l4.grid(row=1, column=2) self.title_text = StringVar() self.e1 = Entry(window, textvariable=self.title_text) self.e1.grid(row=0, column=1) self.author_text = StringVar() self.e2 = Entry(window, textvariable=self.author_text)
Character Who Said the Quote Actor who played The Character User can - Add - Delete - Edit - View All - Search - Close """ from tkinter import * from backend import Database database=Database("quotes.db") class Window(object): def __init__(self, window): self.window=window() self.window.title("QuoteBook") self.window.wm_title("QuoteBook") self.window.configure(background="White Smoke") #TITLE title_label = Label(window, text="QUOTEBOOK", justify=CENTER, fg = "Gray13", font = "Helvetica 30 bold italic", bg="White Smoke") title_label.grid(row=0, column=0, columnspan=3 ,sticky=NSEW, pady=16)