Question: import tkinter as tk from tkinter.filedialog import askopenfilename, asksaveasfilename import qr def open_file(): filepath = askopenfilename( filetypes=[(Text Files, *.txt), (All Files, *.*)] ) if not
import tkinter as tk
from tkinter.filedialog import askopenfilename, asksaveasfilename
import qr
def open_file():
filepath = askopenfilename(
filetypes=[("Text Files", "*.txt"), ("All Files", "*.*")]
)
if not filepath:
return
txt_edit.delete(1.0, tk.END)
with open(filepath, "r") as input_file:
text = input_file.read()
txt_edit.insert(tk.END, text)
window.title(f"QR System - {filepath}")
def save_file():
filepath = asksaveasfilename(
defaultextension="txt",
filetypes=[("Text Files", "*.txt"), ("All Files", "*.*")],
)
if not filepath:
return
with open(filepath, "w") as output_file:
text = txt_edit.get(1.0, tk.END)
output_file.write(text)
window.title(f"QR System - {filepath}")
def delete_label():
window.destroy()
window = tk.Tk()
window.title("QR System")
window.rowconfigure(0, minsize=480, weight=1)
window.columnconfigure(1, minsize=480, weight=1)
txt_edit = tk.Text(window)
fr_buttons = tk.Frame(window, relief=tk.RAISED, bd=2)
btn_open = tk.Button(fr_buttons, text="Open", command=open_file)
btn_save = tk.Button(fr_buttons, text="Save As...", command=save_file)
btn_delete=tk.Button(fr_buttons, text="Delete",command=delete_label)
btn_open.grid(row=0, column=0, sticky="ew", padx=5, pady=5)
btn_save.grid(row=1, column=0, sticky="ew", padx=5)
btn_delete.grid(row=2, column=0, sticky="ew", padx=5, pady=5)
fr_buttons.grid(row=0, column=0, sticky="ns")
txt_edit.grid(row=0, column=1, sticky="nsew")
window.mainloop()
I want add for this code converter QR code and output must be pdf file and this pdf include QR code image on the top for this text. please help my code. to sum up want a QR code generator with python and this code must be have input a text and have del and submit button. output must be pdf and this pdf have this text and on the top QR code for this pdf. we scan this qr, output must be this pdf. If you write all code beginning 0, not problem. thanks for help. please write code, I do not want a basic explanation
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
