INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
Selects a single cell
def select_cell(self, row, col, add_to_selected=False): """Selects a single cell""" self.grid.SelectBlock(row, col, row, col, addToSelected=add_to_selected)
Selects a slice of cells Parameters ---------- * row_slc: Integer or Slice \tRows to be selected * col_slc: Integer or Slice \tColumns to be selected * add_to_selected: Bool, defaults to False \tOld selections are cleared if False
def select_slice(self, row_slc, col_slc, add_to_selected=False): """Selects a slice of cells Parameters ---------- * row_slc: Integer or Slice \tRows to be selected * col_slc: Integer or Slice \tColumns to be selected * add_to_selected: Bool, defaults ...
Deletes selection, marks content as changed If selection is None then the current grid selection is used. Parameters ---------- selection: Selection, defaults to None \tSelection that shall be deleted
def delete_selection(self, selection=None): """Deletes selection, marks content as changed If selection is None then the current grid selection is used. Parameters ---------- selection: Selection, defaults to None \tSelection that shall be deleted """ ...
Deletes a selection if any else deletes the cursor cell Refreshes grid after deletion
def delete(self): """Deletes a selection if any else deletes the cursor cell Refreshes grid after deletion """ if self.grid.IsSelection(): # Delete selection self.grid.actions.delete_selection() else: # Delete cell at cursor cur...
Quotes selected cells, marks content as changed
def quote_selection(self): """Quotes selected cells, marks content as changed""" selection = self.get_selection() current_table = self.grid.current_table for row, col, tab in self.grid.code_array.dict_grid.keys(): if tab == current_table and (row, col) in selection: ...
Copys access_string to selection to the clipboard An access string is Python code to reference the selection If there is no selection then a reference to the current cell is copied
def copy_selection_access_string(self): """Copys access_string to selection to the clipboard An access string is Python code to reference the selection If there is no selection then a reference to the current cell is copied """ selection = self.get_selection() if not s...
Pastes cell formats Pasting starts at cursor or at top left bbox corner
def paste_format(self): """Pastes cell formats Pasting starts at cursor or at top left bbox corner """ row, col, tab = self.grid.actions.cursor selection = self.get_selection() if selection: # Use selection rather than cursor for top left cell if present ...
Copies the format of the selected cells to the Clipboard Cells are shifted so that the top left bbox corner is at 0,0
def copy_format(self): """Copies the format of the selected cells to the Clipboard Cells are shifted so that the top left bbox corner is at 0,0 """ row, col, tab = self.grid.actions.cursor code_array = self.grid.code_array # Cell attributes new_cell_attribute...
Return next position of event_find_string in MainGrid Parameters: ----------- gridpos: 3-tuple of Integer \tPosition at which the search starts find_string: String \tString to find in grid flags: List of strings \tSearch flag out of \t["UP" xor "D...
def find(self, gridpos, find_string, flags, search_result=True): """Return next position of event_find_string in MainGrid Parameters: ----------- gridpos: 3-tuple of Integer \tPosition at which the search starts find_string: String \tString to find in grid ...
Return list of all positions of event_find_string in MainGrid. Only the code is searched. The result is not searched here. Parameters: ----------- gridpos: 3-tuple of Integer \tPosition at which the search starts find_string: String \tString to find in grid ...
def find_all(self, find_string, flags): """Return list of all positions of event_find_string in MainGrid. Only the code is searched. The result is not searched here. Parameters: ----------- gridpos: 3-tuple of Integer \tPosition at which the search starts find_s...
Replaces occurrences of find_string with replace_string at findpos and marks content as changed Parameters ---------- findpositions: List of 3-Tuple of Integer \tPositions in grid that shall be replaced find_string: String \tString to be overwritten in the cell...
def replace_all(self, findpositions, find_string, replace_string): """Replaces occurrences of find_string with replace_string at findpos and marks content as changed Parameters ---------- findpositions: List of 3-Tuple of Integer \tPositions in grid that shall be repla...
Replaces occurrences of find_string with replace_string at findpos and marks content as changed Parameters ---------- findpos: 3-Tuple of Integer \tPosition in grid that shall be replaced find_string: String \tString to be overwritten in the cell replac...
def replace(self, findpos, find_string, replace_string): """Replaces occurrences of find_string with replace_string at findpos and marks content as changed Parameters ---------- findpos: 3-Tuple of Integer \tPosition in grid that shall be replaced find_string: ...
Returns bbox, in which None is replaced by grid boundaries
def _replace_bbox_none(self, bbox): """Returns bbox, in which None is replaced by grid boundaries""" (bb_top, bb_left), (bb_bottom, bb_right) = bbox if bb_top is None: bb_top = 0 if bb_left is None: bb_left = 0 if bb_bottom is None: bb_bott...
Returns OrderedDict of filetypes to wildcards The filetypes that are provided in the filetypes parameter are checked for availability. Only available filetypes are inluded in the return ODict. Parameters ---------- filetypes: Iterable of strings \tFiletype list
def get_filetypes2wildcards(filetypes): """Returns OrderedDict of filetypes to wildcards The filetypes that are provided in the filetypes parameter are checked for availability. Only available filetypes are inluded in the return ODict. Parameters ---------- filetypes: Iterable of strings \...
Displays parameter entry dialog and returns parameter dict Parameters ---------- gpg_key_param_list: List of 2-tuples \tContains GPG key generation parameters but not name_real
def get_key_params_from_user(gpg_key_param_list): """Displays parameter entry dialog and returns parameter dict Parameters ---------- gpg_key_param_list: List of 2-tuples \tContains GPG key generation parameters but not name_real """ params = [[_('Real name'), 'name_real']] vals = [...
Queries grid dimensions in a model dialog and returns n-tuple Parameters ---------- no_dim: Integer \t Number of grid dimensions, currently must be 3
def get_dimensions_from_user(self, no_dim): """Queries grid dimensions in a model dialog and returns n-tuple Parameters ---------- no_dim: Integer \t Number of grid dimensions, currently must be 3 """ # Grid dimension dialog if no_dim != 3: ...
Launches preferences dialog and returns dict with preferences
def get_preferences_from_user(self): """Launches preferences dialog and returns dict with preferences""" dlg = PreferencesDialog(self.main_window) change_choice = dlg.ShowModal() preferences = {} if change_choice == wx.ID_OK: for (parameter, _), ctrl in zip(dlg.pa...
Queries user if grid should be saved
def get_save_request_from_user(self): """Queries user if grid should be saved""" msg = _("There are unsaved changes.\nDo you want to save?") dlg = GMD.GenericMessageDialog( self.main_window, msg, _("Unsaved changes"), wx.YES_NO | wx.ICON_QUESTION | wx.CANCEL) s...
Opens a file dialog and returns filepath and filterindex Parameters ---------- wildcard: String \tWildcard string for file dialog message: String \tMessage in the file dialog style: Integer \tDialog style, e. g. wx.OPEN | wx.CHANGE_DIR filterindex...
def get_filepath_findex_from_user(self, wildcard, message, style, filterindex=0): """Opens a file dialog and returns filepath and filterindex Parameters ---------- wildcard: String \tWildcard string for file dialog message: String ...
Displays a warning message
def display_warning(self, message, short_message, style=wx.OK | wx.ICON_WARNING): """Displays a warning message""" dlg = GMD.GenericMessageDialog(self.main_window, message, short_message, style) dlg.ShowModal() dlg.Destroy()
Launches proceeding dialog and returns True if ok to proceed
def get_warning_choice(self, message, short_message, style=wx.YES_NO | wx.NO_DEFAULT | wx.ICON_WARNING): """Launches proceeding dialog and returns True if ok to proceed""" dlg = GMD.GenericMessageDialog(self.main_window, message, short_m...
Opens print setup dialog and returns print_data
def get_print_setup(self, print_data): """Opens print setup dialog and returns print_data""" psd = wx.PageSetupDialogData(print_data) # psd.EnablePrinter(False) psd.CalculatePaperSizeFromId() dlg = wx.PageSetupDialog(self.main_window, psd) dlg.ShowModal() # this...
Launches the csv dialog and returns csv_info csv_info is a tuple of dialect, has_header, digest_types Parameters ---------- path: String \tFile path of csv file
def get_csv_import_info(self, path): """Launches the csv dialog and returns csv_info csv_info is a tuple of dialect, has_header, digest_types Parameters ---------- path: String \tFile path of csv file """ csvfilename = os.path.split(path)[1] ...
Shows csv export preview dialog and returns csv_info csv_info is a tuple of dialect, has_header, digest_types Parameters ---------- preview_data: Iterable of iterables \tContains csv export data row-wise
def get_csv_export_info(self, preview_data): """Shows csv export preview dialog and returns csv_info csv_info is a tuple of dialect, has_header, digest_types Parameters ---------- preview_data: Iterable of iterables \tContains csv export data row-wise """ ...
Shows Cairo export dialog and returns info Parameters ---------- filetype: String in ["pdf", "svg"] \tFile type for which export info is gathered
def get_cairo_export_info(self, filetype): """Shows Cairo export dialog and returns info Parameters ---------- filetype: String in ["pdf", "svg"] \tFile type for which export info is gathered """ export_dlg = CairoExportDialog(self.main_window, filetype=filetyp...
Opens an integer entry dialog and returns integer Parameters ---------- title: String \tDialog title cond_func: Function \tIf cond_func of int(<entry_value> then result is returned. \tOtherwise the dialog pops up again.
def get_int_from_user(self, title="Enter integer value", cond_func=lambda i: i is not None): """Opens an integer entry dialog and returns integer Parameters ---------- title: String \tDialog title cond_func: Function \tIf cond_func of in...
Opens a PasteAsDialog and returns parameters dict
def get_pasteas_parameters_from_user(self, obj): """Opens a PasteAsDialog and returns parameters dict""" dlg = PasteAsDialog(None, -1, obj) dlg_choice = dlg.ShowModal() if dlg_choice != wx.ID_OK: dlg.Destroy() return None parameters = {} paramet...
Called to create the control, which must derive from wx.Control. *Must Override*
def Create(self, parent, id, evtHandler): """ Called to create the control, which must derive from wx.Control. *Must Override* """ style = wx.TE_MULTILINE self._tc = wx.TextCtrl(parent, id, "", style=style) # Disable if cell is clocked, enable if cell is not loc...
Called to position/size the edit control within the cell rectangle. If you don't fill the cell (the rect) then be sure to override PaintBackground and do something meaningful there.
def SetSize(self, rect): """ Called to position/size the edit control within the cell rectangle. If you don't fill the cell (the rect) then be sure to override PaintBackground and do something meaningful there. """ grid = self.main_window.grid key = grid.actions...
Show or hide the edit control. You can use the attr (if not None) to set colours or fonts for the control.
def Show(self, show, attr): """ Show or hide the edit control. You can use the attr (if not None) to set colours or fonts for the control. """ super(GridCellEditor, self).Show(show, attr)
Executes cell code
def _execute_cell_code(self, row, col, grid): """Executes cell code""" key = row, col, grid.current_table grid.code_array[key] grid.ForceRefresh()
Fetch the value from the table and prepare the edit control to begin editing. Set the focus to the edit control. *Must Override*
def BeginEdit(self, row, col, grid): """ Fetch the value from the table and prepare the edit control to begin editing. Set the focus to the edit control. *Must Override* """ # Disable if cell is locked, enable if cell is not locked grid = self.main_window.grid ...
End editing the cell. This function must check if the current value of the editing control is valid and different from the original value (available as oldval in its string form.) If it has not changed then simply return None, otherwise return the value in its string form. *Mus...
def EndEdit(self, row, col, grid, oldVal=None): """ End editing the cell. This function must check if the current value of the editing control is valid and different from the original value (available as oldval in its string form.) If it has not changed then simply return None,...
This function should save the value of the control into the grid or grid table. It is called only after EndEdit() returns a non-None value. *Must Override*
def ApplyEdit(self, row, col, grid): """ This function should save the value of the control into the grid or grid table. It is called only after EndEdit() returns a non-None value. *Must Override* """ val = self._tc.GetValue() grid.GetTable().SetValue(row...
Reset the value in the control back to its starting value. *Must Override*
def Reset(self): """ Reset the value in the control back to its starting value. *Must Override* """ try: self._tc.SetValue(self.startValue) except TypeError: # Start value was None pass self._tc.SetInsertionPointEnd() #...
Return True to allow the given key to start editing: the base class version only checks that the event has no modifiers. F2 is special and will always start the editor.
def IsAcceptedKey(self, evt): """ Return True to allow the given key to start editing: the base class version only checks that the event has no modifiers. F2 is special and will always start the editor. """ ## We can ask the base class to do it #return super(My...
If the editor is enabled by pressing keys on the grid, this will be called to let the editor do something about that first key if desired.
def StartingKey(self, evt): """ If the editor is enabled by pressing keys on the grid, this will be called to let the editor do something about that first key if desired. """ key = evt.GetKeyCode() ch = None if key in [ wx.WXK_NUMPAD0, wx.WXK_NUMP...
Returns page information What is the page range available, and what is the selected page range.
def GetPageInfo(self): """Returns page information What is the page range available, and what is the selected page range. """ return self.first_tab, self.last_tab, self.first_tab, self.last_tab
Returns quoted code if not already quoted and if possible Parameters ---------- code: String \tCode thta is quoted
def quote(code): """Returns quoted code if not already quoted and if possible Parameters ---------- code: String \tCode thta is quoted """ try: code = code.rstrip() except AttributeError: # code is not a string, may be None --> There is no code to quote retur...
Sets grid states
def _states(self): """Sets grid states""" # The currently visible table self.current_table = 0 # The cell that has been selected before the latest selection self._last_selected_cell = 0, 0, 0 # If we are viewing cells based on their frozen status or normally # ...
Initial layout of grid
def _layout(self): """Initial layout of grid""" self.EnableGridLines(False) # Standard row and col sizes for zooming default_cell_attributes = \ self.code_array.cell_attributes.default_cell_attributes self.std_row_size = default_cell_attributes["row-height"] ...
Bind events to handlers
def _bind(self): """Bind events to handlers""" main_window = self.main_window handlers = self.handlers c_handlers = self.cell_handlers # Non wx.Grid events self.Bind(wx.EVT_MOUSEWHEEL, handlers.OnMouseWheel) self.Bind(wx.EVT_KEY_DOWN, handlers.OnKey) ...
True if key in merged area shall be drawn This is the case if it is the top left most visible key of the merge area on the screen.
def is_merged_cell_drawn(self, key): """True if key in merged area shall be drawn This is the case if it is the top left most visible key of the merge area on the screen. """ row, col, tab = key # Is key not merged? --> False cell_attributes = self.code_array....
Updates the entry line Parameters ---------- key: 3-tuple of Integer, defaults to current cell \tCell to which code the entry line is updated
def update_entry_line(self, key=None): """Updates the entry line Parameters ---------- key: 3-tuple of Integer, defaults to current cell \tCell to which code the entry line is updated """ if key is None: key = self.actions.cursor cell_code ...
Updates the attribute toolbar Parameters ---------- key: 3-tuple of Integer, defaults to current cell \tCell to which attributes the attributes toolbar is updated
def update_attribute_toolbar(self, key=None): """Updates the attribute toolbar Parameters ---------- key: 3-tuple of Integer, defaults to current cell \tCell to which attributes the attributes toolbar is updated """ if key is None: key = self.action...
Updates the panel cell attrutes of a panel cell
def _update_video_volume_cell_attributes(self, key): """Updates the panel cell attrutes of a panel cell""" try: video_cell_panel = self.grid_renderer.video_cells[key] except KeyError: return old_video_volume = self.code_array.cell_attributes[key]["video_volume"]...
Refresh hook
def ForceRefresh(self, *args, **kwargs): """Refresh hook""" wx.grid.Grid.ForceRefresh(self, *args, **kwargs) for video_cell_key in self.grid_renderer.video_cells: if video_cell_key[2] == self.current_table: video_cell = self.grid_renderer.video_cells[video_cell_key]...
Text entry event handler
def OnCellText(self, event): """Text entry event handler""" row, col, _ = self.grid.actions.cursor self.grid.GetTable().SetValue(row, col, event.code) event.Skip()
Insert bitmap event handler
def OnInsertBitmap(self, event): """Insert bitmap event handler""" key = self.grid.actions.cursor # Get file name wildcard = _("Bitmap file") + " (*)|*" if rsvg is not None: wildcard += "|" + _("SVG file") + " (*.svg)|*.svg" message = _("Select image for cu...
Link bitmap event handler
def OnLinkBitmap(self, event): """Link bitmap event handler""" # Get file name wildcard = "*" message = _("Select bitmap for current cell") style = wx.OPEN | wx.CHANGE_DIR filepath, __ = \ self.grid.interfaces.get_filepath_findex_from_user(wildcard, ...
VLC video code event handler
def OnLinkVLCVideo(self, event): """VLC video code event handler""" key = self.grid.actions.cursor if event.videofile: try: video_volume = \ self.grid.code_array.cell_attributes[key]["video_volume"] except KeyError: vi...
Chart dialog event handler
def OnInsertChartDialog(self, event): """Chart dialog event handler""" key = self.grid.actions.cursor cell_code = self.grid.code_array(key) if cell_code is None: cell_code = u"" chart_dialog = ChartDialog(self.grid.main_window, key, cell_code) if chart_di...
Paste format event handler
def OnPasteFormat(self, event): """Paste format event handler""" with undo.group(_("Paste format")): self.grid.actions.paste_format() self.grid.ForceRefresh() self.grid.update_attribute_toolbar() self.grid.actions.zoom()
Cell font event handler
def OnCellFont(self, event): """Cell font event handler""" with undo.group(_("Font")): self.grid.actions.set_attr("textfont", event.font) self.grid.ForceRefresh() self.grid.update_attribute_toolbar() event.Skip()
Cell font size event handler
def OnCellFontSize(self, event): """Cell font size event handler""" with undo.group(_("Font size")): self.grid.actions.set_attr("pointsize", event.size) self.grid.ForceRefresh() self.grid.update_attribute_toolbar() event.Skip()
Cell font bold event handler
def OnCellFontBold(self, event): """Cell font bold event handler""" with undo.group(_("Bold")): try: try: weight = getattr(wx, event.weight[2:]) except AttributeError: msg = _("Weight {weight} unknown").format( ...
Cell font underline event handler
def OnCellFontUnderline(self, event): """Cell font underline event handler""" with undo.group(_("Underline")): self.grid.actions.toggle_attr("underline") self.grid.ForceRefresh() self.grid.update_attribute_toolbar() event.Skip()
Cell frozen event handler
def OnCellFrozen(self, event): """Cell frozen event handler""" with undo.group(_("Frozen")): self.grid.actions.change_frozen_attr() self.grid.ForceRefresh() self.grid.update_attribute_toolbar() event.Skip()
Button cell event handler
def OnButtonCell(self, event): """Button cell event handler""" # The button text text = event.text with undo.group(_("Button")): self.grid.actions.set_attr("button_cell", text) self.grid.ForceRefresh() self.grid.update_attribute_toolbar() event.Sk...
Merge cells event handler
def OnMerge(self, event): """Merge cells event handler""" with undo.group(_("Merge cells")): self.grid.actions.merge_selected_cells(self.grid.selection) self.grid.ForceRefresh() self.grid.update_attribute_toolbar()
Cell border width event handler
def OnCellBorderWidth(self, event): """Cell border width event handler""" with undo.group(_("Border width")): self.grid.actions.set_border_attr("borderwidth", event.width, event.borders) self.grid.ForceRefresh() self.grid.updat...
Cell border color event handler
def OnCellBorderColor(self, event): """Cell border color event handler""" with undo.group(_("Border color")): self.grid.actions.set_border_attr("bordercolor", event.color, event.borders) self.grid.ForceRefresh() self.grid.updat...
Cell background color event handler
def OnCellBackgroundColor(self, event): """Cell background color event handler""" with undo.group(_("Background color")): self.grid.actions.set_attr("bgcolor", event.color) self.grid.ForceRefresh() self.grid.update_attribute_toolbar() event.Skip()
Text rotation dialog event handler
def OnTextRotation0(self, event): """Text rotation dialog event handler""" with undo.group(_("Rotation 0°")): self.grid.actions.set_attr("angle", 0) self.grid.ForceRefresh() self.grid.update_attribute_toolbar()
Cell text rotation event handler
def OnCellTextRotation(self, event): """Cell text rotation event handler""" with undo.group(_("Rotation")): self.grid.actions.toggle_attr("angle") self.grid.ForceRefresh() self.grid.update_attribute_toolbar() if is_gtk(): try: wx.Yield(...
Cell selection event handler
def OnCellSelected(self, event): """Cell selection event handler""" key = row, col, tab = event.Row, event.Col, self.grid.current_table # Is the cell merged then go to merging cell cell_attributes = self.grid.code_array.cell_attributes merging_cell = cell_attributes.get_merging...
Mouse motion event handler
def OnMouseMotion(self, event): """Mouse motion event handler""" grid = self.grid pos_x, pos_y = grid.CalcUnscrolledPosition(event.GetPosition()) row = grid.YToRow(pos_y) col = grid.XToCol(pos_x) tab = grid.current_table key = row, col, tab merge_area...
Handles non-standard shortcut events
def OnKey(self, event): """Handles non-standard shortcut events""" def switch_to_next_table(): newtable = self.grid.current_table + 1 post_command_event(self.grid, self.GridActionTableSwitchMsg, newtable=newtable) def switch_to_previous_ta...
Event handler for grid selection
def OnRangeSelected(self, event): """Event handler for grid selection""" # If grid editing is disabled then pyspread is in selection mode if not self.grid.IsEditable(): selection = self.grid.selection row, col, __ = self.grid.sel_mode_cursor if (row, col) in ...
Show cells as frozen status
def OnViewFrozen(self, event): """Show cells as frozen status""" self.grid._view_frozen = not self.grid._view_frozen self.grid.grid_renderer.cell_cache.clear() self.grid.ForceRefresh() event.Skip()
Shift a given cell into view
def OnGoToCell(self, event): """Shift a given cell into view""" row, col, tab = event.key try: self.grid.actions.cursor = row, col, tab except ValueError: msg = _("Cell {key} outside grid shape {shape}").format( key=event.key, shape=self.grid.co...
Event handler for entering selection mode, disables cell edits
def OnEnterSelectionMode(self, event): """Event handler for entering selection mode, disables cell edits""" self.grid.sel_mode_cursor = list(self.grid.actions.cursor) self.grid.EnableDragGridSize(False) self.grid.EnableEditing(False)
Event handler for leaving selection mode, enables cell edits
def OnExitSelectionMode(self, event): """Event handler for leaving selection mode, enables cell edits""" self.grid.sel_mode_cursor = None self.grid.EnableDragGridSize(True) self.grid.EnableEditing(True)
Event handler for refreshing the selected cells via menu
def OnRefreshSelectedCells(self, event): """Event handler for refreshing the selected cells via menu""" self.grid.actions.refresh_selected_frozen_cells() self.grid.ForceRefresh() event.Skip()
Toggles the timer for updating frozen cells
def OnTimerToggle(self, event): """Toggles the timer for updating frozen cells""" if self.grid.timer_running: # Stop timer self.grid.timer_running = False self.grid.timer.Stop() del self.grid.timer else: # Start timer self...
Update all frozen cells because of timer call
def OnTimer(self, event): """Update all frozen cells because of timer call""" self.timer_updating = True shape = self.grid.code_array.shape[:2] selection = Selection([(0, 0)], [(shape)], [], [], []) self.grid.actions.refresh_selected_frozen_cells(selection) self.grid.Fo...
Event handler for resetting grid zoom
def OnZoomStandard(self, event): """Event handler for resetting grid zoom""" self.grid.actions.zoom(zoom=1.0) event.Skip()
Context menu event handler
def OnContextMenu(self, event): """Context menu event handler""" self.grid.PopupMenu(self.grid.contextmenu) event.Skip()
Event handler for mouse wheel actions Invokes zoom when mouse when Ctrl is also pressed
def OnMouseWheel(self, event): """Event handler for mouse wheel actions Invokes zoom when mouse when Ctrl is also pressed """ if event.ControlDown(): if event.WheelRotation > 0: post_command_event(self.grid, self.grid.ZoomInMsg) else: ...
Find functionality, called from toolbar, returns find position
def OnFind(self, event): """Find functionality, called from toolbar, returns find position""" # Search starts in next cell after the current one gridpos = list(self.grid.actions.cursor) text, flags = event.text, event.flags findpos = self.grid.actions.find(gridpos, text, flags) ...
Calls the find-replace dialog
def OnShowFindReplace(self, event): """Calls the find-replace dialog""" data = wx.FindReplaceData(wx.FR_DOWN) dlg = wx.FindReplaceDialog(self.grid, data, "Find & Replace", wx.FR_REPLACEDIALOG) dlg.data = data # save a reference to data dlg.Sho...
Called when a find operation is started from F&R dialog
def OnReplaceFind(self, event): """Called when a find operation is started from F&R dialog""" event.text = event.GetFindString() event.flags = self._wxflag2flag(event.GetFlags()) self.OnFind(event)
Called when a replace operation is started, returns find position
def OnReplace(self, event): """Called when a replace operation is started, returns find position""" find_string = event.GetFindString() flags = self._wxflag2flag(event.GetFlags()) replace_string = event.GetReplaceString() gridpos = list(self.grid.actions.cursor) findpo...
Called when a replace all operation is started
def OnReplaceAll(self, event): """Called when a replace all operation is started""" find_string = event.GetFindString() flags = self._wxflag2flag(event.GetFlags()) replace_string = event.GetReplaceString() findpositions = self.grid.actions.find_all(find_string, flags) ...
Returns tuple of number of rows and cols from bbox
def _get_no_rowscols(self, bbox): """Returns tuple of number of rows and cols from bbox""" if bbox is None: return 1, 1 else: (bb_top, bb_left), (bb_bottom, bb_right) = bbox if bb_top is None: bb_top = 0 if bb_left is None: ...
Insert the maximum of 1 and the number of selected rows
def OnInsertRows(self, event): """Insert the maximum of 1 and the number of selected rows""" bbox = self.grid.selection.get_bbox() if bbox is None or bbox[1][0] is None: # Insert rows at cursor ins_point = self.grid.actions.cursor[0] - 1 no_rows = 1 ...
Inserts the maximum of 1 and the number of selected columns
def OnInsertCols(self, event): """Inserts the maximum of 1 and the number of selected columns""" bbox = self.grid.selection.get_bbox() if bbox is None or bbox[1][1] is None: # Insert rows at cursor ins_point = self.grid.actions.cursor[1] - 1 no_cols = 1 ...
Insert one table into grid
def OnInsertTabs(self, event): """Insert one table into grid""" with undo.group(_("Insert table")): self.grid.actions.insert_tabs(self.grid.current_table - 1, 1) self.grid.GetTable().ResetView() self.grid.actions.zoom() event.Skip()
Deletes rows from all tables of the grid
def OnDeleteRows(self, event): """Deletes rows from all tables of the grid""" bbox = self.grid.selection.get_bbox() if bbox is None or bbox[1][0] is None: # Insert rows at cursor del_point = self.grid.actions.cursor[0] no_rows = 1 else: #...
Deletes columns from all tables of the grid
def OnDeleteCols(self, event): """Deletes columns from all tables of the grid""" bbox = self.grid.selection.get_bbox() if bbox is None or bbox[1][1] is None: # Insert rows at cursor del_point = self.grid.actions.cursor[1] no_cols = 1 else: ...
Deletes tables
def OnDeleteTabs(self, event): """Deletes tables""" with undo.group(_("Delete table")): self.grid.actions.delete_tabs(self.grid.current_table, 1) self.grid.GetTable().ResetView() self.grid.actions.zoom() event.Skip()
Resizes current grid by appending/deleting rows, cols and tables
def OnResizeGridDialog(self, event): """Resizes current grid by appending/deleting rows, cols and tables""" # Get grid dimensions new_shape = self.interfaces.get_dimensions_from_user(no_dim=3) if new_shape is None: return with undo.group(_("Resize grid")): ...
Quotes selection or if none the current cell
def OnQuote(self, event): """Quotes selection or if none the current cell""" grid = self.grid grid.DisableCellEditControl() with undo.group(_("Quote cell(s)")): # Is a selection present? if self.grid.IsSelection(): # Enclose all selected cells ...
Row size event handler
def OnRowSize(self, event): """Row size event handler""" row = event.GetRowOrCol() tab = self.grid.current_table rowsize = self.grid.GetRowSize(row) / self.grid.grid_renderer.zoom # Detect for resizing group of rows rows = self.grid.GetSelectedRows() if len(rows...
Column size event handler
def OnColSize(self, event): """Column size event handler""" col = event.GetRowOrCol() tab = self.grid.current_table colsize = self.grid.GetColSize(col) / self.grid.grid_renderer.zoom # Detect for resizing group of cols cols = self.grid.GetSelectedCols() if len(c...
Sort ascending event handler
def OnSortAscending(self, event): """Sort ascending event handler""" try: with undo.group(_("Sort ascending")): self.grid.actions.sort_ascending(self.grid.actions.cursor) statustext = _(u"Sorting complete.") except Exception, err: statustext ...
Calls the grid undo method
def OnUndo(self, event): """Calls the grid undo method""" statustext = undo.stack().undotext() undo.stack().undo() # Update content changed state try: post_command_event(self.grid.main_window, self.grid.ContentChangedMsg) excep...
Adjusts row heights and column widths to match the template Parameters ---------- target_tab: Integer \tTable to be adjusted template_tab: Integer, defaults to 0 \tTemplate table
def rowcol_from_template(target_tab, template_tab=0): """Adjusts row heights and column widths to match the template Parameters ---------- target_tab: Integer \tTable to be adjusted template_tab: Integer, defaults to 0 \tTemplate table """ for row, tab in S.row_heights.keys(): # Delete all row heights in ...
Adjusts cell paarmeters to match the template Parameters ---------- target_tab: Integer \tTable to be adjusted template_tab: Integer, defaults to 0 \tTemplate table
def cell_attributes_from_template(target_tab, template_tab=0): """Adjusts cell paarmeters to match the template Parameters ---------- target_tab: Integer \tTable to be adjusted template_tab: Integer, defaults to 0 \tTemplate table """ new_cell_attributes = [] for attr in S.cell_attributes: if attr[1] == ...
Returns wx.Font from fontdata string
def get_font_from_data(fontdata): """Returns wx.Font from fontdata string""" textfont = get_default_font() if fontdata != "": nativefontinfo = wx.NativeFontInfo() nativefontinfo.FromString(fontdata) # OS X does not like a PointSize of 0 # Therefore, it is explicitly set to...