def test1(self): class FT(QToolBar): def paintEvent(self, e): pass w = QMainWindow() ftt, ftb = FT(), FT() ftt.setFixedHeight(15) ftb.setFixedHeight(15) w.addToolBar(Qt.TopToolBarArea, ftt) w.addToolBar(Qt.BottomToolBarArea, ftb) f = dropshadow.DropShadowFrame() te = QTextEdit() c = QWidget() c.setLayout(QVBoxLayout()) c.layout().setContentsMargins(20, 0, 20, 0) c.layout().addWidget(te) w.setCentralWidget(c) f.setWidget(te) f.radius = 15 f.color = QColor(Qt.blue) w.show() self.singleShot(3000, lambda: f.setColor(Qt.red)) self.singleShot(4000, lambda: f.setRadius(30)) self.singleShot(5000, lambda: f.setRadius(40)) self.app.exec_()
class TestToolbar(object): def setup_method(self, method): self.app = QApplication(sys.argv) self.win = QMainWindow() p = plt.plot([1, 2, 3])[0] self.canvas = p.axes.figure.canvas self.axes = p.axes self.tb = GlueToolbar(self.canvas, self.win) self.mode = TestMode(self.axes, release_callback=self.callback) self.tb.add_mode(self.mode) self.win.addToolBar(self.tb) self._called_back = False def callback(self, mode): self._called_back = True def assert_valid_mode_state(self, target_mode): for mode in self.tb.buttons: if mode == target_mode: assert self.tb.buttons[mode].isChecked() else: assert not self.tb.buttons[mode].isChecked() assert self.tb._active == target_mode @pytest.mark.skip("Test running into issues with widget locks?") def test_mode_exclusive(self): for mode in self.tb.buttons: self.tb.buttons[mode].trigger() self.assert_valid_mode_state(mode) def test_callback(self): self.tb.buttons["TEST"].trigger() self.mode.release(None) assert self._called_back
class TestToolbar(object): def setup_method(self, method): self.win = QMainWindow() p = plt.plot([1, 2, 3])[0] self.canvas = p.axes.figure.canvas self.axes = p.axes self.tb = GlueToolbar(self.canvas, self.win) self.mode = TestMode(self.axes, release_callback=self.callback) self.tb.add_mode(self.mode) self.win.addToolBar(self.tb) self._called_back = False def callback(self, mode): self._called_back = True def assert_valid_mode_state(self, target_mode): for mode in self.tb.buttons: if mode == target_mode and self.tb.buttons[mode].isCheckable(): assert self.tb.buttons[mode].isChecked() self.tb._active == target_mode else: assert not self.tb.buttons[mode].isChecked() def test_callback(self): self.tb.buttons['TEST'].trigger() self.mode.release(None) assert self._called_back
def main(): app = QApplication(sys.argv) window = QMainWindow() splitter = QSplitter(window) window.setCentralWidget(splitter) left_view = MouseDevicesView(window) left_view.checkedDevicesChanged.connect(partial(show, 'left:')) right_view = MouseDevicesView(window) right_view.checkedDevicesChanged.connect(partial(show, 'right:')) splitter.addWidget(left_view) splitter.addWidget(right_view) def _move_checked_state(source, dest): checked = source.property('checkedDevices').toPyObject() dest.setProperty('checkedDevices', checked) toolbar = window.addToolBar('Actions') move_selection_left = QAction(QIcon.fromTheme('arrow-left'), 'Moved checked state left', window, triggered=partial(_move_checked_state, right_view, left_view)) move_selection_right = QAction(QIcon.fromTheme('arrow-right'), 'Moved checked state right', window, triggered=partial(_move_checked_state, left_view, right_view)) toolbar.addAction(move_selection_left) toolbar.addAction(move_selection_right) window.show() app.exec_()
def main(): app = QApplication(sys.argv) window = QMainWindow() splitter = QSplitter(window) window.setCentralWidget(splitter) left_view = MouseDevicesView(window) left_view.checkedDevicesChanged.connect(partial(show, 'left:')) right_view = MouseDevicesView(window) right_view.checkedDevicesChanged.connect(partial(show, 'right:')) splitter.addWidget(left_view) splitter.addWidget(right_view) def _move_checked_state(source, dest): checked = source.property('checkedDevices').toPyObject() dest.setProperty('checkedDevices', checked) toolbar = window.addToolBar('Actions') move_selection_left = QAction( QIcon.fromTheme('arrow-left'), 'Moved checked state left', window, triggered=partial(_move_checked_state, right_view, left_view)) move_selection_right = QAction( QIcon.fromTheme('arrow-right'), 'Moved checked state right', window, triggered=partial(_move_checked_state, left_view, right_view)) toolbar.addAction(move_selection_left) toolbar.addAction(move_selection_right) window.show() app.exec_()
def run(self): app = QApplication(sys.argv) w = QMainWindow() w.resize(700, 700) w.move(400, 0) w.setWindowTitle('Simple') w.show() w.isDrawMode = self.isDrawMode w.fileMenu = w.menuBar().addMenu("&File") w.fileSaveMenuItem = SfAction("&Save", w, shortcut="CTRL+S", tip="Save current scenario") w.fileSaveMenuItem.triggered.connect(self.fileSave) w.fileMenu.addAction(w.fileSaveMenuItem) w.fileMenu.addAction(SfAction("&Quit", w, slot=self.fileQuit(), shortcut="ALT+F4", tip="Quit SimFrames")) w.toolbar = w.addToolBar("Activities Toolbar") w.toolbar.setObjectName("ActivitiesToolbar") playActionsGroup = QActionGroup(w) w.toolbar.addAction(SfAction("&Play", w, "play.png", self.play, "CTRL+P", "Start the project", True, actionGroup=playActionsGroup )) w.toolbar.addAction(SfAction("&Stop", w, "stop.png", self.stop, "CTRL+F", "Stop executing", True, actionGroup=playActionsGroup, checked=True )) w.toolbar.addAction(SfSeparator(w)) self.mouseModeGroup = QActionGroup(w) w.toolbar.addAction(SfAction("&Move", self.mouseModeGroup, "moveMode.png", shortcut="CTRL+M", tip="Turn on mode to move components around canvas", checkable=True, checked=True)) self.drawAction = SfAction("&Draw", self.mouseModeGroup, "connectMode.png", shortcut="CTRL+D", tip="Turn on mode to connect components in canvas", checkable=True) w.toolbar.addAction(self.drawAction) w.toolbar.addAction(SfSeparator(w)) w.accordion = SfAccordion() functions = SfAccordionSection("Functions") functions.addComponents([SfComponent("add.png",), SfComponent("minus.png"), SfComponent("multiplication.png")]) inputSection = SfAccordionSection("Input") inputSection.addComponents([SfComponent("scale.png", ), SfComponent("square.png"), SfComponent("constant.png" )]) outputSection = SfAccordionSection("Output") outputSection.addComponents([SfComponent("txt.png", ), SfComponent("graph.png", )]) w.accordion.addSections([functions, inputSection, outputSection]) scene = SfGraphicsScene(w) self.canvas = SfGraphicsView(scene) scene.sceneRectChanged.connect(self.canvas.updateSceneRect) centralWidget = QWidget() mainLayout = QBoxLayout(QBoxLayout.LeftToRight, centralWidget) mainLayout.addWidget(w.accordion) mainLayout.addWidget(self.canvas) centralWidget.setLayout(mainLayout) w.setCentralWidget(centralWidget) w.quitAction = SfAction("&Quit", w, slot=self.fileQuit(), shortcut="ALT+F4", tip="Quit SimFrames") app.exec_()
def main(): app = QApplication(sys.argv) window = QMainWindow() central_widget = QWidget(window) start_action = QAction('Start', window) stop_action = QAction('Stop', window) toolbar = window.addToolBar('Monitor') toolbar.addAction(start_action) toolbar.addAction(stop_action) central_layout = QVBoxLayout(central_widget) monitor_name = QLabel(central_widget) central_layout.addWidget(monitor_name) state_label = QLabel(central_widget) central_layout.addWidget(state_label) combo_box = QComboBox(central_widget) items = [('No keys', AbstractKeyboardMonitor.IGNORE_NO_KEYS), ('Modifiers', AbstractKeyboardMonitor.IGNORE_MODIFIER_KEYS), ('Modifier combos', AbstractKeyboardMonitor.IGNORE_MODIFIER_COMBOS)] for label, userdata in items: combo_box.addItem(label, userdata) def _update_ignore_keys(index): monitor.keys_to_ignore = combo_box.itemData(index).toPyObject() combo_box.currentIndexChanged[int].connect(_update_ignore_keys) central_layout.addWidget(combo_box) central_widget.setLayout(central_layout) window.setCentralWidget(central_widget) monitor = create_keyboard_monitor(window) monitor_name.setText('Using monitor class {0}'.format( monitor.__class__.__name__)) monitor.typingStarted.connect(partial(state_label.setText, 'typing')) monitor.typingStopped.connect(partial(state_label.setText, 'not typing')) start_action.triggered.connect(monitor.start) stop_action.triggered.connect(monitor.stop) stop_action.setEnabled(False) monitor.started.connect(partial(start_action.setEnabled, False)) monitor.started.connect(partial(stop_action.setEnabled, True)) monitor.stopped.connect(partial(start_action.setEnabled, True)) monitor.stopped.connect(partial(stop_action.setEnabled, False)) window.show() app.exec_()
def main(): app = QApplication(sys.argv) window = QMainWindow() central_widget = QWidget(window) start_action = QAction('Start', window) stop_action = QAction('Stop', window) toolbar = window.addToolBar('Monitor') toolbar.addAction(start_action) toolbar.addAction(stop_action) central_layout = QVBoxLayout(central_widget) monitor_name = QLabel(central_widget) central_layout.addWidget(monitor_name) state_label = QLabel(central_widget) central_layout.addWidget(state_label) combo_box = QComboBox(central_widget) items = [ ('No keys', AbstractKeyboardMonitor.IGNORE_NO_KEYS), ('Modifiers', AbstractKeyboardMonitor.IGNORE_MODIFIER_KEYS), ('Modifier combos', AbstractKeyboardMonitor.IGNORE_MODIFIER_COMBOS)] for label, userdata in items: combo_box.addItem(label, userdata) def _update_ignore_keys(index): monitor.keys_to_ignore = combo_box.itemData(index).toPyObject() combo_box.currentIndexChanged[int].connect(_update_ignore_keys) central_layout.addWidget(combo_box) central_widget.setLayout(central_layout) window.setCentralWidget(central_widget) monitor = create_keyboard_monitor(window) monitor_name.setText('Using monitor class {0}'.format( monitor.__class__.__name__)) monitor.typingStarted.connect(partial(state_label.setText, 'typing')) monitor.typingStopped.connect(partial(state_label.setText, 'not typing')) start_action.triggered.connect(monitor.start) stop_action.triggered.connect(monitor.stop) stop_action.setEnabled(False) monitor.started.connect(partial(start_action.setEnabled, False)) monitor.started.connect(partial(stop_action.setEnabled, True)) monitor.stopped.connect(partial(start_action.setEnabled, True)) monitor.stopped.connect(partial(stop_action.setEnabled, False)) window.show() app.exec_()
def test(self): lv = QListView() mw = QMainWindow() # Add two tool bars, the shadow should extend over them. mw.addToolBar(Qt.BottomToolBarArea, QToolBar()) mw.addToolBar(Qt.TopToolBarArea, QToolBar()) mw.setCentralWidget(lv) f = dropshadow.DropShadowFrame(color=Qt.blue, radius=20) f.setWidget(lv) self.assertIs(f.parentWidget(), mw) self.assertIs(f.widget(), lv) mw.show() self.app.processEvents() self.singleShot(3000, lambda: f.setColor(Qt.red)) self.singleShot(4000, lambda: f.setRadius(30)) self.singleShot(5000, lambda: f.setRadius(40)) self.app.exec_()
def main(icon_spec): app = QApplication(sys.argv) main_window = QMainWindow() def sigint_handler(*args): main_window.close() signal.signal(signal.SIGINT, sigint_handler) # the timer enables triggering the sigint_handler signal_timer = QTimer() signal_timer.start(100) signal_timer.timeout.connect(lambda: None) tool_bar = QToolBar() main_window.addToolBar(Qt.TopToolBarArea, tool_bar) table_view = QTableView() table_view.setSelectionBehavior(QAbstractItemView.SelectRows) table_view.setSelectionMode(QAbstractItemView.SingleSelection) table_view.setSortingEnabled(True) main_window.setCentralWidget(table_view) proxy_model = QSortFilterProxyModel() proxy_model.setFilterCaseSensitivity(Qt.CaseInsensitive) proxy_model.setFilterKeyColumn(1) table_view.setModel(proxy_model) proxy_model.layoutChanged.connect(table_view.resizeRowsToContents) item_model = QStandardItemModel() proxy_model.setSourceModel(item_model) # get all icons and their available sizes QIcon.setThemeName("gnome") icons = [] all_sizes = set([]) for context, icon_names in icon_spec: for icon_name in icon_names: icon = QIcon.fromTheme(icon_name) sizes = [] for size in icon.availableSizes(): size = (size.width(), size.height()) sizes.append(size) all_sizes.add(size) sizes.sort() icons.append({ 'context': context, 'icon_name': icon_name, 'icon': icon, 'sizes': sizes, }) all_sizes = list(all_sizes) all_sizes.sort() # input field for filter def filter_changed(value): proxy_model.setFilterRegExp(value) table_view.resizeRowsToContents() filter_line_edit = QLineEdit() filter_line_edit.setMaximumWidth(200) filter_line_edit.setPlaceholderText('Filter name') filter_line_edit.setToolTip('Filter name optionally using regular expressions (' + QKeySequence(QKeySequence.Find).toString() + ')') filter_line_edit.textChanged.connect(filter_changed) tool_bar.addWidget(filter_line_edit) # actions to toggle visibility of available sizes/columns def action_toggled(index): column = 2 + index table_view.setColumnHidden(column, not table_view.isColumnHidden(column)) table_view.resizeColumnsToContents() table_view.resizeRowsToContents() signal_mapper = QSignalMapper() for i, size in enumerate(all_sizes): action = QAction('%dx%d' % size, tool_bar) action.setCheckable(True) action.setChecked(True) tool_bar.addAction(action) action.toggled.connect(signal_mapper.map) signal_mapper.setMapping(action, i) # set tool tip and handle key sequence tool_tip = 'Toggle visibility of column' if i < 10: digit = ('%d' % (i + 1))[-1] tool_tip += ' (%s)' % QKeySequence('Ctrl+%s' % digit).toString() action.setToolTip(tool_tip) signal_mapper.mapped.connect(action_toggled) # label columns header_labels = ['context', 'name'] for width, height in all_sizes: header_labels.append('%dx%d' % (width, height)) item_model.setColumnCount(len(header_labels)) item_model.setHorizontalHeaderLabels(header_labels) # fill rows item_model.setRowCount(len(icons)) for row, icon_data in enumerate(icons): # context item = QStandardItem(icon_data['context']) item.setFlags(item.flags() ^ Qt.ItemIsEditable) item_model.setItem(row, 0, item) # icon name item = QStandardItem(icon_data['icon_name']) item.setFlags(item.flags() ^ Qt.ItemIsEditable) item_model.setItem(row, 1, item) for index_in_all_sizes, size in enumerate(all_sizes): column = 2 + index_in_all_sizes if size in icon_data['sizes']: # icon as pixmap to keep specific size item = QStandardItem('') pixmap = icon_data['icon'].pixmap(size[0], size[1]) item.setData(pixmap, Qt.DecorationRole) item.setFlags(item.flags() ^ Qt.ItemIsEditable) item_model.setItem(row, column, item) else: # single space to be sortable against icons item = QStandardItem(' ') item.setFlags(item.flags() ^ Qt.ItemIsEditable) item_model.setItem(row, column, item) table_view.resizeColumnsToContents() # manually set row heights because resizeRowsToContents is not working properly for row, icon_data in enumerate(icons): if len(icon_data['sizes']) > 0: max_size = icon_data['sizes'][-1] table_view.setRowHeight(row, max_size[1]) # enable focus find (ctrl+f) and toggle columns (ctrl+NUM) def main_window_keyPressEvent(self, event, old_keyPressEvent=QMainWindow.keyPressEvent): if event.matches(QKeySequence.Find): filter_line_edit.setFocus() return if event.modifiers() == Qt.ControlModifier and event.key() >= Qt.Key_0 and event.key() <= Qt.Key_9: index = event.key() - Qt.Key_1 if event.key() == Qt.Key_0: index += 10 action = signal_mapper.mapping(index) if action: action.toggle() return old_keyPressEvent(self, event) main_window.keyPressEvent = new.instancemethod(main_window_keyPressEvent, table_view, None) # enable copy (ctrl+c) name of icon to clipboard def table_view_keyPressEvent(self, event, old_keyPressEvent=QTableView.keyPressEvent): if event.matches(QKeySequence.Copy): selection_model = self.selectionModel() if selection_model.hasSelection(): index = selection_model.selectedRows()[0] source_index = self.model().mapToSource(index) item = self.model().sourceModel().item(source_index.row(), 1) icon_name = item.data(Qt.EditRole) app.clipboard().setText(icon_name.toString()) return old_keyPressEvent(self, event) table_view.keyPressEvent = new.instancemethod(table_view_keyPressEvent, table_view, None) print 'Icon Theme: ', QIcon.themeName() print 'Theme Search Paths:' for item in QIcon.themeSearchPaths(): print item main_window.showMaximized() return app.exec_()
def main(icon_spec): app = QApplication(sys.argv) main_window = QMainWindow() def sigint_handler(*args): main_window.close() signal.signal(signal.SIGINT, sigint_handler) # the timer enables triggering the sigint_handler signal_timer = QTimer() signal_timer.start(100) signal_timer.timeout.connect(lambda: None) tool_bar = QToolBar() main_window.addToolBar(Qt.TopToolBarArea, tool_bar) table_view = QTableView() table_view.setSelectionBehavior(QAbstractItemView.SelectRows) table_view.setSelectionMode(QAbstractItemView.SingleSelection) table_view.setSortingEnabled(True) main_window.setCentralWidget(table_view) proxy_model = QSortFilterProxyModel() proxy_model.setFilterCaseSensitivity(Qt.CaseInsensitive) proxy_model.setFilterKeyColumn(1) table_view.setModel(proxy_model) proxy_model.layoutChanged.connect(table_view.resizeRowsToContents) item_model = QStandardItemModel() proxy_model.setSourceModel(item_model) # get all icons and their available sizes QIcon.setThemeName("gnome") icons = [] all_sizes = set([]) for context, icon_names in icon_spec: for icon_name in icon_names: icon = QIcon.fromTheme(icon_name) sizes = [] for size in icon.availableSizes(): size = (size.width(), size.height()) sizes.append(size) all_sizes.add(size) sizes.sort() icons.append({ 'context': context, 'icon_name': icon_name, 'icon': icon, 'sizes': sizes, }) all_sizes = list(all_sizes) all_sizes.sort() # input field for filter def filter_changed(value): proxy_model.setFilterRegExp(value) table_view.resizeRowsToContents() filter_line_edit = QLineEdit() filter_line_edit.setMaximumWidth(200) filter_line_edit.setPlaceholderText('Filter name') filter_line_edit.setToolTip( 'Filter name optionally using regular expressions (' + QKeySequence(QKeySequence.Find).toString() + ')') filter_line_edit.textChanged.connect(filter_changed) tool_bar.addWidget(filter_line_edit) # actions to toggle visibility of available sizes/columns def action_toggled(index): column = 2 + index table_view.setColumnHidden(column, not table_view.isColumnHidden(column)) table_view.resizeColumnsToContents() table_view.resizeRowsToContents() signal_mapper = QSignalMapper() for i, size in enumerate(all_sizes): action = QAction('%dx%d' % size, tool_bar) action.setCheckable(True) action.setChecked(True) tool_bar.addAction(action) action.toggled.connect(signal_mapper.map) signal_mapper.setMapping(action, i) # set tool tip and handle key sequence tool_tip = 'Toggle visibility of column' if i < 10: digit = ('%d' % (i + 1))[-1] tool_tip += ' (%s)' % QKeySequence('Ctrl+%s' % digit).toString() action.setToolTip(tool_tip) signal_mapper.mapped.connect(action_toggled) # label columns header_labels = ['context', 'name'] for width, height in all_sizes: header_labels.append('%dx%d' % (width, height)) item_model.setColumnCount(len(header_labels)) item_model.setHorizontalHeaderLabels(header_labels) # fill rows item_model.setRowCount(len(icons)) for row, icon_data in enumerate(icons): # context item = QStandardItem(icon_data['context']) item.setFlags(item.flags() ^ Qt.ItemIsEditable) item_model.setItem(row, 0, item) # icon name item = QStandardItem(icon_data['icon_name']) item.setFlags(item.flags() ^ Qt.ItemIsEditable) item_model.setItem(row, 1, item) for index_in_all_sizes, size in enumerate(all_sizes): column = 2 + index_in_all_sizes if size in icon_data['sizes']: # icon as pixmap to keep specific size item = QStandardItem('') pixmap = icon_data['icon'].pixmap(size[0], size[1]) item.setData(pixmap, Qt.DecorationRole) item.setFlags(item.flags() ^ Qt.ItemIsEditable) item_model.setItem(row, column, item) else: # single space to be sortable against icons item = QStandardItem(' ') item.setFlags(item.flags() ^ Qt.ItemIsEditable) item_model.setItem(row, column, item) table_view.resizeColumnsToContents() # manually set row heights because resizeRowsToContents is not working properly for row, icon_data in enumerate(icons): if len(icon_data['sizes']) > 0: max_size = icon_data['sizes'][-1] table_view.setRowHeight(row, max_size[1]) # enable focus find (ctrl+f) and toggle columns (ctrl+NUM) def main_window_keyPressEvent(self, event, old_keyPressEvent=QMainWindow.keyPressEvent): if event.matches(QKeySequence.Find): filter_line_edit.setFocus() return if event.modifiers() == Qt.ControlModifier and event.key( ) >= Qt.Key_0 and event.key() <= Qt.Key_9: index = event.key() - Qt.Key_1 if event.key() == Qt.Key_0: index += 10 action = signal_mapper.mapping(index) if action: action.toggle() return old_keyPressEvent(self, event) main_window.keyPressEvent = new.instancemethod(main_window_keyPressEvent, table_view, None) # enable copy (ctrl+c) name of icon to clipboard def table_view_keyPressEvent(self, event, old_keyPressEvent=QTableView.keyPressEvent): if event.matches(QKeySequence.Copy): selection_model = self.selectionModel() if selection_model.hasSelection(): index = selection_model.selectedRows()[0] source_index = self.model().mapToSource(index) item = self.model().sourceModel().item(source_index.row(), 1) icon_name = item.data(Qt.EditRole) app.clipboard().setText(icon_name.toString()) return old_keyPressEvent(self, event) table_view.keyPressEvent = new.instancemethod(table_view_keyPressEvent, table_view, None) print 'Icon Theme: ', QIcon.themeName() print 'Theme Search Paths:' for item in QIcon.themeSearchPaths(): print item main_window.showMaximized() return app.exec_()
return spacer if __name__ == "__main__": import sys from PyQt4.QtGui import QMainWindow from manager.componentsManager import Manager from umbra.managers.actionsManager import ActionsManager from umbra.managers.layoutsManager import LayoutsManager from umbra.preferences import Preferences application = umbra.ui.common.getApplicationInstance() mainWindow = QMainWindow() mainWindow.settings = Preferences() mainWindow.actionsManager = ActionsManager(mainWindow) mainWindow.layoutsManager = LayoutsManager(mainWindow) mainWindow.componentsManager = Manager() mainWindow.toggleFullScreen = lambda: sys.stdout.write("toggleFullScreen()\n") mainWindow.setCentralWidget(QLabel()) application_QToolBar = Application_QToolBar(mainWindow) mainWindow.addToolBar(application_QToolBar) mainWindow.show() mainWindow.raise_() sys.exit(application.exec_())
app = QApplication(['']) mw = QMainWindow() f = Figure() if '--agg' not in sys.argv: fc = FigureCanvasQTOpenGL(f) else: fc = FigureCanvasQTAgg(f) ax = f.add_subplot(111) if '--size' in sys.argv: sz = int(sys.argv[-1]) else: sz = 10 ** 6 x = np.random.normal(0, 1, sz) y = np.random.normal(0, 1, sz) lines, = ax.plot(x, y, 'o', alpha=.1) lines2, = ax.plot(x, np.sin(x), 'ro', alpha=.2) tb = NavigationToolbar2QT(fc, None) mw.setCentralWidget(fc) mw.addToolBar(tb) mw.show() show.mainloop()
app = QApplication(['']) mw = QMainWindow() f = Figure() if '--agg' not in sys.argv: fc = FigureCanvasQTOpenGL(f) else: fc = FigureCanvasQTAgg(f) ax = f.add_subplot(111) if '--size' in sys.argv: sz = int(sys.argv[-1]) else: sz = 10**6 x = np.random.normal(0, 1, sz) y = np.random.normal(0, 1, sz) lines, = ax.plot(x, y, 'o', alpha=.1) lines2, = ax.plot(x, np.sin(x), 'ro', alpha=.2) tb = NavigationToolbar2QT(fc, None) mw.setCentralWidget(fc) mw.addToolBar(tb) mw.show() show.mainloop()