本文整理汇总了Python中history.History.can_redo方法的典型用法代码示例。如果您正苦于以下问题:Python History.can_redo方法的具体用法?Python History.can_redo怎么用?Python History.can_redo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类history.History
的用法示例。
在下文中一共展示了History.can_redo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import can_redo [as 别名]
#.........这里部分代码省略.........
self.ui.menuCustom_filters.addAction(action)
action.triggered.connect(lambda: self._image_editor_wrapper(self.image_editor.linear_filter,
matrix, divisor))
def _get_two_params_and_edit(self, param1, param2, editor_func):
dialog = BaseTwoParamsDialog(param1, param2)
if dialog.exec_():
param1_value, param2_value = dialog.get_values()
self._image_editor_wrapper(editor_func, param1_value, param2_value)
@staticmethod
def _choose_directory():
return str(QtGui.QFileDialog.getExistingDirectory(None, 'Choose directory', '.', QtGui.QFileDialog.ShowDirsOnly))
def _set_golden_images_dir(self, dirname):
if dirname:
self.golden_images_dir = dirname
self.user_settings_dump_n_loader.set_golden_images_dir(dirname)
def _set_diff_images_dir(self, dirname):
if dirname:
self.golden_images_dir = dirname
self.user_settings_dump_n_loader.set_diff_images_dir(dirname)
def _diff_images(self):
self.image_editor.update_image(self.np_img)
basename = os.path.basename(str(self.image_saver.filename))
try:
golden_np_img = scipy.misc.imread(os.path.join(str(self.golden_images_dir), basename))
is_ok, diff_img, percentage = self.image_editor.diff_images(golden_np_img)
if not is_ok:
QtGui.QMessageBox.about(self, 'Error', 'Images have different size.s')
else:
QtGui.QMessageBox.about(self, 'Diff percentage', 'diff: %.1f %%' % percentage)
diff_filename = os.path.join(str(self.diff_images_dir), basename)
if percentage:
self.image_saver.save_any(diff_img, diff_filename)
except IOError:
QtGui.QMessageBox.about(self, 'Error', 'There is no golden image with corresponding name.')
def _open_file(self):
self.np_img = self.image_opener.open_file()
self.image_history.reset()
self.image_history.add_new_state(self.np_img)
self.image_saver.filename = self.image_opener.filename
# in case of png files swap channels
if self.np_img.shape[2] == 4:
self.np_img = utils.bgra2rgba(self.np_img)
self._show_np_image()
self._enable_menu_items(True)
self._enable_undo_redo()
self.ui.actionSave_As.setEnabled(True)
def _save_file(self):
self.image_saver.np_img = self.np_img
self.image_saver.save_file()
self.ui.actionSave.setEnabled(False)
def _undo(self):
if self.image_history.can_undo():
self.np_img = self.image_history.undo()
self._show_np_image()
self._enable_undo_redo()
def _redo(self):
if self.image_history.can_redo():
self.np_img = self.image_history.redo()
self._show_np_image()
self._enable_undo_redo()
def _enable_undo_redo(self):
undo_state, redo_state = True, True
if not self.image_history.can_redo():
redo_state = False
if not self.image_history.can_undo():
undo_state = False
self.ui.actionRedo.setEnabled(redo_state)
self.ui.actionUndo.setEnabled(undo_state)
def _show_np_image(self):
img = utils.np_to_qimage(self.np_img)
self._show_image(img)
def _show_image(self, img):
pixmap = QtGui.QPixmap.fromImage(img)
pixmap = self.scale_pixmap(pixmap)
self.view.setPixmap(pixmap)
def scale_pixmap(self, pixmap):
dest_height, dest_width = self.view.size().height(), self.view.size().width()
if dest_height < pixmap.size().height():
pixmap = pixmap.scaledToHeight(self.view.size().height())
elif dest_width < pixmap.size().width():
pixmap = pixmap.scaledToWidth(self.view.size().width())
return pixmap
def show_window(self):
self.show()