Example #1
0
def del_face():
    # memunculkan window baru dan listbox (hapus wajah)
    del_window = tk.Toplevel(mainWindow)
    listbox = tk.Listbox(del_window)

    # merefresh listbox
    box_refresh(listbox)

    # function untuk command ketika tombol delete ditekan
    def del_name():
        # jika terdapat nama yang dipilih dalam listbox
        if listbox.curselection() != ():
            # mengampil nama yang dipilih
            nama = listbox.get(listbox.curselection())
            # menampilkan messagebox question yes or no
            msg_box = messagebox.askyesno('Delete Face', 'Are you sure want to delete ' + nama
                                          + ' face?', icon='warning')
            # jika menekan tombol yes
            if msg_box:
                # menghapus data wajah berdasarkan nama
                sqlModule.delete_people_encoding(nama)
                # merefresh listbox
                box_refresh(listbox)

    # menambahkan button delete wajah
    del_btn = tk.Button(del_window, text='Delete', command=del_name)
    del_btn.pack(side=tk.BOTTOM)

    listbox.pack()
def SSTF(head, req):
    requests = list(req)
    current = head
    seekOperations = 0
    final = []
    final.append(head)
    tk.Label(text="Execution order:   ", fg="black", bg="#ffeeec", font=(' Helvetica', 9)).pack()
    while requests:
        closestReq = abs(current - requests[0])
        closestIndex = 0
        for x in range(1, len(requests)):
            if abs(current - requests[x]) < closestReq:
                closestReq = abs(current - requests[x])
                closestIndex = x
        seekOperations += abs(current - requests[closestIndex])
        current = requests[closestIndex]
        tk.Label(text=(str(current)), fg="black", bg="#ffeeec", font=(' Helvetica', 9)).pack()
        final.append(current)
        requests.remove(current)
    y = []
    for i in range(len(final), 0, -1):
        y.append(i)
    fig=simulate(final, y)
    fig.update_layout(title_text="Disk sequence chart using SSTF algorithm")
    plot(fig)
    tk.Label(text="Total seek operations:  " + str(seekOperations), width=40, font=(' Helvetica', 9)).pack()
    tk.Button(root, text="Reset", bg="#EAC2B0", fg="black", command=reset, font=(' Helvetica', 11)).pack()
    return seekOperations
Example #3
0
def add_face():
    # memunculkan window baru dan listbox (tambah wajah)
    addwindow = tk.Toplevel(mainWindow)
    listbox = tk.Listbox(addwindow)

    # refreshing listbox
    box_refresh(listbox)

    # function untuk command saat button add photo ditekan
    def add_photos():
        # menampilkan filedialog untuk mengambil file pada filesystem
        mainWindow.filename = filedialog.askopenfilename(initialdir='~',
                                                         title='Select a Picture',
                                                         filetypes=(('jpeg files', '*.jpg'),
                                                                    ('jpeg files', '*.jpeg'),
                                                                    ('all files', '*.*')))
        # jika terdapat file yang dipilih
        if mainWindow.filename != ():
            # menampilkan simple dialog untuk memasukkan nama
            name = simpledialog.askstring('Input', 'What\'s your name?', parent=mainWindow)
            # jika form nama tidak kosong
            if name is not None:
                # load image file to variable
                image = face_recognition.load_image_file(mainWindow.filename)
                # encode image
                face_encode = face_recognition.face_encodings(image)
                # jika gambar valid (terdapat wajah)
                if face_encode != []:
                    # menambahkan nama dan gambar ke database
                    sqlModule.insert_people_encoding(name, face_encode)
                    # merefresh listbox
                    box_refresh(listbox)
                # jika tidak ada wajah yang terdeteksi
                else:
                    print('face not detected')
            # jika form nama kosong
            else:
                print('name must be filled')
        # jika tidak ada file yang dipilih
        else:
            print('no file selected')

    # menambahkan button tambah photo
    add_btn = tk.Button(addwindow, text='Add photo', command=add_photos)
    add_btn.pack(side=tk.BOTTOM)

    listbox.pack()
