_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q232000
SelectionActions.delete
train
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...
python
{ "resource": "" }
q232001
SelectionActions.quote_selection
train
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: ...
python
{ "resource": "" }
q232002
SelectionActions.copy_selection_access_string
train
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...
python
{ "resource": "" }
q232003
SelectionActions.copy_format
train
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...
python
{ "resource": "" }
q232004
SelectionActions.paste_format
train
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 ...
python
{ "resource": "" }
q232005
FindActions.find_all
train
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...
python
{ "resource": "" }
q232006
FindActions.find
train
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 ...
python
{ "resource": "" }
q232007
AllGridActions._replace_bbox_none
train
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...
python
{ "resource": "" }
q232008
get_filetypes2wildcards
train
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 \...
python
{ "resource": "" }
q232009
get_key_params_from_user
train
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 = [...
python
{ "resource": "" }
q232010
ModalDialogInterfaceMixin.get_dimensions_from_user
train
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: ...
python
{ "resource": "" }
q232011
ModalDialogInterfaceMixin.get_preferences_from_user
train
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...
python
{ "resource": "" }
q232012
ModalDialogInterfaceMixin.get_save_request_from_user
train
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...
python
{ "resource": "" }
q232013
ModalDialogInterfaceMixin.get_filepath_findex_from_user
train
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 ...
python
{ "resource": "" }
q232014
ModalDialogInterfaceMixin.display_warning
train
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()
python
{ "resource": "" }
q232015
ModalDialogInterfaceMixin.get_warning_choice
train
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...
python
{ "resource": "" }
q232016
ModalDialogInterfaceMixin.get_print_setup
train
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...
python
{ "resource": "" }
q232017
ModalDialogInterfaceMixin.get_csv_import_info
train
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] ...
python
{ "resource": "" }
q232018
ModalDialogInterfaceMixin.get_csv_export_info
train
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 """ ...
python
{ "resource": "" }
q232019
ModalDialogInterfaceMixin.get_cairo_export_info
train
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...
python
{ "resource": "" }
q232020
ModalDialogInterfaceMixin.get_int_from_user
train
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...
python
{ "resource": "" }
q232021
ModalDialogInterfaceMixin.get_pasteas_parameters_from_user
train
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...
python
{ "resource": "" }
q232022
GridCellEditor._execute_cell_code
train
def _execute_cell_code(self, row, col, grid): """Executes cell code""" key = row, col, grid.current_table grid.code_array[key] grid.ForceRefresh()
python
{ "resource": "" }
q232023
GridCellEditor.StartingKey
train
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...
python
{ "resource": "" }
q232024
Printout.GetPageInfo
train
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
python
{ "resource": "" }
q232025
quote
train
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...
python
{ "resource": "" }
q232026
Grid._states
train
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 # ...
python
{ "resource": "" }
q232027
Grid._layout
train
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"] ...
python
{ "resource": "" }
q232028
Grid.is_merged_cell_drawn
train
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....
python
{ "resource": "" }
q232029
Grid.update_entry_line
train
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 ...
python
{ "resource": "" }
q232030
Grid.update_attribute_toolbar
train
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...
python
{ "resource": "" }
q232031
Grid._update_video_volume_cell_attributes
train
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"]...
python
{ "resource": "" }
q232032
GridCellEventHandlers.OnCellText
train
def OnCellText(self, event): """Text entry event handler""" row, col, _ = self.grid.actions.cursor self.grid.GetTable().SetValue(row, col, event.code) event.Skip()
python
{ "resource": "" }
q232033
GridCellEventHandlers.OnInsertBitmap
train
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...
python
{ "resource": "" }
q232034
GridCellEventHandlers.OnLinkBitmap
train
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, ...
python
{ "resource": "" }
q232035
GridCellEventHandlers.OnLinkVLCVideo
train
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...
python
{ "resource": "" }
q232036
GridCellEventHandlers.OnInsertChartDialog
train
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...
python
{ "resource": "" }
q232037
GridCellEventHandlers.OnPasteFormat
train
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()
python
{ "resource": "" }
q232038
GridCellEventHandlers.OnCellFont
train
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()
python
{ "resource": "" }
q232039
GridCellEventHandlers.OnCellFontSize
train
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()
python
{ "resource": "" }
q232040
GridCellEventHandlers.OnCellFontBold
train
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( ...
python
{ "resource": "" }
q232041
GridCellEventHandlers.OnCellFontUnderline
train
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()
python
{ "resource": "" }
q232042
GridCellEventHandlers.OnCellFrozen
train
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()
python
{ "resource": "" }
q232043
GridCellEventHandlers.OnButtonCell
train
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...
python
{ "resource": "" }
q232044
GridCellEventHandlers.OnMerge
train
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()
python
{ "resource": "" }
q232045
GridCellEventHandlers.OnCellBorderWidth
train
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...
python
{ "resource": "" }
q232046
GridCellEventHandlers.OnCellBorderColor
train
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...
python
{ "resource": "" }
q232047
GridCellEventHandlers.OnCellBackgroundColor
train
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()
python
{ "resource": "" }
q232048
GridCellEventHandlers.OnCellTextRotation
train
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(...
python
{ "resource": "" }
q232049
GridCellEventHandlers.OnCellSelected
train
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...
python
{ "resource": "" }
q232050
GridEventHandlers.OnMouseMotion
train
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...
python
{ "resource": "" }
q232051
GridEventHandlers.OnKey
train
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...
python
{ "resource": "" }
q232052
GridEventHandlers.OnRangeSelected
train
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 ...
python
{ "resource": "" }
q232053
GridEventHandlers.OnViewFrozen
train
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()
python
{ "resource": "" }
q232054
GridEventHandlers.OnGoToCell
train
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...
python
{ "resource": "" }
q232055
GridEventHandlers.OnEnterSelectionMode
train
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)
python
{ "resource": "" }
q232056
GridEventHandlers.OnExitSelectionMode
train
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)
python
{ "resource": "" }
q232057
GridEventHandlers.OnRefreshSelectedCells
train
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()
python
{ "resource": "" }
q232058
GridEventHandlers.OnTimerToggle
train
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...
python
{ "resource": "" }
q232059
GridEventHandlers.OnTimer
train
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...
python
{ "resource": "" }
q232060
GridEventHandlers.OnZoomStandard
train
def OnZoomStandard(self, event): """Event handler for resetting grid zoom""" self.grid.actions.zoom(zoom=1.0) event.Skip()
python
{ "resource": "" }
q232061
GridEventHandlers.OnContextMenu
train
def OnContextMenu(self, event): """Context menu event handler""" self.grid.PopupMenu(self.grid.contextmenu) event.Skip()
python
{ "resource": "" }
q232062
GridEventHandlers.OnMouseWheel
train
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: ...
python
{ "resource": "" }
q232063
GridEventHandlers.OnFind
train
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) ...
python
{ "resource": "" }
q232064
GridEventHandlers.OnShowFindReplace
train
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...
python
{ "resource": "" }
q232065
GridEventHandlers.OnReplaceFind
train
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)
python
{ "resource": "" }
q232066
GridEventHandlers.OnReplace
train
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...
python
{ "resource": "" }
q232067
GridEventHandlers.OnReplaceAll
train
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) ...
python
{ "resource": "" }
q232068
GridEventHandlers._get_no_rowscols
train
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: ...
python
{ "resource": "" }
q232069
GridEventHandlers.OnInsertRows
train
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 ...
python
{ "resource": "" }
q232070
GridEventHandlers.OnInsertCols
train
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 ...
python
{ "resource": "" }
q232071
GridEventHandlers.OnInsertTabs
train
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()
python
{ "resource": "" }
q232072
GridEventHandlers.OnDeleteRows
train
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: #...
python
{ "resource": "" }
q232073
GridEventHandlers.OnDeleteCols
train
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: ...
python
{ "resource": "" }
q232074
GridEventHandlers.OnQuote
train
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 ...
python
{ "resource": "" }
q232075
GridEventHandlers.OnRowSize
train
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...
python
{ "resource": "" }
q232076
GridEventHandlers.OnColSize
train
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...
python
{ "resource": "" }
q232077
GridEventHandlers.OnSortAscending
train
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 ...
python
{ "resource": "" }
q232078
GridEventHandlers.OnUndo
train
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...
python
{ "resource": "" }
q232079
rowcol_from_template
train
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 ...
python
{ "resource": "" }
q232080
cell_attributes_from_template
train
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] == ...
python
{ "resource": "" }
q232081
get_font_from_data
train
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...
python
{ "resource": "" }
q232082
get_pen_from_data
train
def get_pen_from_data(pendata): """Returns wx.Pen from pendata attribute list""" pen_color = wx.Colour() pen_color.SetRGB(pendata[0]) pen = wx.Pen(pen_color, *pendata[1:]) pen.SetJoin(wx.JOIN_MITER) return pen
python
{ "resource": "" }
q232083
color_pack2rgb
train
def color_pack2rgb(packed): """Returns r, g, b tuple from packed wx.ColourGetRGB value""" r = packed & 255 g = (packed & (255 << 8)) >> 8 b = (packed & (255 << 16)) >> 16 return r, g, b
python
{ "resource": "" }
q232084
unquote_string
train
def unquote_string(code): """Returns a string from code that contains a repr of the string""" scode = code.strip() assert scode[-1] in ["'", '"'] assert scode[0] in ["'", '"'] or scode[1] in ["'", '"'] return ast.literal_eval(scode)
python
{ "resource": "" }
q232085
parse_dict_strings
train
def parse_dict_strings(code): """Generator of elements of a dict that is given in the code string Parsing is shallow, i.e. all content is yielded as strings Parameters ---------- code: String \tString that contains a dict """ i = 0 level = 0 chunk_start = 0 curr_paren = N...
python
{ "resource": "" }
q232086
common_start
train
def common_start(strings): """Returns start sub-string that is common for all given strings Parameters ---------- strings: List of strings \tThese strings are evaluated for their largest common start string """ def gen_start_strings(string): """Generator that yield start sub-strin...
python
{ "resource": "" }
q232087
is_svg
train
def is_svg(code): """Checks if code is an svg image Parameters ---------- code: String \tCode to be parsed in order to check svg complaince """ if rsvg is None: return try: rsvg.Handle(data=code) except glib.GError: return False # The SVG file has to...
python
{ "resource": "" }
q232088
CairoExportDialog._get_dialog_title
train
def _get_dialog_title(self): """Returns title string""" title_filetype = self.filetype[0].upper() + self.filetype[1:] if self.filetype == "print": title_export = "" else: title_export = " export" return _("{filetype}{export} options").format(filetype=ti...
python
{ "resource": "" }
q232089
CairoExportDialog.on_page_layout_choice
train
def on_page_layout_choice(self, event): """Page layout choice event handler""" width, height = self.paper_sizes_points[event.GetString()] self.page_width_text_ctrl.SetValue(str(width / 72.0)) self.page_height_text_ctrl.SetValue(str(height / 72.0)) event.Skip()
python
{ "resource": "" }
q232090
CairoExportDialog.get_info
train
def get_info(self): """Returns a dict with the dialog PDF info Dict keys are: top_row, bottom_row, left_col, right_col, first_tab, last_tab, paper_width, paper_height """ info = {} info["top_row"] = self.top_row_text_ctrl.GetValue() info["bottom_row"] ...
python
{ "resource": "" }
q232091
get_program_path
train
def get_program_path(): """Returns the path in which pyspread is installed""" src_folder = os.path.dirname(__file__) program_path = os.sep.join(src_folder.split(os.sep)[:-1]) + os.sep return program_path
python
{ "resource": "" }
q232092
get_dpi
train
def get_dpi(): """Returns screen dpi resolution""" def pxmm_2_dpi((pixels, length_mm)): return pixels * 25.6 / length_mm return map(pxmm_2_dpi, zip(wx.GetDisplaySize(), wx.GetDisplaySizeMM()))
python
{ "resource": "" }
q232093
get_font_list
train
def get_font_list(): """Returns a sorted list of all system font names""" font_map = pangocairo.cairo_font_map_get_default() font_list = [f.get_name() for f in font_map.list_families()] font_list.sort() return font_list
python
{ "resource": "" }
q232094
get_dependencies
train
def get_dependencies(): """Returns list of dicts which indicate installed dependencies""" dependencies = [] # Numpy dep_attrs = { "name": "numpy", "min_version": "1.1.0", "description": "required", } try: import numpy dep_attrs["version"] = numpy.version...
python
{ "resource": "" }
q232095
GridCairoRenderer.get_cell_rect
train
def get_cell_rect(self, row, col, tab): """Returns rectangle of cell on canvas""" top_row = self.row_tb[0] left_col = self.col_rl[0] pos_x = self.x_offset pos_y = self.y_offset merge_area = self._get_merge_area((row, col, tab)) for __row in xrange(top_row, row...
python
{ "resource": "" }
q232096
GridCairoRenderer.draw
train
def draw(self): """Draws slice to context""" row_start, row_stop = self.row_tb col_start, col_stop = self.col_rl tab_start, tab_stop = self.tab_fl for tab in xrange(tab_start, tab_stop): # Scale context to page extent # In order to keep the aspect ration...
python
{ "resource": "" }
q232097
GridCellCairoRenderer.draw
train
def draw(self): """Draws cell to context""" cell_background_renderer = GridCellBackgroundCairoRenderer( self.context, self.code_array, self.key, self.rect, self.view_frozen) cell_content_renderer = GridCellContentCairoRenderer( ...
python
{ "resource": "" }
q232098
GridCellContentCairoRenderer.get_cell_content
train
def get_cell_content(self): """Returns cell content""" try: if self.code_array.cell_attributes[self.key]["button_cell"]: return except IndexError: return try: return self.code_array[self.key] except IndexError: p...
python
{ "resource": "" }
q232099
GridCellContentCairoRenderer._get_scalexy
train
def _get_scalexy(self, ims_width, ims_height): """Returns scale_x, scale_y for bitmap display""" # Get cell attributes cell_attributes = self.code_array.cell_attributes[self.key] angle = cell_attributes["angle"] if abs(angle) == 90: scale_x = self.rect[3] / float(im...
python
{ "resource": "" }