def start_gui(self, width, height): # Create new instance of GUI gui = Gui() # Set width and height gui.width = width gui.height = height # Apply the grid as the data source gui.set_data_source(self.a_star) # Set TKInter to the frontmost process if platform.system() == 'Darwin': os.system('''/usr/bin/osascript -e 'tell app "Finder" to set frontmost of process "Python" to true' ''') # Draw the initial GUI gui.draw_initial() # Start the GUI gui.after(0, gui.task) # Start the event mainloop here gui.mainloop() # Set the terminal to the frontmost process (expects iTerm to be the chosen terminal) if platform.system() == 'Darwin': os.system('''/usr/bin/osascript -e 'tell app "Finder" to set frontmost of process "iTerm" to true' ''') # Check if solution for all boards were found if gui.finished: # Pretty print Printer.print_border_top() Printer.print_content('Comparison') # Loop all the data for data in gui.data: # Pretty print Printer.print_border_middle() # Print the name of the behavior Printer.print_content(data.behavior.NAME, align='left') Printer.print_empty() # Print the stats Printer.print_content('States generated: ' + str(len(data.closed) + len(data.open)), align='left') Printer.print_content('Solution path length: ' + str(len(data.goal_path())), align='left') # Print closing border Printer.print_border_bottom()