def FCFS(head, requests):
    current = head
    seekOperations = 0
    final = []
    final.append(head)
    tk.Label(text="Execution order:   ", fg="black", bg="#ffeeec", font=(' Helvetica', 9)).pack()
    for x in range(len(requests)):
        seekOperations += abs(current - requests[x])
        current = requests[x]
        tk.Label(text=(str(current)), fg="black", bg="#ffeeec", font=(' Helvetica', 9)).pack()
        final.append(current)
    y = []
    for i in range(len(final), 0, -1):
        y.append(i)
    fig=simulate(final, y)
    fig.update_layout(title_text="Disk sequence chart using FCFS algorithm")
    plot(fig)
    tk.Label(text="Total seek operations :  " + str(seekOperations), width=40, font=(' Helvetica', 9)).pack()
    tk.Button(root, text="Reset", bg="#EAC2B0", fg="black", command=reset, font=(' Helvetica', 11)).pack()
def SCAN(head, req, given_direction):
    requests = list(req)
    current = head
    direction = given_direction
    seekOperations = 0
    final = []
    final.append(head)
    print(final)
    tk.Label(text="Execution order:   ", fg="black", bg="#ffeeec", font=(' Helvetica', 9)).pack()
    while requests:
        if current in requests:
            print(requests)
            tk.Label(text=(str(current)), fg="black", bg="#ffeeec", font=(' Helvetica', 9)).pack()
            final.append(current)
            requests.remove(current)
            if not requests:
                break
        if direction == "left" and current > 0:
            current -= 1
        if direction == "right" and current < 200:
            current += 1
        seekOperations += 1
        if current == 0:
            tk.Label(text='0', fg="black", bg="#ffeeec", font=(' Helvetica', 9)).pack()
            final.append(0)
            direction = "right"
        if current == 199:
            tk.Label(text='199', fg="black", bg="#ffeeec", font=(' Helvetica', 9)).pack()
            final.append(199)
            direction = "left"
    tk.Label(text="Total seek operations :  " + str(seekOperations), width=40, font=(' Helvetica', 9)).pack()
    y = []
    for i in range(len(final), 0, -1):
        y.append(i)
    fig=simulate(final, y)
    fig.update_layout(title_text="Disk sequence chart using SCAN algorithm")
    plot(fig)
    tk.Button(root, text="Reset", bg="#EAC2B0", fg="black", command=reset, font=(' Helvetica', 11)).pack()
Example #6
0
    s.grid(row=1, column=0, sticky=tkinter.W, pady=2)

    # entry widgets, used to take entry from user
    e1 = tkinter.Entry(top)
    e2 = tkinter.Entry(top)

    def click_button():
        pk = e1.get().lower()
        sk = e2.get().lower()
        my_label = tkinter.Label(top, text="Output.csv created!")
        # my_label.pack()
        my_label.grid(row=3, column=1, pady=2)

        web_scrape(url, pk, sk)

    my_button = tkinter.Button(top, text="Export to CSV", command=click_button)

    # this will arrange entry widgets
    e1.grid(row=0, column=1, pady=2)
    e2.grid(row=1, column=1, pady=2)
    my_button.grid(row=2, column=1, pady=2)

    # entry = tkinter.Entry(top, width=50, bg="white", fg="gray", borderwidth=5)
    # entry.pack()
    # label = tkinter.Label(top, text="pk")
    # label.grid(row=0, column=0)

    # def click_button():
    #     pk = e1.get()
    #     my_label = tkinter.Label(top, text="The button was clicked", width=50)
    #     my_label.grid(row=3, column=1, pady=2)
