Facebook
From B R Arjun, 1 Year ago, written in Python.
This paste is a reply to Abab from Abab - view diff
Embed
Download Paste or View Raw
Hits: 129
  1. from tkinter import *
  2. #BASICS DAAA
  3.  
  4. #window=Tk()  # Instantiate a window for displaying content
  5. #window.geometry("500x500")  #For setting sizes of the window
  6. #window.title("Face Rec GUI")  # For setting title name
  7.  
  8. #icon= PhotoImage(file="
  9. #gesnhin.png")
  10. #window.iconphoto(True,icon) # Icon of the GUI
  11. #window.config(background="green") #Background Colour Change can pass hex value also
  12.  
  13. #window.mainloop() #For displaying the window
  14.  
  15.  
  16.  
  17. #LABELS
  18.  
  19. #window=Tk()
  20. #photo=PhotoImage(file="genshin.png")
  21.  
  22. #label= Label(window,text="GUI FOR FACE RECOGNITION",font=("Times New Roman",35,'italic'),fg="Blue",bg="green",relief=RAISED,bd=15,padx=25,pady=25,image=photo,compound="bottom") #For Showing Label Content.. fg is text colour bg is background colour relief is border style bd is border width padx and pad y are for spaces between border and text
  23. #label.pack() #For setting the name of the label by default centred
  24. #label.place(x=0,y=0) #For keeping the label in certain coordinates
  25.  
  26. #window.mainloop()
  27.  
  28.  
  29.  
  30.  
  31. #BUTTONS
  32. #def click():
  33.  #   print("You clicked the button")
  34.  
  35. #window=Tk()
  36.  
  37. #photo=PhotoImage(file="image.png")
  38.  
  39. #button=Button(window,text="CLICK ME",command=click,font=("Comic Sans",30),fg="RED",bg="BLACK",activeforeground="RED",activebackground="BLACK",image=photo,compound="bottom") #Command is thing that we want it to do activeforeground and activebackground are clicking colours compound is for not overlapping image with text
  40. #button.pack()
  41.  
  42. #window.mainloop()
  43.  
  44.  
  45.  
  46.  
  47. #ENTRY WIDGET
  48.  
  49. #def submit():
  50.  #   username=entry.get()
  51.   #  print("hello"+username)
  52.    # entry.config(state=DISABLED)
  53.  
  54. #def delete():
  55.  #   entry.delete(0,END)
  56.  
  57. #def backspace():
  58.  #   entry.delete(len(entry.get())-1,END)
  59.  
  60. #window=Tk()
  61. #entry=Entry(window,font=("Arial",50),fg="BLACK",bg="RED",show="*") show is for showing what we want to show apart from the actual
  62. #entry.insert(0,"TYPE YOUR TEXT HERE") #FOR DEFAULT TEXT
  63. #entry.pack(side=LEFT) side argument used for placing the widget
  64.  
  65. #submitbutton= Button(window,text="submit",command=submit)
  66. #submitbutton.pack(side=RIGHT)
  67.  
  68.  
  69. #deletebutton= Button(window,text="delete",command=delete)
  70. #deletebutton.pack(side=RIGHT)
  71.  
  72. #backspacebutton= Button(window,text="Backspace",command=backspace)
  73. #backspacebutton.pack(side=RIGHT)
  74.  
  75. #window.mainloop()
  76.  
  77.  
  78.  
  79.  
  80. #CHECK BOXES
  81.  
  82. #def display():
  83.  #   if(x.get()==1):
  84.   #      print("You agreed")
  85.    # else:
  86.     #    print("You don't agree")
  87.  
  88. #window=Tk()
  89. #x=IntVar()
  90. #image1=PhotoImage(file="Screenshot(13).png")
  91. #checkbutton=Checkbutton(window,text="I agree to something",variable=x,onvalue=1,offvalue=0,command=display,font=("Arial",20),fg="green",bg="red",activeforeground="Green",activebackground="red",padx=10,pady=15,image=image1,compound="left")
  92. #checkbutton.pack()
  93.  
  94.  
  95. #window.mainloop()
  96.  
  97.  
  98. #DISCRETE CHECK BOXES
  99. #food=["pizza","hamburger","hotdog"]
  100. #def order():
  101.  #   if (x.get()==0):
  102.   #      print("You ordered pizza")
  103.    # elif (x.get()==1):
  104.     #   print("You ordered hotdog")
  105.     #else:
  106.      #   print("huh")
  107.  
  108.  
  109. #window=Tk()
  110. #pizzaimage= PhotoImage(file="genshin.png.")
  111. #burgerimage= PhotoImage(file="name.png")
  112. #hotdogimage= PhotoImage(file="image.png")
  113. #foodimages=[pizzaimage,burgerimage,hotdogimage]
  114. #x=IntVar()
  115. #for index in range(len(food)):
  116.  #   radiobutton=Radiobutton(window,text=food[index],variable=x,value=index,padx=25,pady=10,font=("Comic Sans",50),image=foodimages[index],compound="left",indicatoron=False,width=375,command=order)#indicatoron=eliminate circle indicators
  117. #  radiobutton.pack()
  118.  #   radiobutton.pack(anchor=W)
  119.  
  120. #window.mainloop()
  121.  
  122.  
  123.  
  124.  
  125. #TEMPERATURE SCALES
  126. #def submit():
  127.  #   print("The temperature is:"+str(scale.get())+"degrees c")
  128. #window=Tk()
  129. #scale=Scale(window,from_=100,to=0,length=600,orient=VERTICAL,font=("Arial",20),tickinterval=10,showvalue=0,troughcolor="blue",fg="red",bg="green")#Orientation Tickinterval adds numeric indicators for value
  130.  
  131. #scale.pack()
  132.  
  133. #button=Button(window,text="submit",command=submit)
  134. #button.pack()
  135.  
  136.  
  137.  
  138. #window.mainloop()
  139.  
  140.  
  141.  
  142.  
  143.  
  144. #LISTBOXES
  145. #def submit():
  146.     #food=[]
  147.     #for index in listbox.curselection():
  148.      #   food.insert(index,listbox.get(index))
  149.     #print("You have ordered:")
  150.     #for index in food:
  151.      #   print(index)
  152. #def add():
  153.  #   listbox.insert(listbox.size(),entrybox.get())
  154.   #  listbox.config(height=listbox.size())
  155.  
  156. #def delete():
  157.  #   for index in reversed(listbox.curselection()):
  158.   #      listbox.delete(index)
  159.    # listbox.config(height=listbox.size())
  160.  
  161. #window=Tk()
  162. #listbox=Listbox(window,bg="green",font=("Constantia",35),width=12,selectmode=MULTIPLE)
  163. #listbox.pack()
  164. #listbox.insert(1,"pizza")
  165. #listbox.insert(2,"burger")
  166. #listbox.insert(3,"soup")
  167. #listbox.insert(4,"salad")
  168. #listbox.insert(5,"jam")
  169.  
  170. #entrybox= Entry(window)
  171. #entrybox.pack()
  172.  
  173. #addbutton= Button(window,text="add",command=add)
  174. #addbutton.pack()
  175.  
  176. #deletebutton= Button(window,text="delete",command=delete)
  177. #deletebutton.pack()
  178.  
  179. #submitbutton= Button(window,text="submit",command=submit)
  180. #submitbutton.pack()
  181. #window.mainloop()
  182.  
  183.  
  184. #MESSAGEBOXES
  185. #from tkinter import messagebox #import message box library
  186.  
  187. #def click():
  188.    # messagebox.showinfo(title="This is an info message box",message="You are a person")
  189.      #messagebox.showwarning(title="Warning", message="You have a Virus!!!")
  190.       #messagebox.showerror(title="Error",message="Something went wrong")
  191.     #   if messagebox.askokcancel(title="ASK OK CANCEL",message="Do you want to continue?"):
  192.      #      print("You continued")
  193.       # else:
  194.        #    print("You stopped")
  195.   # if messagebox.askretrycancel(title="RETRY OR CANCEL", message="Do you want to retry or cancel?"):
  196.    #         print("You retried")
  197.    #else:
  198.     #        print("You stopped")
  199.    # if messagebox.askyesno(title="ASK YES OR NO",message="DOU YOU LIKE CAKE?"):
  200.     #    print("I like cake too")
  201.     #else:
  202.      #   print("Why dont u like it?")
  203.  # answer=(messagebox.askquestion(title="ASK QUESTION",message="DO YOU LIKE PIE?"))
  204.   #if answer=="yes":
  205.    #   print("I like it too")
  206.   #else:
  207.   #    print("Why dont u like it")
  208.  # answer=(messagebox.askyesnocancel(title="ask yes no cancel",message="do u like to code?",icon='error'))#ICON FOR SELECTING TYPE OF ICON CAN BE WARNING ERROR OR INFO
  209.   #if answer==True:
  210.    #    print("ME TOO")
  211.   #elif answer==False:
  212.    #    print("WTF")
  213.   #else:
  214.    #    print("YOU DODGED THE QUESTION")
  215.  
  216.  
  217. #window=Tk()
  218. #button=Button(window,command=click,text="click me")
  219. #button.pack()
  220.  
  221.  
  222. #window.mainloop()
  223.  
  224. #COLOURCHOOSER
  225. #from tkinter import colorchooser #Bcoz its submodule
  226. #def click():
  227. #    window.config(bg=colorchooser.askcolor()[1])#CHANGES BG COLOUR
  228.  
  229.  
  230. #window=Tk()
  231. #window.geometry("420x420")
  232. #button= Button(text="click me",command=click)
  233. #button.pack()
  234. #window.mainloop()
  235.  
  236.  
  237.  
  238.  
  239.  
  240. #TEXT AREA
  241.  
  242. #def submit():
  243.  #   innerput=text.get("1.0",END)
  244.   #  print(innerput)
  245.  
  246.  
  247.  
  248.  
  249. #window=Tk()
  250. #button=Button(window,command=submit,text="submit")
  251. #button.pack()
  252. #text= Text(window,bg="light yellow",font=("Ink Free",20),height=8,width=20,padx=20,pady=20,fg="purple")
  253. #text.pack()
  254.  
  255. #window.mainloop()
  256.  
  257.  
  258.  
  259.  
  260. #FILE DIALOG
  261. #from tkinter import filedialog
  262. #def openfile():
  263.  #   filepath=filedialog.askopenfilename(initialdir="C:\Users\brarj\PycharmProjects",title="Open file")#filetypes=())  #Gives path in strings filetype for what type we want to search for
  264.   #  file=open(filepath,"r")
  265.    # print(file.read())
  266.     #file.close()
  267.  
  268. #window=Tk()
  269. #button=Button(text="open",command=openfile)
  270. #button.pack()
  271.  
  272.  
  273. #window.mainloop()
  274.  
  275. #SAVE FILES
  276. #    def savefile():
  277. #        file=filedialog.asksaveasfile(defaultextension='.txt',filetypes=[("Text File",'txt"'),("HTML FILE",".html"),("ALL FILES",".*")])#use initialdir for saving into folder u want
  278. #        if file is None: #Exception Handling
  279.  #           return
  280.   #      filetext=str(text.get(1.0,END)) #also can use console window for input using filetext=input("Enter some text") should once save file then u can input
  281.    #     file.write(filetext)
  282.     #    file.close
  283.  
  284.  
  285.   #  from tkinter import filedialog
  286.    # window=Tk()
  287.     #button= Button(window,text="save",command=savefile)
  288.     #button.pack()
  289.     #text=Text(window)
  290.     #text.pack()
  291.  
  292.  
  293.  
  294. #window.mainloop()
  295.  
  296.  
  297.  
  298. #MENUBAR
  299. #def openfile():
  300.  #   print("FIle has been opened") #Can change the function to open files using file dialog or smth
  301. #def savefile():
  302.  #   print("FIle has been saved")
  303. #def cut():
  304. #    print("You cut text")
  305. #def copy():
  306.  #   print("You copied text")
  307. #def paste():
  308.  #   print("You pasted text")
  309.  
  310.  
  311.  
  312.  
  313. #window=Tk()
  314. #menubar=Menu(window)
  315. #window.config(menu=menubar)
  316.  
  317. #filemenu= Menu(menubar,tearoff=0,font=("MV Boli",15))
  318. #menubar.add_cascade(label="File",menu=filemenu)
  319. #filemenu.add_command(label="Open",command=openfile)
  320. #filemenu.add_command(label="Save",command=savefile)
  321. #filemenu.add_separator()
  322. #filemenu.add_command(label="Exit",command=quit)
  323.  
  324.  
  325. #editmenu=Menu(menubar,tearoff=0,font=("MV Boli",15))#Tearoff for removing line at the top
  326. #menubar.add_cascade(label="Edit",menu=editmenu)
  327. #editmenu.add_command(label="Cut",command=cut)
  328. #editmenu.add_command(label="Copy",command=copy)
  329. #editmenu.add_command(label="Paste",command=paste)
  330.  
  331.  
  332.  
  333. #window.mainloop()
  334.  
  335.  
  336.  
  337. #NEW WINDOW
  338. #def createwindow():
  339.  #   newwindow=Tk()
  340.  
  341.   #  window.destroy()#close out of old window
  342.  
  343. #window=Tk()
  344. #Button(window,text="Create New Window",command=createwindow).pack()
  345.  
  346.  
  347. #TABS
  348. #from tkinter import ttk
  349.  
  350.  
  351.  
  352.  
  353. #window=Tk()
  354. #notebook=ttk.Notebook(window)#Manages collection of windows
  355. #tab1=Frame(notebook)
  356. #tab2=Frame(notebook)
  357. #notebook.add(tab1,text="Tab 1")
  358. #notebook.add(tab2,text="Tab 2")
  359. #notebook.pack(expand=True,fill="both")#Exapnd will expand to any space not used fill will fill space
  360.  
  361. #Label(tab1,text="Hello",width=50,height=25).pack()
  362. #Label(tab2,text="Bye",width=50,height=25).pack()
  363.  
  364. #window.mainloop()
  365.  
  366.  
  367. #PROGRESS BARS
  368. """from tkinter.ttk import *
  369. import time
  370. def start():
  371.    tasks=10
  372.    x=0
  373.    while x<tasks:
  374.        time.sleep(1)
  375.        bar["value"]+=10
  376.        x+=1
  377.        percent.set(str(int((x/tasks)*100))+"%")
  378.        window.update_idletasks()#After each iteration of while loop it updates the window
  379. window=Tk()
  380. percent=StringVar()
  381. text=StringVar
  382. bar= Progressbar(window,orient=HORIZONTAL,length=300)#or VERTICAL for vertical bar
  383. bar.pack(pady=10)
  384. percentlabel= Label(window,textvariable=percent).pack()
  385. button=Button(window,text="Download",command=start).pack()
  386.  
  387.  
  388.  
  389. window.mainloop()"""
  390.  
  391. #Key Bindings
  392. """def dosomething(event):
  393.    print("HI")
  394.  
  395.  
  396.  
  397. window=Tk()
  398.  
  399. window.bind("<Return>",dosomething)#format is like <key>,function"""
  400.  
  401.  
  402.  
  403.  
  404. window=Tk()
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413. window.mainloop()