def ship_info(self): all_lines = self.ui.lineEdit_2.text() and self.ui.lineEdit_3.text() and self.ui.lineEdit_4.text() and \ self.ui.lineEdit_5.text() and self.ui.lineEdit_6.text() and self.ui.lineEdit_7.text() and \ self.ui.lineEdit_8.text() and self.ui.lineEdit_9.text() # Saving information about the delivery to the database is preliminarily checked for filling in all the fields: if not DB.execute('select * from USER_DATA where id=2').fetchall(): if all_lines: DB.execute(f''' INSERT INTO USER_DATA VALUES ("{self.ui.lineEdit_2.text()}", "{self.ui.lineEdit_3.text()}", "{self.ui.lineEdit_4.text()}", "{self.ui.lineEdit_5.text()}", "{self.ui.lineEdit_6.text()}", {self.ui.lineEdit_7.text()}, "{self.ui.comboBox_4.currentText()}", "{self.ui.comboBox_3.currentText()}", "{self.ui.lineEdit_8.text()}", {self.ui.comboBox.currentText()}, {self.ui.comboBox_2.currentText()}, {self.ui.lineEdit_9.text()}) ''') CONNECTION.commit() self.success = SuccessWindow() self.success.show() else: self.error = ErrorWindow() self.error.show() else: if not all_lines: self.error = ErrorWindow() self.error.show() else: DB.execute(f''' UPDATE USER_DATA SET name="{self.ui.lineEdit_2.text()}", email="{self.ui.lineEdit_3.text()}", tel="{self.ui.lineEdit_4.text()}", address="{self.ui.lineEdit_5.text()}", city="{self.ui.lineEdit_6.text()}", post_code={self.ui.lineEdit_7.text()}, country="{self.ui.comboBox_4.currentText()}", card="{self.ui.comboBox_3.currentText()}", card_number="{self.ui.lineEdit_8.text()}", valid_month={self.ui.comboBox.currentText()}, valid_year={self.ui.comboBox_2.currentText()}, cvv={self.ui.lineEdit_9.text()} WHERE id=2 ''') CONNECTION.commit() self.success = SuccessWindow() self.success.show()
def __init__(self): PyQt5.QtWidgets.QWidget.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) # Run a separate thread for timer operation: self.thread_timer = TimerThread() self.thread_timer.html.connect(self.set_html_timer) self.thread_timer.start() # Items list update: self.start_update() self.ui.pushButton.clicked.connect(self.start_button) self.ui.pushButton_2.clicked.connect(self.ship_info) self.ui.pushButton_3.clicked.connect(self.back_page) self.ui.pushButton_4.clicked.connect(self.ui.lineEdit.clear) self.ui.pushButton_5.clicked.connect(self.update_main_view) self.ui.radioButton.setChecked(True) # Filling fields in the settings from the database: if DB.execute('select * from USER_DATA where id=2').fetchall(): db_data = DB.execute( 'select * from USER_DATA where id=2').fetchall() self.ui.lineEdit_2.setText(db_data[0][1]) self.ui.lineEdit_3.setText(db_data[0][2]) self.ui.lineEdit_4.setText(db_data[0][3]) self.ui.lineEdit_5.setText(db_data[0][4]) self.ui.lineEdit_6.setText(db_data[0][5]) self.ui.lineEdit_7.setText(str(db_data[0][6])) self.ui.comboBox_4.setCurrentText(db_data[0][7]) self.ui.comboBox_3.setCurrentText(db_data[0][8]) self.ui.lineEdit_8.setText(db_data[0][9]) self.ui.comboBox.setCurrentText( '0' + str(db_data[0][10]) if len(str(db_data)) < 2 else '') self.ui.comboBox_2.setCurrentText(str(db_data[0][11])) self.ui.lineEdit_9.setText(str(db_data[0][12]))
def start_button(self): link = self.ui.lineEdit.text() if re.search('https://www.supremenewyork.com/shop/(.+?)', link): # Getting all the values from the database to fill in the delivery information with the bot: db_data = DB.execute( 'select * from USER_DATA where id=2').fetchall() DATA['url_1'] = link DATA['name'] = db_data[0][1] DATA['email'] = db_data[0][2] DATA['tel'] = db_data[0][3] DATA['address'] = db_data[0][4] DATA['city'] = db_data[0][5] DATA['post_code'] = db_data[0][6] DATA['country'] = db_data[0][7] DATA['card'] = db_data[0][8] DATA['card_number'] = db_data[0][9] DATA['valid_month'] = db_data[0][10] DATA['valid_year'] = db_data[0][11] DATA['cvv'] = db_data[0][12] if self.ui.radioButton_8.isChecked(): DATA['size'] = 'Medium' elif self.ui.radioButton_9.isChecked(): DATA['size'] = 'Large' elif self.ui.radioButton_10.isChecked(): DATA['size'] = 'XLarge' if self.ui.radioButton.isChecked(): DATA['img'] = 'on' elif self.ui.radioButton_2.isChecked(): DATA['img'] = 'off' # Check proxy valid: if self.ui.lineEdit_12.text(): checker = grab.Grab() checker.setup(proxy=self.ui.lineEdit_12.text().strip(), proxy_type='http', connect_timeout=5, timeout=5) try: checker.go('https://www.supremenewyork.com/') DATA['proxy'] = self.ui.lineEdit_12.text().strip() self.bot_thread = OrderThread() self.bot_thread.start() except grab.GrabError: self.proxy_error = ProxyError() self.proxy_error.show() else: self.bot_thread = OrderThread() self.bot_thread.start()
def __init__(self): super().__init__() self.db = DB() self.title("Contact-Book") self.geometry("1100x600") self.resizable(False, False) self.label_0 = tk.Label(self, text='!!!!WELCOME TO THE CONTACT MANAGER!!!!', width=50, font=("bold", 20)) self.label_0.place(x=100, y=43) self.label_1 = tk.Label(self, text='Your Contact List', width=50, font=("bold", 20)) self.label_1.place(x=100, y=103) self.scrollbar = ttk.Scrollbar(self) self.scrollbar.pack(side=RIGHT, fill=Y) self.cols = ('ID', 'Name', 'Gender', 'Email', 'Phone', 'Type', 'Address', 'Date Time') self.listbox = ttk.Treeview(self, columns=self.cols, show="headings") for col in self.cols: self.listbox.heading(col, text=col) self.listbox.place(x=10, y=163) self.listbox.column(self.cols[0], width=35) self.listbox.column(self.cols[1], width=150) self.listbox.column(self.cols[2], width=60) self.listbox.column(self.cols[3], width=220) self.listbox.column(self.cols[4], width=150) self.listbox.column(self.cols[5], width=70) self.listbox.column(self.cols[6], width=220) self.listbox.column(self.cols[7], width=160) self.listbox.config(yscrollcommand=self.scrollbar.set) self.scrollbar.config(command=self.listbox.yview) self.scrollbar.config(command=self.listbox.xview) self.search_label = tk.Label(self, text='Search By Name', width=20, font=("bold", 10)) self.search_label.place(x=36, y=420) self.search_entry = ttk.Entry(self) self.search_entry.place(x=200, y=420) sort_list = ['A', 'Name', 'Id', 'Address', 'Date'] self.sort_type = tk.StringVar() droplist = ttk.OptionMenu(self, self.sort_type, *sort_list) droplist.config(width=7) self.sort_type.set('Sort By') droplist.place(x=970, y=383) tk.Button(self, text='Create Contact', command=self.contact_create, width=15, bg='green', fg='white', font=("bold", 10)).place(x=50, y=500) tk.Button(self, text='Show Contact List', command=self.contact_list, width=15, bg='blue', fg='white', font=("bold", 10)).place(x=270, y=500) tk.Button(self, text='Update Contact ', command=self.contact_update, width=15, bg='orange', fg='white', font=("bold", 10)).place(x=490, y=500) tk.Button(self, text='Delete Contact', command=self.contact_delete, width=15, bg='red', fg='white', font=("bold", 10)).place(x=710, y=500) tk.Button(self, text='Search', command=self.search_contact, width=10, bg='yellow', fg='white', font=("bold", 10)).place(x=400, y=415)
class MainWindow(tk.Tk): def __init__(self): super().__init__() self.db = DB() self.title("Contact-Book") self.geometry("1100x600") self.resizable(False, False) self.label_0 = tk.Label(self, text='!!!!WELCOME TO THE CONTACT MANAGER!!!!', width=50, font=("bold", 20)) self.label_0.place(x=100, y=43) self.label_1 = tk.Label(self, text='Your Contact List', width=50, font=("bold", 20)) self.label_1.place(x=100, y=103) self.scrollbar = ttk.Scrollbar(self) self.scrollbar.pack(side=RIGHT, fill=Y) self.cols = ('ID', 'Name', 'Gender', 'Email', 'Phone', 'Type', 'Address', 'Date Time') self.listbox = ttk.Treeview(self, columns=self.cols, show="headings") for col in self.cols: self.listbox.heading(col, text=col) self.listbox.place(x=10, y=163) self.listbox.column(self.cols[0], width=35) self.listbox.column(self.cols[1], width=150) self.listbox.column(self.cols[2], width=60) self.listbox.column(self.cols[3], width=220) self.listbox.column(self.cols[4], width=150) self.listbox.column(self.cols[5], width=70) self.listbox.column(self.cols[6], width=220) self.listbox.column(self.cols[7], width=160) self.listbox.config(yscrollcommand=self.scrollbar.set) self.scrollbar.config(command=self.listbox.yview) self.scrollbar.config(command=self.listbox.xview) self.search_label = tk.Label(self, text='Search By Name', width=20, font=("bold", 10)) self.search_label.place(x=36, y=420) self.search_entry = ttk.Entry(self) self.search_entry.place(x=200, y=420) sort_list = ['A', 'Name', 'Id', 'Address', 'Date'] self.sort_type = tk.StringVar() droplist = ttk.OptionMenu(self, self.sort_type, *sort_list) droplist.config(width=7) self.sort_type.set('Sort By') droplist.place(x=970, y=383) tk.Button(self, text='Create Contact', command=self.contact_create, width=15, bg='green', fg='white', font=("bold", 10)).place(x=50, y=500) tk.Button(self, text='Show Contact List', command=self.contact_list, width=15, bg='blue', fg='white', font=("bold", 10)).place(x=270, y=500) tk.Button(self, text='Update Contact ', command=self.contact_update, width=15, bg='orange', fg='white', font=("bold", 10)).place(x=490, y=500) tk.Button(self, text='Delete Contact', command=self.contact_delete, width=15, bg='red', fg='white', font=("bold", 10)).place(x=710, y=500) tk.Button(self, text='Search', command=self.search_contact, width=10, bg='yellow', fg='white', font=("bold", 10)).place(x=400, y=415) def contact_create(self): self.create = Contact(self) self.create.contact_create_form() def contact_list(self): sort_type = self.sort_type.get() if sort_type == 'Name': self.sort_by_name() elif sort_type == 'Address': self.sort_by_address() elif sort_type == 'Id': self.sort_by_id() elif sort_type == 'Date': self.sort_by_date() else: self.contact = self.db.list_contact() for i in self.listbox.get_children(): self.listbox.delete(i) for c in self.contact: self.listbox.insert("", "end", values=(c['id'], c['name'], c['gender'], c['email'], c['phone'], c['Type'], c['address'], c['date'])) def contact_update(self): try: self.selected_item = self.listbox.selection()[0] values = tuple(self.listbox.item(self.selected_item)['values']) self.update = Contact(self) self.update.contact_update_form(values[0]) except IndexError: msgbox.showerror("error", "First Select the Item") def contact_delete(self): try: if msgbox.askyesno("Delete Contact?", "Do you really want to delete?"): self.selected_item = self.listbox.selection()[0] values = tuple(self.listbox.item(self.selected_item)['values']) self.listbox.delete(self.selected_item) self.db.delete(values[0]) msgbox.showinfo("deleted", "Successfully Deleted") else: pass except IndexError: msgbox.showerror("error", "First Select the Item") def on_closing(self): if msgbox.askokcancel("Quit", "Do you want to quit?"): del self.db self.destroy() def search_contact(self): self.contact_name = self.search_entry.get() self.result = self.db.search(self.contact_name) for i in self.listbox.get_children(): self.listbox.delete(i) if self.result == []: msgbox.showinfo('Not Found', "Search result not found") else: for c in self.result: self.listbox.insert("", "end", values=(c['id'], c['name'], c['gender'], c['email'], c['phone'], c['Type'], c['address'], c['date'])) def sort_by_name(self): self.sort_name = self.db.sort_by_name() for i in self.listbox.get_children(): self.listbox.delete(i) for c in self.sort_name: self.listbox.insert("", "end", values=(c['id'], c['name'], c['gender'], c['email'], c['phone'], c['Type'], c['address'], c['date'])) def sort_by_address(self): self.sort_address = self.db.sort_by_address() for i in self.listbox.get_children(): self.listbox.delete(i) for c in self.sort_address: self.listbox.insert("", "end", values=(c['id'], c['name'], c['gender'], c['email'], c['phone'], c['Type'], c['address'], c['date'])) def sort_by_id(self): self.sort_id = self.db.sort_by_id() for i in self.listbox.get_children(): self.listbox.delete(i) for c in self.sort_id: self.listbox.insert("", "end", values=(c['id'], c['name'], c['gender'], c['email'], c['phone'], c['Type'], c['address'], c['date'])) def sort_by_date(self): self.sort_date = self.db.sort_by_date() for i in self.listbox.get_children(): self.listbox.delete(i) for c in self.sort_date: self.listbox.insert("", "end", values=(c['id'], c['name'], c['gender'], c['email'], c['phone'], c['Type'], c['address'], c['date']))
def __init__(self): self.db = DB()
def __init__(self, master): super().__init__() self.db = DB() self.master = master
class Contact(tk.Toplevel): def __init__(self, master): super().__init__() self.db = DB() self.master = master def contact_create_form(self): self.geometry("500x500") self.resizable(False, False) self.title('Add Contacts') label_0 = tk.Label(self, text='Add Contact Form', width=20, font=("bold", 20)) label_0.place(x=90, y=43) label_1 = tk.Label(self, text='Full Name', width=20, font=("bold", 10)) label_1.place(x=80, y=130) self.name = tk.Entry(self) self.name.place(x=240, y=130) label_2 = tk.Label(self, text='Phone Number', width=20, font=("bold", 10)) label_2.place(x=80, y=180) self.phone = tk.Entry(self) self.phone.place(x=240, y=180) label_3 = tk.Label(self, text='Email', width=20, font=("bold", 10)) label_3.place(x=80, y=230) self.email = tk.Entry(self) self.email.place(x=240, y=230) label_4 = tk.Label(self, text="Gender", width=20, font=("bold", 10)) label_4.place(x=80, y=280) self.gender = tk.StringVar(self, "") tk.Radiobutton(self, text='Male', variable=self.gender, value='Male', bg='lightblue', fg='blue').place(x=240, y=280) tk.Radiobutton(self, text='Female', variable=self.gender, value='Female', bg='lightblue', fg='blue').place(x=330, y=280) label_5 = tk.Label(self, text='Address', width=20, font=('bold', 10)) label_5.place(x=80, y=330) self.address = tk.Entry(self) self.address.place(x=240, y=330) label_6 = tk.Label(self, text="Type", width=20, font=("bold", 10)) label_6.place(x=80, y=380) list1 = ['Telephone', 'Mobile'] self.type = tk.StringVar(self) droplist = tk.OptionMenu(self, self.type, *list1) droplist.config(width=15) self.type.set('Select number type') droplist.place(x=240, y=380) tk.Button(self, text='Submit', command=self.add_to_db, width=15, bg='brown', fg='white').place(x=180, y=450) def contact_update_form(self, id): self.geometry("500x500") self.resizable(False, False) self.id = id self.title(f'Update Contact') label_0 = tk.Label(self, text='Update Contact', width=20, font=("bold", 20)) label_0.place(x=90, y=43) label_1 = tk.Label(self, text='Full Name', width=20, font=("bold", 10)) label_1.place(x=80, y=130) self.name = tk.Entry(self) self.name.place(x=240, y=130) label_2 = tk.Label(self, text='Phone Number', width=20, font=("bold", 10)) label_2.place(x=80, y=180) self.phone = tk.Entry(self) self.phone.place(x=240, y=180) label_3 = tk.Label(self, text='Email', width=20, font=("bold", 10)) label_3.place(x=80, y=230) self.email = tk.Entry(self) self.email.place(x=240, y=230) label_4 = tk.Label(self, text="Gender", width=20, font=("bold", 10)) label_4.place(x=80, y=280) self.gender = tk.StringVar(self, "") tk.Radiobutton(self, text='Male', variable=self.gender, value='Male', bg='lightblue', fg='blue').place(x=240, y=280) tk.Radiobutton(self, text='Female', variable=self.gender, value='Female', bg='lightblue', fg='blue').place(x=330, y=280) label_5 = tk.Label(self, text='Address', width=20, font=('bold', 10)) label_5.place(x=80, y=330) self.address = tk.Entry(self) self.address.place(x=240, y=330) label_6 = tk.Label(self, text="Type", width=20, font=("bold", 10)) label_6.place(x=80, y=380) list1 = ['Telephone', 'Mobile'] self.type = tk.StringVar(self) droplist = tk.OptionMenu(self, self.type, *list1) droplist.config(width=15) self.type.set('Select number type') droplist.place(x=240, y=380) tk.Button(self, text='Submit', command=self.update_db, width=15, bg='brown', fg='white').place(x=180, y=450) def add_to_db(self): name = self.name.get() gender = self.gender.get() email = self.email.get() address = self.address.get() Type = self.type.get() phone = self.phone.get() if msgbox.askyesno("Add Contact?", "Shall we proceed?"): if name == "" or address == "" or phone == "" or gender == "": msgbox.showerror("error", "All fields are required") else: try: self.db.insert(str(name), str(gender), str(email), int(phone), str(Type), str(address)) msgbox.showinfo('success', 'Successfully Created') self.destroy() except ValueError: msgbox.showerror("field", "Fields Error") msgbox.showinfo( "info", f"{user_id} must me integer\n {phone} must be integer") else: pass def update_db(self): name = self.name.get() gender = self.gender.get() email = self.email.get() address = self.address.get() Type = self.type.get() phone = self.phone.get() if msgbox.askyesno("Update Contact?", "Shall we proceed?"): if name == "" or address == "" or phone == "" or gender == "": msgbox.showerror("error", "All fields are required") else: try: self.db.update(str(name), str(gender), int(phone), str(Type), str(email), str(address), self.id) msgbox.showinfo('success', 'Successfully Update') self.destroy() except ValueError: msgbox.showerror("field", "Fields Error") msgbox.showinfo( "info", f"{user_id} must me integer\n {phone} must be integer") else: pass