Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.menu_mode.addAction(self.action_select_mode_xor)
self.menu_mode.addAction(self.action_select_mode_subtract)
self.action_samp_send_table_select_row_list = QtGui.QAction(QtGui.QIcon(iconfile('block--arrow')), 'Broadcast selection over SAMP', self)
self.action_samp_send_table_select_row_list.setShortcut('Ctrl+Shift+B')
#self.toolbar.addAction(self.action_samp_sand_table_select_row_list)
self.menu_samp.addAction(self.action_samp_send_table_select_row_list)
def send_samp_selection(ignore=None):
self.signal_samp_send_selection.emit(self.dataset)
self.send_samp_selection_reference = send_samp_selection # does this fix the bug that clicking the buttons doesn't do anything?
self.action_samp_send_table_select_row_list.triggered.connect(send_samp_selection)
self.action_display_mode_both = QtGui.QAction(QtGui.QIcon(iconfile('picture_empty')), 'Show both', self)
self.action_display_mode_full = QtGui.QAction(QtGui.QIcon(iconfile('picture_empty')), 'Show full', self)
self.action_display_mode_selection = QtGui.QAction(QtGui.QIcon(iconfile('picture_empty')), 'Show selection', self)
self.action_display_mode_both_contour = QtGui.QAction(QtGui.QIcon(iconfile('picture_empty')), 'Show contour', self)
#self.actions_resolution = []
self.actions_display = [self.action_display_mode_both, self.action_display_mode_full, self.action_display_mode_selection, self.action_display_mode_both_contour]
for action in self.actions_display:
self.action_group_display.addAction(action)
action.setCheckable(True)
action = self.actions_display[0]
action.setChecked(True)
self.action_display_current = action
self.action_group_display.triggered.connect(self.onActionDisplay)
#self.zoomButton = QtGui.QToolButton(self, )
#$self.zoomButton.setIcon(QtGui.QIcon(iconfile('glue_zoom_to_rect')))
#self.zoomMenu = QtGui.QMenu(self)
self.action_mini_mode_compact = QtGui.QAction(QtGui.QIcon(iconfile('layout-hf')), 'Compact', self)
self.action_mini_mode_ultra = QtGui.QAction(QtGui.QIcon(iconfile('layout')), 'Ultra compact', self)
self.action_mini_mode_normal.setShortcut("Ctrl+Shift+N")
self.action_mini_mode_compact.setShortcut("Ctrl+Shift+C")
self.action_mini_mode_ultra.setShortcut("Ctrl+Shift+U")
self.action_group_mini_mode = QtGui.QActionGroup(self)
self.action_group_mini_mode.addAction(self.action_mini_mode_normal)
self.action_group_mini_mode.addAction(self.action_mini_mode_compact)
self.action_group_mini_mode.addAction(self.action_mini_mode_ultra)
self.action_fullscreen = QtGui.QAction(QtGui.QIcon(iconfile('picture_empty')), '&Fullscreen', self)
self.action_fullscreen.setCheckable(True)
self.action_fullscreen.setShortcut(("Ctrl+F"))
self.action_toolbar_toggle = QtGui.QAction(QtGui.QIcon(iconfile('ui-toolbar')), '&Toolbars', self)
self.action_toolbar_toggle.setCheckable(True)
self.action_toolbar_toggle.setChecked(True)
self.action_toolbar_toggle.setShortcut(("Ctrl+Shift+T"))
#self.actiongroup_mini_mode.addAction(self.action_fullscreen)
def toggle_fullscreen(ignore=None):
fullscreen = self.windowState() & QtCore.Qt.WindowFullScreen
fullscreen = not fullscreen # toggle
self.action_fullscreen.setChecked(fullscreen)
if fullscreen:
self.setWindowState(self.windowState() | QtCore.Qt.WindowFullScreen);
else:
self.setWindowState(self.windowState() ^ QtCore.Qt.WindowFullScreen);
self.action_zoom_rect = QtGui.QAction(QtGui.QIcon(iconfile('zoom')), '&Zoom to rect', self.dialog)
self.action_zoom_rect.setShortcut("Ctrl+Alt+Z")
self.dialog.menu_mode.addAction(self.action_zoom_rect)
self.action_zoom_x = QtGui.QAction(QtGui.QIcon(iconfile('zoom_x')), '&Zoom x', self.dialog)
self.action_zoom_y = QtGui.QAction(QtGui.QIcon(iconfile('zoom_y')), '&Zoom y', self.dialog)
self.action_zoom = QtGui.QAction(QtGui.QIcon(iconfile('zoom')), '&Zoom(you should not read this)', self.dialog)
self.action_zoom_x.setShortcut("Ctrl+Alt+X")
self.action_zoom_y.setShortcut("Ctrl+Alt+Y")
self.dialog.menu_mode.addAction(self.action_zoom_x)
self.dialog.menu_mode.addAction(self.action_zoom_y)
self.dialog.menu_mode.addSeparator()
self.action_zoom_out = QtGui.QAction(QtGui.QIcon(iconfile('zoom_out')), '&Zoom out', self.dialog)
self.action_zoom_in = QtGui.QAction(QtGui.QIcon(iconfile('zoom_in')), '&Zoom in', self.dialog)
self.action_zoom_fit = QtGui.QAction(QtGui.QIcon(iconfile('arrow_out')), '&Reset view', self.dialog)
#self.action_zoom_use = QtGui.QAction(QtGui.QIcon(iconfile('chart_bar')), '&Use zoom area', self.dialog)
self.action_zoom_out.setShortcut("Ctrl+Alt+-")
self.action_zoom_in.setShortcut("Ctrl+Alt++")
self.action_zoom_fit.setShortcut("Ctrl+Alt+0")
self.dialog.menu_mode.addAction(self.action_zoom_out)
self.dialog.menu_mode.addAction(self.action_zoom_in)
self.dialog.menu_mode.addAction(self.action_zoom_fit)
self.dialog.action_group_main.addAction(self.action_zoom_rect)
self.dialog.action_group_main.addAction(self.action_zoom_x)
self.dialog.action_group_main.addAction(self.action_zoom_y)
if path:
_, ext = os.path.splitext(path)
data = self.dataset.get_selection().to_dict()
if ext == ".yaml":
import yaml
with open(path, "w") as f:
yaml.dump(data, f)
elif ext == ".json":
import json
with open(path, "w") as f:
json.dump(data, f)
else:
dialogs.dialog_error(self, "Unknown extension", "Unknown extension %r" % ext)
#np.save(path, self.dataset.mask)
self.action_selection_store = QtGui.QAction(QtGui.QIcon(iconfile('tag-export')), '&Store selection', self)
self.action_selection_store.triggered.connect(on_store_selection)
#self.action_selection_store.setCheckable(True)
#self.toolbar2.addAction(self.action_selection_store)
self.menu_selection.addAction(self.action_selection_store)
def on_load_selection():
path = self.dataset.name + "-selection.yaml"
path = get_path_open(self, "Open selection", path, "Compatible files for vaex (*.yaml *.json)")
if path:
_, ext = os.path.splitext(path)
if ext == ".yaml":
import yaml
with open(path) as f:
data = yaml.load(f)
elif ext == ".json":
import json
self.action_move.setShortcut("Ctrl+M")
self.menu_mode.addAction(self.action_move)
self.action_pick = QtGui.QAction(QtGui.QIcon(iconfile('cursor')), '&Pick', self)
self.action_pick.setShortcut("Ctrl+P")
self.menu_mode.addAction(self.action_pick)
self.action_select = QtGui.QAction(QtGui.QIcon(iconfile('glue_lasso16')), '&Select(you should not read this)', self)
self.action_xrange = QtGui.QAction(QtGui.QIcon(iconfile('glue_xrange_select16')), '&x-range', self)
self.action_yrange = QtGui.QAction(QtGui.QIcon(iconfile('glue_yrange_select16')), '&y-range', self)
self.action_lasso = QtGui.QAction(QtGui.QIcon(iconfile('glue_lasso16')), '&Lasso', self)
self.action_select_rectangle = QtGui.QAction(QtGui.QIcon(iconfile('glue_square16')), '&Rectangle', self)
self.action_slice = QtGui.QAction(QtGui.QIcon(iconfile('cutlery-knife')), '&Slice', self)
self.action_select_viewport = QtGui.QAction(QtGui.QIcon(iconfile('control-stop-square')), '&Select viewport', self)
self.action_select_none = QtGui.QAction(QtGui.QIcon(iconfile('cross')), '&No selection', self)
self.action_select_invert = QtGui.QAction(QtGui.QIcon(iconfile('arrow-circle-double-135')), '&Invert', self)
self.action_xrange.setShortcut("Ctrl+Shift+X")
self.menu_mode.addAction(self.action_xrange)
self.action_yrange.setShortcut("Ctrl+Shift+Y")
self.menu_mode.addAction(self.action_yrange)
self.action_lasso.setShortcut("Ctrl+L")
self.menu_mode.addAction(self.action_lasso)
self.action_select_rectangle.setShortcut("Ctrl+R")
self.menu_mode.addAction(self.action_select_rectangle)
self.action_slice.setShortcut("Ctrl+S")
self.menu_mode.addAction(self.action_slice)
self.action_select_viewport.setShortcut("Ctrl+Shift+V")
self.menu_mode.addAction(self.action_select_viewport)
self.action_select_none.setShortcut("Ctrl+N")
self.menu_mode.addAction(self.action_select_none)
self.action_select_invert.setShortcut("Ctrl+I")
def plug_toolbar(self):
logger.info("adding zoom plugin")
self.dialog.menu_mode.addSeparator()
self.action_zoom_rect = QtGui.QAction(QtGui.QIcon(iconfile('zoom')), '&Zoom to rect', self.dialog)
self.action_zoom_rect.setShortcut("Ctrl+Alt+Z")
self.dialog.menu_mode.addAction(self.action_zoom_rect)
self.action_zoom_x = QtGui.QAction(QtGui.QIcon(iconfile('zoom_x')), '&Zoom x', self.dialog)
self.action_zoom_y = QtGui.QAction(QtGui.QIcon(iconfile('zoom_y')), '&Zoom y', self.dialog)
self.action_zoom = QtGui.QAction(QtGui.QIcon(iconfile('zoom')), '&Zoom(you should not read this)', self.dialog)
self.action_zoom_x.setShortcut("Ctrl+Alt+X")
self.action_zoom_y.setShortcut("Ctrl+Alt+Y")
self.dialog.menu_mode.addAction(self.action_zoom_x)
self.dialog.menu_mode.addAction(self.action_zoom_y)
self.dialog.menu_mode.addSeparator()
self.action_zoom_out = QtGui.QAction(QtGui.QIcon(iconfile('zoom_out')), '&Zoom out', self.dialog)
self.action_zoom_in = QtGui.QAction(QtGui.QIcon(iconfile('zoom_in')), '&Zoom in', self.dialog)
self.action_zoom_fit = QtGui.QAction(QtGui.QIcon(iconfile('arrow_out')), '&Reset view', self.dialog)
#self.action_zoom_use = QtGui.QAction(QtGui.QIcon(iconfile('chart_bar')), '&Use zoom area', self.dialog)
self.action_zoom_out.setShortcut("Ctrl+Alt+-")
self.action_zoom_in.setShortcut("Ctrl+Alt++")
self.action_toolbar_toggle.triggered.connect(self.on_toolbar_toggle)
self.action_move = QtGui.QAction(QtGui.QIcon(iconfile('edit-move')), '&Move', self)
self.action_move.setShortcut("Ctrl+M")
self.menu_mode.addAction(self.action_move)
self.action_pick = QtGui.QAction(QtGui.QIcon(iconfile('cursor')), '&Pick', self)
self.action_pick.setShortcut("Ctrl+P")
self.menu_mode.addAction(self.action_pick)
self.action_select = QtGui.QAction(QtGui.QIcon(iconfile('glue_lasso16')), '&Select(you should not read this)', self)
self.action_xrange = QtGui.QAction(QtGui.QIcon(iconfile('glue_xrange_select16')), '&x-range', self)
self.action_yrange = QtGui.QAction(QtGui.QIcon(iconfile('glue_yrange_select16')), '&y-range', self)
self.action_lasso = QtGui.QAction(QtGui.QIcon(iconfile('glue_lasso16')), '&Lasso', self)
self.action_select_rectangle = QtGui.QAction(QtGui.QIcon(iconfile('glue_square16')), '&Rectangle', self)
self.action_slice = QtGui.QAction(QtGui.QIcon(iconfile('cutlery-knife')), '&Slice', self)
self.action_select_viewport = QtGui.QAction(QtGui.QIcon(iconfile('control-stop-square')), '&Select viewport', self)
self.action_select_none = QtGui.QAction(QtGui.QIcon(iconfile('cross')), '&No selection', self)
self.action_select_invert = QtGui.QAction(QtGui.QIcon(iconfile('arrow-circle-double-135')), '&Invert', self)
self.action_xrange.setShortcut("Ctrl+Shift+X")
self.menu_mode.addAction(self.action_xrange)
self.action_yrange.setShortcut("Ctrl+Shift+Y")
self.menu_mode.addAction(self.action_yrange)
self.action_lasso.setShortcut("Ctrl+L")
self.menu_mode.addAction(self.action_lasso)
self.action_select_rectangle.setShortcut("Ctrl+R")
self.menu_mode.addAction(self.action_select_rectangle)
self.action_slice.setShortcut("Ctrl+S")
self.menu_mode.addAction(self.action_slice)
self.action_select_viewport.setShortcut("Ctrl+Shift+V")
self.button_layer_new = QtGui.QToolButton(self)
self.button_layer_new.setIcon(QtGui.QIcon(iconfile("layer--plus")))
self.button_layer_new.setPopupMode(QtGui.QToolButton.InstantPopup)
self.button_layer_new.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
toolbuttonSizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
self.button_layer_new.setSizePolicy(toolbuttonSizePolicy)
self.button_layer_new.setText("add")
self.button_layer_new.setEnabled(self.dimensions < 3)
self.menu_layer_new = QtGui.QMenu()
self.fill_menu_layer_new()
self.button_layer_new.setMenu(self.menu_layer_new)
self.button_layer_delete = QtGui.QToolButton(self)
self.button_layer_delete.setIcon(QtGui.QIcon(iconfile("layer--minus")))
self.button_layer_delete.setText("remove")
self.button_layer_delete.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
self.button_layer_delete.setSizePolicy(toolbuttonSizePolicy)
self.button_layer_delete.setEnabled(self.dimensions < 3)
def on_layer_remove(_ignore=None):
logger.debug("remove layer")
self.remove_layer()
self.button_layer_delete.clicked.connect(on_layer_remove)
self.layout_layer_buttons.addWidget(self.button_layer_new, 0)
self.layout_layer_buttons.addWidget(self.button_layer_delete, 0)
self.layer_selection = QtGui.QComboBox(self)
self.layer_selection.addItems(["Layer controls"])
self.layout_layer_box.addLayout(self.layout_layer_buttons)
def __(self):
self.action_store = QtGui.QAction(QtGui.QIcon(iconfile('gear')), 'Store', self.dialog)
self.action_store.setShortcut("Ctrl+B")
self.action_store_toolbar = QtGui.QAction(QtGui.QIcon(iconfile('star')), 'Store', self.dialog)
self.dialog.toolbar.addAction(self.action_store_toolbar)
self.action_store.triggered.connect(self.on_store)
self.action_store_toolbar.triggered.connect(self.on_store)
self.changed_handle = storage_plots.changed.connect(self.load_options_menu)
self.load_options_menu()
self.dialog.menu_mode.addSeparator()
self.action_zoom_rect = QtGui.QAction(QtGui.QIcon(iconfile('zoom')), '&Zoom to rect', self.dialog)
self.action_zoom_rect.setShortcut("Ctrl+Alt+Z")
self.dialog.menu_mode.addAction(self.action_zoom_rect)
self.action_zoom_x = QtGui.QAction(QtGui.QIcon(iconfile('zoom_x')), '&Zoom x', self.dialog)
self.action_select_viewport.setShortcut("Ctrl+Shift+V")
self.menu_mode.addAction(self.action_select_viewport)
self.action_select_none.setShortcut("Ctrl+N")
self.menu_mode.addAction(self.action_select_none)
self.action_select_invert.setShortcut("Ctrl+I")
self.menu_mode.addAction(self.action_select_invert)
self.menu_mode.addSeparator()
self.action_select_invert.setShortcut("Ctrl+I")
#self.menu_mode_select_mode = QtGui.QMenu("Select mode")
#self.menu_mode.addMenu(self.menu_mode_select_mode)
self.action_select_mode_replace = QtGui.QAction(QtGui.QIcon(iconfile('sql-join-right')), '&Replace', self)
self.action_select_mode_and = QtGui.QAction(QtGui.QIcon(iconfile('sql-join-inner')), '&And', self)
self.action_select_mode_or = QtGui.QAction(QtGui.QIcon(iconfile('sql-join-outer')), '&Or', self)
self.action_select_mode_xor = QtGui.QAction(QtGui.QIcon(iconfile('sql-join-outer-exclude')), 'Xor', self)
self.action_select_mode_subtract = QtGui.QAction(QtGui.QIcon(iconfile('sql-join-left-exclude')), 'Subtract', self)
self.action_select_mode_replace.setShortcut("Ctrl+Shift+=")
self.action_select_mode_and.setShortcut("Ctrl+Shift+&")
self.action_select_mode_or.setShortcut("Ctrl+Shift+|")
self.action_select_mode_xor.setShortcut("Ctrl+Shift+^")
self.action_select_mode_subtract.setShortcut("Ctrl+Shift+-")
self.menu_mode.addAction(self.action_select_mode_replace)
self.menu_mode.addAction(self.action_select_mode_and)
self.menu_mode.addAction(self.action_select_mode_or)
self.menu_mode.addAction(self.action_select_mode_xor)
self.menu_mode.addAction(self.action_select_mode_subtract)
self.action_samp_send_table_select_row_list = QtGui.QAction(QtGui.QIcon(iconfile('block--arrow')), 'Broadcast selection over SAMP', self)
self.action_samp_send_table_select_row_list.setShortcut('Ctrl+Shift+B')
#self.toolbar.addAction(self.action_samp_sand_table_select_row_list)