def MasterFunction(): MasterWindow = Tk() MasterWindow.title("Self Destruct") MasterWindow.geometry("1920x1080") def UserName(): global StoredName Canvas(MasterWindow, width=1920, height=1080, bg = "snow").place(x = 0, y = 0) StoredName = StringVar() NameLabel = Label(text = "Please enter your name", bg = "snow", font = font2) NameLabel.pack() NameEntryBox = Entry(bd = 4, textvariable = StoredName, bg = "snow", font = font2) NameEntryBox.pack() ButtonName = Button(text = "Continue", font = font2, bg = "snow", command = ChangeThis) ButtonName.pack() def ChangeThis(): label1 = Label(text = StoredName, bg = "snow", font = font2) label1.pack() def Menu(): #The first window the user sees. Canvas(width = 1920, height = 1080, bg = "snow").place(x = 0, y = 0) TitleMain = Label(MasterWindow, text = "Self Destruct", font = font1, fg = "deep sky blue", bg = "snow").place( x = 845, y = 1) ButtonStart = Button(MasterWindow, text = "Start", font = font2, fg = "deep sky blue", bg = "snow", command = UserName).place( x = 909, y = 60) ButtonExit = Button(MasterWindow, text ="Exit", font = font2, fg = "deep sky blue", bg = "snow", command = exit).place( x = 915, y = 130) Menu()
def Creditos(): Ventana1 = Tk() Ventana1.title("Créditos") Ventana1.geometry("500x200") Ventana1.resizable(width=False, height=False) im = Image.open("Info/proteco.png") im = im.resize((100, 100), Image.ANTIALIAS) ph = ImageTk.PhotoImage(im, master=Ventana1) label = Label(Ventana1, image=ph).place(x=20, y=20) MARIO = Label(Ventana1, text="Mario Alberto Vásquez Cancino ").place(x=140, y=35) MARIO1 = Label(Ventana1, text="Becario PROTECO Generación 37").place(x=160, y=55) MARIO2 = Label(Ventana1, text="Unánse al programa está super padre :)").place(x=140, y=75) PROTECO = Label(Ventana1, text="Info en Facebook: Proteco").place(x=160, y=95) RAUL = Label( Ventana1, text="Agradecimientos especiales a Raul E. Lopez Briega:").place(x=20, y=140) RAUL1 = Label( Ventana1, text="-Por tan buen blog, base para poder realizar este programa." ).place(x=40, y=160) Ventana1.mainloop()
def InfoNor(): Ventana1 = Tk() Ventana1.title("Distribución Normal") Ventana1.geometry("965x290") Ventana1.resizable(width=False, height=False) im = Image.open("Info/nor.png") ph = ImageTk.PhotoImage(im, master=Ventana1) label = Label(Ventana1, image=ph).place(x=0, y=0) Ventana1.mainloop()
def InfoHiper(): Ventana1 = Tk() Ventana1.title("Distribución Hipergeométrica") Ventana1.geometry("985x535") Ventana1.resizable(width=False, height=False) im = Image.open("Info/hiper.png") ph = ImageTk.PhotoImage(im, master=Ventana1) label = Label(Ventana1, image=ph).place(x=0, y=0) Ventana1.mainloop()
def InfoPoi(): Ventana1 = Tk() Ventana1.title("Distribución Poisson") Ventana1.geometry("980x400") Ventana1.resizable(width=False, height=False) im = Image.open("Info/poi.png") ph = ImageTk.PhotoImage(im, master=Ventana1) label = Label(Ventana1, image=ph).place(x=0, y=0) Ventana1.mainloop()
def InfoUni(): Ventana1 = Tk() Ventana1.title("Distribución Uniforme") Ventana1.geometry("730x445") Ventana1.resizable(width=False, height=False) im = Image.open("Info/uni.png") ph = ImageTk.PhotoImage(im, master=Ventana1) label = Label(Ventana1, image=ph).place(x=0, y=0) Uniforme() Ventana1.mainloop()
def InfoBer(): Ventana1 = Tk() Ventana1.title("Distribución Bernoulli") Ventana1.geometry("964x345") Ventana1.resizable(width=False, height=False) im = Image.open("Info/ber.png") ph = ImageTk.PhotoImage(im, master=Ventana1) label = Label(Ventana1, image=ph).place(x=0, y=0) Bernoulli() Ventana1.mainloop()
def InfoExp(): Ventana1 = Tk() Ventana1.title("Distribución Exponencial") Ventana1.geometry("960x284") Ventana1.resizable(width=False, height=False) im = Image.open("Info/exp.png") ph = ImageTk.PhotoImage(im, master=Ventana1) label = Label(Ventana1, image=ph).place(x=0, y=0) Exponencial() Ventana1.mainloop()
def Employee(): filename = "EmployeeDetails\EmployeeDetails.csv" root3 = Tk() root3.title("Employee Table") frame = Frame(root3) frame.pack() pt = Table(frame) pt.importCSV(filename) pt.show() root3.mainloop()
def attendance(): ts = time.time() date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d') filename = "Attendance\Attendance_" + date + ".csv" root2 = Tk() root2.title("Attendance Table") frame = Frame(root2) frame.pack() pt = Table(frame) pt.importCSV(filename) pt.show() root2.mainloop()
def MasterFunction(): MasterWindow = Tk() MasterWindow.title("Self Destruct") MasterWindow.geometry("1920x1080") def UserName(): global StoredName Canvas(MasterWindow, width=1920, height=1080, bg="snow").place(x=0, y=0) StoredName = StringVar() NameLabel = Label(text="Please enter your name", bg="snow", font=font2) NameLabel.pack() NameEntryBox = Entry(bd=4, textvariable=StoredName, bg="snow", font=font2) NameEntryBox.pack() ButtonName = Button(text="Continue", font=font2, bg="snow", command=ChangeThis) ButtonName.pack() def ChangeThis(): label1 = Label(text=StoredName, bg="snow", font=font2) label1.pack() def Menu(): #The first window the user sees. Canvas(width=1920, height=1080, bg="snow").place(x=0, y=0) TitleMain = Label(MasterWindow, text="Self Destruct", font=font1, fg="deep sky blue", bg="snow").place(x=845, y=1) ButtonStart = Button(MasterWindow, text="Start", font=font2, fg="deep sky blue", bg="snow", command=UserName).place(x=909, y=60) ButtonExit = Button(MasterWindow, text="Exit", font=font2, fg="deep sky blue", bg="snow", command=exit).place(x=915, y=130) Menu()
class MainApp: def __init__(self): self.pre = None #model to predict self.model = Model() #creating root self.root = Tk() self.root.title("Digit Recognizer") self.root.resizable(0,0) #Gui elements self.lbl_drawhere = LabelFrame(text = 'Draw Here With Mouse') self.area_draw = Canvas(self.lbl_drawhere, width = 504, height = 504, bg ='black') self.area_draw.bind('<B1-Motion>',self.draw) self.btn_reset = Button(self.lbl_drawhere, text = "Reset Drawing", bg = "lightblue",command = self.reset_drawing) self.btn_predict = Button(self.root, text = 'Predict Digit', bg = "blue", command = self.predict_digit) #Fitting in th Gui self.lbl_drawhere.pack(in_=self.root, side = LEFT, fill = X) self.area_draw.pack() self.btn_reset.pack() self.btn_predict.pack(in_=self.root, side = LEFT) def draw(self,event): self.area_draw.create_oval(event.x,event.y,event.x+27,event.y+27, outline='white',fill = 'white') self.area_draw.create_rectangle(event.x,event.y,event.x+25,event.y+25, outline = 'white',fill = 'white') self.pre = 'D' def run(self): self.root.mainloop() def reset_drawing(self): self.area_draw.delete('all') def predict_digit(self): if(self.pre == None): messagebox.showerror(title = 'No Images', messgae = 'First Draw a number') else: x = self.root.winfo_rootx() + self.area_draw.winfo_x() y = self.root.winfo_rooty() + self.area_draw.winfo_y() x1 = x + self.area_draw.winfo_width() y1 = y + self.area_draw.winfo_height() ImageGrab.grab(bbox = (x,y+10,x1,y1)).save('image.png') messagebox.showinfo( title = 'Prediction' , message = "Number: {}".format(self.model.predict()))
def TkDemo(): # Finally, set up <root> & start UI """ HELP: Tk-GUI-MVC via a Class TESTS: TkDemo() """ root = Tk() root.title( 'TSLA/AAPL' ) root.lift() app = UiSuperFrame( root ) app.mainloop() pass
def openDF(df): df_window = Tk() df_window.title("Findings") cols = list(df.columns) tree = ttk.Treeview(df_window) tree.pack() tree["columns"] = cols for i in cols: tree.column(i, anchor="w") tree.heading(i, text=i, anchor='w') for index, row in df.iterrows(): tree.insert("", 0, text=index, values=list(row)) df_window.mainloop()
def chamarTelaListaMusicas(): janela = Tk() janela.title("Lista de Músicas") telaL = 500 telaA = 400 telaLargura = janela.winfo_screenwidth() telaAltura = janela.winfo_screenheight() x = (telaLargura / 2) - (telaL / 2) y = (telaAltura / 2) - (telaA / 2) janela.geometry("%dx%d+%d+%d" % (telaL, telaA, x, y)) janela.iconbitmap("icones/icon_player.ico") for i in range(len(lista)): Label(text='- ' + lista[i]).pack() janela.mainloop()
def add_user(): root1 = Tk() root1.title("User Registration") Label(root1, text="Employee Name", font=('eras bold itc', 12)).grid(row=0, sticky=W) Label(root1, text="Employee ID", font=('eras bold itc', 12)).grid(row=1, sticky=W) Label(root1, text="Age", font=('eras bold itc', 12)).grid(row=2, sticky=W) Label(root1, text="Department", font=('eras bold itc', 12)).grid(row=3, sticky=W) Label(root1, text="Phone Number", font=('eras bold itc', 12)).grid(row=4, sticky=W) Fname = Entry(root1) Fname.grid(row=0, column=1) id = Entry(root1) id.grid(row=1, column=1) age = Entry(root1) age.grid(row=2, column=1) dept = Entry(root1) dept.grid(row=3, column=1) phone = Entry(root1) phone.grid(row=4, column=1) root1.grid_columnconfigure(1, minsize=150) root1.geometry("290x160") def getInput(): global params1 global params2 global params3 global params4 global params5 params1 = Fname.get() params2 = id.get() params3 = age.get() params4 = dept.get() params5 = phone.get() root1.destroy() Button(root1, text="Submit", font=('cooper black', 12), command=lambda: [getInput(), capture()]).grid(row=5, sticky=W) root1.mainloop()
def chamarTelaListaMusicas(): janela = Tk() janela.title("Lista de Músicas") telaL = 500 telaA = 400 telaLargura = janela.winfo_screenwidth() telaAltura = janela.winfo_screenheight() x = (telaLargura / 2) - (telaL / 2) y = (telaAltura / 2) - (telaA / 2) janela.geometry("%dx%d+%d+%d" % (telaL, telaA, x, y)) janela.iconbitmap( "C:/Users/Romão/PycharmProjects/Exercicios-Python/exercicios/icone.ico" ) for i in range(len(lista)): Label(text='- ' + lista[i]).pack() janela.mainloop()
def mainloop(file): global window global entry global txt global author global send_to send_to = None author = file sock = socket.socket() sock.connect(('25.95.4.168', 10001)) sock.send((file + ' connect').encode('utf-8')) data = sock.recv(1024).decode('utf-8') sock.close() window = Tk() window.resizable(False, False) window.title(file) window.geometry("800x800") while True: quit_btn = Button(window, text="Выйти", command=quit, bg="red") send_btn = Button(window, text="Отправить", command=send, bg="green") data = data.replace(file, "") accounts = data.split() frame = Frame(window) frame.place(x=200, y=0, width=600, height=600) txt = Text(frame, width=580, height=600, wrap=NONE, state=DISABLED) txt.pack(side="left") n = 0 for i in accounts: funk = partial(update, file, i) Button(window, command=funk, text=i).place(x=0, y=n * 120, width=200, height=120) n += 1 scroll = Scrollbar(frame, command=txt.yview, orient=VERTICAL, width=20) scroll.pack(side=RIGHT, fill=Y) txt.config(yscrollcommand=scroll.set) entry = Entry(window) quit_btn.place(x=200, y=695, width=100, height=50) send_btn.place(x=500, y=695, width=100, height=50) entry.place(x=200, y=600, width=600, height=40) window.mainloop() update(file, send_to)
def start(): window = Tk() window.title('BattleShips with AI') window.geometry('500x500') menu = Menu(window) new_item = Menu(menu) new_item.add_command(label='New') new_item.add_command(label='Exit') menu.add_cascade(label='File', menu=new_item) window.config(menu=menu) lbl = Label(window, text='Enter your positions', font=('Helvetica', 25)) lbl.grid(column=0, row=0) ship5 = Entry(window, width=6) ship5.grid(column=1, row=0) ship4 = Entry(window, width=6) ship4.grid(column=1, row=1) ship3_1 = Entry(window, width=6) ship3_1.grid(column=1, row=2) ship3_2 = Entry(window, width=6) ship3_2.grid(column=1, row=3) ship2 = Entry(window, width=6) ship2.grid(column=1, row=4)
def quiz(): mat = Tk() global count, score score = 0 count = 0 mat.geometry("800x400") mat.title("English Quiz") mat.configure(background="yellow") def ask_question(): global score, count # get globals qq = get_questions("english.json") score_readout = Label(mat, text="Score: " + str(score) + "/" + str(count), font=(None, 15), fg="blue", bg="yellow") score_readout.pack(side="top", anchor="w") # retrive questions from json parcer with inputed json files eh1 = Label(mat, text="Question " + str(count + 1), font=(None, 15), fg="blue", bg="yellow") eh1.pack(side="top", anchor="e") spacing_label = Label(mat, text="", font=(None, 15), fg="blue", bg="yellow") spacing_label.pack() question_label = Label(mat, text=qq[4], font=(None, 10), fg="blue", bg="yellow", wraplength=750) question_label.pack(side="top", anchor="w") def correct(): global score, count mixer.init(22050, -8, 4, 65536) mixer.music.load('rr.ogg') mixer.music.play(0) score = score + 1 count = count + 1 unpack_all() if count < 10: ask_question() else: end_score = str(score) + " / " + str(10) messagebox.showinfo( "Score", "Your Score Was: %s" % score + " Out of 10") mat.destroy() def incorrect(): global count, score mixer.init(22050, -8, 4, 65536) mixer.music.load('ww.ogg') mixer.music.play(0) count = count + 1 unpack_all() if count < 10: ask_question() else: # end_score = str(score)+"/"+"10" mat.destroy() messagebox.showinfo( "Score", "Your Score Was: %s" % score + " Out of 10") mat.destroy() score = 0 count = 0 # end_score = 0 spacing_label2 = Label(mat, text="", bg='yellow') spacing_label2.pack() def unpack_all(): for mat_b in bttns: mat_b.pack_forget() score_readout.pack_forget() eh1.pack_forget() question_label.pack_forget() spacing_label.pack_forget() spacing_label2.pack_forget() mat_b1 = Button(mat, text=qq[0], command=correct, font=(None, 12), width=80, bg='gold', fg='blue') mat_b2 = Button(mat, text=qq[1], command=incorrect, font=(None, 12), width=80, bg='gold', fg='blue') mat_b3 = Button(mat, text=qq[2], command=incorrect, font=(None, 12), width=80, bg='gold', fg='blue') mat_b4 = Button(mat, text=qq[3], command=incorrect, font=(None, 12), width=80, bg='gold', fg='blue') bttns = [mat_b1, mat_b2, mat_b3, mat_b4] shuffle(bttns) for mat_ in bttns: mat_.pack(side="top", anchor="w") ask_question() mat.mainloop()
import tkinter as Tk from tkinter import * from tkinter import ttk from motor_print import run_motor master = Tk() master.title("ATFL GUI") w, h = 500, 500 canvas = Canvas(master, width=w, height=h) canvas.pack() tabControl = ttk.Notebook(master) tab1 = ttk.Frame(tabControl) #making a frame tabControl.add(tab1, text='Main Screen') #properties of the fram tab2 = ttk.Frame(tabControl) tabControl.add(tab2, text='Advanced') tabControl.pack(expand=1, fill='both') run_count = 0 def push_button(): global run_count #need this to have a counter run_motor() run_count += 1 print("done run " + str(run_count)) #make sure the value is in string format
m += 1 MotAffiche.pop(2 * k) MotAffiche.insert(2 * k, x) if m == 0: chances += -1 else: score += m print(TransfoListeChaine(MotAffiche)) print("Nombre de vies restantes : " + str(chances)) else: print("La lettre choisie a déjà été demandée") print(TransfoListeChaine(MotAffiche)) NewFenetre = Tk() NewFenetre.title('Le Pendu') NewFenetre.geometry('400x400+400+400') BoutonLancer = Button(NewFenetre, text='Jouer', command=lambda: Afficher_(MotRandom())) BoutonLancer.pack(side=LEFT, padx=4, pady=4) NewFenetre.mainloop() BoutonInstruction = Button(NewFenetre, text='Instructions', command=Regle) BoutonInstruction.pack(side=LEFT, padx=4, pady=4) BoutonQuitter = Button(NewFenetre, text='Quitter', command=NewFenetre.destroy) BoutonQuitter.pack(side=LEFT, padx=4, pady=4) BoutonRejouer = Button(NewFenetre, text='Rejouer', command=Regle) BoutonRejouer.pack(side=LEFT, padx=4, pady=4)
import tkinter as Tk from tkinter import * import pyodbc as odbc from pyodbc import * events = Tk() events.title("Events") events.geometry('400x600') # Databases # Create a Database or Connect to one conn = odbc.connect('Driver={SQL Server};' 'Server=DESKTOP-SCL1250\SQLEXPRESS01;' 'Database=tgt;' 'Trusted_Connection=yes;') # Create Cursor c = conn.cursor() # Create Functions # Create Text Boxes event_id = Entry(events, width=30) event_id.grid(row=1, column=1, padx=20) event_type = Entry(events, width=30) event_type.grid(row=2, column=1, padx=20) event_name = Entry(events, width=30) event_name.grid(row=3, column=1, padx=20) event_winner = Entry(events, width=30) event_winner.grid(row=4, column=1, padx=20)
#!/usr/bin/env python # coding: utf-8 # In[21]: import tkinter as Tk from tkinter import * import tkinter # In[54]: top = Tk() top.title("Data Science") top.geometry("1200x800+0+0") top.configure(background="powderblue") def func(): n = name.get() print(n) tkinter.Label(top, text="Today's Visitor", font=('times', 20, 'bold'), height='1', width='13').grid(row=0, column=0, sticky=W) tkinter.Label(top, text="0",
root = Tk.Tk() def message(): print("on click message") bu = Tk.Button(root, text="CLICK", command=message) bu.pack() root.mainloop() #4. def type(): global e string = e.get() print(string) from tkinter import * root = Tk() root.title('Get text and print') e = Entry(root) e.pack() e.focus_set() b = Button(root, text='ENTER', command=type) b.pack(side='bottom') root.mainloop()
# Tkinter GUI creating library from PIL import ImageTk, Image # from photo image library import Tkinter image and image manipulation from pygame import mixer # Import pygame mixer library to play audio import json # library to decode json into python dictionary from random import randint, shuffle # Library to produce random integers and shuffle lists # Library to create system dialogs root = Tk() # Set root to main tkinter window root.minsize(width=666, height=666) # Specify minimum size for root window root.title("Revision") # Set the title at top of the window sound = True # Variable to allow the user to disable sound def get_questions(json_file): file_open = open(json_file) # Opens specified JSON file for reading json_raw = file_open.read() # Reads JSON file as a string json_data = json.loads(json_raw) # Decodes JSON data as a python dictionary from a string index = json_data['index'] # Gets index of how many questions are in JSON file
import tkinter as Tk from tkinter import * import pyodbc as odbc from pyodbc import * golfers = Tk() golfers.title("Golfers") golfers.geometry('400x600') # Databases # Create a Database or Connect to one conn = odbc.connect('Driver={SQL Server};' 'Server=DESKTOP-SCL1250\SQLEXPRESS01;' 'Database=tgt;' 'Trusted_Connection=yes;') # Create Cursor c = conn.cursor() # # #Commit Changes c.commit() # Close Connection c.close() golfers.mainloop()
#!/bin/env python import tkinter as Tk from tkinter import * about = Tk() about.title("About termux-desktop") about.geometry("320x200") text = Label(about, text=""" Termux-desktop-xfce is an active project with the aim of giving a unique look to termux x11 """) text.pack() mensaje = Label(about, text="Tank you for interest in termux-desktop-xfce!", fg="red") mensaje.pack() creador = Label(about, text=" - The Yisus Development Team", fg="green") creador.pack() about.mainloop()
def __init__(self, url1, url2, url3, url4): window = Tk() window.title("Ping Indicator") frame = Frame(window) frame.pack() self.color = StringVar() self.canvas = Canvas(window, width=700, height=800, bg="white") self.canvas.pack() self.oval_one = self.canvas.create_oval(5, 50, 300, 300, fill="white") self.oval_two = self. canvas.create_oval(400, 50, 700, 300, fill='white') self.oval_three = self.canvas.create_oval(5, 400, 300, 650, fill="white") self.oval_four = self.canvas.create_oval(400, 400, 700, 650, fill='white') self.rectangle_one = self.canvas.create_rectangle(5, 5, 300, 40, fill="#001A57") self.rectanglefill_one = self.canvas.create_text(150, 20, fill="white", width=295, text="Request Result: " + str(url1)) self.rectangle_two = self.canvas.create_rectangle(400, 5, 700, 40, fill="#001A57") self.rectanglefill_two = self.canvas.create_text(550, 20, fill="white", width=295, text="Request Result: " + str(url2)) self.rectangle_three = self.canvas.create_rectangle(5, 335, 300, 370, fill="#001A57") self.rectanglefill_three = self.canvas.create_text(150, 350, fill="white", width=295, text="Request Result: " + str(url3)) self.rectangle_four = self.canvas.create_rectangle(405, 335, 700, 370, fill="#001A57") self.rectanglefill_four = self.canvas.create_text(550, 350, fill="white", width = 295, text="Request Result: " + str(url4)) # self.oval_green = self.canvas.create_oval(230, 10, 330, 110, fill="white") if (ping(url1) != 'False'): self.color.set('G') self.canvas.itemconfig(self.oval_one, fill="green") #window.title("The website returned the ping! :D") else: self.color.set('R') self.canvas.itemconfig(self.oval_one, fill='red') #window.title("The website did not return the ping :( ") if (ping(url2) != 'False'): self.color.set('G') self.canvas.itemconfig(self.oval_two, fill="green") #window.title("The website returned the ping! :D") else: self.color.set('R') self.canvas.itemconfig(self.oval_two, fill='red') if (ping(url3) != 'False'): self.color.set('G') self.canvas.itemconfig(self.oval_three, fill="green") # window.title("The website returned the ping! :D") else: self.color.set('R') self.canvas.itemconfig(self.oval_three, fill='red') # window.title("The website did not return the ping :( ") if (ping(url4) != 'False'): self.color.set('G') self.canvas.itemconfig(self.oval_four, fill="green") # window.title("The website returned the ping! :D") else: self.color.set('R') self.canvas.itemconfig(self.oval_four, fill='red') #window.title("The website did not return the ping :( ") # textbox = Text (window) # textbox.pack() window.mainloop()
def intermediaire3D(): root = Tk() root.config(bg="#DCDCDC") if var_langue == "francais": root.title("Options 3D") else: root.title("3D options") root.geometry("350x800") root.resizable( width=False, height=False) # Redimensionnement de la fenêtre immobilisée. police_options3D = font.Font( root, size=12, weight='bold', family='Helvectica') # Mise en place du style police. label1 = Label(root, text="Sélection les numéros de boutons à afficher :", font=police_options3D) label1.config(bg="#DCDCDC") label1.pack() f3 = Frame(root) s3 = Scrollbar(f3) l3 = Listbox(f3, selectmode=MULTIPLE, exportselection=0, bg='#F9F9F8', font=police_options3D) # EXTENDED f5 = Frame(root) l5 = Listbox(f5, selectmode=MULTIPLE, exportselection=0, bg='#F9F9F8', font=police_options3D) # EXTENDED if var_langue == "francais": l3.insert(0, 'Déselectionner') else: l3.insert(0, 'Deselect') l3.itemconfig(0, bg='#ff6666') if var_langue == "francais": for i in range(1, 40): l3.insert(i, 'Marqueur ' + str(i)) else: for i in range(1, 40): l3.insert(i, 'Marker ' + str(i)) s3.config(command=l3.yview) l3.config(yscrollcommand=s3.set) l3.pack(side=LEFT, fill=Y) s3.pack(side=RIGHT, fill=Y) f3.pack() def clic3(evt): items = l3.curselection() if 0 in items: l3.selection_clear(0, 40) global leger leger.extend(l3.curselection()) return print( items) # On retourne l'élément (un string) sélectionné def clicd3(evt): print(evt.y) # recupere la coordonée selon y print(l3.nearest(evt.y)) # reecupere le bouton le plus proche print(evt) fr = l3.nearest(evt.y) # vou[fr][i][0] # s1 = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] s2 = [] s1 = [] t = [] fig = plt.figure() ax1 = fig.add_subplot(211) ax2 = fig.add_subplot(212, sharex=ax1) for i in range(len(vou[fr]) - 11550): s1.append(vou[fr][i][0]) s2.append((vou[fr][i + 1][0] - vou[fr][i][0]) / 15) t.append(i) print('att') ax1.plot(t, s1) # ax2.plot(t, s2) del s1[i] ax2.plot(t, s2) # t=np.arange(59) multi = MultiCursor(fig.canvas, (ax1, ax2), color='r', lw=1) pts = ginput(2) print(pts) x = math.floor(pts[0][0]) x1 = math.floor(pts[1][0]) y = str(s1[x]) v = str(s2[x]) y1 = str(s1[x1]) v1 = str(s2[x1]) ax1.text(0, 50, r'y(t)=' + y, fontsize=15, bbox={ 'facecolor': 'blue', 'alpha': 0.5, 'pad': 10 }) ax2.text(0, 13, r'v(y)=' + v, fontsize=15) ax1.annotate('y(t)=' + y, xy=(x, s1[x]), xytext=(x + 1, s1[x] + 5), arrowprops=dict(facecolor='black', shrink=0.05)) ax2.annotate('v(y)=' + v, xy=(x, s2[x]), xytext=(x + 1, s2[x] + 5), arrowprops=dict(facecolor='black', shrink=0.05)) ax1.text(0, 50, r'y(t)=' + y1, fontsize=15, bbox={ 'facecolor': 'blue', 'alpha': 0.5, 'pad': 10 }) ax2.text(0, 13, r'v(y)=' + v1, fontsize=15) ax1.annotate('y(t)=' + y1, xy=(x1, s1[x1]), xytext=(x1 + 1, s1[x1] + 5), arrowprops=dict(facecolor='black', shrink=0.05)) ax2.annotate('v(y)=' + v1, xy=(x1, s2[x1]), xytext=(x1 + 1, s2[x1] + 5), arrowprops=dict(facecolor='black', shrink=0.05)) plt.show() l3.bind( '<ButtonRelease-1>', clic3 ) ## on associe l'évènement "relachement du bouton gauche la souris" à la listbox l3.bind('<Double-Button-1>', clicd3) label2 = Label(root, text="Sélection du style :", font=police_options3D) label2.config(bg="#DCDCDC") label2.pack() f4 = Frame(root) s4 = Scrollbar(f4) l4 = Listbox(f4, selectmode=MULTIPLE, exportselection=0, bg='#F9F9F8', font=police_options3D) # EXTENDED if var_langue == "francais": l4.insert(0, 'Déselectionner') l4.itemconfig(0, bg='#ff6666') l4.insert(1, 'Traits') l4.insert(2, 'Points') l4.insert(3, 'Relier') l4.insert(4, 'Effacer') l4.insert(5, 'Historique') else: l4.insert(0, 'Deselect') l4.itemconfig(0, bg='#ff6666') l4.insert(1, 'Lines') l4.insert(2, 'Dots') l4.insert(3, 'Link') l4.insert(4, 'Erase') l4.insert(5, 'History') s4.config(command=l3.yview) l4.config(yscrollcommand=s4.set) l4.pack(side=LEFT, fill=Y) s4.pack(side=RIGHT, fill=Y) f4.pack() def clic4(evt): items = l4.curselection() if 0 in items: l4.selection_clear(0, 4) if 1 in items: l4.selection_clear(3) if 3 in items: l4.selection_clear(1) '''#animate(i)''' fonction3D(fenetreResultat, chemin, l4.curselection(), [], []) if (3 in items) == False: l4.selection_clear(4) if 4 in items: global lourd lourd = [] return print( items) ## On retourne l'élément (un string) sélectionné fonction3D(fenetreResultat, chemin, l4.curselection(), [], []) l4.bind( '<ButtonRelease-1>', clic4 ) ## on associe l'évènement "relachement du bouton gauche la souris" à la listbox label3 = Label(root, text="Points à afficher (tous par défaut):", font=police_options3D) label3.config(bg="#DCDCDC") label3.pack() s5 = Scrollbar(f5) if var_langue == "francais": l5.insert(0, 'Déselectionner') else: l5.insert(0, "Deselect") l5.itemconfig(0, bg='#ff6666') if var_langue == "francais": for i in range(1, 40): l5.insert(i, 'Marqueur ' + str(i)) else: for i in range(1, 40): l5.insert(i, 'Marker ' + str(i)) s5.config(command=l5.yview) l5.config(yscrollcommand=s5.set) l5.pack(side=LEFT, fill=Y) s5.pack(side=RIGHT, fill=Y) f5.pack() def clic5(evt): itemos = l5.curselection() if len(itemos) > 2: l5.selection_clear(itemos[0]) print(len(itemos)) if len(itemos) == 2: global lourd lourd.append(l5.curselection()) if 0 in itemos: l5.selection_clear(0, 40) return print( itemos) ## On retourne l'élément (un string) sélectionné l5.bind( '<ButtonRelease-1>', clic5 ) ## on associe l'évènement "relachement du bouton gauche la souris" à la listbox if var_langue == "anglais": label1["text"] = "Select the number of buttons to display :" label2["text"] = "Select the style :" label3["text"] = "Dots to display (all by default) :" root.mainloop()
import tkinter as Tk from tkinter import * from pygame import mixer from PIL import Image, ImageTk mixer.init() mixer.music.load('goodPlace.mp3') #serial read ser = serial.Serial(" COM11", 9600) s = ser.read() # In[2]: win = Tk() win.title('Mars Feng Shui detector') win.geometry('800x600') label = Label(win, text='風水 Feng Shui', bg="yellow") label.config(width=200) label.config(font=("Courier", 50)) label.pack() label = Label(win, text='開啟所要評分圖片並連接感測器') label.config(width=200) label.config(font=("Courier", 30)) label.pack() # In[3]: img = cv2.imread(tkinter.filedialog.askopenfilename(), 0)