def configure_param_lmme_dialog(self): w = Toplevel() w.protocol('WM_DELETE_WINDOW', self.hide_param_dialog) self.param_dlg = w w.withdraw() # cache la fenetre w.rowconfigure(0, weight=1) w.columnconfigure(0, weight=1) prm = ParamModeLMME( w, "Paramètres du calcul modal pour la méthode LMME", relief='sunken', borderwidth=2) prm.grid(row=0, column=0) self.param_mode_iter_simult_lmme = prm Button(w, text="Appliquer", command=self.anything_changed).grid( row=1, column=0) Button(w, text="OK", command=self.hide_param_dialog).grid( row=2, column=0)
def construct(self): """ Construct the window and the frame used to display the XML :return: """ top = Toplevel() top.withdraw() top.protocol("WM_DELETE_WINDOW", self.view_xml_pane) top.columnconfigure(0, weight=1) top.rowconfigure(0, weight=1) top.title("XML Preview") self._pane = top xml_area = Text(top, borderwidth=2, relief="sunken") xml_area.config(font=("consolas", 12), undo=True, wrap='word', state=DISABLED) xml_area.grid(row=0, column=0, sticky="nsew", padx=2, pady=2) scrollbar = Scrollbar(top, command=xml_area.yview) scrollbar.grid(row=0, column=1, sticky='nsew') xml_area['yscrollcommand'] = scrollbar.set self._text_area = xml_area
def visu_mac(self, mac, resu1, resu2): titre = "matrice de MAC pour " + resu1.nom + " et " + resu2.nom f = Toplevel() size = (20, 300) f.columnconfigure(0, weight=1) f.rowconfigure(0, weight=1) mac_win = MacWindowFrame(f, titre, resu1.nom, resu2.nom, size) mac_win.grid(row=0, column=0, sticky='nsew') afreq1 = resu1.get_modes_data()['FREQ'] noeud_cmp1 = resu1.get_modes_data()['NOEUD_CMP'] afreq2 = resu2.get_modes_data()['FREQ'] noeud_cmp2 = resu2.get_modes_data()['NOEUD_CMP'] # si mode statique, on donne le champ NOEUD_CMP a la place de la # frequence for ind_ordr in range(len(afreq1)): if afreq1[ind_ordr] == None: afreq1[ind_ordr] = noeud_cmp1[ind_ordr] for ind_ordr in range(len(afreq2)): if afreq2[ind_ordr] == None: afreq2[ind_ordr] = noeud_cmp2[ind_ordr] mac_win.set_modes(afreq1, afreq2, mac)
def inicio(c): global ventana2, Labeli, Labelt, img0, img1, imgF, row, cont instruction=None img0=PhotoImage(file="00.gif") # Reads photos img00=PhotoImage(file="0000.gif") imgF=PhotoImage(file="FF.gif") if c: ventana2=Toplevel(ventana) ventana2.title("MANITOR") ventana2.configure(bg="white") ventana2.geometry("1000x600+5+40") Labelt=Label(ventana2,text='BIENVENIDO ', # ventana2 TEXTO fg="black",bg="white",font=("Helvetica 36 ")) ventana2.columnconfigure(0,weight=1) Labelt.grid(row=1,column=0) Labeli=Label(ventana2,image=img00) # ventana2 IMAGEN Labeli.grid(row=2,column=0) else: Labelt.config(text='BIENVENIDO ') Labeli.image = img00 Labeli.config(image=img00) ventana.iconify() # Turns window into an icon row=row+1 cont=cont+1 while 1: nuevoUsuario = detectUser.newUser(3,lower,upper) Labelt.config(text='BIENVENIDO \n Por favor moje sus manos con agua') worksheet.write_datetime(row, col, date_time,f2) worksheet.write_datetime(row, col+1, date_time,f3) worksheet.write(row, col +2, cont, f6) worksheet.write(row, col +3, 'NUEVA PERSONA',f4) ventana2.update() video000() jabon() primero1() ####################### fin instrucciones Labeli=Label(ventana2,image=img00) Labeli.grid(row=2,column=0) Labelt.config(text='Sus manos son seguras') row=row+1 worksheet.write_datetime(row, col, date_time, f2) worksheet.write_datetime(row, col+1, date_time,f3) worksheet.write(row, col +3, 'TERMINO') ventana2.update() ventana2.after(2000)
def inicio(c): global ventana2, Labeli, Labelt, img0, img1, imgF, row, cont instruction = None img0 = PhotoImage(file="00.gif") # Reads photos img00 = PhotoImage(file="0000.gif") imgF = PhotoImage(file="FF.gif") if c: ventana2 = Toplevel(ventana) ventana2.title("MANITOR") ventana2.configure(bg="white") ventana2.geometry("1000x600+5+40") Labelt = Label( ventana2, text='BIENVENIDO ', # ventana2 TEXTO fg="black", bg="white", font=("Helvetica 36 ")) ventana2.columnconfigure(0, weight=1) Labelt.grid(row=1, column=0) Labeli = Label(ventana2, image=img00) # ventana2 IMAGEN Labeli.grid(row=2, column=0) else: Labelt.config(text='BIENVENIDO ') Labeli.image = img00 Labeli.config(image=img00) ventana.iconify() # Turns window into an icon row = row + 1 cont = cont + 1 while 1: queue = Queue() Labelt.config(text='BIENVENIDO \n Por favor moje sus manos con agua') worksheet.write_datetime(row, col, date_time, f2) worksheet.write_datetime(row, col + 1, date_time, f3) worksheet.write(row, col + 2, cont, f6) worksheet.write(row, col + 3, 'NUEVA PERSONA', f4) ventana2.update() video000() def jabon(): def cero(q): analysisRegion = 1 print regionCoord tipoMovimiento = BByOFfile.BByOF(2, lower, upper, regionCoord, analysisRegion, 10) q.put([tipoMovimiento]) Labelt.config(text='Deposite jabón en la mano') global row row = row + 1 worksheet.write(row, col + 3, 'jabon', f5) ventana2.update() c = threading.Thread(target=cero, args=(queue, )) c.start() video00() if c.isAlive(): c.join() instruction = queue.get() instruction = falseType(instruction[0], Labelt, Labeli, img0, imgF) if not instruction: jabon() jabon() ######################## instruccion 1 def primero1(): def primero(q): analysisRegion = 2 tipoMovimiento = BByOFfile.BByOF(2, lower, upper, regionCoord, analysisRegion, 10) q.put([tipoMovimiento]) p = Thread(target=primero, args=(queue, )) p.start() Labelt.config(text='Frote las palmas de las manos \n entre sí') global row row = row + 1 worksheet.write(row, col + 3, 'instruccion1', f5) ventana2.update() ventana2.update() video1() if p.isAlive(): p.join() instruction = queue.get() instruction = falseType(instruction[0], Labelt, Labeli, img0, imgF) if not instruction: primero1() primero1() ########################## instruccion2 ## def segundo(q): ## analysisRegion = 2 ## tipoMovimiento=BByOFfileO.BByOF(2,lower,upper,regionCoord,analysisRegion,10) ## q.put([tipoMovimento]) ## ## s=Thread(target=segundo, args=(queue,)) ## s.start() ## Labelt.config(text='Frote la palma de la mano derecha \n contra el dorso de la mano izquierda \n entrelazando los dedos y viceversa') ## ventana2.update() ## video2() ## ## if s.isAlive(): ## s.join() ## instruction=queue.get() ## instruction=falseType(instruction[0],Labelt,Labeli,img0,imgF) ## if not instruction: ## inicio(0) ######################## fin instrucciones Labeli = Label(ventana2, image=img00) Labeli.grid(row=2, column=0) Labelt.config(text='Sus manos son seguras') row = row + 1 worksheet.write_datetime(row, col, date_time, f2) worksheet.write_datetime(row, col + 1, date_time, f3) worksheet.write(row, col + 3, 'TERMINO') ventana2.update() ventana2.after(2000)
class InstructionsFrame(Frame): def __init__(self, parent, width=500, height=200, background="white"): Frame.__init__(self, parent) self.initialize() def initialize(self): self.instructions_text = \ """ Seating Chart Creator makes an optimal seating chart for a given set of people, tables, and days. It generates a preliminary chart, then searches for a better one by switching people around.\n""" self.instructions_label = Label(self, text=self.instructions_text, font=("Optima", 14), anchor=W, justify=LEFT) self.instructions_label.grid(row=0, column=0, sticky=(W)) miniframe = Frame(self) miniframe.grid(row=1, column=0, padx=0, pady=(0, 20)) self.rules_button = Button(miniframe, text="View list of optimization rules", command=self.show_rules) self.rules_button.grid(row=1, column=0, sticky=(W), padx=10) self.people_example = Button(miniframe, text="View example people input file", command=self.show_people_example) self.people_example.grid(row=1, column=1, sticky=(W), padx=10) self.tables_example = Button(miniframe, text="View example tables input file", command=self.show_tables_example) self.tables_example.grid(row=1, column=2, sticky=(W), padx=10) def show_rules(self): self.windowr = Toplevel(self) self.windowr.wm_title("Optimization Rules") self.windowr.rowconfigure(0, weight=1) self.windowr.rowconfigure(1, weight=1) self.windowr.columnconfigure(0, weight=1) innerwindowr = Canvas(self.windowr) innerwindowr.pack() myscrollbar=Scrollbar(self.windowr, orient="vertical", command=innerwindowr.yview) innerwindowr.configure(yscrollcommand=myscrollbar.set) myscrollbar.pack(side="right",fill="y") #self.rtitle_label2 = Label(z, # text="Seating Chart Creator's Optimization Rules", # font=("Optima Italic", 24)) #self.rtitle_label2.pack() rtext1 = \ """ *** Seating Chart Creator's Optimization Rules *** Depending on the input data, it may or may not be possible to create a perfect seating chart. Even if there is a perfect solution, there is no fast or easy way to find it. Seating Chart Creator searches for that perfect solution using an optimization algorithm. It specifies the criteria to evaluate the solution with, then searches for the solution that best meets that criteria. The search process involves random factors, so if you run it multiple times, you will get different answers. *** The Criteria *** SCC looks for a solution with the lowest 'cost'. The cost of a solution is determined by: * The number of people sitting in the same spot multiple times. * The number of pairs sitting together multiple times. * The number of trios sitting together multiple times. * The distance of each table from its optimal category balance. The table sizes always correspond with those in the input file. *** The Process *** Step 1: Building the First Guess SCC loops through the days of the event. On each day, it considers each person individually and places him or her in the best spot available. People are shuffled each round so that no one consistently gets the 'last pick' of the tables. When considering where to seat a person, the following tables are excluded: - Tables that are already full - Tables that already have enough people of the same category as the person to be seated. The person is then assigned to the table with the fewest people he/she has already sat with. Step 2: Switching People Around The strategy above is fairly good, but not perfect. SCC uses it as a starting point, then generates new solutions by repeatedly switching individuals. The 'cost' is calculated for each new solution. If a new solution is better than the current solution, it is used as the starting point for the next round. The technique SCC uses is called 'simulated annealing'. It is a frequently-used and highly-regarded method for solving problems like this one. However, it is not guaranteed to find a perfect solution. The switching steps take a very long time (minutes - hours) because of the computational complexity of counting the number of times everyone sits together. """ #scrollbar = Scrollbar(innerwindowr) #scrollbar.pack(side=RIGHT, fill=Y) #self.foo = Label(innerwindowr, text=rtext1) self.rules_text_box = Text(innerwindowr, width=100) self.rules_text_box.insert(INSERT, rtext1) self.rules_text_box.config(highlightthickness=0) self.rules_text_box.pack(padx=20) #self.foo.config(yscrollcommand=scrollbar.set) #scrollbar.config(command=self.foo.yview) def show_people_example(self): self.window = Toplevel(self) self.window.wm_title = "People Example" self.window.rowconfigure(0, weight=1) self.window.rowconfigure(1, weight=1) self.window.columnconfigure(0, weight=1) innerwindowp = Frame(self.window) innerwindowp.grid(row=0, column=0) self.ptitle_label2 = Label(innerwindowp, text="Example People Input File", font=("Optima Italic", 24)) self.ptitle_label2.grid(row=0, column=0) ptext1 = \ """ The 'People' input file contains information about the people to be seated and where they might have been preassigned to sit. It should be saved in CSV format.""" pheader1 = "COLUMN NAMES" ptext2 = \ """The file should contain the column headers 'First Name', 'Last Name', and 'Category', written exactly as printed here - capitalization is important. All other columns are assumed to be the names of the days you are making the chart for. They must match the days in your 'Tables' input file exactly (again, capitalization is important).""" pheader2 = "NOTES" ptext3 = \ """Each person should be assigned a category. You can name the categories whatever you like. If a person has been preassigned to the head table on a particular day, write 'Head' (with a capital 'H') in the corresponding cell.""" ptext1label = Label(innerwindowp, text=ptext1, justify=LEFT) ptext1label.grid(row=1, column=0, padx=20, sticky=(W)) pheader1label = Label(innerwindowp, text=pheader1, font=("Optima Italic", 14), justify=LEFT) pheader1label.grid(row=2, column=0, padx=20, pady=(20, 0), sticky=(W)) ptext2label = Label(innerwindowp, text=ptext2, justify=LEFT) ptext2label.grid(row=3, column=0, padx=20, sticky=(W)) pheader2label = Label(innerwindowp, text=pheader2, font=("Optima Italic", 14), justify=LEFT) pheader2label.grid(row=4, column=0, padx=20, pady=(20,0), sticky=(W)) ptext3label = Label(innerwindowp, text=ptext3, justify=LEFT) ptext3label.grid(row=5, column=0, padx=20, sticky=(W)) self.picture2p = PhotoImage(file=find_data_file('static/people-example.gif')) self.picture_label2p = Label(self.window, image = self.picture2p) self.picture_label2p.grid(row=2, column=0) def show_tables_example(self): self.window2 = Toplevel(self) self.window2.wm_title = "Tables Example" self.window2.rowconfigure(0, weight=1) self.window2.rowconfigure(1, weight=1) self.window2.columnconfigure(0, weight=1) innerwindow = Frame(self.window2) innerwindow.grid(row=0, column=0) self.title_label2 = Label(innerwindow, text="Example Tables Input File", font=("Optima Italic", 24)) self.title_label2.grid(row=0, column=0) text1 = \ """ The 'Tables' input file contains information about the individual tables' names and capacities. It should be saved in CSV format.""" header1 = "COLUMN NAMES" text2 = \ """The file should contain the column header 'Table Name', written exactly as printed here - capitalization is important. All other columns are assumed to be the names of the days you are making the chart for. They must match the days in your 'People' input file exactly (again, capitalization is important).""" header2 = "NOTES" text3= \ """You can choose arbitrary table names. If you include a table named 'Head', it will be populated exclusively with the people preassigned to it in the 'People' input file. The number in each cell represents the table's capacity on that day. Make sure the overall capacity is at least as great as the number of people to be seated!""" text1label = Label(innerwindow, text=text1, justify=LEFT) text1label.grid(row=1, column=0, padx=20, sticky=(W)) header1label = Label(innerwindow, text=header1, font=("Optima Italic", 14), justify=LEFT) header1label.grid(row=2, column=0, padx=20, pady=(20, 0), sticky=(W)) text2label = Label(innerwindow, text=text2, justify=LEFT) text2label.grid(row=3, column=0, padx=20, sticky=(W)) header2label = Label(innerwindow, text=header2, font=("Optima Italic", 14), justify=LEFT) header2label.grid(row=4, column=0, padx=20, pady=(20, 0), sticky=(W)) text3label = Label(innerwindow, text=text3, justify=LEFT) text3label.grid(row=5, column=0, padx=20, sticky=(W)) self.picture2 = PhotoImage(file=find_data_file('static/tables-example.gif')) self.picture_label2 = Label(self.window2, image=self.picture2) self.picture_label2.grid(row=2, column=0)
def inicio(c): global ventana2, Labeli, Labelt, panel global img0, img1, imgF img0=PhotoImage(file="00.gif") # Reads photos img1=PhotoImage(file="11.gif") imgF=PhotoImage(file="FF.gif") if c: ventana2=Toplevel(ventana) ventana2.title("MANITOR") ventana2.configure(bg="white") ventana2.geometry("1000x600+5+40") Labelt=Label(ventana2,text='BIENVENIDO ', # ventana2 TEXTO fg="black",bg="white",font=("Helvetica 36 ")) ventana2.columnconfigure(0,weight=1) Labelt.grid(row=1,column=0) Labeli=Label(ventana2,image=img1) # ventana2 IMAGEN ventana2.columnconfigure(0,weight=1) ventana2.update() Labeli.grid(row=2,column=0) else:#Toda esta parte no es necesaria se podria borrar hasta el update, ya que es un estado inical que nunca se muestra igual que arriba Labelt.config(text='BIENVENIDO ') ventana2.update() Labeli=Label(ventana2,image=img1) ventana2.columnconfigure(0,weight=1) Labeli.grid(row=2,column=0) Labeli.config(image=img1) Labeli.image=img1 ventana2.update() ventana.iconify() # Turns window into an icon while 1: ## cur.execute("INSERT INTO manitor VALUES(nextval('usuario_sequence'), current_timestamp, ' inicio ')") Labeli.destroy() ventana2.update() Labelt.config(text='BIENVENIDO \n Por favor moje sus manos con agua') ventana2.update() video000 () ventana2.update() Labelt.config(text='Deposite jabón en la mano') ## cur.execute("INSERT INTO manitor VALUES(nextval('usuario_sequence'), current_timestamp, ' nuevo usuario ')") ventana2.update() def cero(): b,auxType = contadorMovimiento.funcionMovimientoEnRegion(y[1],3,2,lower,upper) instruction = falseType(b,auxType,Labelt,Labeli,img0,imgF) if not instruction: inicio(0) Thread(target=cero).start() Thread(target=video00()).start() ######################## instruccion 1 Labeli.destroy() Labelt.config(text='Frote las palmas de las manos \n entre sí') ventana2.update() def primero(): d,auxType = contadorMovimiento.funcionMovimientoEnRegion(y[1],3,2,lower,upper) instruction = falseType(d,auxType,Labelt,Labeli,img0,imgF) if not instruction: inicio(0) Thread(target=primero).start() Thread(target=video1()).start() ########################## instruccion2 ## ## Labeli.destroy() ## Labelt.config(text='Frote la palma de la mano derecha \n contra el dorso de la mano izquierda \n entrelazando los dedos y viceversa') ## panel = Label(ventana2) ## def segundo(): ## e,auxType = contadorMovimiento.funcionMovimientoEnRegion(y[1],10,2,lower,upper) ## instruction = falseType(e,auxType,Labelt,Labeli,img0,imgF) ## if not instruction: ## inicio(0) ## ## Thread(target=segundo).start() ## Thread(target=video1()).start() ## ## time.sleep(10) ######################## fin instrucciones ## Labeli=Label(ventana2,image=img12) ventana2.columnconfigure(0,weight=1) Labeli.grid(row=2,column=0) ventana2.update() Labelt.config(text='Sus manos son seguras') ## Labeli.config(image=img12) ## Labeli.image=img12 ventana2.update() time.sleep(5)