def __init__(self, names=[], N=10, *args, **kwargs): """ Parameters ---------- %(ColormapModel.parameters)s Other Parameters ---------------- ``*args, **kwargs`` Anything else that is passed to the ColormapDialog """ super(QDialog, self).__init__(*args, **kwargs) vbox = QVBoxLayout() self.table = ColormapTable(names=names, N=N) vbox.addWidget(self.table) self.setLayout(vbox) col_width = self.table.columnWidth(0) header_width = self.table.verticalHeader().width() row_height = self.table.rowHeight(0) available = QDesktopWidget().availableGeometry() height = int(min(row_height * (self.table.rowCount() + 1), 2. * available.height() / 3.)) width = int(min(header_width + col_width * N + 0.5 * col_width, 2. * available.width() / 3.)) self.resize(QtCore.QSize(width, height))
def excepthook(self, type, value, traceback): s = io.StringIO() tb.print_exception(type, value, traceback, file=s) last_tb = '<p>' + '<br>'.join(s.getvalue().splitlines()) + \ '</p>' header = value.message if six.PY2 else str(value) self.showMessage(header + '\n' + last_tb) available_width = QDesktopWidget().availableGeometry().width() / 3. available_height = QDesktopWidget().availableGeometry().height() / 3. width = self.sizeHint().width() height = self.sizeHint().height() # The message window should cover at least one third of the screen self.resize(max(available_width, width), max(available_height, height))
def showTraceback(self, header=None): s = io.StringIO() tb.print_exc(file=s) last_tb = '<p>' + '<br>'.join(s.getvalue().splitlines()) + \ '</p>' header = header + '\n' if header else '' self.showMessage(header + last_tb) available_width = QDesktopWidget().availableGeometry().width() / 3. available_height = QDesktopWidget().availableGeometry().height() / 3. width = self.sizeHint().width() height = self.sizeHint().height() # The message window should cover at least one third of the screen self.resize(max(available_width, width), max(available_height, height))
def new_plots(self, exec_=None): if hasattr(self, 'plot_creator'): try: self.plot_creator.close() except RuntimeError: pass self.plot_creator = PlotCreator(help_explorer=self.help_explorer, parent=self) available_width = QDesktopWidget().availableGeometry().width() / 3. width = self.plot_creator.sizeHint().width() height = self.plot_creator.sizeHint().height() # The plot creator window should cover at least one third of the screen self.plot_creator.resize(max(available_width, width), height) if exec_: self.plot_creator.exec_()
def edit_preferences(self, exec_=None): """Edit Spyder preferences""" if hasattr(self, 'preferences'): try: self.preferences.close() except RuntimeError: pass self.preferences = dlg = Prefences(self) for PrefPageClass in self.config_pages: widget = PrefPageClass(dlg) widget.initialize() dlg.add_page(widget) available_width = 0.667 * QDesktopWidget().availableGeometry().width() width = dlg.sizeHint().width() height = dlg.sizeHint().height() # The preferences window should cover at least one third of the screen dlg.resize(max(available_width, width), height) if exec_: dlg.exec_()
def export_df(cls, parent, df, straditizer, fname=None, exec_=True): """Open a dialog for exporting a DataFrame Parameters ---------- parent: QWidget The parent widget %(ExportDfDialog.parameters)s""" dialog = cls(df, straditizer, fname, parent=parent) if fname is None: available_width = QDesktopWidget().availableGeometry().width() / 3. width = dialog.sizeHint().width() height = dialog.sizeHint().height() # The plot creator window should cover at least one third of the # screen dialog.resize(max(available_width, width), height) if exec_: dialog.exec_() else: return dialog