def __init__(self, admin=None, parent=None, create_inline=False, direction='onetomany', field_name='onetomany', column_width=None, proxy=None, rows=5, **kw): CustomEditor.__init__(self, parent, column_width=column_width) self.setObjectName(field_name) layout = QtWidgets.QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) # # Setup table # from camelot.view.controls.tableview import AdminTableWidget from camelot.view.proxy.collection_proxy import CollectionProxy # parent set by layout manager table = AdminTableWidget(admin, self) table.setObjectName('table') layout.setSizeConstraint(QtGui.QLayout.SetNoConstraint) self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.setMinimumHeight((self._font_height + 5) * rows) table.verticalHeader().sectionClicked.connect(self.trigger_list_action) model = (proxy or CollectionProxy)(admin) table.setModel(model) register.register(model, table) self.admin = admin self.direction = direction self.create_inline = create_inline layout.addWidget(table) self.setLayout(layout) self._new_message = None self.gui_context = ListActionGuiContext() self.gui_context.view = self self.gui_context.admin = self.admin self.gui_context.item_view = table post(self.admin.get_related_toolbar_actions, self.set_right_toolbar_actions, args=(Qt.RightToolBarArea, self.direction)) post(self.get_columns, self.set_columns)
def __init__(self, admin=None, parent=None, create_inline=False, direction='onetomany', field_name='onetomany', **kw): CustomEditor.__init__(self, parent) self.setObjectName(field_name) layout = QtGui.QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) # # Setup table # from camelot.view.controls.tableview import AdminTableWidget # parent set by layout manager table = AdminTableWidget(admin, self) table.setObjectName('table') rowHeight = QtGui.QFontMetrics(self.font()).height() + 5 layout.setSizeConstraint(QtGui.QLayout.SetNoConstraint) self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.setMinimumHeight(rowHeight * 5) table.verticalHeader().sectionClicked.connect(self.trigger_list_action) self.admin = admin self.direction = direction self.create_inline = create_inline layout.addWidget(table) self.setLayout(layout) self.model = None self._new_message = None self.gui_context = ListActionGuiContext() self.gui_context.view = self self.gui_context.admin = self.admin self.gui_context.item_view = table post(self.admin.get_related_toolbar_actions, self.set_right_toolbar_actions, args=(Qt.RightToolBarArea, self.direction))
def __init__(self, parent=None, width=50, height=40, dpi=50, field_name='chart', **kwargs): from matplotlib.figure import Figure from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas super(ChartEditor, self).__init__(parent) AbstractCustomEditor.__init__(self) self.setObjectName(field_name) chart_frame = QtWidgets.QFrame(self) chart_frame.setFrameShape(self.Box) chart_frame.setContentsMargins(1, 1, 1, 1) chart_frame_layout = QtWidgets.QHBoxLayout() chart_frame_layout.setContentsMargins(0, 0, 0, 0) chart_frame.setLayout(chart_frame_layout) # find out background color, because using a transparent # figure fails when the window is resized: the background # is not redrawn # need to do str() else matplotlib gets confused by the qstring # bgcolorrgb = str(self.palette().background().color().name()) self.fig = Figure( figsize=(width, height), dpi=dpi, facecolor='#ffffff', ) layout = QtWidgets.QHBoxLayout() self.canvas = FigureCanvas(self.fig) chart_frame_layout.addWidget(self.canvas) layout.addWidget(chart_frame) button_layout = QtWidgets.QVBoxLayout() button_layout.setSpacing(0) icon = Icon( 'tango/16x16/actions/document-print-preview.png').getQIcon() button_layout.addStretch() print_button = QtWidgets.QToolButton() print_button.setIcon(icon) print_button.setAutoRaise(True) print_button.setToolTip(_('Print Preview')) print_button.clicked.connect(self.print_preview) button_layout.addWidget(print_button) icon = Icon('tango/16x16/actions/edit-copy.png').getQIcon() copy_button = QtWidgets.QToolButton() copy_button.setIcon(icon) copy_button.setAutoRaise(True) copy_button.setToolTip(_('Copy to clipboard')) copy_button.clicked.connect(self.copy_to_clipboard) button_layout.addWidget(copy_button) layout.addLayout(button_layout) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) self.canvas.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.canvas.installEventFilter(self) self.show_fullscreen_signal.connect(self.show_fullscreen) self.canvas.updateGeometry() self._litebox = None self.gui_context = ListActionGuiContext()