Example #7
0
def compare(head, req, given_direction):
    requests = list(req)
    current = head
    direction = given_direction
    seekOperations = 0
    final = []
    final.append(head)
    while requests:
        if current in requests:
            final.append(current)
            requests.remove(current)
            if not requests:
                break
        if direction == "left" and current > 0:
            current -= 1
        if direction == "right" and current < 200:
            current += 1
        seekOperations += 1
        if current == 0:
            final.append(0)
            direction = "right"
        if current == 199:
            final.append(199)
            direction = "left"
    y = []
    for i in range(len(final), 0, -1):
        y.append(i)
    fig = simulate(final, y)
    fig.update_layout(title_text="Disk sequence chart using SCAN algorithm")
    plot(fig)
    tk.Label(text="Total seek operations for SCAN:  " + str(seekOperations),
             width=40,
             fg="black",
             bg="#ffeeec",
             font=(' Helvetica', 10)).pack()

    requests1 = list(req)
    current1 = head
    seekOperations1 = 0
    final1 = []
    final1.append(head)
    while requests1:
        closestReq = abs(current1 - requests1[0])
        closestIndex = 0
        for x in range(1, len(requests1)):
            if abs(current1 - requests1[x]) < closestReq:
                closestReq = abs(current1 - requests1[x])
                closestIndex = x
        seekOperations1 += abs(current1 - requests1[closestIndex])
        current1 = requests1[closestIndex]
        final1.append(current1)
        requests1.remove(current1)
    y1 = []
    for i in range(len(final1), 0, -1):
        y1.append(i)
    fig1 = simulate(final1, y1)
    fig1.update_layout(title_text="Disk sequence chart using SSTF algorithm")
    plot(fig1)
    tk.Label(text="Total seek operations for SSTF are :  " +
             str(seekOperations1),
             width=40,
             fg="black",
             bg="#ffeeec",
             font=(' Helvetica', 10)).pack()

    current2 = head
    requests2 = list(req)
    seekOperations2 = 0
    final2 = []
    final2.append(head)
    for x in range(len(requests2)):
        seekOperations2 += abs(current2 - requests2[x])
        current2 = requests2[x]
        final2.append(current2)
    y2 = []
    for i in range(len(final2), 0, -1):
        y2.append(i)
    fig2 = simulate(final2, y2)
    fig2.update_layout(title_text="Disk sequence chart using FCFS algorithm")
    plot(fig2)
    tk.Label(text="Total seek operations for FCFS:  " + str(seekOperations2),
             width=40,
             fg="black",
             bg="#ffeeec",
             font=(' Helvetica', 10)).pack()

    # comparing the seek operations
    if (seekOperations > seekOperations1):
        if (seekOperations1 > seekOperations2):
            tk.Label(text="FFCS has the shortest seek time",
                     width=40,
                     fg="black",
                     bg="#ffeeec",
                     font=(' Helvetica', 10)).pack()
        elif (seekOperations1 == seekOperations2):
            tk.Label(text="FFCS and SSTF have the shortest seek time",
                     width=40,
                     fg="black",
                     bg="#ffeeec",
                     font=(' Helvetica', 10)).pack()
        else:
            tk.Label(text="SSTF has the shortest seek time",
                     width=40,
                     fg="black",
                     bg="#ffeeec",
                     font=(' Helvetica', 10)).pack()
    elif (seekOperations == seekOperations1):
        tk.Label(text="SCAN and SSTF have the shortest seek time",
                 width=40,
                 fg="black",
                 bg="#ffeeec",
                 font=(' Helvetica', 10)).pack()
    else:
        if (seekOperations > seekOperations2):
            tk.Label(text="FFCS has the shortest seek time",
                     width=40,
                     fg="black",
                     bg="#ffeeec",
                     font=(' Helvetica', 10)).pack()
        elif (seekOperations == seekOperations2):
            tk.Label(text="FFCS and SCAN have the shortest seek time",
                     width=40,
                     fg="black",
                     bg="#ffeeec",
                     font=(' Helvetica', 10)).pack()
        else:
            tk.Label(text="SCAN has the shortest seek time",
                     width=40,
                     fg="black",
                     bg="#ffeeec",
                     font=(' Helvetica', 10)).pack()

    tk.Button(root,
              text="Reset",
              bg="#EAC2B0",
              fg="black",
              command=reset,
              font=(' Helvetica', 11)).pack()
