def close_project(self, accept_func, ignore_func): # check if there are unsaved changes if self.changed: reply = QtGui.QMessageBox.question(self, "Save Unsaved Changes?", "You have made unsaved changes to your project. Would you like to save them?", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No, QtGui.QMessageBox.Cancel) # save project if reply == QtGui.QMessageBox.Yes: if len(self.proj_file) > 0: # currently editing a project already project.save(self, self.proj_file) accept_func() else: # no project file opened -- ask for file name proj_file = QtGui.QFileDialog.getSaveFileName(self, "Save Project", filter="Atmospheric Modeling Project (*.atmodel)") if len(proj_file) > 0: # save project file if a name is selected project.save(self, proj_file) accept_func() else: # no file name selected ignore_func() # don't save project and quit elif reply == QtGui.QMessageBox.No: accept_func() # don't close the window else: ignore_func()
def update_information(self, update): __mt_gl = sniff.get_keys_and_values_from_gitlab(self, update) __mt_rd_id = sniff.get_keys_from_redis(self, update) __mt_gl_id = __mt_gl.keys() # Generate difference and intersection metadata __mt_diff = set(__mt_gl_id).difference(set(__mt_rd_id)) __mt_int = set(__mt_gl_id).intersection(set(__mt_rd_id)) __mt_mod = list(__mt_diff.union(__mt_int)) __mt_del = list(set(__mt_rd_id).difference(set(__mt_gl_id))) # Print alert if config.DEBUGGER: config.print_message("- [ %s ] New or possible updates: %d | Deleted: %d" % (update, len(__mt_mod), len(__mt_del))) # Insert / Modify Information for i in __mt_mod: if update == "users": util_user.save(self, i, __mt_gl[i]) elif update == "groups": util_group.save(self, i, __mt_gl[i]) elif update == "projects": util_project.save(self, i, __mt_gl[i]) # Delete Information for i in __mt_del: if update == "users": util_user.delete(self, i) elif update == "groups": util_group.delete(self, i) elif update == "projects": util_project.delete(self, i)
def saver(self): global pck global pck2 name = QtGui.QFileDialog.getSaveFileName(self, 'Save File') if len(pck2) == 0: project.save(pck, str(name)) else: project.save(pck2, str(name))
def save(self): project.save()
def saveas_func (): proj_file = QtGui.QFileDialog.getSaveFileName(self, "Save Project", filter="Atmospheric Modeling Project (*.atmodel)") if len(proj_file) > 0: # save project file if a name is selected project.save(self, proj_file)
def save_func (): if len(self.proj_file) > 0: # currently editing a project already project.save(self, self.proj_file) else: # no project file opened -- ask for file name saveas_func()
def handle_event(self, event): shift_down = pygame.key.get_mods() & KMOD_SHIFT x_vel = y_vel = 0 if event.type == QUIT: project.save(self.project_dir, self.project) pygame.quit() sys.exit(0) else: if self.viewing_output_tile_form: if self.output_tile_form.process_event(event): self.viewing_output_tile_form = False else: if event.type == KEYDOWN: if event.key == K_LEFT: self.x_vel = -1 elif event.key == K_RIGHT: self.x_vel = 1 elif event.key == K_UP: self.y_vel = -1 elif event.key == K_DOWN: self.y_vel = 1 elif event.type == KEYUP: if event.key == K_LEFT or event.key == K_RIGHT: self.x_vel = 0 elif event.key == K_UP or event.key == K_DOWN: self.y_vel = 0 elif event.key == K_c: self.view_mode = renderer.CHAR_VIEW elif event.key == K_i: self.view_mode = renderer.ID_VIEW elif event.key == K_m: self.view_mode = renderer.MAP_VIEW elif event.key == K_n: self.viewing_output_tile_form = True elif event.key == K_r: self.ui_renderer.highlight_unknown = (not self.ui_renderer.highlight_unknown) elif event.key == K_u: id_to_view = self.project.get_most_unknown_id() if id_to_view != None: self.ui_renderer.toggle_highlighted_id(id_to_view, False, remove_if_exists=False) coords = self.project.get_first_instance_of(id_to_view) self.ui_renderer.centre_display_on(coords[0], coords[1]) elif event.key == K_PAGEUP: self.ui_renderer.output_tile_page_adj(-1) elif event.key == K_PAGEDOWN: self.ui_renderer.output_tile_page_adj(1) elif event.key == K_ESCAPE: self.ui_renderer.clear_highlighted_ids() elif event.type == MOUSEBUTTONUP: screen_x, screen_y = pygame.mouse.get_pos() if self.selection_start_x != None and self.selection_start_y != None: map_x, map_y = self.ui_renderer.screen_to_map_coords(screen_x, screen_y) map_start_x, map_start_y = self.ui_renderer.screen_to_map_coords(self.selection_start_x, self.selection_start_y) self.selection_start_x = self.selection_start_y = None if not shift_down: self.ui_renderer.clear_highlighted_ids() for x in range(min(map_start_x, map_x), max(map_start_x, map_x) + 1): for y in range(min(map_start_y, map_y), max(map_start_y, map_y) + 1): id = self.project.get_id_at(x, y) if id != None: self.ui_renderer.toggle_highlighted_id(self.project.get_id_at(x, y), True, remove_if_exists=(map_start_x == map_x and map_start_y == map_y and shift_down)) elif event.type == MOUSEBUTTONDOWN: screen_x, screen_y = pygame.mouse.get_pos() if pygame.mouse.get_pressed()[0]: output_tile = self.ui_renderer.get_output_tile_at(screen_x, screen_y) if output_tile: self.ui_renderer.toggle_highlighted_output_tile(output_tile, shift_down) else: self.selection_start_x, self.selection_start_y = screen_x, screen_y elif pygame.mouse.get_pressed()[2]: output_tile = self.ui_renderer.get_output_tile_at(screen_x, screen_y) if output_tile: self.ui_renderer.toggle_highlighted_output_tile(output_tile, True, remove_if_exists=False) for id in self.ui_renderer.get_highlighted_ids(): self.project.set_output_tile(id, output_tile)