Add warns,fix graph len

This commit is contained in:
anqude 2023-02-07 00:19:17 +04:00 committed by GitHub
parent 3ca8c9a75c
commit dbebfb9d0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 76 additions and 50 deletions

View File

@ -107,9 +107,10 @@ Copy = CTkButton(tabview.tab("Line"),text="Copy!",command=copy_click, width = 39
Copy.place(x=122, y=140)
def genadiy():
generate_qr(entry.get(),fg_color,bg_color)
state=generate_qr(entry.get(),fg_color,bg_color)
from tkinter import Toplevel,Label
from PIL import ImageTk, Image
if state==True:
window = Toplevel()
window.geometry("200x200")
window.configure(bg=bg_color)
@ -130,6 +131,16 @@ def genadiy():
counter_loop.insert(0,counter_loop[0]+1)
window.bind("<Configure>", resize_image)
window.mainloop()
else:
window = Toplevel()
window.configure(bg=bg_color)
window.title("Warning!")
window.tk.call('wm', 'iconphoto', window._w, PhotoImage(file='./ui/warn.png'))
label = Label(window,background=bg_color,highlightbackground=bg_color,text="Too much data to make QR!",foreground=fg_color,font=("Monospace",16))
label.pack(fill="both", expand=True,anchor='center')
window.attributes('-topmost', True)
window.update()
window.mainloop()
genqr = CTkButton(tabview.tab("Line"),text="Generate QR!",command=genadiy,width = 39)
genqr.place(x=175, y=140)
@ -163,7 +174,8 @@ def gena():
n=int(len_entry.get())
yn=int(y_entry.get())
xn=int(x_entry.get())
from tkinter import Canvas, Toplevel
from tkinter import Canvas, Toplevel, Label
if not ( n<=1 or n>xn*yn):
root = Toplevel()
root.configure(background="#242424")
root.title("Graph")
@ -190,6 +202,16 @@ def gena():
canvas.bind('<Configure>', sizable)
root.mainloop()
else:
root = Toplevel()
root.configure(bg=bg_color)
root.title("Warning!")
root.tk.call('wm', 'iconphoto', root._w, PhotoImage(file='./ui/warn.png'))
label = Label(root,background=bg_color,highlightbackground=bg_color,text="Incorrect length!",foreground=fg_color,font=("Monospace",16))
label.pack(fill="both", expand=True,anchor='center')
root.attributes('-topmost', True)
root.update()
root.mainloop()
generate_graph=CTkButton(tabview.tab("Graph"),command=gena, text="Generate!",width=320)

View File

@ -8,7 +8,7 @@ def graph(x,y): #Создаём двумерный массив, заполне
return a
def ggraph(n,xn,yn):
m = 1
m = 0
xym = [xn,yn]
b = graph(xn, yn)
av = [[-1,-1]]

View File

@ -2,9 +2,13 @@ import qrcode
def generate_qr(password,fg_color,bg_color):
qr = qrcode.QRCode()
qr.add_data('password: '+password)
try:
qr.make(fit=True)
except:
return False
img = qr.make_image(fill_color=fg_color, back_color=bg_color)
img.save("qr.png")
return True
def generate_qr_text(password):
qr = qrcode.QRCode()

BIN
ui/warn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B