mirror of
https://github.com/Shawn-Shan/fawkes.git
synced 2024-12-22 07:09:33 +05:30
Merge remote-tracking branch 'origin/app_dev'
This commit is contained in:
commit
ef85fd5c53
68
app/app.py
68
app/app.py
@ -3,9 +3,10 @@ Simple GUI to facilitate interaction with Fawkes.
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
from tkinter import Tk, BOTH, StringVar
|
from tkinter import Tk, BOTH, StringVar, Canvas, PhotoImage, CENTER, NW
|
||||||
from tkinter.filedialog import askopenfilenames
|
from tkinter.filedialog import askopenfilenames
|
||||||
from tkinter.ttk import Frame, Label, Button
|
from tkinter.ttk import Frame, Label, Button
|
||||||
|
from PIL import ImageTk, Image
|
||||||
|
|
||||||
import fawkes.protection
|
import fawkes.protection
|
||||||
|
|
||||||
@ -15,51 +16,96 @@ class UI(Frame):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self.my_fawkes = fawkes.protection.Fawkes("high_extract", '0', 1)
|
self.my_fawkes = fawkes.protection.Fawkes("high_extract", '0', 1)
|
||||||
self.var = StringVar()
|
self.var = StringVar()
|
||||||
self.var.set('Initial')
|
self.var.set('Select images to cloak!')
|
||||||
self.img_paths = './imgs'
|
self.img_paths = './imgs'
|
||||||
self.initUI()
|
self.initUI()
|
||||||
|
|
||||||
def initUI(self):
|
def initUI(self):
|
||||||
self.master.title("This is a Window")
|
self.master.title("Fawkes")
|
||||||
|
self.master.configure(bg='white')
|
||||||
self.pack(fill=BOTH, expand=1)
|
self.pack(fill=BOTH, expand=1)
|
||||||
|
|
||||||
|
# fawkes image
|
||||||
|
canvas = Canvas(self, width=110, height=150)
|
||||||
|
orig = Image.open("fawkes_mask.jpg")
|
||||||
|
resized = orig.resize((110,150), Image.ANTIALIAS)
|
||||||
|
img = ImageTk.PhotoImage(resized)
|
||||||
|
canvas.create_image(0,0, image=img, anchor=NW)
|
||||||
|
canvas.image = img
|
||||||
|
canvas.pack()
|
||||||
|
|
||||||
|
|
||||||
|
# open button
|
||||||
btn_Open = Button(self,
|
btn_Open = Button(self,
|
||||||
text='open img directory',
|
text='Choose image(s) to cloak',
|
||||||
width=30,
|
width=25,
|
||||||
command=self.select_path)
|
command=self.select_path)
|
||||||
btn_Open.pack()
|
btn_Open.pack()
|
||||||
|
|
||||||
|
# run button
|
||||||
btn_Run = Button(self,
|
btn_Run = Button(self,
|
||||||
text='run the code',
|
text='Cloak images',
|
||||||
width=3,
|
width=25,
|
||||||
command=lambda: thread_it(self.my_fawkes.run_protection, self.img_paths))
|
command=lambda: thread_it(self.my_fawkes.run_protection, self.img_paths))
|
||||||
btn_Run.pack()
|
btn_Run.pack()
|
||||||
|
|
||||||
|
# # save button
|
||||||
|
# btn_Save = Button(self,
|
||||||
|
# text='Save cloaked image(s)',
|
||||||
|
# width=25,
|
||||||
|
# command=self.save_images)
|
||||||
|
# btn_Save.pack()
|
||||||
|
|
||||||
|
# Progress info
|
||||||
Label_Show = Label(self,
|
Label_Show = Label(self,
|
||||||
textvariable=self.var,
|
textvariable=self.var,
|
||||||
font=('Arial', 13), width=50)
|
font=('Arial', 13), width=50)
|
||||||
|
Label_Show.configure(anchor="center")
|
||||||
Label_Show.pack()
|
Label_Show.pack()
|
||||||
|
|
||||||
|
|
||||||
def select_path(self):
|
def select_path(self):
|
||||||
self.img_paths = askopenfilenames(filetypes=[('image', "*.gif *.jpg *.png")])
|
self.img_paths = askopenfilenames(filetypes=[('image', "*.gif *.jpg *.png")])
|
||||||
self.var.set('the paths have been set')
|
self.var.set('Images chosen.')
|
||||||
|
|
||||||
|
def save_images(self):
|
||||||
|
print(self.img_paths)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
root = Tk()
|
root = Tk()
|
||||||
root.title('window')
|
root.title('window')
|
||||||
root.geometry('600x500')
|
root.geometry('200x230')
|
||||||
app = UI()
|
app = UI()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
root.configure(bg='white')
|
||||||
root.mainloop()
|
root.mainloop()
|
||||||
|
|
||||||
|
|
||||||
def thread_it(func, *args):
|
def thread_it(func, *args):
|
||||||
app.var.set('cloak in process')
|
app.var.set('Cloaking in progress.')
|
||||||
t = threading.Thread(target=func, args=args)
|
t = threading.Thread(target=func, args=args)
|
||||||
t.setDaemon(True)
|
t.setDaemon(True)
|
||||||
t.start()
|
t.start()
|
||||||
|
while t.is_alive():
|
||||||
|
pass
|
||||||
|
app.var.set('Cloaking finished.')
|
||||||
|
|
||||||
|
def thread_test():
|
||||||
|
app.var.set('Cloaking in progress.')
|
||||||
|
|
||||||
|
def func(test):
|
||||||
|
print(test)
|
||||||
|
args = "testing"
|
||||||
|
t = threading.Thread(target=func, args=args)
|
||||||
|
t.setDaemon(True)
|
||||||
|
t.start()
|
||||||
|
while t.is_alive():
|
||||||
|
pass
|
||||||
|
t.sleep(1)
|
||||||
|
app.var.set('Cloaking finished.')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
BIN
app/fawkes_mask.jpg
Normal file
BIN
app/fawkes_mask.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 132 KiB |
Loading…
Reference in New Issue
Block a user