repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1 value | code stringlengths 75 19.8k | code_tokens listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1 value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
manns/pyspread | pyspread/src/actions/_grid_actions.py | GridActions.zoom | def zoom(self, zoom=None):
"""Zooms to zoom factor"""
status = True
if zoom is None:
zoom = self.grid.grid_renderer.zoom
status = False
# Zoom factor for grid content
self.grid.grid_renderer.zoom = zoom
# Zoom grid labels
self._zoom_labels(zoom)
# Zoom rows and columns
self._zoom_rows(zoom)
self._zoom_cols(zoom)
if self.main_window.IsFullScreen():
# Do not display labels in fullscreen mode
self.main_window.handlers.row_label_size = \
self.grid.GetRowLabelSize()
self.main_window.handlers.col_label_size = \
self.grid.GetColLabelSize()
self.grid.HideRowLabels()
self.grid.HideColLabels()
self.grid.ForceRefresh()
if status:
statustext = _(u"Zoomed to {0:.2f}.").format(zoom)
post_command_event(self.main_window, self.StatusBarMsg,
text=statustext) | python | def zoom(self, zoom=None):
"""Zooms to zoom factor"""
status = True
if zoom is None:
zoom = self.grid.grid_renderer.zoom
status = False
# Zoom factor for grid content
self.grid.grid_renderer.zoom = zoom
# Zoom grid labels
self._zoom_labels(zoom)
# Zoom rows and columns
self._zoom_rows(zoom)
self._zoom_cols(zoom)
if self.main_window.IsFullScreen():
# Do not display labels in fullscreen mode
self.main_window.handlers.row_label_size = \
self.grid.GetRowLabelSize()
self.main_window.handlers.col_label_size = \
self.grid.GetColLabelSize()
self.grid.HideRowLabels()
self.grid.HideColLabels()
self.grid.ForceRefresh()
if status:
statustext = _(u"Zoomed to {0:.2f}.").format(zoom)
post_command_event(self.main_window, self.StatusBarMsg,
text=statustext) | [
"def",
"zoom",
"(",
"self",
",",
"zoom",
"=",
"None",
")",
":",
"status",
"=",
"True",
"if",
"zoom",
"is",
"None",
":",
"zoom",
"=",
"self",
".",
"grid",
".",
"grid_renderer",
".",
"zoom",
"status",
"=",
"False",
"# Zoom factor for grid content",
"self",
".",
"grid",
".",
"grid_renderer",
".",
"zoom",
"=",
"zoom",
"# Zoom grid labels",
"self",
".",
"_zoom_labels",
"(",
"zoom",
")",
"# Zoom rows and columns",
"self",
".",
"_zoom_rows",
"(",
"zoom",
")",
"self",
".",
"_zoom_cols",
"(",
"zoom",
")",
"if",
"self",
".",
"main_window",
".",
"IsFullScreen",
"(",
")",
":",
"# Do not display labels in fullscreen mode",
"self",
".",
"main_window",
".",
"handlers",
".",
"row_label_size",
"=",
"self",
".",
"grid",
".",
"GetRowLabelSize",
"(",
")",
"self",
".",
"main_window",
".",
"handlers",
".",
"col_label_size",
"=",
"self",
".",
"grid",
".",
"GetColLabelSize",
"(",
")",
"self",
".",
"grid",
".",
"HideRowLabels",
"(",
")",
"self",
".",
"grid",
".",
"HideColLabels",
"(",
")",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")",
"if",
"status",
":",
"statustext",
"=",
"_",
"(",
"u\"Zoomed to {0:.2f}.\"",
")",
".",
"format",
"(",
"zoom",
")",
"post_command_event",
"(",
"self",
".",
"main_window",
",",
"self",
".",
"StatusBarMsg",
",",
"text",
"=",
"statustext",
")"
] | Zooms to zoom factor | [
"Zooms",
"to",
"zoom",
"factor"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1154-L1189 | train | 231,500 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | GridActions.zoom_in | def zoom_in(self):
"""Zooms in by zoom factor"""
zoom = self.grid.grid_renderer.zoom
target_zoom = zoom * (1 + config["zoom_factor"])
if target_zoom < config["maximum_zoom"]:
self.zoom(target_zoom) | python | def zoom_in(self):
"""Zooms in by zoom factor"""
zoom = self.grid.grid_renderer.zoom
target_zoom = zoom * (1 + config["zoom_factor"])
if target_zoom < config["maximum_zoom"]:
self.zoom(target_zoom) | [
"def",
"zoom_in",
"(",
"self",
")",
":",
"zoom",
"=",
"self",
".",
"grid",
".",
"grid_renderer",
".",
"zoom",
"target_zoom",
"=",
"zoom",
"*",
"(",
"1",
"+",
"config",
"[",
"\"zoom_factor\"",
"]",
")",
"if",
"target_zoom",
"<",
"config",
"[",
"\"maximum_zoom\"",
"]",
":",
"self",
".",
"zoom",
"(",
"target_zoom",
")"
] | Zooms in by zoom factor | [
"Zooms",
"in",
"by",
"zoom",
"factor"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1191-L1199 | train | 231,501 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | GridActions.zoom_out | def zoom_out(self):
"""Zooms out by zoom factor"""
zoom = self.grid.grid_renderer.zoom
target_zoom = zoom * (1 - config["zoom_factor"])
if target_zoom > config["minimum_zoom"]:
self.zoom(target_zoom) | python | def zoom_out(self):
"""Zooms out by zoom factor"""
zoom = self.grid.grid_renderer.zoom
target_zoom = zoom * (1 - config["zoom_factor"])
if target_zoom > config["minimum_zoom"]:
self.zoom(target_zoom) | [
"def",
"zoom_out",
"(",
"self",
")",
":",
"zoom",
"=",
"self",
".",
"grid",
".",
"grid_renderer",
".",
"zoom",
"target_zoom",
"=",
"zoom",
"*",
"(",
"1",
"-",
"config",
"[",
"\"zoom_factor\"",
"]",
")",
"if",
"target_zoom",
">",
"config",
"[",
"\"minimum_zoom\"",
"]",
":",
"self",
".",
"zoom",
"(",
"target_zoom",
")"
] | Zooms out by zoom factor | [
"Zooms",
"out",
"by",
"zoom",
"factor"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1201-L1209 | train | 231,502 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | GridActions._get_rows_height | def _get_rows_height(self):
"""Returns the total height of all grid rows"""
tab = self.grid.current_table
no_rows = self.grid.code_array.shape[0]
default_row_height = self.grid.code_array.cell_attributes.\
default_cell_attributes["row-height"]
non_standard_row_heights = []
__row_heights = self.grid.code_array.row_heights
for __row, __tab in __row_heights:
if __tab == tab:
non_standard_row_heights.append(__row_heights[(__row, __tab)])
rows_height = sum(non_standard_row_heights)
rows_height += \
(no_rows - len(non_standard_row_heights)) * default_row_height
return rows_height | python | def _get_rows_height(self):
"""Returns the total height of all grid rows"""
tab = self.grid.current_table
no_rows = self.grid.code_array.shape[0]
default_row_height = self.grid.code_array.cell_attributes.\
default_cell_attributes["row-height"]
non_standard_row_heights = []
__row_heights = self.grid.code_array.row_heights
for __row, __tab in __row_heights:
if __tab == tab:
non_standard_row_heights.append(__row_heights[(__row, __tab)])
rows_height = sum(non_standard_row_heights)
rows_height += \
(no_rows - len(non_standard_row_heights)) * default_row_height
return rows_height | [
"def",
"_get_rows_height",
"(",
"self",
")",
":",
"tab",
"=",
"self",
".",
"grid",
".",
"current_table",
"no_rows",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"shape",
"[",
"0",
"]",
"default_row_height",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"cell_attributes",
".",
"default_cell_attributes",
"[",
"\"row-height\"",
"]",
"non_standard_row_heights",
"=",
"[",
"]",
"__row_heights",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"row_heights",
"for",
"__row",
",",
"__tab",
"in",
"__row_heights",
":",
"if",
"__tab",
"==",
"tab",
":",
"non_standard_row_heights",
".",
"append",
"(",
"__row_heights",
"[",
"(",
"__row",
",",
"__tab",
")",
"]",
")",
"rows_height",
"=",
"sum",
"(",
"non_standard_row_heights",
")",
"rows_height",
"+=",
"(",
"no_rows",
"-",
"len",
"(",
"non_standard_row_heights",
")",
")",
"*",
"default_row_height",
"return",
"rows_height"
] | Returns the total height of all grid rows | [
"Returns",
"the",
"total",
"height",
"of",
"all",
"grid",
"rows"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1211-L1229 | train | 231,503 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | GridActions._get_cols_width | def _get_cols_width(self):
"""Returns the total width of all grid cols"""
tab = self.grid.current_table
no_cols = self.grid.code_array.shape[1]
default_col_width = self.grid.code_array.cell_attributes.\
default_cell_attributes["column-width"]
non_standard_col_widths = []
__col_widths = self.grid.code_array.col_widths
for __col, __tab in __col_widths:
if __tab == tab:
non_standard_col_widths.append(__col_widths[(__col, __tab)])
cols_width = sum(non_standard_col_widths)
cols_width += \
(no_cols - len(non_standard_col_widths)) * default_col_width
return cols_width | python | def _get_cols_width(self):
"""Returns the total width of all grid cols"""
tab = self.grid.current_table
no_cols = self.grid.code_array.shape[1]
default_col_width = self.grid.code_array.cell_attributes.\
default_cell_attributes["column-width"]
non_standard_col_widths = []
__col_widths = self.grid.code_array.col_widths
for __col, __tab in __col_widths:
if __tab == tab:
non_standard_col_widths.append(__col_widths[(__col, __tab)])
cols_width = sum(non_standard_col_widths)
cols_width += \
(no_cols - len(non_standard_col_widths)) * default_col_width
return cols_width | [
"def",
"_get_cols_width",
"(",
"self",
")",
":",
"tab",
"=",
"self",
".",
"grid",
".",
"current_table",
"no_cols",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"shape",
"[",
"1",
"]",
"default_col_width",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"cell_attributes",
".",
"default_cell_attributes",
"[",
"\"column-width\"",
"]",
"non_standard_col_widths",
"=",
"[",
"]",
"__col_widths",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"col_widths",
"for",
"__col",
",",
"__tab",
"in",
"__col_widths",
":",
"if",
"__tab",
"==",
"tab",
":",
"non_standard_col_widths",
".",
"append",
"(",
"__col_widths",
"[",
"(",
"__col",
",",
"__tab",
")",
"]",
")",
"cols_width",
"=",
"sum",
"(",
"non_standard_col_widths",
")",
"cols_width",
"+=",
"(",
"no_cols",
"-",
"len",
"(",
"non_standard_col_widths",
")",
")",
"*",
"default_col_width",
"return",
"cols_width"
] | Returns the total width of all grid cols | [
"Returns",
"the",
"total",
"width",
"of",
"all",
"grid",
"cols"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1231-L1249 | train | 231,504 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | GridActions.zoom_fit | def zoom_fit(self):
"""Zooms the rid to fit the window.
Only has an effect if the resulting zoom level is between
minimum and maximum zoom level.
"""
zoom = self.grid.grid_renderer.zoom
grid_width, grid_height = self.grid.GetSize()
rows_height = self._get_rows_height() + \
(float(self.grid.GetColLabelSize()) / zoom)
cols_width = self._get_cols_width() + \
(float(self.grid.GetRowLabelSize()) / zoom)
# Check target zoom for rows
zoom_height = float(grid_height) / rows_height
# Check target zoom for columns
zoom_width = float(grid_width) / cols_width
# Use the minimum target zoom from rows and column target zooms
target_zoom = min(zoom_height, zoom_width)
# Zoom only if between min and max
if config["minimum_zoom"] < target_zoom < config["maximum_zoom"]:
self.zoom(target_zoom) | python | def zoom_fit(self):
"""Zooms the rid to fit the window.
Only has an effect if the resulting zoom level is between
minimum and maximum zoom level.
"""
zoom = self.grid.grid_renderer.zoom
grid_width, grid_height = self.grid.GetSize()
rows_height = self._get_rows_height() + \
(float(self.grid.GetColLabelSize()) / zoom)
cols_width = self._get_cols_width() + \
(float(self.grid.GetRowLabelSize()) / zoom)
# Check target zoom for rows
zoom_height = float(grid_height) / rows_height
# Check target zoom for columns
zoom_width = float(grid_width) / cols_width
# Use the minimum target zoom from rows and column target zooms
target_zoom = min(zoom_height, zoom_width)
# Zoom only if between min and max
if config["minimum_zoom"] < target_zoom < config["maximum_zoom"]:
self.zoom(target_zoom) | [
"def",
"zoom_fit",
"(",
"self",
")",
":",
"zoom",
"=",
"self",
".",
"grid",
".",
"grid_renderer",
".",
"zoom",
"grid_width",
",",
"grid_height",
"=",
"self",
".",
"grid",
".",
"GetSize",
"(",
")",
"rows_height",
"=",
"self",
".",
"_get_rows_height",
"(",
")",
"+",
"(",
"float",
"(",
"self",
".",
"grid",
".",
"GetColLabelSize",
"(",
")",
")",
"/",
"zoom",
")",
"cols_width",
"=",
"self",
".",
"_get_cols_width",
"(",
")",
"+",
"(",
"float",
"(",
"self",
".",
"grid",
".",
"GetRowLabelSize",
"(",
")",
")",
"/",
"zoom",
")",
"# Check target zoom for rows",
"zoom_height",
"=",
"float",
"(",
"grid_height",
")",
"/",
"rows_height",
"# Check target zoom for columns",
"zoom_width",
"=",
"float",
"(",
"grid_width",
")",
"/",
"cols_width",
"# Use the minimum target zoom from rows and column target zooms",
"target_zoom",
"=",
"min",
"(",
"zoom_height",
",",
"zoom_width",
")",
"# Zoom only if between min and max",
"if",
"config",
"[",
"\"minimum_zoom\"",
"]",
"<",
"target_zoom",
"<",
"config",
"[",
"\"maximum_zoom\"",
"]",
":",
"self",
".",
"zoom",
"(",
"target_zoom",
")"
] | Zooms the rid to fit the window.
Only has an effect if the resulting zoom level is between
minimum and maximum zoom level. | [
"Zooms",
"the",
"rid",
"to",
"fit",
"the",
"window",
"."
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1251-L1280 | train | 231,505 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | GridActions.on_mouse_over | def on_mouse_over(self, key):
"""Displays cell code of cell key in status bar"""
def split_lines(string, line_length=80):
"""Returns string that is split into lines of length line_length"""
result = u""
line = 0
while len(string) > line_length * line:
line_start = line * line_length
result += string[line_start:line_start+line_length]
result += '\n'
line += 1
return result[:-1]
row, col, tab = key
# If the cell is a button cell or a frozen cell then do nothing
cell_attributes = self.grid.code_array.cell_attributes
if cell_attributes[key]["button_cell"] or \
cell_attributes[key]["frozen"]:
return
if (row, col) != self.prev_rowcol and row >= 0 and col >= 0:
self.prev_rowcol[:] = [row, col]
max_result_length = int(config["max_result_length"])
table = self.grid.GetTable()
hinttext = table.GetSource(row, col, tab)[:max_result_length]
if hinttext is None:
hinttext = ''
post_command_event(self.main_window, self.StatusBarMsg,
text=hinttext)
cell_res = self.grid.code_array[row, col, tab]
if cell_res is None:
self.grid.SetToolTip(None)
return
try:
cell_res_str = unicode(cell_res)
except UnicodeEncodeError:
cell_res_str = unicode(cell_res, encoding='utf-8')
if len(cell_res_str) > max_result_length:
cell_res_str = cell_res_str[:max_result_length] + ' [...]'
self.grid.SetToolTipString(split_lines(cell_res_str)) | python | def on_mouse_over(self, key):
"""Displays cell code of cell key in status bar"""
def split_lines(string, line_length=80):
"""Returns string that is split into lines of length line_length"""
result = u""
line = 0
while len(string) > line_length * line:
line_start = line * line_length
result += string[line_start:line_start+line_length]
result += '\n'
line += 1
return result[:-1]
row, col, tab = key
# If the cell is a button cell or a frozen cell then do nothing
cell_attributes = self.grid.code_array.cell_attributes
if cell_attributes[key]["button_cell"] or \
cell_attributes[key]["frozen"]:
return
if (row, col) != self.prev_rowcol and row >= 0 and col >= 0:
self.prev_rowcol[:] = [row, col]
max_result_length = int(config["max_result_length"])
table = self.grid.GetTable()
hinttext = table.GetSource(row, col, tab)[:max_result_length]
if hinttext is None:
hinttext = ''
post_command_event(self.main_window, self.StatusBarMsg,
text=hinttext)
cell_res = self.grid.code_array[row, col, tab]
if cell_res is None:
self.grid.SetToolTip(None)
return
try:
cell_res_str = unicode(cell_res)
except UnicodeEncodeError:
cell_res_str = unicode(cell_res, encoding='utf-8')
if len(cell_res_str) > max_result_length:
cell_res_str = cell_res_str[:max_result_length] + ' [...]'
self.grid.SetToolTipString(split_lines(cell_res_str)) | [
"def",
"on_mouse_over",
"(",
"self",
",",
"key",
")",
":",
"def",
"split_lines",
"(",
"string",
",",
"line_length",
"=",
"80",
")",
":",
"\"\"\"Returns string that is split into lines of length line_length\"\"\"",
"result",
"=",
"u\"\"",
"line",
"=",
"0",
"while",
"len",
"(",
"string",
")",
">",
"line_length",
"*",
"line",
":",
"line_start",
"=",
"line",
"*",
"line_length",
"result",
"+=",
"string",
"[",
"line_start",
":",
"line_start",
"+",
"line_length",
"]",
"result",
"+=",
"'\\n'",
"line",
"+=",
"1",
"return",
"result",
"[",
":",
"-",
"1",
"]",
"row",
",",
"col",
",",
"tab",
"=",
"key",
"# If the cell is a button cell or a frozen cell then do nothing",
"cell_attributes",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"cell_attributes",
"if",
"cell_attributes",
"[",
"key",
"]",
"[",
"\"button_cell\"",
"]",
"or",
"cell_attributes",
"[",
"key",
"]",
"[",
"\"frozen\"",
"]",
":",
"return",
"if",
"(",
"row",
",",
"col",
")",
"!=",
"self",
".",
"prev_rowcol",
"and",
"row",
">=",
"0",
"and",
"col",
">=",
"0",
":",
"self",
".",
"prev_rowcol",
"[",
":",
"]",
"=",
"[",
"row",
",",
"col",
"]",
"max_result_length",
"=",
"int",
"(",
"config",
"[",
"\"max_result_length\"",
"]",
")",
"table",
"=",
"self",
".",
"grid",
".",
"GetTable",
"(",
")",
"hinttext",
"=",
"table",
".",
"GetSource",
"(",
"row",
",",
"col",
",",
"tab",
")",
"[",
":",
"max_result_length",
"]",
"if",
"hinttext",
"is",
"None",
":",
"hinttext",
"=",
"''",
"post_command_event",
"(",
"self",
".",
"main_window",
",",
"self",
".",
"StatusBarMsg",
",",
"text",
"=",
"hinttext",
")",
"cell_res",
"=",
"self",
".",
"grid",
".",
"code_array",
"[",
"row",
",",
"col",
",",
"tab",
"]",
"if",
"cell_res",
"is",
"None",
":",
"self",
".",
"grid",
".",
"SetToolTip",
"(",
"None",
")",
"return",
"try",
":",
"cell_res_str",
"=",
"unicode",
"(",
"cell_res",
")",
"except",
"UnicodeEncodeError",
":",
"cell_res_str",
"=",
"unicode",
"(",
"cell_res",
",",
"encoding",
"=",
"'utf-8'",
")",
"if",
"len",
"(",
"cell_res_str",
")",
">",
"max_result_length",
":",
"cell_res_str",
"=",
"cell_res_str",
"[",
":",
"max_result_length",
"]",
"+",
"' [...]'",
"self",
".",
"grid",
".",
"SetToolTipString",
"(",
"split_lines",
"(",
"cell_res_str",
")",
")"
] | Displays cell code of cell key in status bar | [
"Displays",
"cell",
"code",
"of",
"cell",
"key",
"in",
"status",
"bar"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1284-L1336 | train | 231,506 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | GridActions.get_visible_area | def get_visible_area(self):
"""Returns visible area
Format is a tuple of the top left tuple and the lower right tuple
"""
grid = self.grid
top = grid.YToRow(grid.GetViewStart()[1] * grid.ScrollLineX)
left = grid.XToCol(grid.GetViewStart()[0] * grid.ScrollLineY)
# Now start at top left for determining the bottom right visible cell
bottom, right = top, left
while grid.IsVisible(bottom, left, wholeCellVisible=False):
bottom += 1
while grid.IsVisible(top, right, wholeCellVisible=False):
right += 1
# The derived lower right cell is *NOT* visible
bottom -= 1
right -= 1
return (top, left), (bottom, right) | python | def get_visible_area(self):
"""Returns visible area
Format is a tuple of the top left tuple and the lower right tuple
"""
grid = self.grid
top = grid.YToRow(grid.GetViewStart()[1] * grid.ScrollLineX)
left = grid.XToCol(grid.GetViewStart()[0] * grid.ScrollLineY)
# Now start at top left for determining the bottom right visible cell
bottom, right = top, left
while grid.IsVisible(bottom, left, wholeCellVisible=False):
bottom += 1
while grid.IsVisible(top, right, wholeCellVisible=False):
right += 1
# The derived lower right cell is *NOT* visible
bottom -= 1
right -= 1
return (top, left), (bottom, right) | [
"def",
"get_visible_area",
"(",
"self",
")",
":",
"grid",
"=",
"self",
".",
"grid",
"top",
"=",
"grid",
".",
"YToRow",
"(",
"grid",
".",
"GetViewStart",
"(",
")",
"[",
"1",
"]",
"*",
"grid",
".",
"ScrollLineX",
")",
"left",
"=",
"grid",
".",
"XToCol",
"(",
"grid",
".",
"GetViewStart",
"(",
")",
"[",
"0",
"]",
"*",
"grid",
".",
"ScrollLineY",
")",
"# Now start at top left for determining the bottom right visible cell",
"bottom",
",",
"right",
"=",
"top",
",",
"left",
"while",
"grid",
".",
"IsVisible",
"(",
"bottom",
",",
"left",
",",
"wholeCellVisible",
"=",
"False",
")",
":",
"bottom",
"+=",
"1",
"while",
"grid",
".",
"IsVisible",
"(",
"top",
",",
"right",
",",
"wholeCellVisible",
"=",
"False",
")",
":",
"right",
"+=",
"1",
"# The derived lower right cell is *NOT* visible",
"bottom",
"-=",
"1",
"right",
"-=",
"1",
"return",
"(",
"top",
",",
"left",
")",
",",
"(",
"bottom",
",",
"right",
")"
] | Returns visible area
Format is a tuple of the top left tuple and the lower right tuple | [
"Returns",
"visible",
"area"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1338-L1365 | train | 231,507 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | GridActions.switch_to_table | def switch_to_table(self, event):
"""Switches grid to table
Parameters
----------
event.newtable: Integer
\tTable that the grid is switched to
"""
newtable = event.newtable
no_tabs = self.grid.code_array.shape[2] - 1
if 0 <= newtable <= no_tabs:
self.grid.current_table = newtable
self.grid.SetToolTip(None)
# Delete renderer cache
self.grid.grid_renderer.cell_cache.clear()
# Delete video cells
video_cells = self.grid.grid_renderer.video_cells
for key in video_cells:
video_panel = video_cells[key]
video_panel.player.stop()
video_panel.player.release()
video_panel.Destroy()
video_cells.clear()
# Hide cell editor
cell_editor = self.grid.GetCellEditor(self.grid.GetGridCursorRow(),
self.grid.GetGridCursorCol())
try:
cell_editor.Reset()
except AttributeError:
# No cell editor open
pass
self.grid.HideCellEditControl()
# Change value of entry_line and table choice
post_command_event(self.main_window, self.TableChangedMsg,
table=newtable)
# Reset row heights and column widths by zooming
self.zoom() | python | def switch_to_table(self, event):
"""Switches grid to table
Parameters
----------
event.newtable: Integer
\tTable that the grid is switched to
"""
newtable = event.newtable
no_tabs = self.grid.code_array.shape[2] - 1
if 0 <= newtable <= no_tabs:
self.grid.current_table = newtable
self.grid.SetToolTip(None)
# Delete renderer cache
self.grid.grid_renderer.cell_cache.clear()
# Delete video cells
video_cells = self.grid.grid_renderer.video_cells
for key in video_cells:
video_panel = video_cells[key]
video_panel.player.stop()
video_panel.player.release()
video_panel.Destroy()
video_cells.clear()
# Hide cell editor
cell_editor = self.grid.GetCellEditor(self.grid.GetGridCursorRow(),
self.grid.GetGridCursorCol())
try:
cell_editor.Reset()
except AttributeError:
# No cell editor open
pass
self.grid.HideCellEditControl()
# Change value of entry_line and table choice
post_command_event(self.main_window, self.TableChangedMsg,
table=newtable)
# Reset row heights and column widths by zooming
self.zoom() | [
"def",
"switch_to_table",
"(",
"self",
",",
"event",
")",
":",
"newtable",
"=",
"event",
".",
"newtable",
"no_tabs",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"shape",
"[",
"2",
"]",
"-",
"1",
"if",
"0",
"<=",
"newtable",
"<=",
"no_tabs",
":",
"self",
".",
"grid",
".",
"current_table",
"=",
"newtable",
"self",
".",
"grid",
".",
"SetToolTip",
"(",
"None",
")",
"# Delete renderer cache",
"self",
".",
"grid",
".",
"grid_renderer",
".",
"cell_cache",
".",
"clear",
"(",
")",
"# Delete video cells",
"video_cells",
"=",
"self",
".",
"grid",
".",
"grid_renderer",
".",
"video_cells",
"for",
"key",
"in",
"video_cells",
":",
"video_panel",
"=",
"video_cells",
"[",
"key",
"]",
"video_panel",
".",
"player",
".",
"stop",
"(",
")",
"video_panel",
".",
"player",
".",
"release",
"(",
")",
"video_panel",
".",
"Destroy",
"(",
")",
"video_cells",
".",
"clear",
"(",
")",
"# Hide cell editor",
"cell_editor",
"=",
"self",
".",
"grid",
".",
"GetCellEditor",
"(",
"self",
".",
"grid",
".",
"GetGridCursorRow",
"(",
")",
",",
"self",
".",
"grid",
".",
"GetGridCursorCol",
"(",
")",
")",
"try",
":",
"cell_editor",
".",
"Reset",
"(",
")",
"except",
"AttributeError",
":",
"# No cell editor open",
"pass",
"self",
".",
"grid",
".",
"HideCellEditControl",
"(",
")",
"# Change value of entry_line and table choice",
"post_command_event",
"(",
"self",
".",
"main_window",
",",
"self",
".",
"TableChangedMsg",
",",
"table",
"=",
"newtable",
")",
"# Reset row heights and column widths by zooming",
"self",
".",
"zoom",
"(",
")"
] | Switches grid to table
Parameters
----------
event.newtable: Integer
\tTable that the grid is switched to | [
"Switches",
"grid",
"to",
"table"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1367-L1417 | train | 231,508 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | GridActions.set_cursor | def set_cursor(self, value):
"""Changes the grid cursor cell.
Parameters
----------
value: 2-tuple or 3-tuple of String
\trow, col, tab or row, col for target cursor position
"""
shape = self.grid.code_array.shape
if len(value) == 3:
self.grid._last_selected_cell = row, col, tab = value
if row < 0 or col < 0 or tab < 0 or \
row >= shape[0] or col >= shape[1] or tab >= shape[2]:
raise ValueError("Cell {value} outside of {shape}".format(
value=value, shape=shape))
if tab != self.cursor[2]:
post_command_event(self.main_window,
self.GridActionTableSwitchMsg, newtable=tab)
if is_gtk():
try:
wx.Yield()
except:
pass
else:
row, col = value
if row < 0 or col < 0 or row >= shape[0] or col >= shape[1]:
raise ValueError("Cell {value} outside of {shape}".format(
value=value, shape=shape))
self.grid._last_selected_cell = row, col, self.grid.current_table
if not (row is None and col is None):
if not self.grid.IsVisible(row, col, wholeCellVisible=True):
self.grid.MakeCellVisible(row, col)
self.grid.SetGridCursor(row, col) | python | def set_cursor(self, value):
"""Changes the grid cursor cell.
Parameters
----------
value: 2-tuple or 3-tuple of String
\trow, col, tab or row, col for target cursor position
"""
shape = self.grid.code_array.shape
if len(value) == 3:
self.grid._last_selected_cell = row, col, tab = value
if row < 0 or col < 0 or tab < 0 or \
row >= shape[0] or col >= shape[1] or tab >= shape[2]:
raise ValueError("Cell {value} outside of {shape}".format(
value=value, shape=shape))
if tab != self.cursor[2]:
post_command_event(self.main_window,
self.GridActionTableSwitchMsg, newtable=tab)
if is_gtk():
try:
wx.Yield()
except:
pass
else:
row, col = value
if row < 0 or col < 0 or row >= shape[0] or col >= shape[1]:
raise ValueError("Cell {value} outside of {shape}".format(
value=value, shape=shape))
self.grid._last_selected_cell = row, col, self.grid.current_table
if not (row is None and col is None):
if not self.grid.IsVisible(row, col, wholeCellVisible=True):
self.grid.MakeCellVisible(row, col)
self.grid.SetGridCursor(row, col) | [
"def",
"set_cursor",
"(",
"self",
",",
"value",
")",
":",
"shape",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"shape",
"if",
"len",
"(",
"value",
")",
"==",
"3",
":",
"self",
".",
"grid",
".",
"_last_selected_cell",
"=",
"row",
",",
"col",
",",
"tab",
"=",
"value",
"if",
"row",
"<",
"0",
"or",
"col",
"<",
"0",
"or",
"tab",
"<",
"0",
"or",
"row",
">=",
"shape",
"[",
"0",
"]",
"or",
"col",
">=",
"shape",
"[",
"1",
"]",
"or",
"tab",
">=",
"shape",
"[",
"2",
"]",
":",
"raise",
"ValueError",
"(",
"\"Cell {value} outside of {shape}\"",
".",
"format",
"(",
"value",
"=",
"value",
",",
"shape",
"=",
"shape",
")",
")",
"if",
"tab",
"!=",
"self",
".",
"cursor",
"[",
"2",
"]",
":",
"post_command_event",
"(",
"self",
".",
"main_window",
",",
"self",
".",
"GridActionTableSwitchMsg",
",",
"newtable",
"=",
"tab",
")",
"if",
"is_gtk",
"(",
")",
":",
"try",
":",
"wx",
".",
"Yield",
"(",
")",
"except",
":",
"pass",
"else",
":",
"row",
",",
"col",
"=",
"value",
"if",
"row",
"<",
"0",
"or",
"col",
"<",
"0",
"or",
"row",
">=",
"shape",
"[",
"0",
"]",
"or",
"col",
">=",
"shape",
"[",
"1",
"]",
":",
"raise",
"ValueError",
"(",
"\"Cell {value} outside of {shape}\"",
".",
"format",
"(",
"value",
"=",
"value",
",",
"shape",
"=",
"shape",
")",
")",
"self",
".",
"grid",
".",
"_last_selected_cell",
"=",
"row",
",",
"col",
",",
"self",
".",
"grid",
".",
"current_table",
"if",
"not",
"(",
"row",
"is",
"None",
"and",
"col",
"is",
"None",
")",
":",
"if",
"not",
"self",
".",
"grid",
".",
"IsVisible",
"(",
"row",
",",
"col",
",",
"wholeCellVisible",
"=",
"True",
")",
":",
"self",
".",
"grid",
".",
"MakeCellVisible",
"(",
"row",
",",
"col",
")",
"self",
".",
"grid",
".",
"SetGridCursor",
"(",
"row",
",",
"col",
")"
] | Changes the grid cursor cell.
Parameters
----------
value: 2-tuple or 3-tuple of String
\trow, col, tab or row, col for target cursor position | [
"Changes",
"the",
"grid",
"cursor",
"cell",
"."
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1425-L1464 | train | 231,509 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | SelectionActions.get_selection | def get_selection(self):
"""Returns selected cells in grid as Selection object"""
# GetSelectedCells: individual cells selected by ctrl-clicking
# GetSelectedRows: rows selected by clicking on the labels
# GetSelectedCols: cols selected by clicking on the labels
# GetSelectionBlockTopLeft
# GetSelectionBlockBottomRight: For blocks selected by dragging
# across the grid cells.
block_top_left = self.grid.GetSelectionBlockTopLeft()
block_bottom_right = self.grid.GetSelectionBlockBottomRight()
rows = self.grid.GetSelectedRows()
cols = self.grid.GetSelectedCols()
cells = self.grid.GetSelectedCells()
return Selection(block_top_left, block_bottom_right, rows, cols, cells) | python | def get_selection(self):
"""Returns selected cells in grid as Selection object"""
# GetSelectedCells: individual cells selected by ctrl-clicking
# GetSelectedRows: rows selected by clicking on the labels
# GetSelectedCols: cols selected by clicking on the labels
# GetSelectionBlockTopLeft
# GetSelectionBlockBottomRight: For blocks selected by dragging
# across the grid cells.
block_top_left = self.grid.GetSelectionBlockTopLeft()
block_bottom_right = self.grid.GetSelectionBlockBottomRight()
rows = self.grid.GetSelectedRows()
cols = self.grid.GetSelectedCols()
cells = self.grid.GetSelectedCells()
return Selection(block_top_left, block_bottom_right, rows, cols, cells) | [
"def",
"get_selection",
"(",
"self",
")",
":",
"# GetSelectedCells: individual cells selected by ctrl-clicking",
"# GetSelectedRows: rows selected by clicking on the labels",
"# GetSelectedCols: cols selected by clicking on the labels",
"# GetSelectionBlockTopLeft",
"# GetSelectionBlockBottomRight: For blocks selected by dragging",
"# across the grid cells.",
"block_top_left",
"=",
"self",
".",
"grid",
".",
"GetSelectionBlockTopLeft",
"(",
")",
"block_bottom_right",
"=",
"self",
".",
"grid",
".",
"GetSelectionBlockBottomRight",
"(",
")",
"rows",
"=",
"self",
".",
"grid",
".",
"GetSelectedRows",
"(",
")",
"cols",
"=",
"self",
".",
"grid",
".",
"GetSelectedCols",
"(",
")",
"cells",
"=",
"self",
".",
"grid",
".",
"GetSelectedCells",
"(",
")",
"return",
"Selection",
"(",
"block_top_left",
",",
"block_bottom_right",
",",
"rows",
",",
"cols",
",",
"cells",
")"
] | Returns selected cells in grid as Selection object | [
"Returns",
"selected",
"cells",
"in",
"grid",
"as",
"Selection",
"object"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1472-L1488 | train | 231,510 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | SelectionActions.select_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) | python | 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) | [
"def",
"select_cell",
"(",
"self",
",",
"row",
",",
"col",
",",
"add_to_selected",
"=",
"False",
")",
":",
"self",
".",
"grid",
".",
"SelectBlock",
"(",
"row",
",",
"col",
",",
"row",
",",
"col",
",",
"addToSelected",
"=",
"add_to_selected",
")"
] | Selects a single cell | [
"Selects",
"a",
"single",
"cell"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1490-L1494 | train | 231,511 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | SelectionActions.select_slice | 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 to False
\tOld selections are cleared if False
"""
if not add_to_selected:
self.grid.ClearSelection()
if row_slc == row_slc == slice(None, None, None):
# The whole grid is selected
self.grid.SelectAll()
elif row_slc.stop is None and col_slc.stop is None:
# A block is selected:
self.grid.SelectBlock(row_slc.start, col_slc.start,
row_slc.stop - 1, col_slc.stop - 1)
else:
for row in xrange(row_slc.start, row_slc.stop, row_slc.step):
for col in xrange(col_slc.start, col_slc.stop, col_slc.step):
self.select_cell(row, col, add_to_selected=True) | python | 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 to False
\tOld selections are cleared if False
"""
if not add_to_selected:
self.grid.ClearSelection()
if row_slc == row_slc == slice(None, None, None):
# The whole grid is selected
self.grid.SelectAll()
elif row_slc.stop is None and col_slc.stop is None:
# A block is selected:
self.grid.SelectBlock(row_slc.start, col_slc.start,
row_slc.stop - 1, col_slc.stop - 1)
else:
for row in xrange(row_slc.start, row_slc.stop, row_slc.step):
for col in xrange(col_slc.start, col_slc.stop, col_slc.step):
self.select_cell(row, col, add_to_selected=True) | [
"def",
"select_slice",
"(",
"self",
",",
"row_slc",
",",
"col_slc",
",",
"add_to_selected",
"=",
"False",
")",
":",
"if",
"not",
"add_to_selected",
":",
"self",
".",
"grid",
".",
"ClearSelection",
"(",
")",
"if",
"row_slc",
"==",
"row_slc",
"==",
"slice",
"(",
"None",
",",
"None",
",",
"None",
")",
":",
"# The whole grid is selected",
"self",
".",
"grid",
".",
"SelectAll",
"(",
")",
"elif",
"row_slc",
".",
"stop",
"is",
"None",
"and",
"col_slc",
".",
"stop",
"is",
"None",
":",
"# A block is selected:",
"self",
".",
"grid",
".",
"SelectBlock",
"(",
"row_slc",
".",
"start",
",",
"col_slc",
".",
"start",
",",
"row_slc",
".",
"stop",
"-",
"1",
",",
"col_slc",
".",
"stop",
"-",
"1",
")",
"else",
":",
"for",
"row",
"in",
"xrange",
"(",
"row_slc",
".",
"start",
",",
"row_slc",
".",
"stop",
",",
"row_slc",
".",
"step",
")",
":",
"for",
"col",
"in",
"xrange",
"(",
"col_slc",
".",
"start",
",",
"col_slc",
".",
"stop",
",",
"col_slc",
".",
"step",
")",
":",
"self",
".",
"select_cell",
"(",
"row",
",",
"col",
",",
"add_to_selected",
"=",
"True",
")"
] | 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 | [
"Selects",
"a",
"slice",
"of",
"cells"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1496-L1524 | train | 231,512 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | SelectionActions.delete_selection | 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
"""
# Mark content as changed
post_command_event(self.main_window, self.ContentChangedMsg)
if selection is None:
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:
self.grid.actions.delete_cell((row, col, tab))
self.grid.code_array.result_cache.clear() | python | 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
"""
# Mark content as changed
post_command_event(self.main_window, self.ContentChangedMsg)
if selection is None:
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:
self.grid.actions.delete_cell((row, col, tab))
self.grid.code_array.result_cache.clear() | [
"def",
"delete_selection",
"(",
"self",
",",
"selection",
"=",
"None",
")",
":",
"# Mark content as changed",
"post_command_event",
"(",
"self",
".",
"main_window",
",",
"self",
".",
"ContentChangedMsg",
")",
"if",
"selection",
"is",
"None",
":",
"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",
":",
"self",
".",
"grid",
".",
"actions",
".",
"delete_cell",
"(",
"(",
"row",
",",
"col",
",",
"tab",
")",
")",
"self",
".",
"grid",
".",
"code_array",
".",
"result_cache",
".",
"clear",
"(",
")"
] | 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",
"selection",
"marks",
"content",
"as",
"changed"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1526-L1551 | train | 231,513 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | SelectionActions.delete | 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
cursor = self.grid.actions.cursor
self.grid.actions.delete_cell(cursor)
# Update grid
self.grid.ForceRefresh() | python | 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
cursor = self.grid.actions.cursor
self.grid.actions.delete_cell(cursor)
# Update grid
self.grid.ForceRefresh() | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"self",
".",
"grid",
".",
"IsSelection",
"(",
")",
":",
"# Delete selection",
"self",
".",
"grid",
".",
"actions",
".",
"delete_selection",
"(",
")",
"else",
":",
"# Delete cell at cursor",
"cursor",
"=",
"self",
".",
"grid",
".",
"actions",
".",
"cursor",
"self",
".",
"grid",
".",
"actions",
".",
"delete_cell",
"(",
"cursor",
")",
"# Update grid",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")"
] | Deletes a selection if any else deletes the cursor cell
Refreshes grid after deletion | [
"Deletes",
"a",
"selection",
"if",
"any",
"else",
"deletes",
"the",
"cursor",
"cell"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1553-L1570 | train | 231,514 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | SelectionActions.quote_selection | 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:
self.grid.actions.quote_code((row, col, tab))
self.grid.code_array.result_cache.clear() | python | 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:
self.grid.actions.quote_code((row, col, tab))
self.grid.code_array.result_cache.clear() | [
"def",
"quote_selection",
"(",
"self",
")",
":",
"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",
":",
"self",
".",
"grid",
".",
"actions",
".",
"quote_code",
"(",
"(",
"row",
",",
"col",
",",
"tab",
")",
")",
"self",
".",
"grid",
".",
"code_array",
".",
"result_cache",
".",
"clear",
"(",
")"
] | Quotes selected cells, marks content as changed | [
"Quotes",
"selected",
"cells",
"marks",
"content",
"as",
"changed"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1572-L1581 | train | 231,515 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | SelectionActions.copy_selection_access_string | 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 selection:
cursor = self.grid.actions.cursor
selection = Selection([], [], [], [], [tuple(cursor[:2])])
shape = self.grid.code_array.shape
tab = self.grid.current_table
access_string = selection.get_access_string(shape, tab)
# Copy access string to clipboard
self.grid.main_window.clipboard.set_clipboard(access_string)
# Display copy operation and access string in status bar
statustext = _("Cell reference copied to clipboard: {access_string}")
statustext = statustext.format(access_string=access_string)
post_command_event(self.main_window, self.StatusBarMsg,
text=statustext) | python | 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 selection:
cursor = self.grid.actions.cursor
selection = Selection([], [], [], [], [tuple(cursor[:2])])
shape = self.grid.code_array.shape
tab = self.grid.current_table
access_string = selection.get_access_string(shape, tab)
# Copy access string to clipboard
self.grid.main_window.clipboard.set_clipboard(access_string)
# Display copy operation and access string in status bar
statustext = _("Cell reference copied to clipboard: {access_string}")
statustext = statustext.format(access_string=access_string)
post_command_event(self.main_window, self.StatusBarMsg,
text=statustext) | [
"def",
"copy_selection_access_string",
"(",
"self",
")",
":",
"selection",
"=",
"self",
".",
"get_selection",
"(",
")",
"if",
"not",
"selection",
":",
"cursor",
"=",
"self",
".",
"grid",
".",
"actions",
".",
"cursor",
"selection",
"=",
"Selection",
"(",
"[",
"]",
",",
"[",
"]",
",",
"[",
"]",
",",
"[",
"]",
",",
"[",
"tuple",
"(",
"cursor",
"[",
":",
"2",
"]",
")",
"]",
")",
"shape",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"shape",
"tab",
"=",
"self",
".",
"grid",
".",
"current_table",
"access_string",
"=",
"selection",
".",
"get_access_string",
"(",
"shape",
",",
"tab",
")",
"# Copy access string to clipboard",
"self",
".",
"grid",
".",
"main_window",
".",
"clipboard",
".",
"set_clipboard",
"(",
"access_string",
")",
"# Display copy operation and access string in status bar",
"statustext",
"=",
"_",
"(",
"\"Cell reference copied to clipboard: {access_string}\"",
")",
"statustext",
"=",
"statustext",
".",
"format",
"(",
"access_string",
"=",
"access_string",
")",
"post_command_event",
"(",
"self",
".",
"main_window",
",",
"self",
".",
"StatusBarMsg",
",",
"text",
"=",
"statustext",
")"
] | 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 | [
"Copys",
"access_string",
"to",
"selection",
"to",
"the",
"clipboard"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1583-L1608 | train | 231,516 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | SelectionActions.copy_format | 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_attributes = []
selection = self.get_selection()
if not selection:
# Current cell is chosen for selection
selection = Selection([], [], [], [], [(row, col)])
# Format content is shifted so that the top left corner is 0,0
((top, left), (bottom, right)) = \
selection.get_grid_bbox(self.grid.code_array.shape)
cell_attributes = code_array.cell_attributes
for __selection, table, attrs in cell_attributes:
if tab == table:
new_selection = selection & __selection
if new_selection:
new_shifted_selection = new_selection.shifted(-top, -left)
if "merge_area" not in attrs:
selection_params = new_shifted_selection.parameters
cellattribute = selection_params, table, attrs
new_cell_attributes.append(cellattribute)
# Rows
shifted_new_row_heights = {}
for row, table in code_array.row_heights:
if tab == table and top <= row <= bottom:
shifted_new_row_heights[row-top, table] = \
code_array.row_heights[row, table]
# Columns
shifted_new_col_widths = {}
for col, table in code_array.col_widths:
if tab == table and left <= col <= right:
shifted_new_col_widths[col-left, table] = \
code_array.col_widths[col, table]
format_data = {
"cell_attributes": new_cell_attributes,
"row_heights": shifted_new_row_heights,
"col_widths": shifted_new_col_widths,
}
attr_string = repr(format_data)
self.grid.main_window.clipboard.set_clipboard(attr_string) | python | 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_attributes = []
selection = self.get_selection()
if not selection:
# Current cell is chosen for selection
selection = Selection([], [], [], [], [(row, col)])
# Format content is shifted so that the top left corner is 0,0
((top, left), (bottom, right)) = \
selection.get_grid_bbox(self.grid.code_array.shape)
cell_attributes = code_array.cell_attributes
for __selection, table, attrs in cell_attributes:
if tab == table:
new_selection = selection & __selection
if new_selection:
new_shifted_selection = new_selection.shifted(-top, -left)
if "merge_area" not in attrs:
selection_params = new_shifted_selection.parameters
cellattribute = selection_params, table, attrs
new_cell_attributes.append(cellattribute)
# Rows
shifted_new_row_heights = {}
for row, table in code_array.row_heights:
if tab == table and top <= row <= bottom:
shifted_new_row_heights[row-top, table] = \
code_array.row_heights[row, table]
# Columns
shifted_new_col_widths = {}
for col, table in code_array.col_widths:
if tab == table and left <= col <= right:
shifted_new_col_widths[col-left, table] = \
code_array.col_widths[col, table]
format_data = {
"cell_attributes": new_cell_attributes,
"row_heights": shifted_new_row_heights,
"col_widths": shifted_new_col_widths,
}
attr_string = repr(format_data)
self.grid.main_window.clipboard.set_clipboard(attr_string) | [
"def",
"copy_format",
"(",
"self",
")",
":",
"row",
",",
"col",
",",
"tab",
"=",
"self",
".",
"grid",
".",
"actions",
".",
"cursor",
"code_array",
"=",
"self",
".",
"grid",
".",
"code_array",
"# Cell attributes",
"new_cell_attributes",
"=",
"[",
"]",
"selection",
"=",
"self",
".",
"get_selection",
"(",
")",
"if",
"not",
"selection",
":",
"# Current cell is chosen for selection",
"selection",
"=",
"Selection",
"(",
"[",
"]",
",",
"[",
"]",
",",
"[",
"]",
",",
"[",
"]",
",",
"[",
"(",
"row",
",",
"col",
")",
"]",
")",
"# Format content is shifted so that the top left corner is 0,0",
"(",
"(",
"top",
",",
"left",
")",
",",
"(",
"bottom",
",",
"right",
")",
")",
"=",
"selection",
".",
"get_grid_bbox",
"(",
"self",
".",
"grid",
".",
"code_array",
".",
"shape",
")",
"cell_attributes",
"=",
"code_array",
".",
"cell_attributes",
"for",
"__selection",
",",
"table",
",",
"attrs",
"in",
"cell_attributes",
":",
"if",
"tab",
"==",
"table",
":",
"new_selection",
"=",
"selection",
"&",
"__selection",
"if",
"new_selection",
":",
"new_shifted_selection",
"=",
"new_selection",
".",
"shifted",
"(",
"-",
"top",
",",
"-",
"left",
")",
"if",
"\"merge_area\"",
"not",
"in",
"attrs",
":",
"selection_params",
"=",
"new_shifted_selection",
".",
"parameters",
"cellattribute",
"=",
"selection_params",
",",
"table",
",",
"attrs",
"new_cell_attributes",
".",
"append",
"(",
"cellattribute",
")",
"# Rows",
"shifted_new_row_heights",
"=",
"{",
"}",
"for",
"row",
",",
"table",
"in",
"code_array",
".",
"row_heights",
":",
"if",
"tab",
"==",
"table",
"and",
"top",
"<=",
"row",
"<=",
"bottom",
":",
"shifted_new_row_heights",
"[",
"row",
"-",
"top",
",",
"table",
"]",
"=",
"code_array",
".",
"row_heights",
"[",
"row",
",",
"table",
"]",
"# Columns",
"shifted_new_col_widths",
"=",
"{",
"}",
"for",
"col",
",",
"table",
"in",
"code_array",
".",
"col_widths",
":",
"if",
"tab",
"==",
"table",
"and",
"left",
"<=",
"col",
"<=",
"right",
":",
"shifted_new_col_widths",
"[",
"col",
"-",
"left",
",",
"table",
"]",
"=",
"code_array",
".",
"col_widths",
"[",
"col",
",",
"table",
"]",
"format_data",
"=",
"{",
"\"cell_attributes\"",
":",
"new_cell_attributes",
",",
"\"row_heights\"",
":",
"shifted_new_row_heights",
",",
"\"col_widths\"",
":",
"shifted_new_col_widths",
",",
"}",
"attr_string",
"=",
"repr",
"(",
"format_data",
")",
"self",
".",
"grid",
".",
"main_window",
".",
"clipboard",
".",
"set_clipboard",
"(",
"attr_string",
")"
] | Copies the format of the selected cells to the Clipboard
Cells are shifted so that the top left bbox corner is at 0,0 | [
"Copies",
"the",
"format",
"of",
"the",
"selected",
"cells",
"to",
"the",
"Clipboard"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1610-L1667 | train | 231,517 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | SelectionActions.paste_format | 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
row, col = [tl if tl is not None else 0
for tl in selection.get_bbox()[0]]
cell_attributes = self.grid.code_array.cell_attributes
string_data = self.grid.main_window.clipboard.get_clipboard()
format_data = ast.literal_eval(string_data)
ca = format_data["cell_attributes"]
rh = format_data["row_heights"]
cw = format_data["col_widths"]
assert isinstance(ca, types.ListType)
assert isinstance(rh, types.DictType)
assert isinstance(cw, types.DictType)
# Cell attributes
for selection_params, tab, attrs in ca:
base_selection = Selection(*selection_params)
shifted_selection = base_selection.shifted(row, col)
if "merge_area" not in attrs:
# Do not paste merge areas because this may have
# inintended consequences for existing merge areas
new_cell_attribute = shifted_selection, tab, attrs
cell_attributes.append(new_cell_attribute)
# Row heights
row_heights = self.grid.code_array.row_heights
for __row, __tab in rh:
row_heights[__row+row, tab] = rh[__row, __tab]
# Column widths
col_widths = self.grid.code_array.col_widths
for __col, __tab in cw:
col_widths[__col+col, tab] = cw[(__col, __tab)] | python | 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
row, col = [tl if tl is not None else 0
for tl in selection.get_bbox()[0]]
cell_attributes = self.grid.code_array.cell_attributes
string_data = self.grid.main_window.clipboard.get_clipboard()
format_data = ast.literal_eval(string_data)
ca = format_data["cell_attributes"]
rh = format_data["row_heights"]
cw = format_data["col_widths"]
assert isinstance(ca, types.ListType)
assert isinstance(rh, types.DictType)
assert isinstance(cw, types.DictType)
# Cell attributes
for selection_params, tab, attrs in ca:
base_selection = Selection(*selection_params)
shifted_selection = base_selection.shifted(row, col)
if "merge_area" not in attrs:
# Do not paste merge areas because this may have
# inintended consequences for existing merge areas
new_cell_attribute = shifted_selection, tab, attrs
cell_attributes.append(new_cell_attribute)
# Row heights
row_heights = self.grid.code_array.row_heights
for __row, __tab in rh:
row_heights[__row+row, tab] = rh[__row, __tab]
# Column widths
col_widths = self.grid.code_array.col_widths
for __col, __tab in cw:
col_widths[__col+col, tab] = cw[(__col, __tab)] | [
"def",
"paste_format",
"(",
"self",
")",
":",
"row",
",",
"col",
",",
"tab",
"=",
"self",
".",
"grid",
".",
"actions",
".",
"cursor",
"selection",
"=",
"self",
".",
"get_selection",
"(",
")",
"if",
"selection",
":",
"# Use selection rather than cursor for top left cell if present",
"row",
",",
"col",
"=",
"[",
"tl",
"if",
"tl",
"is",
"not",
"None",
"else",
"0",
"for",
"tl",
"in",
"selection",
".",
"get_bbox",
"(",
")",
"[",
"0",
"]",
"]",
"cell_attributes",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"cell_attributes",
"string_data",
"=",
"self",
".",
"grid",
".",
"main_window",
".",
"clipboard",
".",
"get_clipboard",
"(",
")",
"format_data",
"=",
"ast",
".",
"literal_eval",
"(",
"string_data",
")",
"ca",
"=",
"format_data",
"[",
"\"cell_attributes\"",
"]",
"rh",
"=",
"format_data",
"[",
"\"row_heights\"",
"]",
"cw",
"=",
"format_data",
"[",
"\"col_widths\"",
"]",
"assert",
"isinstance",
"(",
"ca",
",",
"types",
".",
"ListType",
")",
"assert",
"isinstance",
"(",
"rh",
",",
"types",
".",
"DictType",
")",
"assert",
"isinstance",
"(",
"cw",
",",
"types",
".",
"DictType",
")",
"# Cell attributes",
"for",
"selection_params",
",",
"tab",
",",
"attrs",
"in",
"ca",
":",
"base_selection",
"=",
"Selection",
"(",
"*",
"selection_params",
")",
"shifted_selection",
"=",
"base_selection",
".",
"shifted",
"(",
"row",
",",
"col",
")",
"if",
"\"merge_area\"",
"not",
"in",
"attrs",
":",
"# Do not paste merge areas because this may have",
"# inintended consequences for existing merge areas",
"new_cell_attribute",
"=",
"shifted_selection",
",",
"tab",
",",
"attrs",
"cell_attributes",
".",
"append",
"(",
"new_cell_attribute",
")",
"# Row heights",
"row_heights",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"row_heights",
"for",
"__row",
",",
"__tab",
"in",
"rh",
":",
"row_heights",
"[",
"__row",
"+",
"row",
",",
"tab",
"]",
"=",
"rh",
"[",
"__row",
",",
"__tab",
"]",
"# Column widths",
"col_widths",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"col_widths",
"for",
"__col",
",",
"__tab",
"in",
"cw",
":",
"col_widths",
"[",
"__col",
"+",
"col",
",",
"tab",
"]",
"=",
"cw",
"[",
"(",
"__col",
",",
"__tab",
")",
"]"
] | Pastes cell formats
Pasting starts at cursor or at top left bbox corner | [
"Pastes",
"cell",
"formats"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1669-L1716 | train | 231,518 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | FindActions.find_all | 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_string: String
\tString to find in grid
flags: List of strings
\t Search flag out of
\t ["UP" xor "DOWN", "WHOLE_WORD", "MATCH_CASE", "REG_EXP"]
"""
code_array = self.grid.code_array
string_match = code_array.string_match
find_keys = []
for key in code_array:
if string_match(code_array(key), find_string, flags) is not None:
find_keys.append(key)
return find_keys | python | 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_string: String
\tString to find in grid
flags: List of strings
\t Search flag out of
\t ["UP" xor "DOWN", "WHOLE_WORD", "MATCH_CASE", "REG_EXP"]
"""
code_array = self.grid.code_array
string_match = code_array.string_match
find_keys = []
for key in code_array:
if string_match(code_array(key), find_string, flags) is not None:
find_keys.append(key)
return find_keys | [
"def",
"find_all",
"(",
"self",
",",
"find_string",
",",
"flags",
")",
":",
"code_array",
"=",
"self",
".",
"grid",
".",
"code_array",
"string_match",
"=",
"code_array",
".",
"string_match",
"find_keys",
"=",
"[",
"]",
"for",
"key",
"in",
"code_array",
":",
"if",
"string_match",
"(",
"code_array",
"(",
"key",
")",
",",
"find_string",
",",
"flags",
")",
"is",
"not",
"None",
":",
"find_keys",
".",
"append",
"(",
"key",
")",
"return",
"find_keys"
] | 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
flags: List of strings
\t Search flag out of
\t ["UP" xor "DOWN", "WHOLE_WORD", "MATCH_CASE", "REG_EXP"] | [
"Return",
"list",
"of",
"all",
"positions",
"of",
"event_find_string",
"in",
"MainGrid",
"."
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1722-L1748 | train | 231,519 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | FindActions.find | 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
flags: List of strings
\tSearch flag out of
\t["UP" xor "DOWN", "WHOLE_WORD", "MATCH_CASE", "REG_EXP"]
search_result: Bool, defaults to True
\tIf True then the search includes the result string (slower)
"""
findfunc = self.grid.code_array.findnextmatch
if "DOWN" in flags:
if gridpos[0] < self.grid.code_array.shape[0]:
gridpos[0] += 1
elif gridpos[1] < self.grid.code_array.shape[1]:
gridpos[1] += 1
elif gridpos[2] < self.grid.code_array.shape[2]:
gridpos[2] += 1
else:
gridpos = (0, 0, 0)
elif "UP" in flags:
if gridpos[0] > 0:
gridpos[0] -= 1
elif gridpos[1] > 0:
gridpos[1] -= 1
elif gridpos[2] > 0:
gridpos[2] -= 1
else:
gridpos = [dim - 1 for dim in self.grid.code_array.shape]
return findfunc(tuple(gridpos), find_string, flags, search_result) | python | 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
flags: List of strings
\tSearch flag out of
\t["UP" xor "DOWN", "WHOLE_WORD", "MATCH_CASE", "REG_EXP"]
search_result: Bool, defaults to True
\tIf True then the search includes the result string (slower)
"""
findfunc = self.grid.code_array.findnextmatch
if "DOWN" in flags:
if gridpos[0] < self.grid.code_array.shape[0]:
gridpos[0] += 1
elif gridpos[1] < self.grid.code_array.shape[1]:
gridpos[1] += 1
elif gridpos[2] < self.grid.code_array.shape[2]:
gridpos[2] += 1
else:
gridpos = (0, 0, 0)
elif "UP" in flags:
if gridpos[0] > 0:
gridpos[0] -= 1
elif gridpos[1] > 0:
gridpos[1] -= 1
elif gridpos[2] > 0:
gridpos[2] -= 1
else:
gridpos = [dim - 1 for dim in self.grid.code_array.shape]
return findfunc(tuple(gridpos), find_string, flags, search_result) | [
"def",
"find",
"(",
"self",
",",
"gridpos",
",",
"find_string",
",",
"flags",
",",
"search_result",
"=",
"True",
")",
":",
"findfunc",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"findnextmatch",
"if",
"\"DOWN\"",
"in",
"flags",
":",
"if",
"gridpos",
"[",
"0",
"]",
"<",
"self",
".",
"grid",
".",
"code_array",
".",
"shape",
"[",
"0",
"]",
":",
"gridpos",
"[",
"0",
"]",
"+=",
"1",
"elif",
"gridpos",
"[",
"1",
"]",
"<",
"self",
".",
"grid",
".",
"code_array",
".",
"shape",
"[",
"1",
"]",
":",
"gridpos",
"[",
"1",
"]",
"+=",
"1",
"elif",
"gridpos",
"[",
"2",
"]",
"<",
"self",
".",
"grid",
".",
"code_array",
".",
"shape",
"[",
"2",
"]",
":",
"gridpos",
"[",
"2",
"]",
"+=",
"1",
"else",
":",
"gridpos",
"=",
"(",
"0",
",",
"0",
",",
"0",
")",
"elif",
"\"UP\"",
"in",
"flags",
":",
"if",
"gridpos",
"[",
"0",
"]",
">",
"0",
":",
"gridpos",
"[",
"0",
"]",
"-=",
"1",
"elif",
"gridpos",
"[",
"1",
"]",
">",
"0",
":",
"gridpos",
"[",
"1",
"]",
"-=",
"1",
"elif",
"gridpos",
"[",
"2",
"]",
">",
"0",
":",
"gridpos",
"[",
"2",
"]",
"-=",
"1",
"else",
":",
"gridpos",
"=",
"[",
"dim",
"-",
"1",
"for",
"dim",
"in",
"self",
".",
"grid",
".",
"code_array",
".",
"shape",
"]",
"return",
"findfunc",
"(",
"tuple",
"(",
"gridpos",
")",
",",
"find_string",
",",
"flags",
",",
"search_result",
")"
] | 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 "DOWN", "WHOLE_WORD", "MATCH_CASE", "REG_EXP"]
search_result: Bool, defaults to True
\tIf True then the search includes the result string (slower) | [
"Return",
"next",
"position",
"of",
"event_find_string",
"in",
"MainGrid"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1750-L1788 | train | 231,520 |
manns/pyspread | pyspread/src/actions/_grid_actions.py | AllGridActions._replace_bbox_none | 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_bottom = self.code_array.shape[0] - 1
if bb_right is None:
bb_right = self.code_array.shape[1] - 1
return (bb_top, bb_left), (bb_bottom, bb_right) | python | 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_bottom = self.code_array.shape[0] - 1
if bb_right is None:
bb_right = self.code_array.shape[1] - 1
return (bb_top, bb_left), (bb_bottom, bb_right) | [
"def",
"_replace_bbox_none",
"(",
"self",
",",
"bbox",
")",
":",
"(",
"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_bottom",
"=",
"self",
".",
"code_array",
".",
"shape",
"[",
"0",
"]",
"-",
"1",
"if",
"bb_right",
"is",
"None",
":",
"bb_right",
"=",
"self",
".",
"code_array",
".",
"shape",
"[",
"1",
"]",
"-",
"1",
"return",
"(",
"bb_top",
",",
"bb_left",
")",
",",
"(",
"bb_bottom",
",",
"bb_right",
")"
] | Returns bbox, in which None is replaced by grid boundaries | [
"Returns",
"bbox",
"in",
"which",
"None",
"is",
"replaced",
"by",
"grid",
"boundaries"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1869-L1886 | train | 231,521 |
manns/pyspread | pyspread/src/lib/filetypes.py | get_filetypes2wildcards | 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
\tFiletype list
"""
def is_available(filetype):
return filetype not in FILETYPE_AVAILABILITY or \
FILETYPE_AVAILABILITY[filetype]
available_filetypes = filter(is_available, filetypes)
return OrderedDict((ft, FILETYPE2WILDCARD[ft])
for ft in available_filetypes) | python | 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
\tFiletype list
"""
def is_available(filetype):
return filetype not in FILETYPE_AVAILABILITY or \
FILETYPE_AVAILABILITY[filetype]
available_filetypes = filter(is_available, filetypes)
return OrderedDict((ft, FILETYPE2WILDCARD[ft])
for ft in available_filetypes) | [
"def",
"get_filetypes2wildcards",
"(",
"filetypes",
")",
":",
"def",
"is_available",
"(",
"filetype",
")",
":",
"return",
"filetype",
"not",
"in",
"FILETYPE_AVAILABILITY",
"or",
"FILETYPE_AVAILABILITY",
"[",
"filetype",
"]",
"available_filetypes",
"=",
"filter",
"(",
"is_available",
",",
"filetypes",
")",
"return",
"OrderedDict",
"(",
"(",
"ft",
",",
"FILETYPE2WILDCARD",
"[",
"ft",
"]",
")",
"for",
"ft",
"in",
"available_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
\tFiletype list | [
"Returns",
"OrderedDict",
"of",
"filetypes",
"to",
"wildcards"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/filetypes.py#L101-L121 | train | 231,522 |
manns/pyspread | pyspread/src/gui/_gui_interfaces.py | get_key_params_from_user | 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 = [""] * len(params)
while "" in vals:
dlg = GPGParamsDialog(None, -1, "Enter GPG key parameters", params)
dlg.CenterOnScreen()
for val, textctrl in zip(vals, dlg.textctrls):
textctrl.SetValue(val)
if dlg.ShowModal() != wx.ID_OK:
dlg.Destroy()
return
vals = [textctrl.Value for textctrl in dlg.textctrls]
dlg.Destroy()
if "" in vals:
msg = _("Please enter a value in each field.")
dlg = GMD.GenericMessageDialog(None, msg, _("Missing value"),
wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()
for (__, key), val in zip(params, vals):
gpg_key_param_list.insert(-2, (key, val))
return dict(gpg_key_param_list) | python | 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 = [""] * len(params)
while "" in vals:
dlg = GPGParamsDialog(None, -1, "Enter GPG key parameters", params)
dlg.CenterOnScreen()
for val, textctrl in zip(vals, dlg.textctrls):
textctrl.SetValue(val)
if dlg.ShowModal() != wx.ID_OK:
dlg.Destroy()
return
vals = [textctrl.Value for textctrl in dlg.textctrls]
dlg.Destroy()
if "" in vals:
msg = _("Please enter a value in each field.")
dlg = GMD.GenericMessageDialog(None, msg, _("Missing value"),
wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()
for (__, key), val in zip(params, vals):
gpg_key_param_list.insert(-2, (key, val))
return dict(gpg_key_param_list) | [
"def",
"get_key_params_from_user",
"(",
"gpg_key_param_list",
")",
":",
"params",
"=",
"[",
"[",
"_",
"(",
"'Real name'",
")",
",",
"'name_real'",
"]",
"]",
"vals",
"=",
"[",
"\"\"",
"]",
"*",
"len",
"(",
"params",
")",
"while",
"\"\"",
"in",
"vals",
":",
"dlg",
"=",
"GPGParamsDialog",
"(",
"None",
",",
"-",
"1",
",",
"\"Enter GPG key parameters\"",
",",
"params",
")",
"dlg",
".",
"CenterOnScreen",
"(",
")",
"for",
"val",
",",
"textctrl",
"in",
"zip",
"(",
"vals",
",",
"dlg",
".",
"textctrls",
")",
":",
"textctrl",
".",
"SetValue",
"(",
"val",
")",
"if",
"dlg",
".",
"ShowModal",
"(",
")",
"!=",
"wx",
".",
"ID_OK",
":",
"dlg",
".",
"Destroy",
"(",
")",
"return",
"vals",
"=",
"[",
"textctrl",
".",
"Value",
"for",
"textctrl",
"in",
"dlg",
".",
"textctrls",
"]",
"dlg",
".",
"Destroy",
"(",
")",
"if",
"\"\"",
"in",
"vals",
":",
"msg",
"=",
"_",
"(",
"\"Please enter a value in each field.\"",
")",
"dlg",
"=",
"GMD",
".",
"GenericMessageDialog",
"(",
"None",
",",
"msg",
",",
"_",
"(",
"\"Missing value\"",
")",
",",
"wx",
".",
"OK",
"|",
"wx",
".",
"ICON_ERROR",
")",
"dlg",
".",
"ShowModal",
"(",
")",
"dlg",
".",
"Destroy",
"(",
")",
"for",
"(",
"__",
",",
"key",
")",
",",
"val",
"in",
"zip",
"(",
"params",
",",
"vals",
")",
":",
"gpg_key_param_list",
".",
"insert",
"(",
"-",
"2",
",",
"(",
"key",
",",
"val",
")",
")",
"return",
"dict",
"(",
"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 | [
"Displays",
"parameter",
"entry",
"dialog",
"and",
"returns",
"parameter",
"dict"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_gui_interfaces.py#L383-L424 | train | 231,523 |
manns/pyspread | pyspread/src/gui/_gui_interfaces.py | ModalDialogInterfaceMixin.get_dimensions_from_user | 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:
raise NotImplementedError(
_("Currently, only 3D grids are supported."))
dim_dialog = DimensionsEntryDialog(self.main_window)
if dim_dialog.ShowModal() != wx.ID_OK:
dim_dialog.Destroy()
return
dim = tuple(dim_dialog.dimensions)
dim_dialog.Destroy()
return dim | python | 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:
raise NotImplementedError(
_("Currently, only 3D grids are supported."))
dim_dialog = DimensionsEntryDialog(self.main_window)
if dim_dialog.ShowModal() != wx.ID_OK:
dim_dialog.Destroy()
return
dim = tuple(dim_dialog.dimensions)
dim_dialog.Destroy()
return dim | [
"def",
"get_dimensions_from_user",
"(",
"self",
",",
"no_dim",
")",
":",
"# Grid dimension dialog",
"if",
"no_dim",
"!=",
"3",
":",
"raise",
"NotImplementedError",
"(",
"_",
"(",
"\"Currently, only 3D grids are supported.\"",
")",
")",
"dim_dialog",
"=",
"DimensionsEntryDialog",
"(",
"self",
".",
"main_window",
")",
"if",
"dim_dialog",
".",
"ShowModal",
"(",
")",
"!=",
"wx",
".",
"ID_OK",
":",
"dim_dialog",
".",
"Destroy",
"(",
")",
"return",
"dim",
"=",
"tuple",
"(",
"dim_dialog",
".",
"dimensions",
")",
"dim_dialog",
".",
"Destroy",
"(",
")",
"return",
"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 | [
"Queries",
"grid",
"dimensions",
"in",
"a",
"model",
"dialog",
"and",
"returns",
"n",
"-",
"tuple"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_gui_interfaces.py#L64-L89 | train | 231,524 |
manns/pyspread | pyspread/src/gui/_gui_interfaces.py | ModalDialogInterfaceMixin.get_preferences_from_user | 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.parameters, dlg.textctrls):
if isinstance(ctrl, wx.Choice):
value = ctrl.GetStringSelection()
if value:
preferences[parameter] = repr(value)
else:
preferences[parameter] = repr(ctrl.Value)
dlg.Destroy()
return preferences | python | 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.parameters, dlg.textctrls):
if isinstance(ctrl, wx.Choice):
value = ctrl.GetStringSelection()
if value:
preferences[parameter] = repr(value)
else:
preferences[parameter] = repr(ctrl.Value)
dlg.Destroy()
return preferences | [
"def",
"get_preferences_from_user",
"(",
"self",
")",
":",
"dlg",
"=",
"PreferencesDialog",
"(",
"self",
".",
"main_window",
")",
"change_choice",
"=",
"dlg",
".",
"ShowModal",
"(",
")",
"preferences",
"=",
"{",
"}",
"if",
"change_choice",
"==",
"wx",
".",
"ID_OK",
":",
"for",
"(",
"parameter",
",",
"_",
")",
",",
"ctrl",
"in",
"zip",
"(",
"dlg",
".",
"parameters",
",",
"dlg",
".",
"textctrls",
")",
":",
"if",
"isinstance",
"(",
"ctrl",
",",
"wx",
".",
"Choice",
")",
":",
"value",
"=",
"ctrl",
".",
"GetStringSelection",
"(",
")",
"if",
"value",
":",
"preferences",
"[",
"parameter",
"]",
"=",
"repr",
"(",
"value",
")",
"else",
":",
"preferences",
"[",
"parameter",
"]",
"=",
"repr",
"(",
"ctrl",
".",
"Value",
")",
"dlg",
".",
"Destroy",
"(",
")",
"return",
"preferences"
] | Launches preferences dialog and returns dict with preferences | [
"Launches",
"preferences",
"dialog",
"and",
"returns",
"dict",
"with",
"preferences"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_gui_interfaces.py#L91-L111 | train | 231,525 |
manns/pyspread | pyspread/src/gui/_gui_interfaces.py | ModalDialogInterfaceMixin.get_save_request_from_user | 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)
save_choice = dlg.ShowModal()
dlg.Destroy()
if save_choice == wx.ID_YES:
return True
elif save_choice == wx.ID_NO:
return False | python | 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)
save_choice = dlg.ShowModal()
dlg.Destroy()
if save_choice == wx.ID_YES:
return True
elif save_choice == wx.ID_NO:
return False | [
"def",
"get_save_request_from_user",
"(",
"self",
")",
":",
"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",
")",
"save_choice",
"=",
"dlg",
".",
"ShowModal",
"(",
")",
"dlg",
".",
"Destroy",
"(",
")",
"if",
"save_choice",
"==",
"wx",
".",
"ID_YES",
":",
"return",
"True",
"elif",
"save_choice",
"==",
"wx",
".",
"ID_NO",
":",
"return",
"False"
] | Queries user if grid should be saved | [
"Queries",
"user",
"if",
"grid",
"should",
"be",
"saved"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_gui_interfaces.py#L113-L130 | train | 231,526 |
manns/pyspread | pyspread/src/gui/_gui_interfaces.py | ModalDialogInterfaceMixin.get_filepath_findex_from_user | 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
\tMessage in the file dialog
style: Integer
\tDialog style, e. g. wx.OPEN | wx.CHANGE_DIR
filterindex: Integer, defaults to 0
\tDefault filterindex that is selected when the dialog is displayed
"""
dlg = wx.FileDialog(self.main_window, wildcard=wildcard,
message=message, style=style,
defaultDir=os.getcwd(), defaultFile="")
# Set the initial filterindex
dlg.SetFilterIndex(filterindex)
filepath = None
filter_index = None
if dlg.ShowModal() == wx.ID_OK:
filepath = dlg.GetPath()
filter_index = dlg.GetFilterIndex()
dlg.Destroy()
return filepath, filter_index | python | 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
\tMessage in the file dialog
style: Integer
\tDialog style, e. g. wx.OPEN | wx.CHANGE_DIR
filterindex: Integer, defaults to 0
\tDefault filterindex that is selected when the dialog is displayed
"""
dlg = wx.FileDialog(self.main_window, wildcard=wildcard,
message=message, style=style,
defaultDir=os.getcwd(), defaultFile="")
# Set the initial filterindex
dlg.SetFilterIndex(filterindex)
filepath = None
filter_index = None
if dlg.ShowModal() == wx.ID_OK:
filepath = dlg.GetPath()
filter_index = dlg.GetFilterIndex()
dlg.Destroy()
return filepath, filter_index | [
"def",
"get_filepath_findex_from_user",
"(",
"self",
",",
"wildcard",
",",
"message",
",",
"style",
",",
"filterindex",
"=",
"0",
")",
":",
"dlg",
"=",
"wx",
".",
"FileDialog",
"(",
"self",
".",
"main_window",
",",
"wildcard",
"=",
"wildcard",
",",
"message",
"=",
"message",
",",
"style",
"=",
"style",
",",
"defaultDir",
"=",
"os",
".",
"getcwd",
"(",
")",
",",
"defaultFile",
"=",
"\"\"",
")",
"# Set the initial filterindex",
"dlg",
".",
"SetFilterIndex",
"(",
"filterindex",
")",
"filepath",
"=",
"None",
"filter_index",
"=",
"None",
"if",
"dlg",
".",
"ShowModal",
"(",
")",
"==",
"wx",
".",
"ID_OK",
":",
"filepath",
"=",
"dlg",
".",
"GetPath",
"(",
")",
"filter_index",
"=",
"dlg",
".",
"GetFilterIndex",
"(",
")",
"dlg",
".",
"Destroy",
"(",
")",
"return",
"filepath",
",",
"filter_index"
] | 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: Integer, defaults to 0
\tDefault filterindex that is selected when the dialog is displayed | [
"Opens",
"a",
"file",
"dialog",
"and",
"returns",
"filepath",
"and",
"filterindex"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_gui_interfaces.py#L132-L165 | train | 231,527 |
manns/pyspread | pyspread/src/gui/_gui_interfaces.py | ModalDialogInterfaceMixin.display_warning | 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 | 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() | [
"def",
"display_warning",
"(",
"self",
",",
"message",
",",
"short_message",
",",
"style",
"=",
"wx",
".",
"OK",
"|",
"wx",
".",
"ICON_WARNING",
")",
":",
"dlg",
"=",
"GMD",
".",
"GenericMessageDialog",
"(",
"self",
".",
"main_window",
",",
"message",
",",
"short_message",
",",
"style",
")",
"dlg",
".",
"ShowModal",
"(",
")",
"dlg",
".",
"Destroy",
"(",
")"
] | Displays a warning message | [
"Displays",
"a",
"warning",
"message"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_gui_interfaces.py#L167-L174 | train | 231,528 |
manns/pyspread | pyspread/src/gui/_gui_interfaces.py | ModalDialogInterfaceMixin.get_warning_choice | 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_message, style)
choice = dlg.ShowModal()
dlg.Destroy()
return choice == wx.ID_YES | python | 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_message, style)
choice = dlg.ShowModal()
dlg.Destroy()
return choice == wx.ID_YES | [
"def",
"get_warning_choice",
"(",
"self",
",",
"message",
",",
"short_message",
",",
"style",
"=",
"wx",
".",
"YES_NO",
"|",
"wx",
".",
"NO_DEFAULT",
"|",
"wx",
".",
"ICON_WARNING",
")",
":",
"dlg",
"=",
"GMD",
".",
"GenericMessageDialog",
"(",
"self",
".",
"main_window",
",",
"message",
",",
"short_message",
",",
"style",
")",
"choice",
"=",
"dlg",
".",
"ShowModal",
"(",
")",
"dlg",
".",
"Destroy",
"(",
")",
"return",
"choice",
"==",
"wx",
".",
"ID_YES"
] | Launches proceeding dialog and returns True if ok to proceed | [
"Launches",
"proceeding",
"dialog",
"and",
"returns",
"True",
"if",
"ok",
"to",
"proceed"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_gui_interfaces.py#L176-L187 | train | 231,529 |
manns/pyspread | pyspread/src/gui/_gui_interfaces.py | ModalDialogInterfaceMixin.get_print_setup | 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 makes a copy of the wx.PrintData instead of just saving
# a reference to the one inside the PrintDialogData that will
# be destroyed when the dialog is destroyed
data = dlg.GetPageSetupData()
new_print_data = wx.PrintData(data.GetPrintData())
new_print_data.PaperId = data.PaperId
new_print_data.PaperSize = data.PaperSize
dlg.Destroy()
return new_print_data | python | 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 makes a copy of the wx.PrintData instead of just saving
# a reference to the one inside the PrintDialogData that will
# be destroyed when the dialog is destroyed
data = dlg.GetPageSetupData()
new_print_data = wx.PrintData(data.GetPrintData())
new_print_data.PaperId = data.PaperId
new_print_data.PaperSize = data.PaperSize
dlg.Destroy()
return new_print_data | [
"def",
"get_print_setup",
"(",
"self",
",",
"print_data",
")",
":",
"psd",
"=",
"wx",
".",
"PageSetupDialogData",
"(",
"print_data",
")",
"# psd.EnablePrinter(False)",
"psd",
".",
"CalculatePaperSizeFromId",
"(",
")",
"dlg",
"=",
"wx",
".",
"PageSetupDialog",
"(",
"self",
".",
"main_window",
",",
"psd",
")",
"dlg",
".",
"ShowModal",
"(",
")",
"# this makes a copy of the wx.PrintData instead of just saving",
"# a reference to the one inside the PrintDialogData that will",
"# be destroyed when the dialog is destroyed",
"data",
"=",
"dlg",
".",
"GetPageSetupData",
"(",
")",
"new_print_data",
"=",
"wx",
".",
"PrintData",
"(",
"data",
".",
"GetPrintData",
"(",
")",
")",
"new_print_data",
".",
"PaperId",
"=",
"data",
".",
"PaperId",
"new_print_data",
".",
"PaperSize",
"=",
"data",
".",
"PaperSize",
"dlg",
".",
"Destroy",
"(",
")",
"return",
"new_print_data"
] | Opens print setup dialog and returns print_data | [
"Opens",
"print",
"setup",
"dialog",
"and",
"returns",
"print_data"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_gui_interfaces.py#L189-L208 | train | 231,530 |
manns/pyspread | pyspread/src/gui/_gui_interfaces.py | ModalDialogInterfaceMixin.get_csv_import_info | 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]
try:
filterdlg = CsvImportDialog(self.main_window, csvfilepath=path)
except csv.Error, err:
# Display modal warning dialog
msg = _("'{filepath}' does not seem to be a valid CSV file.\n \n"
"Opening it yielded the error:\n{error}")
msg = msg.format(filepath=csvfilename, error=err)
short_msg = _('Error reading CSV file')
self.display_warning(msg, short_msg)
return
if filterdlg.ShowModal() == wx.ID_OK:
dialect, has_header = filterdlg.csvwidgets.get_dialect()
digest_types = filterdlg.grid.dtypes
encoding = filterdlg.csvwidgets.encoding
else:
filterdlg.Destroy()
return
filterdlg.Destroy()
return dialect, has_header, digest_types, encoding | python | 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]
try:
filterdlg = CsvImportDialog(self.main_window, csvfilepath=path)
except csv.Error, err:
# Display modal warning dialog
msg = _("'{filepath}' does not seem to be a valid CSV file.\n \n"
"Opening it yielded the error:\n{error}")
msg = msg.format(filepath=csvfilename, error=err)
short_msg = _('Error reading CSV file')
self.display_warning(msg, short_msg)
return
if filterdlg.ShowModal() == wx.ID_OK:
dialect, has_header = filterdlg.csvwidgets.get_dialect()
digest_types = filterdlg.grid.dtypes
encoding = filterdlg.csvwidgets.encoding
else:
filterdlg.Destroy()
return
filterdlg.Destroy()
return dialect, has_header, digest_types, encoding | [
"def",
"get_csv_import_info",
"(",
"self",
",",
"path",
")",
":",
"csvfilename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"[",
"1",
"]",
"try",
":",
"filterdlg",
"=",
"CsvImportDialog",
"(",
"self",
".",
"main_window",
",",
"csvfilepath",
"=",
"path",
")",
"except",
"csv",
".",
"Error",
",",
"err",
":",
"# Display modal warning dialog",
"msg",
"=",
"_",
"(",
"\"'{filepath}' does not seem to be a valid CSV file.\\n \\n\"",
"\"Opening it yielded the error:\\n{error}\"",
")",
"msg",
"=",
"msg",
".",
"format",
"(",
"filepath",
"=",
"csvfilename",
",",
"error",
"=",
"err",
")",
"short_msg",
"=",
"_",
"(",
"'Error reading CSV file'",
")",
"self",
".",
"display_warning",
"(",
"msg",
",",
"short_msg",
")",
"return",
"if",
"filterdlg",
".",
"ShowModal",
"(",
")",
"==",
"wx",
".",
"ID_OK",
":",
"dialect",
",",
"has_header",
"=",
"filterdlg",
".",
"csvwidgets",
".",
"get_dialect",
"(",
")",
"digest_types",
"=",
"filterdlg",
".",
"grid",
".",
"dtypes",
"encoding",
"=",
"filterdlg",
".",
"csvwidgets",
".",
"encoding",
"else",
":",
"filterdlg",
".",
"Destroy",
"(",
")",
"return",
"filterdlg",
".",
"Destroy",
"(",
")",
"return",
"dialect",
",",
"has_header",
",",
"digest_types",
",",
"encoding"
] | 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 | [
"Launches",
"the",
"csv",
"dialog",
"and",
"returns",
"csv_info"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_gui_interfaces.py#L210-L252 | train | 231,531 |
manns/pyspread | pyspread/src/gui/_gui_interfaces.py | ModalDialogInterfaceMixin.get_csv_export_info | 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
"""
preview_rows = 100
preview_cols = 100
export_preview = list(list(islice(col, None, preview_cols))
for col in islice(preview_data, None,
preview_rows))
filterdlg = CsvExportDialog(self.main_window, data=export_preview)
if filterdlg.ShowModal() == wx.ID_OK:
dialect, has_header = filterdlg.csvwidgets.get_dialect()
digest_types = [types.StringType]
else:
filterdlg.Destroy()
return
filterdlg.Destroy()
return dialect, has_header, digest_types | python | 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
"""
preview_rows = 100
preview_cols = 100
export_preview = list(list(islice(col, None, preview_cols))
for col in islice(preview_data, None,
preview_rows))
filterdlg = CsvExportDialog(self.main_window, data=export_preview)
if filterdlg.ShowModal() == wx.ID_OK:
dialect, has_header = filterdlg.csvwidgets.get_dialect()
digest_types = [types.StringType]
else:
filterdlg.Destroy()
return
filterdlg.Destroy()
return dialect, has_header, digest_types | [
"def",
"get_csv_export_info",
"(",
"self",
",",
"preview_data",
")",
":",
"preview_rows",
"=",
"100",
"preview_cols",
"=",
"100",
"export_preview",
"=",
"list",
"(",
"list",
"(",
"islice",
"(",
"col",
",",
"None",
",",
"preview_cols",
")",
")",
"for",
"col",
"in",
"islice",
"(",
"preview_data",
",",
"None",
",",
"preview_rows",
")",
")",
"filterdlg",
"=",
"CsvExportDialog",
"(",
"self",
".",
"main_window",
",",
"data",
"=",
"export_preview",
")",
"if",
"filterdlg",
".",
"ShowModal",
"(",
")",
"==",
"wx",
".",
"ID_OK",
":",
"dialect",
",",
"has_header",
"=",
"filterdlg",
".",
"csvwidgets",
".",
"get_dialect",
"(",
")",
"digest_types",
"=",
"[",
"types",
".",
"StringType",
"]",
"else",
":",
"filterdlg",
".",
"Destroy",
"(",
")",
"return",
"filterdlg",
".",
"Destroy",
"(",
")",
"return",
"dialect",
",",
"has_header",
",",
"digest_types"
] | 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",
"csv",
"export",
"preview",
"dialog",
"and",
"returns",
"csv_info"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_gui_interfaces.py#L254-L284 | train | 231,532 |
manns/pyspread | pyspread/src/gui/_gui_interfaces.py | ModalDialogInterfaceMixin.get_cairo_export_info | 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=filetype)
if export_dlg.ShowModal() == wx.ID_OK:
info = export_dlg.get_info()
export_dlg.Destroy()
return info
else:
export_dlg.Destroy() | python | 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=filetype)
if export_dlg.ShowModal() == wx.ID_OK:
info = export_dlg.get_info()
export_dlg.Destroy()
return info
else:
export_dlg.Destroy() | [
"def",
"get_cairo_export_info",
"(",
"self",
",",
"filetype",
")",
":",
"export_dlg",
"=",
"CairoExportDialog",
"(",
"self",
".",
"main_window",
",",
"filetype",
"=",
"filetype",
")",
"if",
"export_dlg",
".",
"ShowModal",
"(",
")",
"==",
"wx",
".",
"ID_OK",
":",
"info",
"=",
"export_dlg",
".",
"get_info",
"(",
")",
"export_dlg",
".",
"Destroy",
"(",
")",
"return",
"info",
"else",
":",
"export_dlg",
".",
"Destroy",
"(",
")"
] | Shows Cairo export dialog and returns info
Parameters
----------
filetype: String in ["pdf", "svg"]
\tFile type for which export info is gathered | [
"Shows",
"Cairo",
"export",
"dialog",
"and",
"returns",
"info"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_gui_interfaces.py#L286-L304 | train | 231,533 |
manns/pyspread | pyspread/src/gui/_gui_interfaces.py | ModalDialogInterfaceMixin.get_int_from_user | 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 int(<entry_value> then result is returned.
\tOtherwise the dialog pops up again.
"""
is_integer = False
while not is_integer:
dlg = wx.TextEntryDialog(None, title, title)
if dlg.ShowModal() == wx.ID_OK:
result = dlg.GetValue()
else:
return None
dlg.Destroy()
try:
integer = int(result)
if cond_func(integer):
is_integer = True
except ValueError:
pass
return integer | python | 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 int(<entry_value> then result is returned.
\tOtherwise the dialog pops up again.
"""
is_integer = False
while not is_integer:
dlg = wx.TextEntryDialog(None, title, title)
if dlg.ShowModal() == wx.ID_OK:
result = dlg.GetValue()
else:
return None
dlg.Destroy()
try:
integer = int(result)
if cond_func(integer):
is_integer = True
except ValueError:
pass
return integer | [
"def",
"get_int_from_user",
"(",
"self",
",",
"title",
"=",
"\"Enter integer value\"",
",",
"cond_func",
"=",
"lambda",
"i",
":",
"i",
"is",
"not",
"None",
")",
":",
"is_integer",
"=",
"False",
"while",
"not",
"is_integer",
":",
"dlg",
"=",
"wx",
".",
"TextEntryDialog",
"(",
"None",
",",
"title",
",",
"title",
")",
"if",
"dlg",
".",
"ShowModal",
"(",
")",
"==",
"wx",
".",
"ID_OK",
":",
"result",
"=",
"dlg",
".",
"GetValue",
"(",
")",
"else",
":",
"return",
"None",
"dlg",
".",
"Destroy",
"(",
")",
"try",
":",
"integer",
"=",
"int",
"(",
"result",
")",
"if",
"cond_func",
"(",
"integer",
")",
":",
"is_integer",
"=",
"True",
"except",
"ValueError",
":",
"pass",
"return",
"integer"
] | 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. | [
"Opens",
"an",
"integer",
"entry",
"dialog",
"and",
"returns",
"integer"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_gui_interfaces.py#L306-L341 | train | 231,534 |
manns/pyspread | pyspread/src/gui/_gui_interfaces.py | ModalDialogInterfaceMixin.get_pasteas_parameters_from_user | 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 = {}
parameters.update(dlg.parameters)
dlg.Destroy()
return parameters | python | 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 = {}
parameters.update(dlg.parameters)
dlg.Destroy()
return parameters | [
"def",
"get_pasteas_parameters_from_user",
"(",
"self",
",",
"obj",
")",
":",
"dlg",
"=",
"PasteAsDialog",
"(",
"None",
",",
"-",
"1",
",",
"obj",
")",
"dlg_choice",
"=",
"dlg",
".",
"ShowModal",
"(",
")",
"if",
"dlg_choice",
"!=",
"wx",
".",
"ID_OK",
":",
"dlg",
".",
"Destroy",
"(",
")",
"return",
"None",
"parameters",
"=",
"{",
"}",
"parameters",
".",
"update",
"(",
"dlg",
".",
"parameters",
")",
"dlg",
".",
"Destroy",
"(",
")",
"return",
"parameters"
] | Opens a PasteAsDialog and returns parameters dict | [
"Opens",
"a",
"PasteAsDialog",
"and",
"returns",
"parameters",
"dict"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_gui_interfaces.py#L343-L357 | train | 231,535 |
manns/pyspread | pyspread/src/gui/_grid_cell_editor.py | GridCellEditor._execute_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() | python | def _execute_cell_code(self, row, col, grid):
"""Executes cell code"""
key = row, col, grid.current_table
grid.code_array[key]
grid.ForceRefresh() | [
"def",
"_execute_cell_code",
"(",
"self",
",",
"row",
",",
"col",
",",
"grid",
")",
":",
"key",
"=",
"row",
",",
"col",
",",
"grid",
".",
"current_table",
"grid",
".",
"code_array",
"[",
"key",
"]",
"grid",
".",
"ForceRefresh",
"(",
")"
] | Executes cell code | [
"Executes",
"cell",
"code"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid_cell_editor.py#L119-L125 | train | 231,536 |
manns/pyspread | pyspread/src/gui/_grid_cell_editor.py | GridCellEditor.StartingKey | 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_NUMPAD1, wx.WXK_NUMPAD2, wx.WXK_NUMPAD3,
wx.WXK_NUMPAD4, wx.WXK_NUMPAD5, wx.WXK_NUMPAD6, wx.WXK_NUMPAD7,
wx.WXK_NUMPAD8, wx.WXK_NUMPAD9]:
ch = ch = chr(ord('0') + key - wx.WXK_NUMPAD0)
elif key < 256 and key >= 0 and chr(key) in string.printable:
ch = chr(key)
if ch is not None and self._tc.IsEnabled():
# For this example, replace the text. Normally we would append it.
#self._tc.AppendText(ch)
self._tc.SetValue(ch)
self._tc.SetInsertionPointEnd()
else:
evt.Skip() | python | 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_NUMPAD1, wx.WXK_NUMPAD2, wx.WXK_NUMPAD3,
wx.WXK_NUMPAD4, wx.WXK_NUMPAD5, wx.WXK_NUMPAD6, wx.WXK_NUMPAD7,
wx.WXK_NUMPAD8, wx.WXK_NUMPAD9]:
ch = ch = chr(ord('0') + key - wx.WXK_NUMPAD0)
elif key < 256 and key >= 0 and chr(key) in string.printable:
ch = chr(key)
if ch is not None and self._tc.IsEnabled():
# For this example, replace the text. Normally we would append it.
#self._tc.AppendText(ch)
self._tc.SetValue(ch)
self._tc.SetInsertionPointEnd()
else:
evt.Skip() | [
"def",
"StartingKey",
"(",
"self",
",",
"evt",
")",
":",
"key",
"=",
"evt",
".",
"GetKeyCode",
"(",
")",
"ch",
"=",
"None",
"if",
"key",
"in",
"[",
"wx",
".",
"WXK_NUMPAD0",
",",
"wx",
".",
"WXK_NUMPAD1",
",",
"wx",
".",
"WXK_NUMPAD2",
",",
"wx",
".",
"WXK_NUMPAD3",
",",
"wx",
".",
"WXK_NUMPAD4",
",",
"wx",
".",
"WXK_NUMPAD5",
",",
"wx",
".",
"WXK_NUMPAD6",
",",
"wx",
".",
"WXK_NUMPAD7",
",",
"wx",
".",
"WXK_NUMPAD8",
",",
"wx",
".",
"WXK_NUMPAD9",
"]",
":",
"ch",
"=",
"ch",
"=",
"chr",
"(",
"ord",
"(",
"'0'",
")",
"+",
"key",
"-",
"wx",
".",
"WXK_NUMPAD0",
")",
"elif",
"key",
"<",
"256",
"and",
"key",
">=",
"0",
"and",
"chr",
"(",
"key",
")",
"in",
"string",
".",
"printable",
":",
"ch",
"=",
"chr",
"(",
"key",
")",
"if",
"ch",
"is",
"not",
"None",
"and",
"self",
".",
"_tc",
".",
"IsEnabled",
"(",
")",
":",
"# For this example, replace the text. Normally we would append it.",
"#self._tc.AppendText(ch)",
"self",
".",
"_tc",
".",
"SetValue",
"(",
"ch",
")",
"self",
".",
"_tc",
".",
"SetInsertionPointEnd",
"(",
")",
"else",
":",
"evt",
".",
"Skip",
"(",
")"
] | 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. | [
"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",
"."
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid_cell_editor.py#L264-L288 | train | 231,537 |
manns/pyspread | pyspread/src/gui/_printout.py | Printout.GetPageInfo | 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 | 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 | [
"def",
"GetPageInfo",
"(",
"self",
")",
":",
"return",
"self",
".",
"first_tab",
",",
"self",
".",
"last_tab",
",",
"self",
".",
"first_tab",
",",
"self",
".",
"last_tab"
] | Returns page information
What is the page range available, and what is the selected page range. | [
"Returns",
"page",
"information"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_printout.py#L87-L94 | train | 231,538 |
manns/pyspread | pyspread/src/lib/_string_helpers.py | quote | 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
return code
if code and code[0] + code[-1] not in ('""', "''", "u'", '"') \
and '"' not in code:
return 'u"' + code + '"'
else:
return code | python | 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
return code
if code and code[0] + code[-1] not in ('""', "''", "u'", '"') \
and '"' not in code:
return 'u"' + code + '"'
else:
return code | [
"def",
"quote",
"(",
"code",
")",
":",
"try",
":",
"code",
"=",
"code",
".",
"rstrip",
"(",
")",
"except",
"AttributeError",
":",
"# code is not a string, may be None --> There is no code to quote",
"return",
"code",
"if",
"code",
"and",
"code",
"[",
"0",
"]",
"+",
"code",
"[",
"-",
"1",
"]",
"not",
"in",
"(",
"'\"\"'",
",",
"\"''\"",
",",
"\"u'\"",
",",
"'\"'",
")",
"and",
"'\"'",
"not",
"in",
"code",
":",
"return",
"'u\"'",
"+",
"code",
"+",
"'\"'",
"else",
":",
"return",
"code"
] | Returns quoted code if not already quoted and if possible
Parameters
----------
code: String
\tCode thta is quoted | [
"Returns",
"quoted",
"code",
"if",
"not",
"already",
"quoted",
"and",
"if",
"possible"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/_string_helpers.py#L35-L57 | train | 231,539 |
manns/pyspread | pyspread/src/gui/_grid.py | 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
# (When true, a cross-hatch is displayed for frozen cells)
self._view_frozen = False
# Timer for updating frozen cells
self.timer_running = False | python | 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
# (When true, a cross-hatch is displayed for frozen cells)
self._view_frozen = False
# Timer for updating frozen cells
self.timer_running = False | [
"def",
"_states",
"(",
"self",
")",
":",
"# 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",
"# (When true, a cross-hatch is displayed for frozen cells)",
"self",
".",
"_view_frozen",
"=",
"False",
"# Timer for updating frozen cells",
"self",
".",
"timer_running",
"=",
"False"
] | Sets grid states | [
"Sets",
"grid",
"states"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L132-L146 | train | 231,540 |
manns/pyspread | pyspread/src/gui/_grid.py | Grid._layout | 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"]
self.std_col_size = default_cell_attributes["column-width"]
self.SetDefaultRowSize(self.std_row_size)
self.SetDefaultColSize(self.std_col_size)
# Standard row and col label sizes for zooming
self.col_label_size = self.GetColLabelSize()
self.row_label_size = self.GetRowLabelSize()
self.SetRowMinimalAcceptableHeight(1)
self.SetColMinimalAcceptableWidth(1)
self.SetCellHighlightPenWidth(0) | python | 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"]
self.std_col_size = default_cell_attributes["column-width"]
self.SetDefaultRowSize(self.std_row_size)
self.SetDefaultColSize(self.std_col_size)
# Standard row and col label sizes for zooming
self.col_label_size = self.GetColLabelSize()
self.row_label_size = self.GetRowLabelSize()
self.SetRowMinimalAcceptableHeight(1)
self.SetColMinimalAcceptableWidth(1)
self.SetCellHighlightPenWidth(0) | [
"def",
"_layout",
"(",
"self",
")",
":",
"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\"",
"]",
"self",
".",
"std_col_size",
"=",
"default_cell_attributes",
"[",
"\"column-width\"",
"]",
"self",
".",
"SetDefaultRowSize",
"(",
"self",
".",
"std_row_size",
")",
"self",
".",
"SetDefaultColSize",
"(",
"self",
".",
"std_col_size",
")",
"# Standard row and col label sizes for zooming",
"self",
".",
"col_label_size",
"=",
"self",
".",
"GetColLabelSize",
"(",
")",
"self",
".",
"row_label_size",
"=",
"self",
".",
"GetRowLabelSize",
"(",
")",
"self",
".",
"SetRowMinimalAcceptableHeight",
"(",
"1",
")",
"self",
".",
"SetColMinimalAcceptableWidth",
"(",
"1",
")",
"self",
".",
"SetCellHighlightPenWidth",
"(",
"0",
")"
] | Initial layout of grid | [
"Initial",
"layout",
"of",
"grid"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L148-L170 | train | 231,541 |
manns/pyspread | pyspread/src/gui/_grid.py | Grid.is_merged_cell_drawn | 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.cell_attributes
top, left, __ = cell_attributes.get_merging_cell(key)
# Case 1: Top left cell of merge is visible
# --> Only top left cell returns True
top_left_drawn = \
row == top and col == left and \
self.IsVisible(row, col, wholeCellVisible=False)
# Case 2: Leftmost column is visible
# --> Only top visible leftmost cell returns True
left_drawn = \
col == left and \
self.IsVisible(row, col, wholeCellVisible=False) and \
not self.IsVisible(row-1, col, wholeCellVisible=False)
# Case 3: Top row is visible
# --> Only left visible top cell returns True
top_drawn = \
row == top and \
self.IsVisible(row, col, wholeCellVisible=False) and \
not self.IsVisible(row, col-1, wholeCellVisible=False)
# Case 4: Top row and leftmost column are invisible
# --> Only top left visible cell returns True
middle_drawn = \
self.IsVisible(row, col, wholeCellVisible=False) and \
not self.IsVisible(row-1, col, wholeCellVisible=False) and \
not self.IsVisible(row, col-1, wholeCellVisible=False)
return top_left_drawn or left_drawn or top_drawn or middle_drawn | python | 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.cell_attributes
top, left, __ = cell_attributes.get_merging_cell(key)
# Case 1: Top left cell of merge is visible
# --> Only top left cell returns True
top_left_drawn = \
row == top and col == left and \
self.IsVisible(row, col, wholeCellVisible=False)
# Case 2: Leftmost column is visible
# --> Only top visible leftmost cell returns True
left_drawn = \
col == left and \
self.IsVisible(row, col, wholeCellVisible=False) and \
not self.IsVisible(row-1, col, wholeCellVisible=False)
# Case 3: Top row is visible
# --> Only left visible top cell returns True
top_drawn = \
row == top and \
self.IsVisible(row, col, wholeCellVisible=False) and \
not self.IsVisible(row, col-1, wholeCellVisible=False)
# Case 4: Top row and leftmost column are invisible
# --> Only top left visible cell returns True
middle_drawn = \
self.IsVisible(row, col, wholeCellVisible=False) and \
not self.IsVisible(row-1, col, wholeCellVisible=False) and \
not self.IsVisible(row, col-1, wholeCellVisible=False)
return top_left_drawn or left_drawn or top_drawn or middle_drawn | [
"def",
"is_merged_cell_drawn",
"(",
"self",
",",
"key",
")",
":",
"row",
",",
"col",
",",
"tab",
"=",
"key",
"# Is key not merged? --> False",
"cell_attributes",
"=",
"self",
".",
"code_array",
".",
"cell_attributes",
"top",
",",
"left",
",",
"__",
"=",
"cell_attributes",
".",
"get_merging_cell",
"(",
"key",
")",
"# Case 1: Top left cell of merge is visible",
"# --> Only top left cell returns True",
"top_left_drawn",
"=",
"row",
"==",
"top",
"and",
"col",
"==",
"left",
"and",
"self",
".",
"IsVisible",
"(",
"row",
",",
"col",
",",
"wholeCellVisible",
"=",
"False",
")",
"# Case 2: Leftmost column is visible",
"# --> Only top visible leftmost cell returns True",
"left_drawn",
"=",
"col",
"==",
"left",
"and",
"self",
".",
"IsVisible",
"(",
"row",
",",
"col",
",",
"wholeCellVisible",
"=",
"False",
")",
"and",
"not",
"self",
".",
"IsVisible",
"(",
"row",
"-",
"1",
",",
"col",
",",
"wholeCellVisible",
"=",
"False",
")",
"# Case 3: Top row is visible",
"# --> Only left visible top cell returns True",
"top_drawn",
"=",
"row",
"==",
"top",
"and",
"self",
".",
"IsVisible",
"(",
"row",
",",
"col",
",",
"wholeCellVisible",
"=",
"False",
")",
"and",
"not",
"self",
".",
"IsVisible",
"(",
"row",
",",
"col",
"-",
"1",
",",
"wholeCellVisible",
"=",
"False",
")",
"# Case 4: Top row and leftmost column are invisible",
"# --> Only top left visible cell returns True",
"middle_drawn",
"=",
"self",
".",
"IsVisible",
"(",
"row",
",",
"col",
",",
"wholeCellVisible",
"=",
"False",
")",
"and",
"not",
"self",
".",
"IsVisible",
"(",
"row",
"-",
"1",
",",
"col",
",",
"wholeCellVisible",
"=",
"False",
")",
"and",
"not",
"self",
".",
"IsVisible",
"(",
"row",
",",
"col",
"-",
"1",
",",
"wholeCellVisible",
"=",
"False",
")",
"return",
"top_left_drawn",
"or",
"left_drawn",
"or",
"top_drawn",
"or",
"middle_drawn"
] | 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. | [
"True",
"if",
"key",
"in",
"merged",
"area",
"shall",
"be",
"drawn"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L312-L357 | train | 231,542 |
manns/pyspread | pyspread/src/gui/_grid.py | Grid.update_entry_line | 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 = self.GetTable().GetValue(*key)
post_command_event(self, self.EntryLineMsg, text=cell_code) | python | 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 = self.GetTable().GetValue(*key)
post_command_event(self, self.EntryLineMsg, text=cell_code) | [
"def",
"update_entry_line",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
":",
"key",
"=",
"self",
".",
"actions",
".",
"cursor",
"cell_code",
"=",
"self",
".",
"GetTable",
"(",
")",
".",
"GetValue",
"(",
"*",
"key",
")",
"post_command_event",
"(",
"self",
",",
"self",
".",
"EntryLineMsg",
",",
"text",
"=",
"cell_code",
")"
] | Updates the entry line
Parameters
----------
key: 3-tuple of Integer, defaults to current cell
\tCell to which code the entry line is updated | [
"Updates",
"the",
"entry",
"line"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L359-L374 | train | 231,543 |
manns/pyspread | pyspread/src/gui/_grid.py | Grid.update_attribute_toolbar | 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.actions.cursor
post_command_event(self, self.ToolbarUpdateMsg, key=key,
attr=self.code_array.cell_attributes[key]) | python | 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.actions.cursor
post_command_event(self, self.ToolbarUpdateMsg, key=key,
attr=self.code_array.cell_attributes[key]) | [
"def",
"update_attribute_toolbar",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
":",
"key",
"=",
"self",
".",
"actions",
".",
"cursor",
"post_command_event",
"(",
"self",
",",
"self",
".",
"ToolbarUpdateMsg",
",",
"key",
"=",
"key",
",",
"attr",
"=",
"self",
".",
"code_array",
".",
"cell_attributes",
"[",
"key",
"]",
")"
] | Updates the attribute toolbar
Parameters
----------
key: 3-tuple of Integer, defaults to current cell
\tCell to which attributes the attributes toolbar is updated | [
"Updates",
"the",
"attribute",
"toolbar"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L388-L402 | train | 231,544 |
manns/pyspread | pyspread/src/gui/_grid.py | Grid._update_video_volume_cell_attributes | 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"]
new_video_volume = video_cell_panel.volume
if old_video_volume == new_video_volume:
return
selection = Selection([], [], [], [], [key])
self.actions.set_attr("video_volume", new_video_volume, selection) | python | 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"]
new_video_volume = video_cell_panel.volume
if old_video_volume == new_video_volume:
return
selection = Selection([], [], [], [], [key])
self.actions.set_attr("video_volume", new_video_volume, selection) | [
"def",
"_update_video_volume_cell_attributes",
"(",
"self",
",",
"key",
")",
":",
"try",
":",
"video_cell_panel",
"=",
"self",
".",
"grid_renderer",
".",
"video_cells",
"[",
"key",
"]",
"except",
"KeyError",
":",
"return",
"old_video_volume",
"=",
"self",
".",
"code_array",
".",
"cell_attributes",
"[",
"key",
"]",
"[",
"\"video_volume\"",
"]",
"new_video_volume",
"=",
"video_cell_panel",
".",
"volume",
"if",
"old_video_volume",
"==",
"new_video_volume",
":",
"return",
"selection",
"=",
"Selection",
"(",
"[",
"]",
",",
"[",
"]",
",",
"[",
"]",
",",
"[",
"]",
",",
"[",
"key",
"]",
")",
"self",
".",
"actions",
".",
"set_attr",
"(",
"\"video_volume\"",
",",
"new_video_volume",
",",
"selection",
")"
] | Updates the panel cell attrutes of a panel cell | [
"Updates",
"the",
"panel",
"cell",
"attrutes",
"of",
"a",
"panel",
"cell"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L404-L420 | train | 231,545 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnCellText | 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 | def OnCellText(self, event):
"""Text entry event handler"""
row, col, _ = self.grid.actions.cursor
self.grid.GetTable().SetValue(row, col, event.code)
event.Skip() | [
"def",
"OnCellText",
"(",
"self",
",",
"event",
")",
":",
"row",
",",
"col",
",",
"_",
"=",
"self",
".",
"grid",
".",
"actions",
".",
"cursor",
"self",
".",
"grid",
".",
"GetTable",
"(",
")",
".",
"SetValue",
"(",
"row",
",",
"col",
",",
"event",
".",
"code",
")",
"event",
".",
"Skip",
"(",
")"
] | Text entry event handler | [
"Text",
"entry",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L448-L454 | train | 231,546 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnInsertBitmap | 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 current cell")
style = wx.OPEN | wx.CHANGE_DIR
filepath, index = \
self.grid.interfaces.get_filepath_findex_from_user(wildcard,
message, style)
if index == 0:
# Bitmap loaded
try:
img = wx.EmptyImage(1, 1)
img.LoadFile(filepath)
except TypeError:
return
if img.GetSize() == (-1, -1):
# Bitmap could not be read
return
code = self.grid.main_window.actions.img2code(key, img)
elif index == 1 and rsvg is not None:
# SVG loaded
with open(filepath) as infile:
try:
code = infile.read()
except IOError:
return
if is_svg(code):
code = 'u"""' + code + '"""'
else:
# Does not seem to be an svg file
return
else:
code = None
if code:
self.grid.actions.set_code(key, code) | python | 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 current cell")
style = wx.OPEN | wx.CHANGE_DIR
filepath, index = \
self.grid.interfaces.get_filepath_findex_from_user(wildcard,
message, style)
if index == 0:
# Bitmap loaded
try:
img = wx.EmptyImage(1, 1)
img.LoadFile(filepath)
except TypeError:
return
if img.GetSize() == (-1, -1):
# Bitmap could not be read
return
code = self.grid.main_window.actions.img2code(key, img)
elif index == 1 and rsvg is not None:
# SVG loaded
with open(filepath) as infile:
try:
code = infile.read()
except IOError:
return
if is_svg(code):
code = 'u"""' + code + '"""'
else:
# Does not seem to be an svg file
return
else:
code = None
if code:
self.grid.actions.set_code(key, code) | [
"def",
"OnInsertBitmap",
"(",
"self",
",",
"event",
")",
":",
"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 current cell\"",
")",
"style",
"=",
"wx",
".",
"OPEN",
"|",
"wx",
".",
"CHANGE_DIR",
"filepath",
",",
"index",
"=",
"self",
".",
"grid",
".",
"interfaces",
".",
"get_filepath_findex_from_user",
"(",
"wildcard",
",",
"message",
",",
"style",
")",
"if",
"index",
"==",
"0",
":",
"# Bitmap loaded",
"try",
":",
"img",
"=",
"wx",
".",
"EmptyImage",
"(",
"1",
",",
"1",
")",
"img",
".",
"LoadFile",
"(",
"filepath",
")",
"except",
"TypeError",
":",
"return",
"if",
"img",
".",
"GetSize",
"(",
")",
"==",
"(",
"-",
"1",
",",
"-",
"1",
")",
":",
"# Bitmap could not be read",
"return",
"code",
"=",
"self",
".",
"grid",
".",
"main_window",
".",
"actions",
".",
"img2code",
"(",
"key",
",",
"img",
")",
"elif",
"index",
"==",
"1",
"and",
"rsvg",
"is",
"not",
"None",
":",
"# SVG loaded",
"with",
"open",
"(",
"filepath",
")",
"as",
"infile",
":",
"try",
":",
"code",
"=",
"infile",
".",
"read",
"(",
")",
"except",
"IOError",
":",
"return",
"if",
"is_svg",
"(",
"code",
")",
":",
"code",
"=",
"'u\"\"\"'",
"+",
"code",
"+",
"'\"\"\"'",
"else",
":",
"# Does not seem to be an svg file",
"return",
"else",
":",
"code",
"=",
"None",
"if",
"code",
":",
"self",
".",
"grid",
".",
"actions",
".",
"set_code",
"(",
"key",
",",
"code",
")"
] | Insert bitmap event handler | [
"Insert",
"bitmap",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L456-L502 | train | 231,547 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnLinkBitmap | 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,
message, style)
try:
bmp = wx.Bitmap(filepath)
except TypeError:
return
if bmp.Size == (-1, -1):
# Bitmap could not be read
return
code = "wx.Bitmap(r'{filepath}')".format(filepath=filepath)
key = self.grid.actions.cursor
self.grid.actions.set_code(key, code) | python | 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,
message, style)
try:
bmp = wx.Bitmap(filepath)
except TypeError:
return
if bmp.Size == (-1, -1):
# Bitmap could not be read
return
code = "wx.Bitmap(r'{filepath}')".format(filepath=filepath)
key = self.grid.actions.cursor
self.grid.actions.set_code(key, code) | [
"def",
"OnLinkBitmap",
"(",
"self",
",",
"event",
")",
":",
"# 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",
",",
"message",
",",
"style",
")",
"try",
":",
"bmp",
"=",
"wx",
".",
"Bitmap",
"(",
"filepath",
")",
"except",
"TypeError",
":",
"return",
"if",
"bmp",
".",
"Size",
"==",
"(",
"-",
"1",
",",
"-",
"1",
")",
":",
"# Bitmap could not be read",
"return",
"code",
"=",
"\"wx.Bitmap(r'{filepath}')\"",
".",
"format",
"(",
"filepath",
"=",
"filepath",
")",
"key",
"=",
"self",
".",
"grid",
".",
"actions",
".",
"cursor",
"self",
".",
"grid",
".",
"actions",
".",
"set_code",
"(",
"key",
",",
"code",
")"
] | Link bitmap event handler | [
"Link",
"bitmap",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L504-L526 | train | 231,548 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnLinkVLCVideo | 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:
video_volume = None
self.grid.actions.set_attr("panel_cell", True)
if video_volume is not None:
code = 'vlcpanel_factory("{}", {})'.format(
event.videofile, video_volume)
else:
code = 'vlcpanel_factory("{}")'.format(event.videofile)
self.grid.actions.set_code(key, code)
else:
try:
video_panel = self.grid.grid_renderer.video_cells.pop(key)
video_panel.player.stop()
video_panel.player.release()
video_panel.Destroy()
except KeyError:
pass
self.grid.actions.set_code(key, u"") | python | 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:
video_volume = None
self.grid.actions.set_attr("panel_cell", True)
if video_volume is not None:
code = 'vlcpanel_factory("{}", {})'.format(
event.videofile, video_volume)
else:
code = 'vlcpanel_factory("{}")'.format(event.videofile)
self.grid.actions.set_code(key, code)
else:
try:
video_panel = self.grid.grid_renderer.video_cells.pop(key)
video_panel.player.stop()
video_panel.player.release()
video_panel.Destroy()
except KeyError:
pass
self.grid.actions.set_code(key, u"") | [
"def",
"OnLinkVLCVideo",
"(",
"self",
",",
"event",
")",
":",
"key",
"=",
"self",
".",
"grid",
".",
"actions",
".",
"cursor",
"if",
"event",
".",
"videofile",
":",
"try",
":",
"video_volume",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"cell_attributes",
"[",
"key",
"]",
"[",
"\"video_volume\"",
"]",
"except",
"KeyError",
":",
"video_volume",
"=",
"None",
"self",
".",
"grid",
".",
"actions",
".",
"set_attr",
"(",
"\"panel_cell\"",
",",
"True",
")",
"if",
"video_volume",
"is",
"not",
"None",
":",
"code",
"=",
"'vlcpanel_factory(\"{}\", {})'",
".",
"format",
"(",
"event",
".",
"videofile",
",",
"video_volume",
")",
"else",
":",
"code",
"=",
"'vlcpanel_factory(\"{}\")'",
".",
"format",
"(",
"event",
".",
"videofile",
")",
"self",
".",
"grid",
".",
"actions",
".",
"set_code",
"(",
"key",
",",
"code",
")",
"else",
":",
"try",
":",
"video_panel",
"=",
"self",
".",
"grid",
".",
"grid_renderer",
".",
"video_cells",
".",
"pop",
"(",
"key",
")",
"video_panel",
".",
"player",
".",
"stop",
"(",
")",
"video_panel",
".",
"player",
".",
"release",
"(",
")",
"video_panel",
".",
"Destroy",
"(",
")",
"except",
"KeyError",
":",
"pass",
"self",
".",
"grid",
".",
"actions",
".",
"set_code",
"(",
"key",
",",
"u\"\"",
")"
] | VLC video code event handler | [
"VLC",
"video",
"code",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L528-L559 | train | 231,549 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnInsertChartDialog | 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_dialog.ShowModal() == wx.ID_OK:
code = chart_dialog.get_code()
key = self.grid.actions.cursor
self.grid.actions.set_code(key, code) | python | 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_dialog.ShowModal() == wx.ID_OK:
code = chart_dialog.get_code()
key = self.grid.actions.cursor
self.grid.actions.set_code(key, code) | [
"def",
"OnInsertChartDialog",
"(",
"self",
",",
"event",
")",
":",
"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_dialog",
".",
"ShowModal",
"(",
")",
"==",
"wx",
".",
"ID_OK",
":",
"code",
"=",
"chart_dialog",
".",
"get_code",
"(",
")",
"key",
"=",
"self",
".",
"grid",
".",
"actions",
".",
"cursor",
"self",
".",
"grid",
".",
"actions",
".",
"set_code",
"(",
"key",
",",
"code",
")"
] | Chart dialog event handler | [
"Chart",
"dialog",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L561-L576 | train | 231,550 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnPasteFormat | 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 | 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() | [
"def",
"OnPasteFormat",
"(",
"self",
",",
"event",
")",
":",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Paste format\"",
")",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"paste_format",
"(",
")",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")",
"self",
".",
"grid",
".",
"update_attribute_toolbar",
"(",
")",
"self",
".",
"grid",
".",
"actions",
".",
"zoom",
"(",
")"
] | Paste format event handler | [
"Paste",
"format",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L585-L593 | train | 231,551 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnCellFont | 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 | 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() | [
"def",
"OnCellFont",
"(",
"self",
",",
"event",
")",
":",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Font\"",
")",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"set_attr",
"(",
"\"textfont\"",
",",
"event",
".",
"font",
")",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")",
"self",
".",
"grid",
".",
"update_attribute_toolbar",
"(",
")",
"event",
".",
"Skip",
"(",
")"
] | Cell font event handler | [
"Cell",
"font",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L595-L605 | train | 231,552 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnCellFontSize | 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 | 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() | [
"def",
"OnCellFontSize",
"(",
"self",
",",
"event",
")",
":",
"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 size event handler | [
"Cell",
"font",
"size",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L607-L617 | train | 231,553 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnCellFontBold | 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(
weight=event.weight)
raise ValueError(msg)
self.grid.actions.set_attr("fontweight", weight)
except AttributeError:
self.grid.actions.toggle_attr("fontweight")
self.grid.ForceRefresh()
self.grid.update_attribute_toolbar()
event.Skip() | python | 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(
weight=event.weight)
raise ValueError(msg)
self.grid.actions.set_attr("fontweight", weight)
except AttributeError:
self.grid.actions.toggle_attr("fontweight")
self.grid.ForceRefresh()
self.grid.update_attribute_toolbar()
event.Skip() | [
"def",
"OnCellFontBold",
"(",
"self",
",",
"event",
")",
":",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Bold\"",
")",
")",
":",
"try",
":",
"try",
":",
"weight",
"=",
"getattr",
"(",
"wx",
",",
"event",
".",
"weight",
"[",
"2",
":",
"]",
")",
"except",
"AttributeError",
":",
"msg",
"=",
"_",
"(",
"\"Weight {weight} unknown\"",
")",
".",
"format",
"(",
"weight",
"=",
"event",
".",
"weight",
")",
"raise",
"ValueError",
"(",
"msg",
")",
"self",
".",
"grid",
".",
"actions",
".",
"set_attr",
"(",
"\"fontweight\"",
",",
"weight",
")",
"except",
"AttributeError",
":",
"self",
".",
"grid",
".",
"actions",
".",
"toggle_attr",
"(",
"\"fontweight\"",
")",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")",
"self",
".",
"grid",
".",
"update_attribute_toolbar",
"(",
")",
"event",
".",
"Skip",
"(",
")"
] | Cell font bold event handler | [
"Cell",
"font",
"bold",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L619-L641 | train | 231,554 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnCellFontUnderline | 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 | 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() | [
"def",
"OnCellFontUnderline",
"(",
"self",
",",
"event",
")",
":",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Underline\"",
")",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"toggle_attr",
"(",
"\"underline\"",
")",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")",
"self",
".",
"grid",
".",
"update_attribute_toolbar",
"(",
")",
"event",
".",
"Skip",
"(",
")"
] | Cell font underline event handler | [
"Cell",
"font",
"underline",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L666-L676 | train | 231,555 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnCellFrozen | 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 | 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() | [
"def",
"OnCellFrozen",
"(",
"self",
",",
"event",
")",
":",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Frozen\"",
")",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"change_frozen_attr",
"(",
")",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")",
"self",
".",
"grid",
".",
"update_attribute_toolbar",
"(",
")",
"event",
".",
"Skip",
"(",
")"
] | Cell frozen event handler | [
"Cell",
"frozen",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L690-L700 | train | 231,556 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnButtonCell | 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.Skip() | python | 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.Skip() | [
"def",
"OnButtonCell",
"(",
"self",
",",
"event",
")",
":",
"# 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",
".",
"Skip",
"(",
")"
] | Button cell event handler | [
"Button",
"cell",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L714-L727 | train | 231,557 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnMerge | 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 | 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() | [
"def",
"OnMerge",
"(",
"self",
",",
"event",
")",
":",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Merge cells\"",
")",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"merge_selected_cells",
"(",
"self",
".",
"grid",
".",
"selection",
")",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")",
"self",
".",
"grid",
".",
"update_attribute_toolbar",
"(",
")"
] | Merge cells event handler | [
"Merge",
"cells",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L741-L749 | train | 231,558 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnCellBorderWidth | 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.update_attribute_toolbar()
event.Skip() | python | 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.update_attribute_toolbar()
event.Skip() | [
"def",
"OnCellBorderWidth",
"(",
"self",
",",
"event",
")",
":",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Border width\"",
")",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"set_border_attr",
"(",
"\"borderwidth\"",
",",
"event",
".",
"width",
",",
"event",
".",
"borders",
")",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")",
"self",
".",
"grid",
".",
"update_attribute_toolbar",
"(",
")",
"event",
".",
"Skip",
"(",
")"
] | Cell border width event handler | [
"Cell",
"border",
"width",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L775-L786 | train | 231,559 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnCellBorderColor | 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.update_attribute_toolbar()
event.Skip() | python | 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.update_attribute_toolbar()
event.Skip() | [
"def",
"OnCellBorderColor",
"(",
"self",
",",
"event",
")",
":",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Border color\"",
")",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"set_border_attr",
"(",
"\"bordercolor\"",
",",
"event",
".",
"color",
",",
"event",
".",
"borders",
")",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")",
"self",
".",
"grid",
".",
"update_attribute_toolbar",
"(",
")",
"event",
".",
"Skip",
"(",
")"
] | Cell border color event handler | [
"Cell",
"border",
"color",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L788-L799 | train | 231,560 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnCellBackgroundColor | 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 | 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() | [
"def",
"OnCellBackgroundColor",
"(",
"self",
",",
"event",
")",
":",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Background color\"",
")",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"set_attr",
"(",
"\"bgcolor\"",
",",
"event",
".",
"color",
")",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")",
"self",
".",
"grid",
".",
"update_attribute_toolbar",
"(",
")",
"event",
".",
"Skip",
"(",
")"
] | Cell background color event handler | [
"Cell",
"background",
"color",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L801-L811 | train | 231,561 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnCellTextRotation | 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()
except:
pass
event.Skip() | python | 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()
except:
pass
event.Skip() | [
"def",
"OnCellTextRotation",
"(",
"self",
",",
"event",
")",
":",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Rotation\"",
")",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"toggle_attr",
"(",
"\"angle\"",
")",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")",
"self",
".",
"grid",
".",
"update_attribute_toolbar",
"(",
")",
"if",
"is_gtk",
"(",
")",
":",
"try",
":",
"wx",
".",
"Yield",
"(",
")",
"except",
":",
"pass",
"event",
".",
"Skip",
"(",
")"
] | Cell text rotation event handler | [
"Cell",
"text",
"rotation",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L865-L881 | train | 231,562 |
manns/pyspread | pyspread/src/gui/_grid.py | GridCellEventHandlers.OnCellSelected | 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_cell(key)
if merging_cell is not None and merging_cell != key:
post_command_event(self.grid, self.grid.GotoCellMsg,
key=merging_cell)
# Check if the merging cell is a button cell
if cell_attributes[merging_cell]["button_cell"]:
# Button cells shall be executed on click
self.grid.EnableCellEditControl()
return
# If in selection mode do nothing
# This prevents the current cell from changing
if not self.grid.IsEditable():
return
# Redraw cursor
self.grid.ForceRefresh()
# Disable entry line if cell is locked
self.grid.lock_entry_line(
self.grid.code_array.cell_attributes[key]["locked"])
# Update entry line
self.grid.update_entry_line(key)
# Update attribute toolbar
self.grid.update_attribute_toolbar(key)
self.grid._last_selected_cell = key
event.Skip() | python | 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_cell(key)
if merging_cell is not None and merging_cell != key:
post_command_event(self.grid, self.grid.GotoCellMsg,
key=merging_cell)
# Check if the merging cell is a button cell
if cell_attributes[merging_cell]["button_cell"]:
# Button cells shall be executed on click
self.grid.EnableCellEditControl()
return
# If in selection mode do nothing
# This prevents the current cell from changing
if not self.grid.IsEditable():
return
# Redraw cursor
self.grid.ForceRefresh()
# Disable entry line if cell is locked
self.grid.lock_entry_line(
self.grid.code_array.cell_attributes[key]["locked"])
# Update entry line
self.grid.update_entry_line(key)
# Update attribute toolbar
self.grid.update_attribute_toolbar(key)
self.grid._last_selected_cell = key
event.Skip() | [
"def",
"OnCellSelected",
"(",
"self",
",",
"event",
")",
":",
"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_cell",
"(",
"key",
")",
"if",
"merging_cell",
"is",
"not",
"None",
"and",
"merging_cell",
"!=",
"key",
":",
"post_command_event",
"(",
"self",
".",
"grid",
",",
"self",
".",
"grid",
".",
"GotoCellMsg",
",",
"key",
"=",
"merging_cell",
")",
"# Check if the merging cell is a button cell",
"if",
"cell_attributes",
"[",
"merging_cell",
"]",
"[",
"\"button_cell\"",
"]",
":",
"# Button cells shall be executed on click",
"self",
".",
"grid",
".",
"EnableCellEditControl",
"(",
")",
"return",
"# If in selection mode do nothing",
"# This prevents the current cell from changing",
"if",
"not",
"self",
".",
"grid",
".",
"IsEditable",
"(",
")",
":",
"return",
"# Redraw cursor",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")",
"# Disable entry line if cell is locked",
"self",
".",
"grid",
".",
"lock_entry_line",
"(",
"self",
".",
"grid",
".",
"code_array",
".",
"cell_attributes",
"[",
"key",
"]",
"[",
"\"locked\"",
"]",
")",
"# Update entry line",
"self",
".",
"grid",
".",
"update_entry_line",
"(",
"key",
")",
"# Update attribute toolbar",
"self",
".",
"grid",
".",
"update_attribute_toolbar",
"(",
"key",
")",
"self",
".",
"grid",
".",
"_last_selected_cell",
"=",
"key",
"event",
".",
"Skip",
"(",
")"
] | Cell selection event handler | [
"Cell",
"selection",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L883-L922 | train | 231,563 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnMouseMotion | 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 = self.grid.code_array.cell_attributes[key]["merge_area"]
if merge_area is not None:
top, left, bottom, right = merge_area
row, col = top, left
grid.actions.on_mouse_over((row, col, tab))
event.Skip() | python | 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 = self.grid.code_array.cell_attributes[key]["merge_area"]
if merge_area is not None:
top, left, bottom, right = merge_area
row, col = top, left
grid.actions.on_mouse_over((row, col, tab))
event.Skip() | [
"def",
"OnMouseMotion",
"(",
"self",
",",
"event",
")",
":",
"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",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"cell_attributes",
"[",
"key",
"]",
"[",
"\"merge_area\"",
"]",
"if",
"merge_area",
"is",
"not",
"None",
":",
"top",
",",
"left",
",",
"bottom",
",",
"right",
"=",
"merge_area",
"row",
",",
"col",
"=",
"top",
",",
"left",
"grid",
".",
"actions",
".",
"on_mouse_over",
"(",
"(",
"row",
",",
"col",
",",
"tab",
")",
")",
"event",
".",
"Skip",
"(",
")"
] | Mouse motion event handler | [
"Mouse",
"motion",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L933-L953 | train | 231,564 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnKey | 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_table():
newtable = self.grid.current_table - 1
post_command_event(self.grid, self.GridActionTableSwitchMsg,
newtable=newtable)
grid = self.grid
actions = grid.actions
shift, alt, ctrl = 1, 1 << 1, 1 << 2
# Shortcuts key tuple: (modifier, keycode)
# Modifier may be e. g. shift | ctrl
shortcuts = {
# <Esc> pressed
(0, 27): lambda: setattr(actions, "need_abort", True),
# <Del> pressed
(0, 127): actions.delete,
# <Home> pressed
(0, 313): lambda: actions.set_cursor((grid.GetGridCursorRow(), 0)),
# <Ctrl> + R pressed
(ctrl, 82): actions.copy_selection_access_string,
# <Ctrl> + + pressed
(ctrl, 388): actions.zoom_in,
# <Ctrl> + - pressed
(ctrl, 390): actions.zoom_out,
# <Shift> + <Space> pressed
(shift, 32): lambda: grid.SelectRow(grid.GetGridCursorRow()),
# <Ctrl> + <Space> pressed
(ctrl, 32): lambda: grid.SelectCol(grid.GetGridCursorCol()),
# <Shift> + <Ctrl> + <Space> pressed
(shift | ctrl, 32): grid.SelectAll,
}
if self.main_window.IsFullScreen():
# <Arrow up> pressed
shortcuts[(0, 315)] = switch_to_previous_table
# <Arrow down> pressed
shortcuts[(0, 317)] = switch_to_next_table
# <Space> pressed
shortcuts[(0, 32)] = switch_to_next_table
keycode = event.GetKeyCode()
modifier = shift * event.ShiftDown() | \
alt * event.AltDown() | ctrl * event.ControlDown()
if (modifier, keycode) in shortcuts:
shortcuts[(modifier, keycode)]()
else:
event.Skip() | python | 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_table():
newtable = self.grid.current_table - 1
post_command_event(self.grid, self.GridActionTableSwitchMsg,
newtable=newtable)
grid = self.grid
actions = grid.actions
shift, alt, ctrl = 1, 1 << 1, 1 << 2
# Shortcuts key tuple: (modifier, keycode)
# Modifier may be e. g. shift | ctrl
shortcuts = {
# <Esc> pressed
(0, 27): lambda: setattr(actions, "need_abort", True),
# <Del> pressed
(0, 127): actions.delete,
# <Home> pressed
(0, 313): lambda: actions.set_cursor((grid.GetGridCursorRow(), 0)),
# <Ctrl> + R pressed
(ctrl, 82): actions.copy_selection_access_string,
# <Ctrl> + + pressed
(ctrl, 388): actions.zoom_in,
# <Ctrl> + - pressed
(ctrl, 390): actions.zoom_out,
# <Shift> + <Space> pressed
(shift, 32): lambda: grid.SelectRow(grid.GetGridCursorRow()),
# <Ctrl> + <Space> pressed
(ctrl, 32): lambda: grid.SelectCol(grid.GetGridCursorCol()),
# <Shift> + <Ctrl> + <Space> pressed
(shift | ctrl, 32): grid.SelectAll,
}
if self.main_window.IsFullScreen():
# <Arrow up> pressed
shortcuts[(0, 315)] = switch_to_previous_table
# <Arrow down> pressed
shortcuts[(0, 317)] = switch_to_next_table
# <Space> pressed
shortcuts[(0, 32)] = switch_to_next_table
keycode = event.GetKeyCode()
modifier = shift * event.ShiftDown() | \
alt * event.AltDown() | ctrl * event.ControlDown()
if (modifier, keycode) in shortcuts:
shortcuts[(modifier, keycode)]()
else:
event.Skip() | [
"def",
"OnKey",
"(",
"self",
",",
"event",
")",
":",
"def",
"switch_to_next_table",
"(",
")",
":",
"newtable",
"=",
"self",
".",
"grid",
".",
"current_table",
"+",
"1",
"post_command_event",
"(",
"self",
".",
"grid",
",",
"self",
".",
"GridActionTableSwitchMsg",
",",
"newtable",
"=",
"newtable",
")",
"def",
"switch_to_previous_table",
"(",
")",
":",
"newtable",
"=",
"self",
".",
"grid",
".",
"current_table",
"-",
"1",
"post_command_event",
"(",
"self",
".",
"grid",
",",
"self",
".",
"GridActionTableSwitchMsg",
",",
"newtable",
"=",
"newtable",
")",
"grid",
"=",
"self",
".",
"grid",
"actions",
"=",
"grid",
".",
"actions",
"shift",
",",
"alt",
",",
"ctrl",
"=",
"1",
",",
"1",
"<<",
"1",
",",
"1",
"<<",
"2",
"# Shortcuts key tuple: (modifier, keycode)",
"# Modifier may be e. g. shift | ctrl",
"shortcuts",
"=",
"{",
"# <Esc> pressed",
"(",
"0",
",",
"27",
")",
":",
"lambda",
":",
"setattr",
"(",
"actions",
",",
"\"need_abort\"",
",",
"True",
")",
",",
"# <Del> pressed",
"(",
"0",
",",
"127",
")",
":",
"actions",
".",
"delete",
",",
"# <Home> pressed",
"(",
"0",
",",
"313",
")",
":",
"lambda",
":",
"actions",
".",
"set_cursor",
"(",
"(",
"grid",
".",
"GetGridCursorRow",
"(",
")",
",",
"0",
")",
")",
",",
"# <Ctrl> + R pressed",
"(",
"ctrl",
",",
"82",
")",
":",
"actions",
".",
"copy_selection_access_string",
",",
"# <Ctrl> + + pressed",
"(",
"ctrl",
",",
"388",
")",
":",
"actions",
".",
"zoom_in",
",",
"# <Ctrl> + - pressed",
"(",
"ctrl",
",",
"390",
")",
":",
"actions",
".",
"zoom_out",
",",
"# <Shift> + <Space> pressed",
"(",
"shift",
",",
"32",
")",
":",
"lambda",
":",
"grid",
".",
"SelectRow",
"(",
"grid",
".",
"GetGridCursorRow",
"(",
")",
")",
",",
"# <Ctrl> + <Space> pressed",
"(",
"ctrl",
",",
"32",
")",
":",
"lambda",
":",
"grid",
".",
"SelectCol",
"(",
"grid",
".",
"GetGridCursorCol",
"(",
")",
")",
",",
"# <Shift> + <Ctrl> + <Space> pressed",
"(",
"shift",
"|",
"ctrl",
",",
"32",
")",
":",
"grid",
".",
"SelectAll",
",",
"}",
"if",
"self",
".",
"main_window",
".",
"IsFullScreen",
"(",
")",
":",
"# <Arrow up> pressed",
"shortcuts",
"[",
"(",
"0",
",",
"315",
")",
"]",
"=",
"switch_to_previous_table",
"# <Arrow down> pressed",
"shortcuts",
"[",
"(",
"0",
",",
"317",
")",
"]",
"=",
"switch_to_next_table",
"# <Space> pressed",
"shortcuts",
"[",
"(",
"0",
",",
"32",
")",
"]",
"=",
"switch_to_next_table",
"keycode",
"=",
"event",
".",
"GetKeyCode",
"(",
")",
"modifier",
"=",
"shift",
"*",
"event",
".",
"ShiftDown",
"(",
")",
"|",
"alt",
"*",
"event",
".",
"AltDown",
"(",
")",
"|",
"ctrl",
"*",
"event",
".",
"ControlDown",
"(",
")",
"if",
"(",
"modifier",
",",
"keycode",
")",
"in",
"shortcuts",
":",
"shortcuts",
"[",
"(",
"modifier",
",",
"keycode",
")",
"]",
"(",
")",
"else",
":",
"event",
".",
"Skip",
"(",
")"
] | Handles non-standard shortcut events | [
"Handles",
"non",
"-",
"standard",
"shortcut",
"events"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L955-L1014 | train | 231,565 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnRangeSelected | 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 selection:
self.grid.ClearSelection()
else:
self.grid.SetGridCursor(row, col)
post_command_event(self.grid, self.grid.SelectionMsg,
selection=selection) | python | 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 selection:
self.grid.ClearSelection()
else:
self.grid.SetGridCursor(row, col)
post_command_event(self.grid, self.grid.SelectionMsg,
selection=selection) | [
"def",
"OnRangeSelected",
"(",
"self",
",",
"event",
")",
":",
"# 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",
"selection",
":",
"self",
".",
"grid",
".",
"ClearSelection",
"(",
")",
"else",
":",
"self",
".",
"grid",
".",
"SetGridCursor",
"(",
"row",
",",
"col",
")",
"post_command_event",
"(",
"self",
".",
"grid",
",",
"self",
".",
"grid",
".",
"SelectionMsg",
",",
"selection",
"=",
"selection",
")"
] | Event handler for grid selection | [
"Event",
"handler",
"for",
"grid",
"selection"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1016-L1028 | train | 231,566 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnViewFrozen | 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 | 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() | [
"def",
"OnViewFrozen",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"grid",
".",
"_view_frozen",
"=",
"not",
"self",
".",
"grid",
".",
"_view_frozen",
"self",
".",
"grid",
".",
"grid_renderer",
".",
"cell_cache",
".",
"clear",
"(",
")",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")",
"event",
".",
"Skip",
"(",
")"
] | Show cells as frozen status | [
"Show",
"cells",
"as",
"frozen",
"status"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1032-L1040 | train | 231,567 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnGoToCell | 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.code_array.shape)
post_command_event(self.grid.main_window, self.grid.StatusBarMsg,
text=msg)
event.Skip()
return
self.grid.MakeCellVisible(row, col)
event.Skip() | python | 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.code_array.shape)
post_command_event(self.grid.main_window, self.grid.StatusBarMsg,
text=msg)
event.Skip()
return
self.grid.MakeCellVisible(row, col)
event.Skip() | [
"def",
"OnGoToCell",
"(",
"self",
",",
"event",
")",
":",
"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",
".",
"code_array",
".",
"shape",
")",
"post_command_event",
"(",
"self",
".",
"grid",
".",
"main_window",
",",
"self",
".",
"grid",
".",
"StatusBarMsg",
",",
"text",
"=",
"msg",
")",
"event",
".",
"Skip",
"(",
")",
"return",
"self",
".",
"grid",
".",
"MakeCellVisible",
"(",
"row",
",",
"col",
")",
"event",
".",
"Skip",
"(",
")"
] | Shift a given cell into view | [
"Shift",
"a",
"given",
"cell",
"into",
"view"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1049-L1068 | train | 231,568 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnEnterSelectionMode | 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 | 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) | [
"def",
"OnEnterSelectionMode",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"grid",
".",
"sel_mode_cursor",
"=",
"list",
"(",
"self",
".",
"grid",
".",
"actions",
".",
"cursor",
")",
"self",
".",
"grid",
".",
"EnableDragGridSize",
"(",
"False",
")",
"self",
".",
"grid",
".",
"EnableEditing",
"(",
"False",
")"
] | Event handler for entering selection mode, disables cell edits | [
"Event",
"handler",
"for",
"entering",
"selection",
"mode",
"disables",
"cell",
"edits"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1070-L1075 | train | 231,569 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnExitSelectionMode | 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 | 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) | [
"def",
"OnExitSelectionMode",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"grid",
".",
"sel_mode_cursor",
"=",
"None",
"self",
".",
"grid",
".",
"EnableDragGridSize",
"(",
"True",
")",
"self",
".",
"grid",
".",
"EnableEditing",
"(",
"True",
")"
] | Event handler for leaving selection mode, enables cell edits | [
"Event",
"handler",
"for",
"leaving",
"selection",
"mode",
"enables",
"cell",
"edits"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1077-L1082 | train | 231,570 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnRefreshSelectedCells | 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 | 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() | [
"def",
"OnRefreshSelectedCells",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"refresh_selected_frozen_cells",
"(",
")",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")",
"event",
".",
"Skip",
"(",
")"
] | Event handler for refreshing the selected cells via menu | [
"Event",
"handler",
"for",
"refreshing",
"the",
"selected",
"cells",
"via",
"menu"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1084-L1090 | train | 231,571 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnTimerToggle | 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.grid.timer_running = True
self.grid.timer = wx.Timer(self.grid)
self.grid.timer.Start(config["timer_interval"]) | python | 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.grid.timer_running = True
self.grid.timer = wx.Timer(self.grid)
self.grid.timer.Start(config["timer_interval"]) | [
"def",
"OnTimerToggle",
"(",
"self",
",",
"event",
")",
":",
"if",
"self",
".",
"grid",
".",
"timer_running",
":",
"# Stop timer",
"self",
".",
"grid",
".",
"timer_running",
"=",
"False",
"self",
".",
"grid",
".",
"timer",
".",
"Stop",
"(",
")",
"del",
"self",
".",
"grid",
".",
"timer",
"else",
":",
"# Start timer",
"self",
".",
"grid",
".",
"timer_running",
"=",
"True",
"self",
".",
"grid",
".",
"timer",
"=",
"wx",
".",
"Timer",
"(",
"self",
".",
"grid",
")",
"self",
".",
"grid",
".",
"timer",
".",
"Start",
"(",
"config",
"[",
"\"timer_interval\"",
"]",
")"
] | Toggles the timer for updating frozen cells | [
"Toggles",
"the",
"timer",
"for",
"updating",
"frozen",
"cells"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1092-L1105 | train | 231,572 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnTimer | 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.ForceRefresh() | python | 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.ForceRefresh() | [
"def",
"OnTimer",
"(",
"self",
",",
"event",
")",
":",
"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",
".",
"ForceRefresh",
"(",
")"
] | Update all frozen cells because of timer call | [
"Update",
"all",
"frozen",
"cells",
"because",
"of",
"timer",
"call"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1107-L1115 | train | 231,573 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnZoomStandard | def OnZoomStandard(self, event):
"""Event handler for resetting grid zoom"""
self.grid.actions.zoom(zoom=1.0)
event.Skip() | python | def OnZoomStandard(self, event):
"""Event handler for resetting grid zoom"""
self.grid.actions.zoom(zoom=1.0)
event.Skip() | [
"def",
"OnZoomStandard",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"zoom",
"(",
"zoom",
"=",
"1.0",
")",
"event",
".",
"Skip",
"(",
")"
] | Event handler for resetting grid zoom | [
"Event",
"handler",
"for",
"resetting",
"grid",
"zoom"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1131-L1136 | train | 231,574 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnContextMenu | def OnContextMenu(self, event):
"""Context menu event handler"""
self.grid.PopupMenu(self.grid.contextmenu)
event.Skip() | python | def OnContextMenu(self, event):
"""Context menu event handler"""
self.grid.PopupMenu(self.grid.contextmenu)
event.Skip() | [
"def",
"OnContextMenu",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"grid",
".",
"PopupMenu",
"(",
"self",
".",
"grid",
".",
"contextmenu",
")",
"event",
".",
"Skip",
"(",
")"
] | Context menu event handler | [
"Context",
"menu",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1145-L1150 | train | 231,575 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnMouseWheel | 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:
post_command_event(self.grid, self.grid.ZoomOutMsg)
elif self.main_window.IsFullScreen():
if event.WheelRotation > 0:
newtable = self.grid.current_table - 1
else:
newtable = self.grid.current_table + 1
post_command_event(self.grid, self.GridActionTableSwitchMsg,
newtable=newtable)
return
else:
wheel_speed = config["mouse_wheel_speed_factor"]
x, y = self.grid.GetViewStart()
direction = wheel_speed if event.GetWheelRotation() < 0 \
else -wheel_speed
if event.ShiftDown():
# Scroll sideways if shift is pressed.
self.grid.Scroll(x + direction, y)
else:
self.grid.Scroll(x, y + direction) | python | 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:
post_command_event(self.grid, self.grid.ZoomOutMsg)
elif self.main_window.IsFullScreen():
if event.WheelRotation > 0:
newtable = self.grid.current_table - 1
else:
newtable = self.grid.current_table + 1
post_command_event(self.grid, self.GridActionTableSwitchMsg,
newtable=newtable)
return
else:
wheel_speed = config["mouse_wheel_speed_factor"]
x, y = self.grid.GetViewStart()
direction = wheel_speed if event.GetWheelRotation() < 0 \
else -wheel_speed
if event.ShiftDown():
# Scroll sideways if shift is pressed.
self.grid.Scroll(x + direction, y)
else:
self.grid.Scroll(x, y + direction) | [
"def",
"OnMouseWheel",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"ControlDown",
"(",
")",
":",
"if",
"event",
".",
"WheelRotation",
">",
"0",
":",
"post_command_event",
"(",
"self",
".",
"grid",
",",
"self",
".",
"grid",
".",
"ZoomInMsg",
")",
"else",
":",
"post_command_event",
"(",
"self",
".",
"grid",
",",
"self",
".",
"grid",
".",
"ZoomOutMsg",
")",
"elif",
"self",
".",
"main_window",
".",
"IsFullScreen",
"(",
")",
":",
"if",
"event",
".",
"WheelRotation",
">",
"0",
":",
"newtable",
"=",
"self",
".",
"grid",
".",
"current_table",
"-",
"1",
"else",
":",
"newtable",
"=",
"self",
".",
"grid",
".",
"current_table",
"+",
"1",
"post_command_event",
"(",
"self",
".",
"grid",
",",
"self",
".",
"GridActionTableSwitchMsg",
",",
"newtable",
"=",
"newtable",
")",
"return",
"else",
":",
"wheel_speed",
"=",
"config",
"[",
"\"mouse_wheel_speed_factor\"",
"]",
"x",
",",
"y",
"=",
"self",
".",
"grid",
".",
"GetViewStart",
"(",
")",
"direction",
"=",
"wheel_speed",
"if",
"event",
".",
"GetWheelRotation",
"(",
")",
"<",
"0",
"else",
"-",
"wheel_speed",
"if",
"event",
".",
"ShiftDown",
"(",
")",
":",
"# Scroll sideways if shift is pressed.",
"self",
".",
"grid",
".",
"Scroll",
"(",
"x",
"+",
"direction",
",",
"y",
")",
"else",
":",
"self",
".",
"grid",
".",
"Scroll",
"(",
"x",
",",
"y",
"+",
"direction",
")"
] | Event handler for mouse wheel actions
Invokes zoom when mouse when Ctrl is also pressed | [
"Event",
"handler",
"for",
"mouse",
"wheel",
"actions"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1152-L1184 | train | 231,576 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnFind | 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)
if findpos is None:
# If nothing is found mention it in the statusbar and return
statustext = _("'{text}' not found.").format(text=text)
else:
# Otherwise select cell with next occurrence if successful
self.grid.actions.cursor = findpos
# Update statusbar
statustext = _(u"Found '{text}' in cell {key}.")
statustext = statustext.format(text=text, key=findpos)
post_command_event(self.grid.main_window, self.grid.StatusBarMsg,
text=statustext)
event.Skip() | python | 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)
if findpos is None:
# If nothing is found mention it in the statusbar and return
statustext = _("'{text}' not found.").format(text=text)
else:
# Otherwise select cell with next occurrence if successful
self.grid.actions.cursor = findpos
# Update statusbar
statustext = _(u"Found '{text}' in cell {key}.")
statustext = statustext.format(text=text, key=findpos)
post_command_event(self.grid.main_window, self.grid.StatusBarMsg,
text=statustext)
event.Skip() | [
"def",
"OnFind",
"(",
"self",
",",
"event",
")",
":",
"# 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",
")",
"if",
"findpos",
"is",
"None",
":",
"# If nothing is found mention it in the statusbar and return",
"statustext",
"=",
"_",
"(",
"\"'{text}' not found.\"",
")",
".",
"format",
"(",
"text",
"=",
"text",
")",
"else",
":",
"# Otherwise select cell with next occurrence if successful",
"self",
".",
"grid",
".",
"actions",
".",
"cursor",
"=",
"findpos",
"# Update statusbar",
"statustext",
"=",
"_",
"(",
"u\"Found '{text}' in cell {key}.\"",
")",
"statustext",
"=",
"statustext",
".",
"format",
"(",
"text",
"=",
"text",
",",
"key",
"=",
"findpos",
")",
"post_command_event",
"(",
"self",
".",
"grid",
".",
"main_window",
",",
"self",
".",
"grid",
".",
"StatusBarMsg",
",",
"text",
"=",
"statustext",
")",
"event",
".",
"Skip",
"(",
")"
] | Find functionality, called from toolbar, returns find position | [
"Find",
"functionality",
"called",
"from",
"toolbar",
"returns",
"find",
"position"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1188-L1212 | train | 231,577 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnShowFindReplace | 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.Show(True) | python | 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.Show(True) | [
"def",
"OnShowFindReplace",
"(",
"self",
",",
"event",
")",
":",
"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",
".",
"Show",
"(",
"True",
")"
] | Calls the find-replace dialog | [
"Calls",
"the",
"find",
"-",
"replace",
"dialog"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1214-L1221 | train | 231,578 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnReplaceFind | 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 | 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) | [
"def",
"OnReplaceFind",
"(",
"self",
",",
"event",
")",
":",
"event",
".",
"text",
"=",
"event",
".",
"GetFindString",
"(",
")",
"event",
".",
"flags",
"=",
"self",
".",
"_wxflag2flag",
"(",
"event",
".",
"GetFlags",
"(",
")",
")",
"self",
".",
"OnFind",
"(",
"event",
")"
] | Called when a find operation is started from F&R dialog | [
"Called",
"when",
"a",
"find",
"operation",
"is",
"started",
"from",
"F&R",
"dialog"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1239-L1245 | train | 231,579 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnReplace | 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)
findpos = self.grid.actions.find(gridpos, find_string, flags,
search_result=False)
if findpos is None:
statustext = _(u"'{find_string}' not found.")
statustext = statustext.format(find_string=find_string)
else:
with undo.group(_("Replace")):
self.grid.actions.replace(findpos, find_string, replace_string)
self.grid.actions.cursor = findpos
# Update statusbar
statustext = _(u"Replaced '{find_string}' in cell {key} with "
u"{replace_string}.")
statustext = statustext.format(find_string=find_string,
key=findpos,
replace_string=replace_string)
post_command_event(self.grid.main_window, self.grid.StatusBarMsg,
text=statustext)
event.Skip() | python | 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)
findpos = self.grid.actions.find(gridpos, find_string, flags,
search_result=False)
if findpos is None:
statustext = _(u"'{find_string}' not found.")
statustext = statustext.format(find_string=find_string)
else:
with undo.group(_("Replace")):
self.grid.actions.replace(findpos, find_string, replace_string)
self.grid.actions.cursor = findpos
# Update statusbar
statustext = _(u"Replaced '{find_string}' in cell {key} with "
u"{replace_string}.")
statustext = statustext.format(find_string=find_string,
key=findpos,
replace_string=replace_string)
post_command_event(self.grid.main_window, self.grid.StatusBarMsg,
text=statustext)
event.Skip() | [
"def",
"OnReplace",
"(",
"self",
",",
"event",
")",
":",
"find_string",
"=",
"event",
".",
"GetFindString",
"(",
")",
"flags",
"=",
"self",
".",
"_wxflag2flag",
"(",
"event",
".",
"GetFlags",
"(",
")",
")",
"replace_string",
"=",
"event",
".",
"GetReplaceString",
"(",
")",
"gridpos",
"=",
"list",
"(",
"self",
".",
"grid",
".",
"actions",
".",
"cursor",
")",
"findpos",
"=",
"self",
".",
"grid",
".",
"actions",
".",
"find",
"(",
"gridpos",
",",
"find_string",
",",
"flags",
",",
"search_result",
"=",
"False",
")",
"if",
"findpos",
"is",
"None",
":",
"statustext",
"=",
"_",
"(",
"u\"'{find_string}' not found.\"",
")",
"statustext",
"=",
"statustext",
".",
"format",
"(",
"find_string",
"=",
"find_string",
")",
"else",
":",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Replace\"",
")",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"replace",
"(",
"findpos",
",",
"find_string",
",",
"replace_string",
")",
"self",
".",
"grid",
".",
"actions",
".",
"cursor",
"=",
"findpos",
"# Update statusbar",
"statustext",
"=",
"_",
"(",
"u\"Replaced '{find_string}' in cell {key} with \"",
"u\"{replace_string}.\"",
")",
"statustext",
"=",
"statustext",
".",
"format",
"(",
"find_string",
"=",
"find_string",
",",
"key",
"=",
"findpos",
",",
"replace_string",
"=",
"replace_string",
")",
"post_command_event",
"(",
"self",
".",
"grid",
".",
"main_window",
",",
"self",
".",
"grid",
".",
"StatusBarMsg",
",",
"text",
"=",
"statustext",
")",
"event",
".",
"Skip",
"(",
")"
] | Called when a replace operation is started, returns find position | [
"Called",
"when",
"a",
"replace",
"operation",
"is",
"started",
"returns",
"find",
"position"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1247-L1278 | train | 231,580 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnReplaceAll | 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)
with undo.group(_("Replace all")):
self.grid.actions.replace_all(findpositions, find_string,
replace_string)
event.Skip() | python | 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)
with undo.group(_("Replace all")):
self.grid.actions.replace_all(findpositions, find_string,
replace_string)
event.Skip() | [
"def",
"OnReplaceAll",
"(",
"self",
",",
"event",
")",
":",
"find_string",
"=",
"event",
".",
"GetFindString",
"(",
")",
"flags",
"=",
"self",
".",
"_wxflag2flag",
"(",
"event",
".",
"GetFlags",
"(",
")",
")",
"replace_string",
"=",
"event",
".",
"GetReplaceString",
"(",
")",
"findpositions",
"=",
"self",
".",
"grid",
".",
"actions",
".",
"find_all",
"(",
"find_string",
",",
"flags",
")",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Replace all\"",
")",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"replace_all",
"(",
"findpositions",
",",
"find_string",
",",
"replace_string",
")",
"event",
".",
"Skip",
"(",
")"
] | Called when a replace all operation is started | [
"Called",
"when",
"a",
"replace",
"all",
"operation",
"is",
"started"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1280-L1293 | train | 231,581 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers._get_no_rowscols | 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:
bb_left = 0
if bb_bottom is None:
bb_bottom = self.grid.code_array.shape[0] - 1
if bb_right is None:
bb_right = self.grid.code_array.shape[1] - 1
return bb_bottom - bb_top + 1, bb_right - bb_left + 1 | python | 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:
bb_left = 0
if bb_bottom is None:
bb_bottom = self.grid.code_array.shape[0] - 1
if bb_right is None:
bb_right = self.grid.code_array.shape[1] - 1
return bb_bottom - bb_top + 1, bb_right - bb_left + 1 | [
"def",
"_get_no_rowscols",
"(",
"self",
",",
"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",
":",
"bb_left",
"=",
"0",
"if",
"bb_bottom",
"is",
"None",
":",
"bb_bottom",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"shape",
"[",
"0",
"]",
"-",
"1",
"if",
"bb_right",
"is",
"None",
":",
"bb_right",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"shape",
"[",
"1",
"]",
"-",
"1",
"return",
"bb_bottom",
"-",
"bb_top",
"+",
"1",
",",
"bb_right",
"-",
"bb_left",
"+",
"1"
] | Returns tuple of number of rows and cols from bbox | [
"Returns",
"tuple",
"of",
"number",
"of",
"rows",
"and",
"cols",
"from",
"bbox"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1304-L1320 | train | 231,582 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnInsertRows | 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
else:
# Insert at lower edge of bounding box
ins_point = bbox[0][0] - 1
no_rows = self._get_no_rowscols(bbox)[0]
with undo.group(_("Insert rows")):
self.grid.actions.insert_rows(ins_point, no_rows)
self.grid.GetTable().ResetView()
# Update the default sized cell sizes
self.grid.actions.zoom()
event.Skip() | python | 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
else:
# Insert at lower edge of bounding box
ins_point = bbox[0][0] - 1
no_rows = self._get_no_rowscols(bbox)[0]
with undo.group(_("Insert rows")):
self.grid.actions.insert_rows(ins_point, no_rows)
self.grid.GetTable().ResetView()
# Update the default sized cell sizes
self.grid.actions.zoom()
event.Skip() | [
"def",
"OnInsertRows",
"(",
"self",
",",
"event",
")",
":",
"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",
"else",
":",
"# Insert at lower edge of bounding box",
"ins_point",
"=",
"bbox",
"[",
"0",
"]",
"[",
"0",
"]",
"-",
"1",
"no_rows",
"=",
"self",
".",
"_get_no_rowscols",
"(",
"bbox",
")",
"[",
"0",
"]",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Insert rows\"",
")",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"insert_rows",
"(",
"ins_point",
",",
"no_rows",
")",
"self",
".",
"grid",
".",
"GetTable",
"(",
")",
".",
"ResetView",
"(",
")",
"# Update the default sized cell sizes",
"self",
".",
"grid",
".",
"actions",
".",
"zoom",
"(",
")",
"event",
".",
"Skip",
"(",
")"
] | Insert the maximum of 1 and the number of selected rows | [
"Insert",
"the",
"maximum",
"of",
"1",
"and",
"the",
"number",
"of",
"selected",
"rows"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1322-L1344 | train | 231,583 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnInsertCols | 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
else:
# Insert at right edge of bounding box
ins_point = bbox[0][1] - 1
no_cols = self._get_no_rowscols(bbox)[1]
with undo.group(_("Insert columns")):
self.grid.actions.insert_cols(ins_point, no_cols)
self.grid.GetTable().ResetView()
# Update the default sized cell sizes
self.grid.actions.zoom()
event.Skip() | python | 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
else:
# Insert at right edge of bounding box
ins_point = bbox[0][1] - 1
no_cols = self._get_no_rowscols(bbox)[1]
with undo.group(_("Insert columns")):
self.grid.actions.insert_cols(ins_point, no_cols)
self.grid.GetTable().ResetView()
# Update the default sized cell sizes
self.grid.actions.zoom()
event.Skip() | [
"def",
"OnInsertCols",
"(",
"self",
",",
"event",
")",
":",
"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",
"else",
":",
"# Insert at right edge of bounding box",
"ins_point",
"=",
"bbox",
"[",
"0",
"]",
"[",
"1",
"]",
"-",
"1",
"no_cols",
"=",
"self",
".",
"_get_no_rowscols",
"(",
"bbox",
")",
"[",
"1",
"]",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Insert columns\"",
")",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"insert_cols",
"(",
"ins_point",
",",
"no_cols",
")",
"self",
".",
"grid",
".",
"GetTable",
"(",
")",
".",
"ResetView",
"(",
")",
"# Update the default sized cell sizes",
"self",
".",
"grid",
".",
"actions",
".",
"zoom",
"(",
")",
"event",
".",
"Skip",
"(",
")"
] | Inserts the maximum of 1 and the number of selected columns | [
"Inserts",
"the",
"maximum",
"of",
"1",
"and",
"the",
"number",
"of",
"selected",
"columns"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1346-L1368 | train | 231,584 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnInsertTabs | 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 | 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() | [
"def",
"OnInsertTabs",
"(",
"self",
",",
"event",
")",
":",
"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",
"(",
")"
] | Insert one table into grid | [
"Insert",
"one",
"table",
"into",
"grid"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1370-L1379 | train | 231,585 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnDeleteRows | 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:
# Insert at lower edge of bounding box
del_point = bbox[0][0]
no_rows = self._get_no_rowscols(bbox)[0]
with undo.group(_("Delete rows")):
self.grid.actions.delete_rows(del_point, no_rows)
self.grid.GetTable().ResetView()
# Update the default sized cell sizes
self.grid.actions.zoom()
event.Skip() | python | 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:
# Insert at lower edge of bounding box
del_point = bbox[0][0]
no_rows = self._get_no_rowscols(bbox)[0]
with undo.group(_("Delete rows")):
self.grid.actions.delete_rows(del_point, no_rows)
self.grid.GetTable().ResetView()
# Update the default sized cell sizes
self.grid.actions.zoom()
event.Skip() | [
"def",
"OnDeleteRows",
"(",
"self",
",",
"event",
")",
":",
"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",
":",
"# Insert at lower edge of bounding box",
"del_point",
"=",
"bbox",
"[",
"0",
"]",
"[",
"0",
"]",
"no_rows",
"=",
"self",
".",
"_get_no_rowscols",
"(",
"bbox",
")",
"[",
"0",
"]",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Delete rows\"",
")",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"delete_rows",
"(",
"del_point",
",",
"no_rows",
")",
"self",
".",
"grid",
".",
"GetTable",
"(",
")",
".",
"ResetView",
"(",
")",
"# Update the default sized cell sizes",
"self",
".",
"grid",
".",
"actions",
".",
"zoom",
"(",
")",
"event",
".",
"Skip",
"(",
")"
] | Deletes rows from all tables of the grid | [
"Deletes",
"rows",
"from",
"all",
"tables",
"of",
"the",
"grid"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1381-L1403 | train | 231,586 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnDeleteCols | 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:
# Insert at right edge of bounding box
del_point = bbox[0][1]
no_cols = self._get_no_rowscols(bbox)[1]
with undo.group(_("Delete columns")):
self.grid.actions.delete_cols(del_point, no_cols)
self.grid.GetTable().ResetView()
# Update the default sized cell sizes
self.grid.actions.zoom()
event.Skip() | python | 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:
# Insert at right edge of bounding box
del_point = bbox[0][1]
no_cols = self._get_no_rowscols(bbox)[1]
with undo.group(_("Delete columns")):
self.grid.actions.delete_cols(del_point, no_cols)
self.grid.GetTable().ResetView()
# Update the default sized cell sizes
self.grid.actions.zoom()
event.Skip() | [
"def",
"OnDeleteCols",
"(",
"self",
",",
"event",
")",
":",
"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",
":",
"# Insert at right edge of bounding box",
"del_point",
"=",
"bbox",
"[",
"0",
"]",
"[",
"1",
"]",
"no_cols",
"=",
"self",
".",
"_get_no_rowscols",
"(",
"bbox",
")",
"[",
"1",
"]",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Delete columns\"",
")",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"delete_cols",
"(",
"del_point",
",",
"no_cols",
")",
"self",
".",
"grid",
".",
"GetTable",
"(",
")",
".",
"ResetView",
"(",
")",
"# Update the default sized cell sizes",
"self",
".",
"grid",
".",
"actions",
".",
"zoom",
"(",
")",
"event",
".",
"Skip",
"(",
")"
] | Deletes columns from all tables of the grid | [
"Deletes",
"columns",
"from",
"all",
"tables",
"of",
"the",
"grid"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1405-L1427 | train | 231,587 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnQuote | 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
self.grid.actions.quote_selection()
# Update grid
self.grid.ForceRefresh()
else:
row = self.grid.GetGridCursorRow()
col = self.grid.GetGridCursorCol()
key = row, col, grid.current_table
self.grid.actions.quote_code(key)
grid.MoveCursorDown(False) | python | 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
self.grid.actions.quote_selection()
# Update grid
self.grid.ForceRefresh()
else:
row = self.grid.GetGridCursorRow()
col = self.grid.GetGridCursorCol()
key = row, col, grid.current_table
self.grid.actions.quote_code(key)
grid.MoveCursorDown(False) | [
"def",
"OnQuote",
"(",
"self",
",",
"event",
")",
":",
"grid",
"=",
"self",
".",
"grid",
"grid",
".",
"DisableCellEditControl",
"(",
")",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Quote cell(s)\"",
")",
")",
":",
"# Is a selection present?",
"if",
"self",
".",
"grid",
".",
"IsSelection",
"(",
")",
":",
"# Enclose all selected cells",
"self",
".",
"grid",
".",
"actions",
".",
"quote_selection",
"(",
")",
"# Update grid",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")",
"else",
":",
"row",
"=",
"self",
".",
"grid",
".",
"GetGridCursorRow",
"(",
")",
"col",
"=",
"self",
".",
"grid",
".",
"GetGridCursorCol",
"(",
")",
"key",
"=",
"row",
",",
"col",
",",
"grid",
".",
"current_table",
"self",
".",
"grid",
".",
"actions",
".",
"quote_code",
"(",
"key",
")",
"grid",
".",
"MoveCursorDown",
"(",
"False",
")"
] | Quotes selection or if none the current cell | [
"Quotes",
"selection",
"or",
"if",
"none",
"the",
"current",
"cell"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1460-L1482 | train | 231,588 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnRowSize | 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) == 0:
rows = [row, ]
# Detect for selection of rows spanning all columns
selection = self.grid.selection
num_cols = self.grid.code_array.shape[1]-1
for box in zip(selection.block_tl, selection.block_br):
leftmost_col = box[0][1]
rightmost_col = box[1][1]
if leftmost_col == 0 and rightmost_col == num_cols:
rows += range(box[0][0], box[1][0]+1)
# All row resizing is undone in one click
with undo.group(_("Resize Rows")):
for row in rows:
self.grid.code_array.set_row_height(row, tab, rowsize)
zoomed_rowsize = rowsize * self.grid.grid_renderer.zoom
self.grid.SetRowSize(row, zoomed_rowsize)
# Mark content as changed
post_command_event(self.grid.main_window, self.grid.ContentChangedMsg)
event.Skip()
self.grid.ForceRefresh() | python | 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) == 0:
rows = [row, ]
# Detect for selection of rows spanning all columns
selection = self.grid.selection
num_cols = self.grid.code_array.shape[1]-1
for box in zip(selection.block_tl, selection.block_br):
leftmost_col = box[0][1]
rightmost_col = box[1][1]
if leftmost_col == 0 and rightmost_col == num_cols:
rows += range(box[0][0], box[1][0]+1)
# All row resizing is undone in one click
with undo.group(_("Resize Rows")):
for row in rows:
self.grid.code_array.set_row_height(row, tab, rowsize)
zoomed_rowsize = rowsize * self.grid.grid_renderer.zoom
self.grid.SetRowSize(row, zoomed_rowsize)
# Mark content as changed
post_command_event(self.grid.main_window, self.grid.ContentChangedMsg)
event.Skip()
self.grid.ForceRefresh() | [
"def",
"OnRowSize",
"(",
"self",
",",
"event",
")",
":",
"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",
")",
"==",
"0",
":",
"rows",
"=",
"[",
"row",
",",
"]",
"# Detect for selection of rows spanning all columns",
"selection",
"=",
"self",
".",
"grid",
".",
"selection",
"num_cols",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"shape",
"[",
"1",
"]",
"-",
"1",
"for",
"box",
"in",
"zip",
"(",
"selection",
".",
"block_tl",
",",
"selection",
".",
"block_br",
")",
":",
"leftmost_col",
"=",
"box",
"[",
"0",
"]",
"[",
"1",
"]",
"rightmost_col",
"=",
"box",
"[",
"1",
"]",
"[",
"1",
"]",
"if",
"leftmost_col",
"==",
"0",
"and",
"rightmost_col",
"==",
"num_cols",
":",
"rows",
"+=",
"range",
"(",
"box",
"[",
"0",
"]",
"[",
"0",
"]",
",",
"box",
"[",
"1",
"]",
"[",
"0",
"]",
"+",
"1",
")",
"# All row resizing is undone in one click",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Resize Rows\"",
")",
")",
":",
"for",
"row",
"in",
"rows",
":",
"self",
".",
"grid",
".",
"code_array",
".",
"set_row_height",
"(",
"row",
",",
"tab",
",",
"rowsize",
")",
"zoomed_rowsize",
"=",
"rowsize",
"*",
"self",
".",
"grid",
".",
"grid_renderer",
".",
"zoom",
"self",
".",
"grid",
".",
"SetRowSize",
"(",
"row",
",",
"zoomed_rowsize",
")",
"# Mark content as changed",
"post_command_event",
"(",
"self",
".",
"grid",
".",
"main_window",
",",
"self",
".",
"grid",
".",
"ContentChangedMsg",
")",
"event",
".",
"Skip",
"(",
")",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")"
] | Row size event handler | [
"Row",
"size",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1486-L1518 | train | 231,589 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnColSize | 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(cols) == 0:
cols = [col, ]
# Detect for selection of rows spanning all columns
selection = self.grid.selection
num_rows = self.grid.code_array.shape[0]-1
for box in zip(selection.block_tl, selection.block_br):
top_row = box[0][0]
bottom_row = box[1][0]
if top_row == 0 and bottom_row == num_rows:
cols += range(box[0][1], box[1][1]+1)
# All column resizing is undone in one click
with undo.group(_("Resize Columns")):
for col in cols:
self.grid.code_array.set_col_width(col, tab, colsize)
zoomed_colsize = colsize * self.grid.grid_renderer.zoom
self.grid.SetColSize(col, zoomed_colsize)
# Mark content as changed
post_command_event(self.grid.main_window, self.grid.ContentChangedMsg)
event.Skip()
self.grid.ForceRefresh() | python | 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(cols) == 0:
cols = [col, ]
# Detect for selection of rows spanning all columns
selection = self.grid.selection
num_rows = self.grid.code_array.shape[0]-1
for box in zip(selection.block_tl, selection.block_br):
top_row = box[0][0]
bottom_row = box[1][0]
if top_row == 0 and bottom_row == num_rows:
cols += range(box[0][1], box[1][1]+1)
# All column resizing is undone in one click
with undo.group(_("Resize Columns")):
for col in cols:
self.grid.code_array.set_col_width(col, tab, colsize)
zoomed_colsize = colsize * self.grid.grid_renderer.zoom
self.grid.SetColSize(col, zoomed_colsize)
# Mark content as changed
post_command_event(self.grid.main_window, self.grid.ContentChangedMsg)
event.Skip()
self.grid.ForceRefresh() | [
"def",
"OnColSize",
"(",
"self",
",",
"event",
")",
":",
"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",
"(",
"cols",
")",
"==",
"0",
":",
"cols",
"=",
"[",
"col",
",",
"]",
"# Detect for selection of rows spanning all columns",
"selection",
"=",
"self",
".",
"grid",
".",
"selection",
"num_rows",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"shape",
"[",
"0",
"]",
"-",
"1",
"for",
"box",
"in",
"zip",
"(",
"selection",
".",
"block_tl",
",",
"selection",
".",
"block_br",
")",
":",
"top_row",
"=",
"box",
"[",
"0",
"]",
"[",
"0",
"]",
"bottom_row",
"=",
"box",
"[",
"1",
"]",
"[",
"0",
"]",
"if",
"top_row",
"==",
"0",
"and",
"bottom_row",
"==",
"num_rows",
":",
"cols",
"+=",
"range",
"(",
"box",
"[",
"0",
"]",
"[",
"1",
"]",
",",
"box",
"[",
"1",
"]",
"[",
"1",
"]",
"+",
"1",
")",
"# All column resizing is undone in one click",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Resize Columns\"",
")",
")",
":",
"for",
"col",
"in",
"cols",
":",
"self",
".",
"grid",
".",
"code_array",
".",
"set_col_width",
"(",
"col",
",",
"tab",
",",
"colsize",
")",
"zoomed_colsize",
"=",
"colsize",
"*",
"self",
".",
"grid",
".",
"grid_renderer",
".",
"zoom",
"self",
".",
"grid",
".",
"SetColSize",
"(",
"col",
",",
"zoomed_colsize",
")",
"# Mark content as changed",
"post_command_event",
"(",
"self",
".",
"grid",
".",
"main_window",
",",
"self",
".",
"grid",
".",
"ContentChangedMsg",
")",
"event",
".",
"Skip",
"(",
")",
"self",
".",
"grid",
".",
"ForceRefresh",
"(",
")"
] | Column size event handler | [
"Column",
"size",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1520-L1552 | train | 231,590 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnSortAscending | 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 = _(u"Sorting failed: {}").format(err)
post_command_event(self.grid.main_window, self.grid.StatusBarMsg,
text=statustext) | python | 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 = _(u"Sorting failed: {}").format(err)
post_command_event(self.grid.main_window, self.grid.StatusBarMsg,
text=statustext) | [
"def",
"OnSortAscending",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"with",
"undo",
".",
"group",
"(",
"_",
"(",
"\"Sort ascending\"",
")",
")",
":",
"self",
".",
"grid",
".",
"actions",
".",
"sort_ascending",
"(",
"self",
".",
"grid",
".",
"actions",
".",
"cursor",
")",
"statustext",
"=",
"_",
"(",
"u\"Sorting complete.\"",
")",
"except",
"Exception",
",",
"err",
":",
"statustext",
"=",
"_",
"(",
"u\"Sorting failed: {}\"",
")",
".",
"format",
"(",
"err",
")",
"post_command_event",
"(",
"self",
".",
"grid",
".",
"main_window",
",",
"self",
".",
"grid",
".",
"StatusBarMsg",
",",
"text",
"=",
"statustext",
")"
] | Sort ascending event handler | [
"Sort",
"ascending",
"event",
"handler"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1554-L1566 | train | 231,591 |
manns/pyspread | pyspread/src/gui/_grid.py | GridEventHandlers.OnUndo | 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)
except TypeError:
# The main window does not exist any more
pass
self.grid.code_array.result_cache.clear()
post_command_event(self.grid.main_window, self.grid.TableChangedMsg,
updated_cell=True)
# Reset row heights and column widths by zooming
self.grid.actions.zoom()
# Change grid table dimensions
self.grid.GetTable().ResetView()
# Update TableChoiceIntCtrl
shape = self.grid.code_array.shape
post_command_event(self.main_window, self.grid.ResizeGridMsg,
shape=shape)
# Update toolbars
self.grid.update_entry_line()
self.grid.update_attribute_toolbar()
post_command_event(self.grid.main_window, self.grid.StatusBarMsg,
text=statustext) | python | 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)
except TypeError:
# The main window does not exist any more
pass
self.grid.code_array.result_cache.clear()
post_command_event(self.grid.main_window, self.grid.TableChangedMsg,
updated_cell=True)
# Reset row heights and column widths by zooming
self.grid.actions.zoom()
# Change grid table dimensions
self.grid.GetTable().ResetView()
# Update TableChoiceIntCtrl
shape = self.grid.code_array.shape
post_command_event(self.main_window, self.grid.ResizeGridMsg,
shape=shape)
# Update toolbars
self.grid.update_entry_line()
self.grid.update_attribute_toolbar()
post_command_event(self.grid.main_window, self.grid.StatusBarMsg,
text=statustext) | [
"def",
"OnUndo",
"(",
"self",
",",
"event",
")",
":",
"statustext",
"=",
"undo",
".",
"stack",
"(",
")",
".",
"undotext",
"(",
")",
"undo",
".",
"stack",
"(",
")",
".",
"undo",
"(",
")",
"# Update content changed state",
"try",
":",
"post_command_event",
"(",
"self",
".",
"grid",
".",
"main_window",
",",
"self",
".",
"grid",
".",
"ContentChangedMsg",
")",
"except",
"TypeError",
":",
"# The main window does not exist any more",
"pass",
"self",
".",
"grid",
".",
"code_array",
".",
"result_cache",
".",
"clear",
"(",
")",
"post_command_event",
"(",
"self",
".",
"grid",
".",
"main_window",
",",
"self",
".",
"grid",
".",
"TableChangedMsg",
",",
"updated_cell",
"=",
"True",
")",
"# Reset row heights and column widths by zooming",
"self",
".",
"grid",
".",
"actions",
".",
"zoom",
"(",
")",
"# Change grid table dimensions",
"self",
".",
"grid",
".",
"GetTable",
"(",
")",
".",
"ResetView",
"(",
")",
"# Update TableChoiceIntCtrl",
"shape",
"=",
"self",
".",
"grid",
".",
"code_array",
".",
"shape",
"post_command_event",
"(",
"self",
".",
"main_window",
",",
"self",
".",
"grid",
".",
"ResizeGridMsg",
",",
"shape",
"=",
"shape",
")",
"# Update toolbars",
"self",
".",
"grid",
".",
"update_entry_line",
"(",
")",
"self",
".",
"grid",
".",
"update_attribute_toolbar",
"(",
")",
"post_command_event",
"(",
"self",
".",
"grid",
".",
"main_window",
",",
"self",
".",
"grid",
".",
"StatusBarMsg",
",",
"text",
"=",
"statustext",
")"
] | Calls the grid undo method | [
"Calls",
"the",
"grid",
"undo",
"method"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1584-L1619 | train | 231,592 |
manns/pyspread | pyspread/examples/template_macro.py | rowcol_from_template | 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 target table
if tab == target_tab:
S.row_heights.pop((row, tab))
if tab == template_tab:
S.row_heights[(row, target_tab)] = \
S.row_heights[(row, tab)]
for col, tab in S.col_widths.keys():
# Delete all column widths in target table
if tab == target_tab:
S.col_widths.pop((col, tab))
if tab == template_tab:
S.col_widths[(col, target_tab)] = \
S.col_widths[(col, tab)]
return "Table {tab} adjusted.".format(tab=target_tab) | python | 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 target table
if tab == target_tab:
S.row_heights.pop((row, tab))
if tab == template_tab:
S.row_heights[(row, target_tab)] = \
S.row_heights[(row, tab)]
for col, tab in S.col_widths.keys():
# Delete all column widths in target table
if tab == target_tab:
S.col_widths.pop((col, tab))
if tab == template_tab:
S.col_widths[(col, target_tab)] = \
S.col_widths[(col, tab)]
return "Table {tab} adjusted.".format(tab=target_tab) | [
"def",
"rowcol_from_template",
"(",
"target_tab",
",",
"template_tab",
"=",
"0",
")",
":",
"for",
"row",
",",
"tab",
"in",
"S",
".",
"row_heights",
".",
"keys",
"(",
")",
":",
"# Delete all row heights in target table",
"if",
"tab",
"==",
"target_tab",
":",
"S",
".",
"row_heights",
".",
"pop",
"(",
"(",
"row",
",",
"tab",
")",
")",
"if",
"tab",
"==",
"template_tab",
":",
"S",
".",
"row_heights",
"[",
"(",
"row",
",",
"target_tab",
")",
"]",
"=",
"S",
".",
"row_heights",
"[",
"(",
"row",
",",
"tab",
")",
"]",
"for",
"col",
",",
"tab",
"in",
"S",
".",
"col_widths",
".",
"keys",
"(",
")",
":",
"# Delete all column widths in target table",
"if",
"tab",
"==",
"target_tab",
":",
"S",
".",
"col_widths",
".",
"pop",
"(",
"(",
"col",
",",
"tab",
")",
")",
"if",
"tab",
"==",
"template_tab",
":",
"S",
".",
"col_widths",
"[",
"(",
"col",
",",
"target_tab",
")",
"]",
"=",
"S",
".",
"col_widths",
"[",
"(",
"col",
",",
"tab",
")",
"]",
"return",
"\"Table {tab} adjusted.\"",
".",
"format",
"(",
"tab",
"=",
"target_tab",
")"
] | 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 | [
"Adjusts",
"row",
"heights",
"and",
"column",
"widths",
"to",
"match",
"the",
"template"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/examples/template_macro.py#L1-L31 | train | 231,593 |
manns/pyspread | pyspread/examples/template_macro.py | cell_attributes_from_template | 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] == template_tab:
new_attr = (attr[0], target_tab, attr[2])
new_cell_attributes.append(new_attr)
S.cell_attributes.extend(new_cell_attributes)
return "Table {tab} adjusted.".format(tab=target_tab) | python | 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] == template_tab:
new_attr = (attr[0], target_tab, attr[2])
new_cell_attributes.append(new_attr)
S.cell_attributes.extend(new_cell_attributes)
return "Table {tab} adjusted.".format(tab=target_tab) | [
"def",
"cell_attributes_from_template",
"(",
"target_tab",
",",
"template_tab",
"=",
"0",
")",
":",
"new_cell_attributes",
"=",
"[",
"]",
"for",
"attr",
"in",
"S",
".",
"cell_attributes",
":",
"if",
"attr",
"[",
"1",
"]",
"==",
"template_tab",
":",
"new_attr",
"=",
"(",
"attr",
"[",
"0",
"]",
",",
"target_tab",
",",
"attr",
"[",
"2",
"]",
")",
"new_cell_attributes",
".",
"append",
"(",
"new_attr",
")",
"S",
".",
"cell_attributes",
".",
"extend",
"(",
"new_cell_attributes",
")",
"return",
"\"Table {tab} adjusted.\"",
".",
"format",
"(",
"tab",
"=",
"target_tab",
")"
] | Adjusts cell paarmeters to match the template
Parameters
----------
target_tab: Integer
\tTable to be adjusted
template_tab: Integer, defaults to 0
\tTemplate table | [
"Adjusts",
"cell",
"paarmeters",
"to",
"match",
"the",
"template"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/examples/template_macro.py#L33-L52 | train | 231,594 |
manns/pyspread | pyspread/src/lib/parsers.py | get_font_from_data | 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 the system default font point size
if not nativefontinfo.GetPointSize():
nativefontinfo.SetPointSize(get_default_font().GetPointSize())
textfont.SetNativeFontInfo(nativefontinfo)
return textfont | python | 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 the system default font point size
if not nativefontinfo.GetPointSize():
nativefontinfo.SetPointSize(get_default_font().GetPointSize())
textfont.SetNativeFontInfo(nativefontinfo)
return textfont | [
"def",
"get_font_from_data",
"(",
"fontdata",
")",
":",
"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 the system default font point size",
"if",
"not",
"nativefontinfo",
".",
"GetPointSize",
"(",
")",
":",
"nativefontinfo",
".",
"SetPointSize",
"(",
"get_default_font",
"(",
")",
".",
"GetPointSize",
"(",
")",
")",
"textfont",
".",
"SetNativeFontInfo",
"(",
"nativefontinfo",
")",
"return",
"textfont"
] | Returns wx.Font from fontdata string | [
"Returns",
"wx",
".",
"Font",
"from",
"fontdata",
"string"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/parsers.py#L52-L69 | train | 231,595 |
manns/pyspread | pyspread/src/lib/parsers.py | get_pen_from_data | 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 | 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 | [
"def",
"get_pen_from_data",
"(",
"pendata",
")",
":",
"pen_color",
"=",
"wx",
".",
"Colour",
"(",
")",
"pen_color",
".",
"SetRGB",
"(",
"pendata",
"[",
"0",
"]",
")",
"pen",
"=",
"wx",
".",
"Pen",
"(",
"pen_color",
",",
"*",
"pendata",
"[",
"1",
":",
"]",
")",
"pen",
".",
"SetJoin",
"(",
"wx",
".",
"JOIN_MITER",
")",
"return",
"pen"
] | Returns wx.Pen from pendata attribute list | [
"Returns",
"wx",
".",
"Pen",
"from",
"pendata",
"attribute",
"list"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/parsers.py#L72-L80 | train | 231,596 |
manns/pyspread | pyspread/src/lib/parsers.py | color_pack2rgb | 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 | 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 | [
"def",
"color_pack2rgb",
"(",
"packed",
")",
":",
"r",
"=",
"packed",
"&",
"255",
"g",
"=",
"(",
"packed",
"&",
"(",
"255",
"<<",
"8",
")",
")",
">>",
"8",
"b",
"=",
"(",
"packed",
"&",
"(",
"255",
"<<",
"16",
")",
")",
">>",
"16",
"return",
"r",
",",
"g",
",",
"b"
] | Returns r, g, b tuple from packed wx.ColourGetRGB value | [
"Returns",
"r",
"g",
"b",
"tuple",
"from",
"packed",
"wx",
".",
"ColourGetRGB",
"value"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/parsers.py#L98-L105 | train | 231,597 |
manns/pyspread | pyspread/src/lib/parsers.py | unquote_string | 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 | 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) | [
"def",
"unquote_string",
"(",
"code",
")",
":",
"scode",
"=",
"code",
".",
"strip",
"(",
")",
"assert",
"scode",
"[",
"-",
"1",
"]",
"in",
"[",
"\"'\"",
",",
"'\"'",
"]",
"assert",
"scode",
"[",
"0",
"]",
"in",
"[",
"\"'\"",
",",
"'\"'",
"]",
"or",
"scode",
"[",
"1",
"]",
"in",
"[",
"\"'\"",
",",
"'\"'",
"]",
"return",
"ast",
".",
"literal_eval",
"(",
"scode",
")"
] | Returns a string from code that contains a repr of the string | [
"Returns",
"a",
"string",
"from",
"code",
"that",
"contains",
"a",
"repr",
"of",
"the",
"string"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/parsers.py#L114-L121 | train | 231,598 |
manns/pyspread | pyspread/src/lib/parsers.py | parse_dict_strings | 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 = None
for i, char in enumerate(code):
if char in ["(", "[", "{"] and curr_paren is None:
level += 1
elif char in [")", "]", "}"] and curr_paren is None:
level -= 1
elif char in ['"', "'"]:
if curr_paren == char:
curr_paren = None
elif curr_paren is None:
curr_paren = char
if level == 0 and char in [':', ','] and curr_paren is None:
yield code[chunk_start: i].strip()
chunk_start = i + 1
yield code[chunk_start:i + 1].strip() | python | 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 = None
for i, char in enumerate(code):
if char in ["(", "[", "{"] and curr_paren is None:
level += 1
elif char in [")", "]", "}"] and curr_paren is None:
level -= 1
elif char in ['"', "'"]:
if curr_paren == char:
curr_paren = None
elif curr_paren is None:
curr_paren = char
if level == 0 and char in [':', ','] and curr_paren is None:
yield code[chunk_start: i].strip()
chunk_start = i + 1
yield code[chunk_start:i + 1].strip() | [
"def",
"parse_dict_strings",
"(",
"code",
")",
":",
"i",
"=",
"0",
"level",
"=",
"0",
"chunk_start",
"=",
"0",
"curr_paren",
"=",
"None",
"for",
"i",
",",
"char",
"in",
"enumerate",
"(",
"code",
")",
":",
"if",
"char",
"in",
"[",
"\"(\"",
",",
"\"[\"",
",",
"\"{\"",
"]",
"and",
"curr_paren",
"is",
"None",
":",
"level",
"+=",
"1",
"elif",
"char",
"in",
"[",
"\")\"",
",",
"\"]\"",
",",
"\"}\"",
"]",
"and",
"curr_paren",
"is",
"None",
":",
"level",
"-=",
"1",
"elif",
"char",
"in",
"[",
"'\"'",
",",
"\"'\"",
"]",
":",
"if",
"curr_paren",
"==",
"char",
":",
"curr_paren",
"=",
"None",
"elif",
"curr_paren",
"is",
"None",
":",
"curr_paren",
"=",
"char",
"if",
"level",
"==",
"0",
"and",
"char",
"in",
"[",
"':'",
",",
"','",
"]",
"and",
"curr_paren",
"is",
"None",
":",
"yield",
"code",
"[",
"chunk_start",
":",
"i",
"]",
".",
"strip",
"(",
")",
"chunk_start",
"=",
"i",
"+",
"1",
"yield",
"code",
"[",
"chunk_start",
":",
"i",
"+",
"1",
"]",
".",
"strip",
"(",
")"
] | 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 | [
"Generator",
"of",
"elements",
"of",
"a",
"dict",
"that",
"is",
"given",
"in",
"the",
"code",
"string"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/parsers.py#L124-L156 | train | 231,599 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.