def clear_image(self): dummy_image = Icon('tango/32x32/mimetypes/image-x-generic.png') self.set_pixmap(dummy_image.getQPixmap())
class ChangeObjects(ActionStep): """ Pop up a list for the user to change objects :param objects: a list of objects to change :param admin: an instance of an admin class to use to edit the objects. .. image:: /_static/listactions/import_from_file_preview.png This action step can be customised using these attributes : .. attribute:: window_title the window title of the dialog shown .. attribute:: title the title of the dialog shown .. attribute:: subtitle the subtitle of the dialog shown .. attribute:: icon the :class:`camelot.view.art.Icon` in the top right corner of the dialog """ def __init__(self, objects, admin): self.objects = objects self.admin = admin self.window_title = admin.get_verbose_name_plural() self.title = _("Data Preview") self.subtitle = _("Please review the data below.") self.icon = Icon("tango/32x32/mimetypes/x-office-spreadsheet.png") def get_objects(self): """Use this method to get access to the objects to change in unit tests :return: the object to change """ return self.objects def render(self): """create the dialog. this method is used to unit test the action step.""" dialog = ChangeObjectsDialog(self.objects, self.admin) dialog.setWindowTitle(unicode(self.window_title)) dialog.set_banner_title(unicode(self.title)) dialog.set_banner_subtitle(unicode(self.subtitle)) dialog.set_banner_logo_pixmap(self.icon.getQPixmap()) # # the dialog cannot estimate its size, so use 75% of screen estate # desktop = QtGui.QApplication.desktop() available_geometry = desktop.availableGeometry(dialog) dialog.resize(available_geometry.width() * 0.75, available_geometry.height() * 0.75) return dialog def gui_run(self, gui_context): dialog = self.render() result = dialog.exec_() if result == QtGui.QDialog.Rejected: raise CancelRequest() return self.objects
class ChangeObjects( ActionStep ): """ Pop up a list for the user to change objects :param objects: a list of objects to change :param admin: an instance of an admin class to use to edit the objects. .. image:: /_static/listactions/import_from_file_preview.png This action step can be customised using these attributes : .. attribute:: window_title the window title of the dialog shown .. attribute:: title the title of the dialog shown .. attribute:: subtitle the subtitle of the dialog shown .. attribute:: icon the :class:`camelot.view.art.Icon` in the top right corner of the dialog """ def __init__( self, objects, admin ): self.objects = objects self.admin = admin self.window_title = admin.get_verbose_name_plural() self.title = _('Data Preview') self.subtitle = _('Please review the data below.') self.icon = Icon('tango/32x32/mimetypes/x-office-spreadsheet.png') def get_objects( self ): """Use this method to get access to the objects to change in unit tests :return: the object to change """ return self.objects def render( self ): """create the dialog. this method is used to unit test the action step.""" dialog = ChangeObjectsDialog( self.objects, self.admin ) dialog.setWindowTitle( unicode( self.window_title ) ) dialog.set_banner_title( unicode( self.title ) ) dialog.set_banner_subtitle( unicode( self.subtitle ) ) dialog.set_banner_logo_pixmap( self.icon.getQPixmap() ) # # the dialog cannot estimate its size, so use 75% of screen estate # desktop = QtGui.QApplication.desktop() available_geometry = desktop.availableGeometry( dialog ) dialog.resize( available_geometry.width() * 0.75, available_geometry.height() * 0.75 ) return dialog def gui_run( self, gui_context ): dialog = self.render() result = dialog.exec_() if result == QtGui.QDialog.Rejected: raise CancelRequest() return self.objects