Example #8
0

# randomize button
e = tk.Entry(root,
             textvariable=name_var,
             font=('calibre', 10, 'normal'),
             width=50)
e.pack()
c = tk.Radiobutton(root,
                   text="Randomize",
                   fg="black",
                   bg="#ffeeec",
                   command=randomize).pack(pady=2)
clr = tk.Button(root,
                text='clear',
                command=clear,
                font=(' Helvetica', 10),
                bg="#EAC2B0").pack()

# head pos button
tk.Label(root,
         text="Enter the intial head position:",
         fg="black",
         bg="#ffeeec",
         font=('Helvetica', 11)).pack(padx=3)
f = tk.Entry(root,
             textvariable=name_var1,
             font=('calibre', 10, 'normal'),
             width=50)
f.pack()
Example #9
0
File: ex3.py Project: vaj90/python
from future.moves import tkinter
from tkinter import *
window = tkinter.Tk()
window.title('Gui in Python')
# set frame and geometry location widthxheight+xpos+ypos
window.geometry('900x500+100+100')

top_frame = tkinter.Frame(window).pack()
bottom_frame = tkinter.Frame(window).pack(side="bottom")


btn1 = tkinter.Button(top_frame, text='Button 1', bg='red', fg='white').pack()
btn2 = tkinter.Button(top_frame, text='Button 2', bg='green', fg='white').pack()
btn3 = tkinter.Button(bottom_frame, text='Button 3', bg='blue', fg='white').pack(side="left")
btn4 = tkinter.Button(bottom_frame, text='Button 4', bg='blue', fg='orange').pack(side="left")

window.mainloop()
Example #10
0
label = tk.Label(window,
                 text="Find out the genre of your playlist",
                 bg='#66ff66',
                 borderwidth=2,
                 relief="groove",
                 font=("Courier", 20))
label.place(relx=0.5, rely=0.15, relwidth=0.9, relheight=0.05, anchor='n')

# Entry row
frame = tk.Frame(window, bg='lightgray', borderwidth=2, relief="groove")

frame.place(relx=0.5, rely=0.2, relwidth=0.9, relheight=0.04, anchor='n')
username_entry = tk.Entry(frame, font=40)
username_entry.place(relwidth=0.3, relheight=1)

button = tk.Button(frame, text="Search User", command=callback)
button.place(relx=0.3, relheight=1, relwidth=0.2)

variable = tk.StringVar(window)
variable.set(OptionList[0])
opt = tk.OptionMenu(frame, variable, *OptionList)
opt.config(width=90, font=('Helvetica', 12))
opt.place(relx=0.5, relwidth=0.5, relheight=1)
variable.trace("w", callback)

button = tk.Button(window,
                   text=">>> Analyze Playlist <<<",
                   command=determine,
                   bg='lightgray')
button.place(relx=0.05, rely=0.24, relheight=0.05, relwidth=0.9)
    text=
    "This is a simulator that demonstrates the three common disk scheduling algorithms which are SCAN,SSTF and FCFS",
    fg="black",
    bg="#ffeeec",
    font=(' Helvetica', 11)).pack()
tk.Label(root,
         text="Choose any of the options below",
         fg="black",
         bg="#ffeeec",
         font=(' Helvetica', 12)).pack()
sub_btn = tk.Button(
    root,
    wraplength=100,
    text=
    'To generate a chart showing the sequence in which the requests have been serviced',
    command=graph,
    height=10,
    width=20,
    bg="#EAC2B0",
    fg="black",
    font=(' Helvetica', 12)).pack(padx=10, pady=10)
