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
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)
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()
# in cmd line # pip install future # then restart pycharm from future.moves import tkinter from tkinter import * window = tkinter.Tk() window.title('Gui in Python') lblHello = tkinter.Label(window, text='Hello World').pack() window.mainloop()
data = list(file) words = data[1] word = words[0].split(";") primary_kw = word[0] secondary_kw = word[1] url = url + primary_kw #for row in data: # print(row) else: top = tkinter.Tk() top.title("Content Generator") # this wil create a label widget p = tkinter.Label(top, text="Primary Keyword:") s = tkinter.Label(top, text="Secondary Keyword:") # code for project here # grid method to arrange labels in respective # rows and columns as specified p.grid(row=0, column=0, sticky=tkinter.W, pady=2) 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()
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()
}] }] }, frames=frames) fig.layout.plot_bgcolor = '#ffeeec' fig.layout.paper_bgcolor = '#fff' fig.update_xaxes(range=[0, 200]) fig.update_yaxes(range=[0, max(y) + 1]) fig.update_layout(transition_duration=3000) return fig # disk simulator heading a = tk.Label(root, text="Disk Scheduling Simulator", fg="black", bg="#ffeeec", font=('Helvetica', 15), wraplength=1300) a.pack(pady=30) # enter the disk sequence heading b = tk.Label( root, text= "Enter the disk sequence:\n (make sure that the integers are comma seperated ex:12,13,14)", fg="black", bg="#ffeeec", font=('Helvetica', 11)) b.pack() # variables
# convert color from BGR to RGBA cv2img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA) # get image from array img = Image.fromarray(cv2img) # create instance of ImageTk and add it into mainwindow imgtk = ImageTk.PhotoImage(image=img) main_window.imgtk = imgtk main_window.configure(image=imgtk) main_window.after(8, show_recog_cam) if __name__ == '__main__': mainWindow = tk.Tk() mainWindow.bind('<Escape>', lambda e: mainWindow.quit()) main_window = tk.Label(mainWindow) main_window.pack() # initiate connection to database sqlModule.init_connection() # refreshing known_face... list refresh() menuBar = tk.Menu(mainWindow) fileMenu = tk.Menu(menuBar, tearoff=0) fileMenu.add_command(label='Add New Face', command=add_face) fileMenu.add_command(label="Delete Face", command=del_face) fileMenu.add_separator() fileMenu.add_command(label='Exit', command=mainWindow.quit)
def determine(): global playlist global variable # Reset genre composition dictionary playlist.all_genres = { 'rock': 0, 'electronic': 0, 'acoustic': 0, 'rnb': 0, 'country': 0, 'blues': 0, 'alternative': 0, 'classical': 0, 'rap': 0, 'hip-hop': 0, 'indie': 0, 'jazz': 0, 'reggae': 0, 'pop': 0, 'punk': 0, 'metal': 0, 'ballad': 0 } # ERROR: Username not found if (username_entry.get() == "" or username_entry.get() == None): messagebox.showerror( title="Username Error", message= "Username not found. Your Spotify username can be found in the upper-right hand corner of the desktop app and in the settings menu in the mobile app." ) else: # QUERY playlist_found = False for k, v in playlist.get_user_playlists_api().items(): if k == variable or variable == "All Playlists": playlist_found = True # 1 playlist if k == variable: song_apis = playlist.get_playlist_song_apis(v) for api in song_apis: song_artist = playlist.get_song_artist(api) queried_genres = playlist.get_genres((song_artist)) for genre in queried_genres: if genre.lower() in playlist.all_genres.keys(): playlist.all_genres[genre.lower()] += 1 # All playlist else: song_apis = playlist.get_playlist_song_apis(v) for song_api in song_apis: song_artist = playlist.get_song_artist(song_api) queried_genres = playlist.get_genres((song_artist)) for genre in queried_genres: if genre.lower() in playlist.all_genres.keys(): playlist.all_genres[genre.lower()] += 1 # PIE CHART AND RANKING if playlist_found: # RANKING frame2 = tk.Frame(window, bg='#66ff66') frame2.place(relx=0.75, rely=0.35, relwidth=0.3, relheight=0.5, anchor='n') label = tk.Label(frame2, text="Top 5 Genres", bg='#737373', fg='#ffffff') label.place(relx=0.5, rely=0, relwidth=1, relheight=0.1, anchor='n') colors = [ 'gold', 'yellowgreen', 'lightcoral', 'lightskyblue', 'orange' ] explode = (0.1, 0, 0, 0, 0) # explode 1st slice # Drop genres with 0 count null_genres = [] for k, v in playlist.all_genres.items(): if v == 0: null_genres.append(k) for null_genre in null_genres: del playlist.all_genres[null_genre] # if more than 5 genres pick the top 5 if len(playlist.all_genres) > 5: genre_count = dict(Counter(playlist.all_genres).most_common(5)) # print(genre_count) # print(playlist.all_genres) label = tk.Label(frame2, text="(1) {}".format( list(genre_count.keys())[0]), bg='#66ff66', fg='#000000', borderwidth=2, relief="groove") label.place(relx=0.5, rely=0.1, relwidth=1, relheight=0.18, anchor='n') label = tk.Label(frame2, text="(2) {}".format( list(genre_count.keys())[1]), bg='#66ff66', fg='#000000', borderwidth=2, relief="groove") label.place(relx=0.5, rely=0.28, relwidth=1, relheight=0.18, anchor='n') label = tk.Label(frame2, text="(3) {}".format( list(genre_count.keys())[2]), bg='#66ff66', fg='#000000', borderwidth=2, relief="groove") label.place(relx=0.5, rely=0.46, relwidth=1, relheight=0.18, anchor='n') label = tk.Label(frame2, text="(4) {}".format( list(genre_count.keys())[3]), bg='#66ff66', fg='#000000', borderwidth=2, relief="groove") label.place(relx=0.5, rely=0.64, relwidth=1, relheight=0.18, anchor='n') label = tk.Label(frame2, text="(5) {}".format( list(genre_count.keys())[4]), bg='#66ff66', fg='#000000', borderwidth=2, relief="groove") label.place(relx=0.5, rely=0.82, relwidth=1, relheight=0.18, anchor='n') # if less than or equal to 5 genres pick only that amount else: label = tk.Label(frame2, text="", bg='#66ff66', fg='#000000', borderwidth=2, relief="groove") label.place(relx=0.5, rely=0.1, relwidth=1, relheight=0.18, anchor='n') label = tk.Label(frame2, text="", bg='#66ff66', fg='#000000', borderwidth=2, relief="groove") label.place(relx=0.5, rely=0.28, relwidth=1, relheight=0.18, anchor='n') label = tk.Label(frame2, text="", bg='#66ff66', fg='#000000', borderwidth=2, relief="groove") label.place(relx=0.5, rely=0.46, relwidth=1, relheight=0.18, anchor='n') label = tk.Label(frame2, text="", bg='#66ff66', fg='#000000', borderwidth=2, relief="groove") label.place(relx=0.5, rely=0.64, relwidth=1, relheight=0.18, anchor='n') label = tk.Label(frame2, text="", bg='#66ff66', fg='#000000', borderwidth=2, relief="groove") label.place(relx=0.5, rely=0.82, relwidth=1, relheight=0.18, anchor='n') genre_count = dict( Counter(playlist.all_genres).most_common( len(playlist.all_genres))) colors = [ 'gold', 'yellowgreen', 'lightcoral', 'lightskyblue', 'orange' ] explode = np.repeat(0, len(genre_count)) # explode 1st slice explode[len(explode) - 1] = 0 colors = colors[:len(genre_count)] for i in range(len(genre_count)): label = tk.Label(frame2, text="({}) {}".format( i + 1, list(genre_count.keys())[i]), bg='#66ff66', fg='#000000', borderwidth=2, relief="groove") label.place(relx=0.5, rely=0.1 + 0.18 * i, relwidth=1, relheight=0.18, anchor='n') # print(explode) # print(genre_count) # print(playlist.all_genres) fig = Figure(figsize=(5, 4), dpi=100) plot = fig.add_subplot(111) plot.pie(list(genre_count.values()), explode=explode, labels=list(genre_count.keys()), colors=colors, autopct='%1.1f%%', shadow=True, startangle=140) canvas = FigureCanvasTkAgg(fig, master=window) # A tk.DrawingArea. canvas.draw() canvas.get_tk_widget().place(relx=0.05, rely=0.3, relwidth=0.5, relheight=0.5) fig.patch.set_facecolor("lightgray") # Top Genre Report messagebox.showinfo(title="Top Genre", message="Top genre is {}.".format( list(genre_count.keys())[0])) print(genre_count) # ERROR: Playlist not found else: messagebox.showerror(title="Playlist Error", message="Select your playlist!")
window.tk.call('wm', 'iconphoto', window._w, tk.PhotoImage(file='spotify.png')) window.tk.call('wm', 'iconphoto', window._w, tk.PhotoImage(file='spotify.png')) # Background color background_color = tk.Frame(window, bg="#ebadad") background_color.place(relx=0.5, rely=0, relwidth=1, relheight=1, anchor='n') # Border outline border = tk.Frame(window, borderwidth=2, relief='groove', bg="lightgray") border.place(relx=0.5, rely=0.05, relwidth=0.9, relheight=0.9, anchor='n') # Header label = tk.Label(window, text="SpotiPlus by h1yung", bg='#737373', fg='#ffffff', borderwidth=2, relief="groove", font=("Courier", 44)) label.place(relx=0.5, rely=0.05, relwidth=0.9, relheight=0.1, anchor='n') 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")
root.title("Disk simulator") def graph(): os.system('maingui.py') def recomm(): os.system('recommender.py') root.configure(bg="#ffeeec") #disk simulator heading a = tk.Label(root, text="Disk Scheduling Simulator", fg="black", bg="#ffeeec", font=('Helvetica', 30), wraplength=1300).pack(pady=15, padx=30) tk.Label( root, 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(
from tkinter import * from sys import byteorder from array import array from struct import pack import pyaudio import wave #const NUM = 12 root = tk.Tk() # width x height + x_offset + y_offset: root.geometry("800x480+300+300") root.configure(bg='#505050') chart = tk.Label(root, text="chart", bg="grey") chart.place(x=20, y=20, width=760, height=200) slider = [ '#1', '#2', '#3', '#4', '#5', '#6', '#7', '#8', '#9', '#10', '#11', '#12' ] slider_values = [] labels = range(12) for i in range(12): slider_values.append(IntVar()) bg_colour = '#808080' #l = tk.Label(root, # text=slider[i], # bg=bg_colour)
from future.moves import tkinter 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
from future.moves import tkinter from tkinter import * from tkinter import messagebox from tkinter.ttk import * window = tkinter.Tk() window.title('Gui in Python') # set frame and geometry location widthxheight+xpos+ypos window.geometry('900x500+100+100') # Label lblHello = tkinter.Label(window, text='Enter your name: ', font=("Arial", 16)) lblHello.grid(row=0, column=0) lblOutput = tkinter.Label(window, text='Output:', font=("Arial", 16)) lblOutput.grid(row=1, column=0) # Textbox txtEntry = Entry(window, widt=30) txtEntry.grid(row=0, column=1) # Action def clicked(): res = "Hello " + txtEntry.get() lblOutput.configure(text='Output:' + res) messagebox.showinfo('Greetings Window', res) # Combobox cboLocation = Combobox(window)
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()