sub_btn = tk.Button(
    root,
    wraplength=100,
    text='To find the best algorithm for a given disk sequence',
    command=recomm,
    height=7,
    width=20,
    fg="black",
    bg="#EAC2B0",
    font=(' Helvetica', 12)).pack(padx=10, pady=10)
Example #12
0
        ButtonRecord.config(text="Stop Recording")
        thread = threading.Thread(target=thread_record, args=(1, ))
        thread.daemon = True  # Daemonize thread
        thread.start()  # Start the execution
        # record_to_file('demo.wav')
    else:
        is_recording = False
        ButtonRecord.config(text="Record")


def button_play():
    pass


ButtonRecord = tk.Button(text="Record",
                         bg="#bb0d1c",
                         fg="black",
                         command=button_record)
ButtonRecord.place(x=150, y=425, width=150, height=40)

ButtonPlay = tk.Button(text="Play",
                       bg="#bb0d1c",
                       fg="black",
                       command=button_play)
ButtonPlay.place(x=500, y=425, width=150, height=40)

ButtonDebug = tk.Button(text="Debug",
                        bg="yellow",
                        fg="black",
                        command=print_selection)
ButtonDebug.place(x=355, y=425, width=90, height=40)
Example #13
0
import Rendezvous
import Auto_orbit

top = tkinter.Tk()

#define

# The Rendevous Scritp
label_rendezvous = tkinter.Label(
    top,
    text=
    'Start a rendez-vous as follows:\n1. Launch Space Plane.\n2. Select Target.\n3. Press \'Rendez-vous\'',
    anchor="e",
    justify='left')
button_rendezvous = tkinter.Button(top,
                                   text='Rendez-vous',
                                   command=lambda: Rendezvous.rendez_vous())

# The Auto_Orbit Script
# Enter Target Apoapsis
label_target_ap = tkinter.Label(
    top,
    text=
    'Start auto_orbit as follows:\n1. Define the target Apoapsis in meters:',
    anchor="e",
    justify='left')
entry_target_ap = tkinter.Entry(top)
entry_target_ap.insert(0, '90000')

# Enter Orbital Inclination
label_orbit_inc = tkinter.Label(
Example #14
0
File: ex2.py Project: vaj90/python
                         'Cabbage town')
cboLocation.current(0)
cboLocation.grid(row=2, column=0)

# Checkbox
chkSelect = BooleanVar(window)
chkSelect.set(True)
chkObj = Checkbutton(window, text='Select if True', var=chkSelect)
chkObj.grid(row=3, column=0)

# Radio button
rad1 = Radiobutton(window, text='Python', value=1)
rad1.grid(row=4, column=0)
rad2 = Radiobutton(window, text='Java', value=2)
rad2.grid(row=4, column=1)
rad3 = Radiobutton(window, text='C#', value=3)
rad3.grid(row=4, column=2)

# Button
btnClick = tkinter.Button(window,
                          text='Submit',
                          bg='blue',
                          fg='white',
                          command=clicked)
btnClick.grid(row=6, column=0)

# Spinbox
spnNumber = tkinter.Spinbox(window, from_=0, to=100, width=20)
spnNumber.grid(row=5, column=0)

window.mainloop()
Example #15
0
from future.moves import tkinter
from tkinter import *
window = tkinter.Tk()
window.title('Gui in Python')
# set frame and geometry location widthxheight+xpos+ypos
window.geometry('900x500+100+100')

tkinter.Label(window, text="Username").grid(row=0)
tkinter.Entry(window, width=30).grid(row=0, column=1)
tkinter.Label(window, text="Password").grid(row=1)
tkinter.Entry(window, width=30).grid(row=1, column=1)
tkinter.Button(window, text='login', bg='red', fg='white').grid(columnspan=2,
                                                                row=2)
window.mainloop()