id
int32
0
252k
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
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
236,600
manns/pyspread
pyspread/src/gui/_grid_table.py
GridTable.GetValue
def GetValue(self, row, col, table=None): """Return the result value of a cell, line split if too much data""" if table is None: table = self.grid.current_table try: cell_code = self.code_array((row, col, table)) except IndexError: cell_code = None # Put EOLs into result if it is too long maxlength = int(config["max_textctrl_length"]) if cell_code is not None and len(cell_code) > maxlength: chunk = 80 cell_code = "\n".join(cell_code[i:i + chunk] for i in xrange(0, len(cell_code), chunk)) return cell_code
python
def GetValue(self, row, col, table=None): """Return the result value of a cell, line split if too much data""" if table is None: table = self.grid.current_table try: cell_code = self.code_array((row, col, table)) except IndexError: cell_code = None # Put EOLs into result if it is too long maxlength = int(config["max_textctrl_length"]) if cell_code is not None and len(cell_code) > maxlength: chunk = 80 cell_code = "\n".join(cell_code[i:i + chunk] for i in xrange(0, len(cell_code), chunk)) return cell_code
[ "def", "GetValue", "(", "self", ",", "row", ",", "col", ",", "table", "=", "None", ")", ":", "if", "table", "is", "None", ":", "table", "=", "self", ".", "grid", ".", "current_table", "try", ":", "cell_code", "=", "self", ".", "code_array", "(", "(", "row", ",", "col", ",", "table", ")", ")", "except", "IndexError", ":", "cell_code", "=", "None", "# Put EOLs into result if it is too long", "maxlength", "=", "int", "(", "config", "[", "\"max_textctrl_length\"", "]", ")", "if", "cell_code", "is", "not", "None", "and", "len", "(", "cell_code", ")", ">", "maxlength", ":", "chunk", "=", "80", "cell_code", "=", "\"\\n\"", ".", "join", "(", "cell_code", "[", "i", ":", "i", "+", "chunk", "]", "for", "i", "in", "xrange", "(", "0", ",", "len", "(", "cell_code", ")", ",", "chunk", ")", ")", "return", "cell_code" ]
Return the result value of a cell, line split if too much data
[ "Return", "the", "result", "value", "of", "a", "cell", "line", "split", "if", "too", "much", "data" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid_table.py#L82-L101
236,601
manns/pyspread
pyspread/src/gui/_grid_table.py
GridTable.SetValue
def SetValue(self, row, col, value, refresh=True): """Set the value of a cell, merge line breaks""" # Join code that has been split because of long line issue value = "".join(value.split("\n")) key = row, col, self.grid.current_table old_code = self.grid.code_array(key) if old_code is None: old_code = "" if value != old_code: self.grid.actions.set_code(key, value)
python
def SetValue(self, row, col, value, refresh=True): """Set the value of a cell, merge line breaks""" # Join code that has been split because of long line issue value = "".join(value.split("\n")) key = row, col, self.grid.current_table old_code = self.grid.code_array(key) if old_code is None: old_code = "" if value != old_code: self.grid.actions.set_code(key, value)
[ "def", "SetValue", "(", "self", ",", "row", ",", "col", ",", "value", ",", "refresh", "=", "True", ")", ":", "# Join code that has been split because of long line issue", "value", "=", "\"\"", ".", "join", "(", "value", ".", "split", "(", "\"\\n\"", ")", ")", "key", "=", "row", ",", "col", ",", "self", ".", "grid", ".", "current_table", "old_code", "=", "self", ".", "grid", ".", "code_array", "(", "key", ")", "if", "old_code", "is", "None", ":", "old_code", "=", "\"\"", "if", "value", "!=", "old_code", ":", "self", ".", "grid", ".", "actions", ".", "set_code", "(", "key", ",", "value", ")" ]
Set the value of a cell, merge line breaks
[ "Set", "the", "value", "of", "a", "cell", "merge", "line", "breaks" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid_table.py#L103-L116
236,602
manns/pyspread
pyspread/src/gui/_grid_table.py
GridTable.UpdateValues
def UpdateValues(self): """Update all displayed values""" # This sends an event to the grid table # to update all of the values msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES) self.grid.ProcessTableMessage(msg)
python
def UpdateValues(self): """Update all displayed values""" # This sends an event to the grid table # to update all of the values msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES) self.grid.ProcessTableMessage(msg)
[ "def", "UpdateValues", "(", "self", ")", ":", "# This sends an event to the grid table", "# to update all of the values", "msg", "=", "wx", ".", "grid", ".", "GridTableMessage", "(", "self", ",", "wx", ".", "grid", ".", "GRIDTABLE_REQUEST_VIEW_GET_VALUES", ")", "self", ".", "grid", ".", "ProcessTableMessage", "(", "msg", ")" ]
Update all displayed values
[ "Update", "all", "displayed", "values" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid_table.py#L118-L126
236,603
manns/pyspread
pyspread/src/gui/_events.py
post_command_event
def post_command_event(target, msg_cls, **kwargs): """Posts command event to main window Command events propagate. Parameters ---------- * msg_cls: class \tMessage class from new_command_event() * kwargs: dict \tMessage arguments """ msg = msg_cls(id=-1, **kwargs) wx.PostEvent(target, msg)
python
def post_command_event(target, msg_cls, **kwargs): """Posts command event to main window Command events propagate. Parameters ---------- * msg_cls: class \tMessage class from new_command_event() * kwargs: dict \tMessage arguments """ msg = msg_cls(id=-1, **kwargs) wx.PostEvent(target, msg)
[ "def", "post_command_event", "(", "target", ",", "msg_cls", ",", "*", "*", "kwargs", ")", ":", "msg", "=", "msg_cls", "(", "id", "=", "-", "1", ",", "*", "*", "kwargs", ")", "wx", ".", "PostEvent", "(", "target", ",", "msg", ")" ]
Posts command event to main window Command events propagate. Parameters ---------- * msg_cls: class \tMessage class from new_command_event() * kwargs: dict \tMessage arguments
[ "Posts", "command", "event", "to", "main", "window" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_events.py#L40-L55
236,604
manns/pyspread
pyspread/src/lib/clipboard.py
Clipboard._convert_clipboard
def _convert_clipboard(self, datastring=None, sep='\t'): """Converts data string to iterable. Parameters: ----------- datastring: string, defaults to None \tThe data string to be converted. \tself.get_clipboard() is called if set to None sep: string \tSeparator for columns in datastring """ if datastring is None: datastring = self.get_clipboard() data_it = ((ele for ele in line.split(sep)) for line in datastring.splitlines()) return data_it
python
def _convert_clipboard(self, datastring=None, sep='\t'): """Converts data string to iterable. Parameters: ----------- datastring: string, defaults to None \tThe data string to be converted. \tself.get_clipboard() is called if set to None sep: string \tSeparator for columns in datastring """ if datastring is None: datastring = self.get_clipboard() data_it = ((ele for ele in line.split(sep)) for line in datastring.splitlines()) return data_it
[ "def", "_convert_clipboard", "(", "self", ",", "datastring", "=", "None", ",", "sep", "=", "'\\t'", ")", ":", "if", "datastring", "is", "None", ":", "datastring", "=", "self", ".", "get_clipboard", "(", ")", "data_it", "=", "(", "(", "ele", "for", "ele", "in", "line", ".", "split", "(", "sep", ")", ")", "for", "line", "in", "datastring", ".", "splitlines", "(", ")", ")", "return", "data_it" ]
Converts data string to iterable. Parameters: ----------- datastring: string, defaults to None \tThe data string to be converted. \tself.get_clipboard() is called if set to None sep: string \tSeparator for columns in datastring
[ "Converts", "data", "string", "to", "iterable", "." ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/clipboard.py#L54-L72
236,605
manns/pyspread
pyspread/src/lib/clipboard.py
Clipboard.get_clipboard
def get_clipboard(self): """Returns the clipboard content If a bitmap is contained then it is returned. Otherwise, the clipboard text is returned. """ bmpdata = wx.BitmapDataObject() textdata = wx.TextDataObject() if self.clipboard.Open(): is_bmp_present = self.clipboard.GetData(bmpdata) self.clipboard.GetData(textdata) self.clipboard.Close() else: wx.MessageBox(_("Can't open the clipboard"), _("Error")) if is_bmp_present: return bmpdata.GetBitmap() else: return textdata.GetText()
python
def get_clipboard(self): """Returns the clipboard content If a bitmap is contained then it is returned. Otherwise, the clipboard text is returned. """ bmpdata = wx.BitmapDataObject() textdata = wx.TextDataObject() if self.clipboard.Open(): is_bmp_present = self.clipboard.GetData(bmpdata) self.clipboard.GetData(textdata) self.clipboard.Close() else: wx.MessageBox(_("Can't open the clipboard"), _("Error")) if is_bmp_present: return bmpdata.GetBitmap() else: return textdata.GetText()
[ "def", "get_clipboard", "(", "self", ")", ":", "bmpdata", "=", "wx", ".", "BitmapDataObject", "(", ")", "textdata", "=", "wx", ".", "TextDataObject", "(", ")", "if", "self", ".", "clipboard", ".", "Open", "(", ")", ":", "is_bmp_present", "=", "self", ".", "clipboard", ".", "GetData", "(", "bmpdata", ")", "self", ".", "clipboard", ".", "GetData", "(", "textdata", ")", "self", ".", "clipboard", ".", "Close", "(", ")", "else", ":", "wx", ".", "MessageBox", "(", "_", "(", "\"Can't open the clipboard\"", ")", ",", "_", "(", "\"Error\"", ")", ")", "if", "is_bmp_present", ":", "return", "bmpdata", ".", "GetBitmap", "(", ")", "else", ":", "return", "textdata", ".", "GetText", "(", ")" ]
Returns the clipboard content If a bitmap is contained then it is returned. Otherwise, the clipboard text is returned.
[ "Returns", "the", "clipboard", "content" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/clipboard.py#L74-L95
236,606
manns/pyspread
pyspread/src/lib/clipboard.py
Clipboard.set_clipboard
def set_clipboard(self, data, datatype="text"): """Writes data to the clipboard Parameters ---------- data: Object \tData object for clipboard datatype: String in ["text", "bitmap"] \tIdentifies datatype to be copied to the clipboard """ error_log = [] if datatype == "text": clip_data = wx.TextDataObject(text=data) elif datatype == "bitmap": clip_data = wx.BitmapDataObject(bitmap=data) else: msg = _("Datatype {type} unknown").format(type=datatype) raise ValueError(msg) if self.clipboard.Open(): self.clipboard.SetData(clip_data) self.clipboard.Close() else: wx.MessageBox(_("Can't open the clipboard"), _("Error")) return error_log
python
def set_clipboard(self, data, datatype="text"): """Writes data to the clipboard Parameters ---------- data: Object \tData object for clipboard datatype: String in ["text", "bitmap"] \tIdentifies datatype to be copied to the clipboard """ error_log = [] if datatype == "text": clip_data = wx.TextDataObject(text=data) elif datatype == "bitmap": clip_data = wx.BitmapDataObject(bitmap=data) else: msg = _("Datatype {type} unknown").format(type=datatype) raise ValueError(msg) if self.clipboard.Open(): self.clipboard.SetData(clip_data) self.clipboard.Close() else: wx.MessageBox(_("Can't open the clipboard"), _("Error")) return error_log
[ "def", "set_clipboard", "(", "self", ",", "data", ",", "datatype", "=", "\"text\"", ")", ":", "error_log", "=", "[", "]", "if", "datatype", "==", "\"text\"", ":", "clip_data", "=", "wx", ".", "TextDataObject", "(", "text", "=", "data", ")", "elif", "datatype", "==", "\"bitmap\"", ":", "clip_data", "=", "wx", ".", "BitmapDataObject", "(", "bitmap", "=", "data", ")", "else", ":", "msg", "=", "_", "(", "\"Datatype {type} unknown\"", ")", ".", "format", "(", "type", "=", "datatype", ")", "raise", "ValueError", "(", "msg", ")", "if", "self", ".", "clipboard", ".", "Open", "(", ")", ":", "self", ".", "clipboard", ".", "SetData", "(", "clip_data", ")", "self", ".", "clipboard", ".", "Close", "(", ")", "else", ":", "wx", ".", "MessageBox", "(", "_", "(", "\"Can't open the clipboard\"", ")", ",", "_", "(", "\"Error\"", ")", ")", "return", "error_log" ]
Writes data to the clipboard Parameters ---------- data: Object \tData object for clipboard datatype: String in ["text", "bitmap"] \tIdentifies datatype to be copied to the clipboard
[ "Writes", "data", "to", "the", "clipboard" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/clipboard.py#L97-L127
236,607
manns/pyspread
pyspread/examples/macro_draw.py
draw_rect
def draw_rect(grid, attr, dc, rect): """Draws a rect""" dc.SetBrush(wx.Brush(wx.Colour(15, 255, 127), wx.SOLID)) dc.SetPen(wx.Pen(wx.BLUE, 1, wx.SOLID)) dc.DrawRectangleRect(rect)
python
def draw_rect(grid, attr, dc, rect): """Draws a rect""" dc.SetBrush(wx.Brush(wx.Colour(15, 255, 127), wx.SOLID)) dc.SetPen(wx.Pen(wx.BLUE, 1, wx.SOLID)) dc.DrawRectangleRect(rect)
[ "def", "draw_rect", "(", "grid", ",", "attr", ",", "dc", ",", "rect", ")", ":", "dc", ".", "SetBrush", "(", "wx", ".", "Brush", "(", "wx", ".", "Colour", "(", "15", ",", "255", ",", "127", ")", ",", "wx", ".", "SOLID", ")", ")", "dc", ".", "SetPen", "(", "wx", ".", "Pen", "(", "wx", ".", "BLUE", ",", "1", ",", "wx", ".", "SOLID", ")", ")", "dc", ".", "DrawRectangleRect", "(", "rect", ")" ]
Draws a rect
[ "Draws", "a", "rect" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/examples/macro_draw.py#L2-L6
236,608
manns/pyspread
pyspread/src/actions/_grid_actions.py
FileActions._is_aborted
def _is_aborted(self, cycle, statustext, total_elements=None, freq=None): """Displays progress and returns True if abort Parameters ---------- cycle: Integer \tThe current operation cycle statustext: String \tLeft text in statusbar to be displayed total_elements: Integer: \tThe number of elements that have to be processed freq: Integer, defaults to None \tNo. operations between two abort possibilities, 1000 if None """ if total_elements is None: statustext += _("{nele} elements processed. Press <Esc> to abort.") else: statustext += _("{nele} of {totalele} elements processed. " "Press <Esc> to abort.") if freq is None: show_msg = False freq = 1000 else: show_msg = True # Show progress in statusbar each freq (1000) cells if cycle % freq == 0: if show_msg: text = statustext.format(nele=cycle, totalele=total_elements) try: post_command_event(self.main_window, self.StatusBarMsg, text=text) except TypeError: # The main window does not exist any more pass # Now wait for the statusbar update to be written on screen if is_gtk(): try: wx.Yield() except: pass # Abort if we have to if self.need_abort: # We have to abort` return True # Continue return False
python
def _is_aborted(self, cycle, statustext, total_elements=None, freq=None): """Displays progress and returns True if abort Parameters ---------- cycle: Integer \tThe current operation cycle statustext: String \tLeft text in statusbar to be displayed total_elements: Integer: \tThe number of elements that have to be processed freq: Integer, defaults to None \tNo. operations between two abort possibilities, 1000 if None """ if total_elements is None: statustext += _("{nele} elements processed. Press <Esc> to abort.") else: statustext += _("{nele} of {totalele} elements processed. " "Press <Esc> to abort.") if freq is None: show_msg = False freq = 1000 else: show_msg = True # Show progress in statusbar each freq (1000) cells if cycle % freq == 0: if show_msg: text = statustext.format(nele=cycle, totalele=total_elements) try: post_command_event(self.main_window, self.StatusBarMsg, text=text) except TypeError: # The main window does not exist any more pass # Now wait for the statusbar update to be written on screen if is_gtk(): try: wx.Yield() except: pass # Abort if we have to if self.need_abort: # We have to abort` return True # Continue return False
[ "def", "_is_aborted", "(", "self", ",", "cycle", ",", "statustext", ",", "total_elements", "=", "None", ",", "freq", "=", "None", ")", ":", "if", "total_elements", "is", "None", ":", "statustext", "+=", "_", "(", "\"{nele} elements processed. Press <Esc> to abort.\"", ")", "else", ":", "statustext", "+=", "_", "(", "\"{nele} of {totalele} elements processed. \"", "\"Press <Esc> to abort.\"", ")", "if", "freq", "is", "None", ":", "show_msg", "=", "False", "freq", "=", "1000", "else", ":", "show_msg", "=", "True", "# Show progress in statusbar each freq (1000) cells", "if", "cycle", "%", "freq", "==", "0", ":", "if", "show_msg", ":", "text", "=", "statustext", ".", "format", "(", "nele", "=", "cycle", ",", "totalele", "=", "total_elements", ")", "try", ":", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "StatusBarMsg", ",", "text", "=", "text", ")", "except", "TypeError", ":", "# The main window does not exist any more", "pass", "# Now wait for the statusbar update to be written on screen", "if", "is_gtk", "(", ")", ":", "try", ":", "wx", ".", "Yield", "(", ")", "except", ":", "pass", "# Abort if we have to", "if", "self", ".", "need_abort", ":", "# We have to abort`", "return", "True", "# Continue", "return", "False" ]
Displays progress and returns True if abort Parameters ---------- cycle: Integer \tThe current operation cycle statustext: String \tLeft text in statusbar to be displayed total_elements: Integer: \tThe number of elements that have to be processed freq: Integer, defaults to None \tNo. operations between two abort possibilities, 1000 if None
[ "Displays", "progress", "and", "returns", "True", "if", "abort" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L127-L180
236,609
manns/pyspread
pyspread/src/actions/_grid_actions.py
FileActions.validate_signature
def validate_signature(self, filename): """Returns True if a valid signature is present for filename""" if not GPG_PRESENT: return False sigfilename = filename + '.sig' try: with open(sigfilename): pass except IOError: # Signature file does not exist return False # Check if the sig is valid for the sigfile # TODO: Check for whitespace in filepaths return verify(sigfilename, filename)
python
def validate_signature(self, filename): """Returns True if a valid signature is present for filename""" if not GPG_PRESENT: return False sigfilename = filename + '.sig' try: with open(sigfilename): pass except IOError: # Signature file does not exist return False # Check if the sig is valid for the sigfile # TODO: Check for whitespace in filepaths return verify(sigfilename, filename)
[ "def", "validate_signature", "(", "self", ",", "filename", ")", ":", "if", "not", "GPG_PRESENT", ":", "return", "False", "sigfilename", "=", "filename", "+", "'.sig'", "try", ":", "with", "open", "(", "sigfilename", ")", ":", "pass", "except", "IOError", ":", "# Signature file does not exist", "return", "False", "# Check if the sig is valid for the sigfile", "# TODO: Check for whitespace in filepaths", "return", "verify", "(", "sigfilename", ",", "filename", ")" ]
Returns True if a valid signature is present for filename
[ "Returns", "True", "if", "a", "valid", "signature", "is", "present", "for", "filename" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L182-L200
236,610
manns/pyspread
pyspread/src/actions/_grid_actions.py
FileActions.leave_safe_mode
def leave_safe_mode(self): """Leaves safe mode""" self.code_array.safe_mode = False # Clear result cache self.code_array.result_cache.clear() # Execute macros self.main_window.actions.execute_macros() post_command_event(self.main_window, self.SafeModeExitMsg)
python
def leave_safe_mode(self): """Leaves safe mode""" self.code_array.safe_mode = False # Clear result cache self.code_array.result_cache.clear() # Execute macros self.main_window.actions.execute_macros() post_command_event(self.main_window, self.SafeModeExitMsg)
[ "def", "leave_safe_mode", "(", "self", ")", ":", "self", ".", "code_array", ".", "safe_mode", "=", "False", "# Clear result cache", "self", ".", "code_array", ".", "result_cache", ".", "clear", "(", ")", "# Execute macros", "self", ".", "main_window", ".", "actions", ".", "execute_macros", "(", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "SafeModeExitMsg", ")" ]
Leaves safe mode
[ "Leaves", "safe", "mode" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L207-L218
236,611
manns/pyspread
pyspread/src/actions/_grid_actions.py
FileActions.approve
def approve(self, filepath): """Sets safe mode if signature missing of invalid""" try: signature_valid = self.validate_signature(filepath) except ValueError: # GPG is not installed signature_valid = False if signature_valid: self.leave_safe_mode() post_command_event(self.main_window, self.SafeModeExitMsg) statustext = _("Valid signature found. File is trusted.") post_command_event(self.main_window, self.StatusBarMsg, text=statustext) else: self.enter_safe_mode() post_command_event(self.main_window, self.SafeModeEntryMsg) statustext = \ _("File is not properly signed. Safe mode " "activated. Select File -> Approve to leave safe mode.") post_command_event(self.main_window, self.StatusBarMsg, text=statustext)
python
def approve(self, filepath): """Sets safe mode if signature missing of invalid""" try: signature_valid = self.validate_signature(filepath) except ValueError: # GPG is not installed signature_valid = False if signature_valid: self.leave_safe_mode() post_command_event(self.main_window, self.SafeModeExitMsg) statustext = _("Valid signature found. File is trusted.") post_command_event(self.main_window, self.StatusBarMsg, text=statustext) else: self.enter_safe_mode() post_command_event(self.main_window, self.SafeModeEntryMsg) statustext = \ _("File is not properly signed. Safe mode " "activated. Select File -> Approve to leave safe mode.") post_command_event(self.main_window, self.StatusBarMsg, text=statustext)
[ "def", "approve", "(", "self", ",", "filepath", ")", ":", "try", ":", "signature_valid", "=", "self", ".", "validate_signature", "(", "filepath", ")", "except", "ValueError", ":", "# GPG is not installed", "signature_valid", "=", "False", "if", "signature_valid", ":", "self", ".", "leave_safe_mode", "(", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "SafeModeExitMsg", ")", "statustext", "=", "_", "(", "\"Valid signature found. File is trusted.\"", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "StatusBarMsg", ",", "text", "=", "statustext", ")", "else", ":", "self", ".", "enter_safe_mode", "(", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "SafeModeEntryMsg", ")", "statustext", "=", "_", "(", "\"File is not properly signed. Safe mode \"", "\"activated. Select File -> Approve to leave safe mode.\"", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "StatusBarMsg", ",", "text", "=", "statustext", ")" ]
Sets safe mode if signature missing of invalid
[ "Sets", "safe", "mode", "if", "signature", "missing", "of", "invalid" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L220-L246
236,612
manns/pyspread
pyspread/src/actions/_grid_actions.py
FileActions.clear_globals_reload_modules
def clear_globals_reload_modules(self): """Clears globals and reloads modules""" self.code_array.clear_globals() self.code_array.reload_modules() # Clear result cache self.code_array.result_cache.clear()
python
def clear_globals_reload_modules(self): """Clears globals and reloads modules""" self.code_array.clear_globals() self.code_array.reload_modules() # Clear result cache self.code_array.result_cache.clear()
[ "def", "clear_globals_reload_modules", "(", "self", ")", ":", "self", ".", "code_array", ".", "clear_globals", "(", ")", "self", ".", "code_array", ".", "reload_modules", "(", ")", "# Clear result cache", "self", ".", "code_array", ".", "result_cache", ".", "clear", "(", ")" ]
Clears globals and reloads modules
[ "Clears", "globals", "and", "reloads", "modules" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L248-L255
236,613
manns/pyspread
pyspread/src/actions/_grid_actions.py
FileActions._get_file_version
def _get_file_version(self, infile): """Returns infile version string.""" # Determine file version for line1 in infile: if line1.strip() != "[Pyspread save file version]": raise ValueError(_("File format unsupported.")) break for line2 in infile: return line2.strip()
python
def _get_file_version(self, infile): """Returns infile version string.""" # Determine file version for line1 in infile: if line1.strip() != "[Pyspread save file version]": raise ValueError(_("File format unsupported.")) break for line2 in infile: return line2.strip()
[ "def", "_get_file_version", "(", "self", ",", "infile", ")", ":", "# Determine file version", "for", "line1", "in", "infile", ":", "if", "line1", ".", "strip", "(", ")", "!=", "\"[Pyspread save file version]\"", ":", "raise", "ValueError", "(", "_", "(", "\"File format unsupported.\"", ")", ")", "break", "for", "line2", "in", "infile", ":", "return", "line2", ".", "strip", "(", ")" ]
Returns infile version string.
[ "Returns", "infile", "version", "string", "." ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L257-L267
236,614
manns/pyspread
pyspread/src/actions/_grid_actions.py
FileActions.clear
def clear(self, shape=None): """Empties grid and sets shape to shape Clears all attributes, row heights, column withs and frozen states. Empties undo/redo list and caches. Empties globals. Properties ---------- shape: 3-tuple of Integer, defaults to None \tTarget shape of grid after clearing all content. \tShape unchanged if None """ # Without setting this explicitly, the cursor is set too late self.grid.actions.cursor = 0, 0, 0 self.grid.current_table = 0 post_command_event(self.main_window.grid, self.GotoCellMsg, key=(0, 0, 0)) # Clear cells self.code_array.dict_grid.clear() # Clear attributes del self.code_array.dict_grid.cell_attributes[:] if shape is not None: # Set shape self.code_array.shape = shape # Clear row heights and column widths self.code_array.row_heights.clear() self.code_array.col_widths.clear() # Clear macros self.code_array.macros = "" # Clear caches self.code_array.result_cache.clear() # Clear globals self.code_array.clear_globals() self.code_array.reload_modules()
python
def clear(self, shape=None): """Empties grid and sets shape to shape Clears all attributes, row heights, column withs and frozen states. Empties undo/redo list and caches. Empties globals. Properties ---------- shape: 3-tuple of Integer, defaults to None \tTarget shape of grid after clearing all content. \tShape unchanged if None """ # Without setting this explicitly, the cursor is set too late self.grid.actions.cursor = 0, 0, 0 self.grid.current_table = 0 post_command_event(self.main_window.grid, self.GotoCellMsg, key=(0, 0, 0)) # Clear cells self.code_array.dict_grid.clear() # Clear attributes del self.code_array.dict_grid.cell_attributes[:] if shape is not None: # Set shape self.code_array.shape = shape # Clear row heights and column widths self.code_array.row_heights.clear() self.code_array.col_widths.clear() # Clear macros self.code_array.macros = "" # Clear caches self.code_array.result_cache.clear() # Clear globals self.code_array.clear_globals() self.code_array.reload_modules()
[ "def", "clear", "(", "self", ",", "shape", "=", "None", ")", ":", "# Without setting this explicitly, the cursor is set too late", "self", ".", "grid", ".", "actions", ".", "cursor", "=", "0", ",", "0", ",", "0", "self", ".", "grid", ".", "current_table", "=", "0", "post_command_event", "(", "self", ".", "main_window", ".", "grid", ",", "self", ".", "GotoCellMsg", ",", "key", "=", "(", "0", ",", "0", ",", "0", ")", ")", "# Clear cells", "self", ".", "code_array", ".", "dict_grid", ".", "clear", "(", ")", "# Clear attributes", "del", "self", ".", "code_array", ".", "dict_grid", ".", "cell_attributes", "[", ":", "]", "if", "shape", "is", "not", "None", ":", "# Set shape", "self", ".", "code_array", ".", "shape", "=", "shape", "# Clear row heights and column widths", "self", ".", "code_array", ".", "row_heights", ".", "clear", "(", ")", "self", ".", "code_array", ".", "col_widths", ".", "clear", "(", ")", "# Clear macros", "self", ".", "code_array", ".", "macros", "=", "\"\"", "# Clear caches", "self", ".", "code_array", ".", "result_cache", ".", "clear", "(", ")", "# Clear globals", "self", ".", "code_array", ".", "clear_globals", "(", ")", "self", ".", "code_array", ".", "reload_modules", "(", ")" ]
Empties grid and sets shape to shape Clears all attributes, row heights, column withs and frozen states. Empties undo/redo list and caches. Empties globals. Properties ---------- shape: 3-tuple of Integer, defaults to None \tTarget shape of grid after clearing all content. \tShape unchanged if None
[ "Empties", "grid", "and", "sets", "shape", "to", "shape" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L269-L313
236,615
manns/pyspread
pyspread/src/actions/_grid_actions.py
FileActions.open
def open(self, event): """Opens a file that is specified in event.attr Parameters ---------- event.attr: Dict \tkey filepath contains file path of file to be loaded \tkey filetype contains file type of file to be loaded \tFiletypes can be pys, pysu, xls """ filepath = event.attr["filepath"] try: filetype = event.attr["filetype"] except KeyError: try: file_ext = filepath.strip().split(".")[-1] except: file_ext = None if file_ext in ["pys", "pysu", "xls", "xlsx", "ods"]: filetype = file_ext else: filetype = "pys" type2opener = { "pys": (Bz2AOpen, [filepath, "r"], {"main_window": self.main_window}), "pysu": (AOpen, [filepath, "r"], {"main_window": self.main_window}) } if xlrd is not None: type2opener["xls"] = \ (xlrd.open_workbook, [filepath], {"formatting_info": True}) type2opener["xlsx"] = \ (xlrd.open_workbook, [filepath], {"formatting_info": False}) if odf is not None and Ods is not None: type2opener["ods"] = (open, [filepath, "rb"], {}) # Specify the interface that shall be used opener, op_args, op_kwargs = type2opener[filetype] Interface = self.type2interface[filetype] # Set state for file open self.opening = True try: with opener(*op_args, **op_kwargs) as infile: # Make loading safe self.approve(filepath) if xlrd is None: interface_errors = (ValueError, ) else: interface_errors = (ValueError, xlrd.biffh.XLRDError) try: wx.BeginBusyCursor() self.grid.Disable() self.clear() interface = Interface(self.grid.code_array, infile) interface.to_code_array() self.grid.main_window.macro_panel.codetext_ctrl.SetText( self.grid.code_array.macros) except interface_errors, err: post_command_event(self.main_window, self.StatusBarMsg, text=str(err)) finally: self.grid.GetTable().ResetView() post_command_event(self.main_window, self.ResizeGridMsg, shape=self.grid.code_array.shape) self.grid.Enable() wx.EndBusyCursor() # Execute macros self.main_window.actions.execute_macros() self.grid.GetTable().ResetView() self.grid.ForceRefresh() # File sucessfully opened. Approve again to show status. self.approve(filepath) # Change current directory to file directory filedir = os.path.dirname(filepath) os.chdir(filedir) except IOError, err: txt = _("Error opening file {filepath}:").format(filepath=filepath) txt += " " + str(err) post_command_event(self.main_window, self.StatusBarMsg, text=txt) return False except EOFError: # Normally on empty grids pass finally: # Unset state for file open self.opening = False
python
def open(self, event): """Opens a file that is specified in event.attr Parameters ---------- event.attr: Dict \tkey filepath contains file path of file to be loaded \tkey filetype contains file type of file to be loaded \tFiletypes can be pys, pysu, xls """ filepath = event.attr["filepath"] try: filetype = event.attr["filetype"] except KeyError: try: file_ext = filepath.strip().split(".")[-1] except: file_ext = None if file_ext in ["pys", "pysu", "xls", "xlsx", "ods"]: filetype = file_ext else: filetype = "pys" type2opener = { "pys": (Bz2AOpen, [filepath, "r"], {"main_window": self.main_window}), "pysu": (AOpen, [filepath, "r"], {"main_window": self.main_window}) } if xlrd is not None: type2opener["xls"] = \ (xlrd.open_workbook, [filepath], {"formatting_info": True}) type2opener["xlsx"] = \ (xlrd.open_workbook, [filepath], {"formatting_info": False}) if odf is not None and Ods is not None: type2opener["ods"] = (open, [filepath, "rb"], {}) # Specify the interface that shall be used opener, op_args, op_kwargs = type2opener[filetype] Interface = self.type2interface[filetype] # Set state for file open self.opening = True try: with opener(*op_args, **op_kwargs) as infile: # Make loading safe self.approve(filepath) if xlrd is None: interface_errors = (ValueError, ) else: interface_errors = (ValueError, xlrd.biffh.XLRDError) try: wx.BeginBusyCursor() self.grid.Disable() self.clear() interface = Interface(self.grid.code_array, infile) interface.to_code_array() self.grid.main_window.macro_panel.codetext_ctrl.SetText( self.grid.code_array.macros) except interface_errors, err: post_command_event(self.main_window, self.StatusBarMsg, text=str(err)) finally: self.grid.GetTable().ResetView() post_command_event(self.main_window, self.ResizeGridMsg, shape=self.grid.code_array.shape) self.grid.Enable() wx.EndBusyCursor() # Execute macros self.main_window.actions.execute_macros() self.grid.GetTable().ResetView() self.grid.ForceRefresh() # File sucessfully opened. Approve again to show status. self.approve(filepath) # Change current directory to file directory filedir = os.path.dirname(filepath) os.chdir(filedir) except IOError, err: txt = _("Error opening file {filepath}:").format(filepath=filepath) txt += " " + str(err) post_command_event(self.main_window, self.StatusBarMsg, text=txt) return False except EOFError: # Normally on empty grids pass finally: # Unset state for file open self.opening = False
[ "def", "open", "(", "self", ",", "event", ")", ":", "filepath", "=", "event", ".", "attr", "[", "\"filepath\"", "]", "try", ":", "filetype", "=", "event", ".", "attr", "[", "\"filetype\"", "]", "except", "KeyError", ":", "try", ":", "file_ext", "=", "filepath", ".", "strip", "(", ")", ".", "split", "(", "\".\"", ")", "[", "-", "1", "]", "except", ":", "file_ext", "=", "None", "if", "file_ext", "in", "[", "\"pys\"", ",", "\"pysu\"", ",", "\"xls\"", ",", "\"xlsx\"", ",", "\"ods\"", "]", ":", "filetype", "=", "file_ext", "else", ":", "filetype", "=", "\"pys\"", "type2opener", "=", "{", "\"pys\"", ":", "(", "Bz2AOpen", ",", "[", "filepath", ",", "\"r\"", "]", ",", "{", "\"main_window\"", ":", "self", ".", "main_window", "}", ")", ",", "\"pysu\"", ":", "(", "AOpen", ",", "[", "filepath", ",", "\"r\"", "]", ",", "{", "\"main_window\"", ":", "self", ".", "main_window", "}", ")", "}", "if", "xlrd", "is", "not", "None", ":", "type2opener", "[", "\"xls\"", "]", "=", "(", "xlrd", ".", "open_workbook", ",", "[", "filepath", "]", ",", "{", "\"formatting_info\"", ":", "True", "}", ")", "type2opener", "[", "\"xlsx\"", "]", "=", "(", "xlrd", ".", "open_workbook", ",", "[", "filepath", "]", ",", "{", "\"formatting_info\"", ":", "False", "}", ")", "if", "odf", "is", "not", "None", "and", "Ods", "is", "not", "None", ":", "type2opener", "[", "\"ods\"", "]", "=", "(", "open", ",", "[", "filepath", ",", "\"rb\"", "]", ",", "{", "}", ")", "# Specify the interface that shall be used", "opener", ",", "op_args", ",", "op_kwargs", "=", "type2opener", "[", "filetype", "]", "Interface", "=", "self", ".", "type2interface", "[", "filetype", "]", "# Set state for file open", "self", ".", "opening", "=", "True", "try", ":", "with", "opener", "(", "*", "op_args", ",", "*", "*", "op_kwargs", ")", "as", "infile", ":", "# Make loading safe", "self", ".", "approve", "(", "filepath", ")", "if", "xlrd", "is", "None", ":", "interface_errors", "=", "(", "ValueError", ",", ")", "else", ":", "interface_errors", "=", "(", "ValueError", ",", "xlrd", ".", "biffh", ".", "XLRDError", ")", "try", ":", "wx", ".", "BeginBusyCursor", "(", ")", "self", ".", "grid", ".", "Disable", "(", ")", "self", ".", "clear", "(", ")", "interface", "=", "Interface", "(", "self", ".", "grid", ".", "code_array", ",", "infile", ")", "interface", ".", "to_code_array", "(", ")", "self", ".", "grid", ".", "main_window", ".", "macro_panel", ".", "codetext_ctrl", ".", "SetText", "(", "self", ".", "grid", ".", "code_array", ".", "macros", ")", "except", "interface_errors", ",", "err", ":", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "StatusBarMsg", ",", "text", "=", "str", "(", "err", ")", ")", "finally", ":", "self", ".", "grid", ".", "GetTable", "(", ")", ".", "ResetView", "(", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ResizeGridMsg", ",", "shape", "=", "self", ".", "grid", ".", "code_array", ".", "shape", ")", "self", ".", "grid", ".", "Enable", "(", ")", "wx", ".", "EndBusyCursor", "(", ")", "# Execute macros", "self", ".", "main_window", ".", "actions", ".", "execute_macros", "(", ")", "self", ".", "grid", ".", "GetTable", "(", ")", ".", "ResetView", "(", ")", "self", ".", "grid", ".", "ForceRefresh", "(", ")", "# File sucessfully opened. Approve again to show status.", "self", ".", "approve", "(", "filepath", ")", "# Change current directory to file directory", "filedir", "=", "os", ".", "path", ".", "dirname", "(", "filepath", ")", "os", ".", "chdir", "(", "filedir", ")", "except", "IOError", ",", "err", ":", "txt", "=", "_", "(", "\"Error opening file {filepath}:\"", ")", ".", "format", "(", "filepath", "=", "filepath", ")", "txt", "+=", "\" \"", "+", "str", "(", "err", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "StatusBarMsg", ",", "text", "=", "txt", ")", "return", "False", "except", "EOFError", ":", "# Normally on empty grids", "pass", "finally", ":", "# Unset state for file open", "self", ".", "opening", "=", "False" ]
Opens a file that is specified in event.attr Parameters ---------- event.attr: Dict \tkey filepath contains file path of file to be loaded \tkey filetype contains file type of file to be loaded \tFiletypes can be pys, pysu, xls
[ "Opens", "a", "file", "that", "is", "specified", "in", "event", ".", "attr" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L315-L421
236,616
manns/pyspread
pyspread/src/actions/_grid_actions.py
FileActions.sign_file
def sign_file(self, filepath): """Signs file if possible""" if not GPG_PRESENT: return signed_data = sign(filepath) signature = signed_data.data if signature is None or not signature: statustext = _('Error signing file. ') + signed_data.stderr try: post_command_event(self.main_window, self.StatusBarMsg, text=statustext) except TypeError: # The main window does not exist any more pass return with open(filepath + '.sig', 'wb') as signfile: signfile.write(signature) # Statustext differs if a save has occurred if self.code_array.safe_mode: statustext = _('File saved and signed') else: statustext = _('File signed') try: post_command_event(self.main_window, self.StatusBarMsg, text=statustext) except TypeError: # The main window does not exist any more pass
python
def sign_file(self, filepath): """Signs file if possible""" if not GPG_PRESENT: return signed_data = sign(filepath) signature = signed_data.data if signature is None or not signature: statustext = _('Error signing file. ') + signed_data.stderr try: post_command_event(self.main_window, self.StatusBarMsg, text=statustext) except TypeError: # The main window does not exist any more pass return with open(filepath + '.sig', 'wb') as signfile: signfile.write(signature) # Statustext differs if a save has occurred if self.code_array.safe_mode: statustext = _('File saved and signed') else: statustext = _('File signed') try: post_command_event(self.main_window, self.StatusBarMsg, text=statustext) except TypeError: # The main window does not exist any more pass
[ "def", "sign_file", "(", "self", ",", "filepath", ")", ":", "if", "not", "GPG_PRESENT", ":", "return", "signed_data", "=", "sign", "(", "filepath", ")", "signature", "=", "signed_data", ".", "data", "if", "signature", "is", "None", "or", "not", "signature", ":", "statustext", "=", "_", "(", "'Error signing file. '", ")", "+", "signed_data", ".", "stderr", "try", ":", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "StatusBarMsg", ",", "text", "=", "statustext", ")", "except", "TypeError", ":", "# The main window does not exist any more", "pass", "return", "with", "open", "(", "filepath", "+", "'.sig'", ",", "'wb'", ")", "as", "signfile", ":", "signfile", ".", "write", "(", "signature", ")", "# Statustext differs if a save has occurred", "if", "self", ".", "code_array", ".", "safe_mode", ":", "statustext", "=", "_", "(", "'File saved and signed'", ")", "else", ":", "statustext", "=", "_", "(", "'File signed'", ")", "try", ":", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "StatusBarMsg", ",", "text", "=", "statustext", ")", "except", "TypeError", ":", "# The main window does not exist any more", "pass" ]
Signs file if possible
[ "Signs", "file", "if", "possible" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L423-L458
236,617
manns/pyspread
pyspread/src/actions/_grid_actions.py
FileActions._set_save_states
def _set_save_states(self): """Sets application save states""" wx.BeginBusyCursor() self.saving = True self.grid.Disable()
python
def _set_save_states(self): """Sets application save states""" wx.BeginBusyCursor() self.saving = True self.grid.Disable()
[ "def", "_set_save_states", "(", "self", ")", ":", "wx", ".", "BeginBusyCursor", "(", ")", "self", ".", "saving", "=", "True", "self", ".", "grid", ".", "Disable", "(", ")" ]
Sets application save states
[ "Sets", "application", "save", "states" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L460-L465
236,618
manns/pyspread
pyspread/src/actions/_grid_actions.py
FileActions._release_save_states
def _release_save_states(self): """Releases application save states""" self.saving = False self.grid.Enable() wx.EndBusyCursor() # Mark content as unchanged try: post_command_event(self.main_window, self.ContentChangedMsg) except TypeError: # The main window does not exist any more pass
python
def _release_save_states(self): """Releases application save states""" self.saving = False self.grid.Enable() wx.EndBusyCursor() # Mark content as unchanged try: post_command_event(self.main_window, self.ContentChangedMsg) except TypeError: # The main window does not exist any more pass
[ "def", "_release_save_states", "(", "self", ")", ":", "self", ".", "saving", "=", "False", "self", ".", "grid", ".", "Enable", "(", ")", "wx", ".", "EndBusyCursor", "(", ")", "# Mark content as unchanged", "try", ":", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ContentChangedMsg", ")", "except", "TypeError", ":", "# The main window does not exist any more", "pass" ]
Releases application save states
[ "Releases", "application", "save", "states" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L467-L479
236,619
manns/pyspread
pyspread/src/actions/_grid_actions.py
FileActions._move_tmp_file
def _move_tmp_file(self, tmpfilepath, filepath): """Moves tmpfile over file after saving is finished Parameters ---------- filepath: String \tTarget file path for xls file tmpfilepath: String \tTemporary file file path for xls file """ try: shutil.move(tmpfilepath, filepath) except OSError, err: # No tmp file present post_command_event(self.main_window, self.StatusBarMsg, text=err)
python
def _move_tmp_file(self, tmpfilepath, filepath): """Moves tmpfile over file after saving is finished Parameters ---------- filepath: String \tTarget file path for xls file tmpfilepath: String \tTemporary file file path for xls file """ try: shutil.move(tmpfilepath, filepath) except OSError, err: # No tmp file present post_command_event(self.main_window, self.StatusBarMsg, text=err)
[ "def", "_move_tmp_file", "(", "self", ",", "tmpfilepath", ",", "filepath", ")", ":", "try", ":", "shutil", ".", "move", "(", "tmpfilepath", ",", "filepath", ")", "except", "OSError", ",", "err", ":", "# No tmp file present", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "StatusBarMsg", ",", "text", "=", "err", ")" ]
Moves tmpfile over file after saving is finished Parameters ---------- filepath: String \tTarget file path for xls file tmpfilepath: String \tTemporary file file path for xls file
[ "Moves", "tmpfile", "over", "file", "after", "saving", "is", "finished" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L481-L499
236,620
manns/pyspread
pyspread/src/actions/_grid_actions.py
FileActions._save_xls
def _save_xls(self, filepath): """Saves file as xls workbook Parameters ---------- filepath: String \tTarget file path for xls file """ Interface = self.type2interface["xls"] workbook = xlwt.Workbook() interface = Interface(self.grid.code_array, workbook) interface.from_code_array() try: workbook.save(filepath) except IOError, err: try: post_command_event(self.main_window, self.StatusBarMsg, text=err) except TypeError: # The main window does not exist any more pass
python
def _save_xls(self, filepath): """Saves file as xls workbook Parameters ---------- filepath: String \tTarget file path for xls file """ Interface = self.type2interface["xls"] workbook = xlwt.Workbook() interface = Interface(self.grid.code_array, workbook) interface.from_code_array() try: workbook.save(filepath) except IOError, err: try: post_command_event(self.main_window, self.StatusBarMsg, text=err) except TypeError: # The main window does not exist any more pass
[ "def", "_save_xls", "(", "self", ",", "filepath", ")", ":", "Interface", "=", "self", ".", "type2interface", "[", "\"xls\"", "]", "workbook", "=", "xlwt", ".", "Workbook", "(", ")", "interface", "=", "Interface", "(", "self", ".", "grid", ".", "code_array", ",", "workbook", ")", "interface", ".", "from_code_array", "(", ")", "try", ":", "workbook", ".", "save", "(", "filepath", ")", "except", "IOError", ",", "err", ":", "try", ":", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "StatusBarMsg", ",", "text", "=", "err", ")", "except", "TypeError", ":", "# The main window does not exist any more", "pass" ]
Saves file as xls workbook Parameters ---------- filepath: String \tTarget file path for xls file
[ "Saves", "file", "as", "xls", "workbook" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L501-L527
236,621
manns/pyspread
pyspread/src/actions/_grid_actions.py
FileActions._save_pys
def _save_pys(self, filepath): """Saves file as pys file and returns True if save success Parameters ---------- filepath: String \tTarget file path for xls file """ try: with Bz2AOpen(filepath, "wb", main_window=self.main_window) as outfile: interface = Pys(self.grid.code_array, outfile) interface.from_code_array() except (IOError, ValueError), err: try: post_command_event(self.main_window, self.StatusBarMsg, text=err) return except TypeError: # The main window does not exist any more pass return not outfile.aborted
python
def _save_pys(self, filepath): """Saves file as pys file and returns True if save success Parameters ---------- filepath: String \tTarget file path for xls file """ try: with Bz2AOpen(filepath, "wb", main_window=self.main_window) as outfile: interface = Pys(self.grid.code_array, outfile) interface.from_code_array() except (IOError, ValueError), err: try: post_command_event(self.main_window, self.StatusBarMsg, text=err) return except TypeError: # The main window does not exist any more pass return not outfile.aborted
[ "def", "_save_pys", "(", "self", ",", "filepath", ")", ":", "try", ":", "with", "Bz2AOpen", "(", "filepath", ",", "\"wb\"", ",", "main_window", "=", "self", ".", "main_window", ")", "as", "outfile", ":", "interface", "=", "Pys", "(", "self", ".", "grid", ".", "code_array", ",", "outfile", ")", "interface", ".", "from_code_array", "(", ")", "except", "(", "IOError", ",", "ValueError", ")", ",", "err", ":", "try", ":", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "StatusBarMsg", ",", "text", "=", "err", ")", "return", "except", "TypeError", ":", "# The main window does not exist any more", "pass", "return", "not", "outfile", ".", "aborted" ]
Saves file as pys file and returns True if save success Parameters ---------- filepath: String \tTarget file path for xls file
[ "Saves", "file", "as", "pys", "file", "and", "returns", "True", "if", "save", "success" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L529-L555
236,622
manns/pyspread
pyspread/src/actions/_grid_actions.py
FileActions._save_sign
def _save_sign(self, filepath): """Sign so that the new file may be retrieved without safe mode""" if self.code_array.safe_mode: msg = _("File saved but not signed because it is unapproved.") try: post_command_event(self.main_window, self.StatusBarMsg, text=msg) except TypeError: # The main window does not exist any more pass else: try: self.sign_file(filepath) except ValueError, err: msg = "Signing file failed. " + unicode(err) post_command_event(self.main_window, self.StatusBarMsg, text=msg)
python
def _save_sign(self, filepath): """Sign so that the new file may be retrieved without safe mode""" if self.code_array.safe_mode: msg = _("File saved but not signed because it is unapproved.") try: post_command_event(self.main_window, self.StatusBarMsg, text=msg) except TypeError: # The main window does not exist any more pass else: try: self.sign_file(filepath) except ValueError, err: msg = "Signing file failed. " + unicode(err) post_command_event(self.main_window, self.StatusBarMsg, text=msg)
[ "def", "_save_sign", "(", "self", ",", "filepath", ")", ":", "if", "self", ".", "code_array", ".", "safe_mode", ":", "msg", "=", "_", "(", "\"File saved but not signed because it is unapproved.\"", ")", "try", ":", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "StatusBarMsg", ",", "text", "=", "msg", ")", "except", "TypeError", ":", "# The main window does not exist any more", "pass", "else", ":", "try", ":", "self", ".", "sign_file", "(", "filepath", ")", "except", "ValueError", ",", "err", ":", "msg", "=", "\"Signing file failed. \"", "+", "unicode", "(", "err", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "StatusBarMsg", ",", "text", "=", "msg", ")" ]
Sign so that the new file may be retrieved without safe mode
[ "Sign", "so", "that", "the", "new", "file", "may", "be", "retrieved", "without", "safe", "mode" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L585-L604
236,623
manns/pyspread
pyspread/src/actions/_grid_actions.py
FileActions.save
def save(self, event): """Saves a file that is specified in event.attr Parameters ---------- event.attr: Dict \tkey filepath contains file path of file to be saved """ filepath = event.attr["filepath"] try: filetype = event.attr["filetype"] except KeyError: filetype = "pys" # If saving is already in progress abort if self.saving: return # Use tmpfile to make sure that old save file does not get lost # on abort save __, tmpfilepath = tempfile.mkstemp() if filetype == "xls": self._set_save_states() self._save_xls(tmpfilepath) self._move_tmp_file(tmpfilepath, filepath) self._release_save_states() elif filetype == "pys" or filetype == "all": self._set_save_states() if self._save_pys(tmpfilepath): # Writing was successful self._move_tmp_file(tmpfilepath, filepath) self._save_sign(filepath) self._release_save_states() elif filetype == "pysu": self._set_save_states() if self._save_pysu(tmpfilepath): # Writing was successful self._move_tmp_file(tmpfilepath, filepath) self._save_sign(filepath) self._release_save_states() else: os.remove(tmpfilepath) msg = "Filetype {filetype} unknown.".format(filetype=filetype) raise ValueError(msg) try: os.remove(tmpfilepath) except OSError: pass
python
def save(self, event): """Saves a file that is specified in event.attr Parameters ---------- event.attr: Dict \tkey filepath contains file path of file to be saved """ filepath = event.attr["filepath"] try: filetype = event.attr["filetype"] except KeyError: filetype = "pys" # If saving is already in progress abort if self.saving: return # Use tmpfile to make sure that old save file does not get lost # on abort save __, tmpfilepath = tempfile.mkstemp() if filetype == "xls": self._set_save_states() self._save_xls(tmpfilepath) self._move_tmp_file(tmpfilepath, filepath) self._release_save_states() elif filetype == "pys" or filetype == "all": self._set_save_states() if self._save_pys(tmpfilepath): # Writing was successful self._move_tmp_file(tmpfilepath, filepath) self._save_sign(filepath) self._release_save_states() elif filetype == "pysu": self._set_save_states() if self._save_pysu(tmpfilepath): # Writing was successful self._move_tmp_file(tmpfilepath, filepath) self._save_sign(filepath) self._release_save_states() else: os.remove(tmpfilepath) msg = "Filetype {filetype} unknown.".format(filetype=filetype) raise ValueError(msg) try: os.remove(tmpfilepath) except OSError: pass
[ "def", "save", "(", "self", ",", "event", ")", ":", "filepath", "=", "event", ".", "attr", "[", "\"filepath\"", "]", "try", ":", "filetype", "=", "event", ".", "attr", "[", "\"filetype\"", "]", "except", "KeyError", ":", "filetype", "=", "\"pys\"", "# If saving is already in progress abort", "if", "self", ".", "saving", ":", "return", "# Use tmpfile to make sure that old save file does not get lost", "# on abort save", "__", ",", "tmpfilepath", "=", "tempfile", ".", "mkstemp", "(", ")", "if", "filetype", "==", "\"xls\"", ":", "self", ".", "_set_save_states", "(", ")", "self", ".", "_save_xls", "(", "tmpfilepath", ")", "self", ".", "_move_tmp_file", "(", "tmpfilepath", ",", "filepath", ")", "self", ".", "_release_save_states", "(", ")", "elif", "filetype", "==", "\"pys\"", "or", "filetype", "==", "\"all\"", ":", "self", ".", "_set_save_states", "(", ")", "if", "self", ".", "_save_pys", "(", "tmpfilepath", ")", ":", "# Writing was successful", "self", ".", "_move_tmp_file", "(", "tmpfilepath", ",", "filepath", ")", "self", ".", "_save_sign", "(", "filepath", ")", "self", ".", "_release_save_states", "(", ")", "elif", "filetype", "==", "\"pysu\"", ":", "self", ".", "_set_save_states", "(", ")", "if", "self", ".", "_save_pysu", "(", "tmpfilepath", ")", ":", "# Writing was successful", "self", ".", "_move_tmp_file", "(", "tmpfilepath", ",", "filepath", ")", "self", ".", "_save_sign", "(", "filepath", ")", "self", ".", "_release_save_states", "(", ")", "else", ":", "os", ".", "remove", "(", "tmpfilepath", ")", "msg", "=", "\"Filetype {filetype} unknown.\"", ".", "format", "(", "filetype", "=", "filetype", ")", "raise", "ValueError", "(", "msg", ")", "try", ":", "os", ".", "remove", "(", "tmpfilepath", ")", "except", "OSError", ":", "pass" ]
Saves a file that is specified in event.attr Parameters ---------- event.attr: Dict \tkey filepath contains file path of file to be saved
[ "Saves", "a", "file", "that", "is", "specified", "in", "event", ".", "attr" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L606-L662
236,624
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableRowActionsMixin.set_row_height
def set_row_height(self, row, height): """Sets row height and marks grid as changed""" # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) tab = self.grid.current_table self.code_array.set_row_height(row, tab, height) self.grid.SetRowSize(row, height)
python
def set_row_height(self, row, height): """Sets row height and marks grid as changed""" # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) tab = self.grid.current_table self.code_array.set_row_height(row, tab, height) self.grid.SetRowSize(row, height)
[ "def", "set_row_height", "(", "self", ",", "row", ",", "height", ")", ":", "# Mark content as changed", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ContentChangedMsg", ")", "tab", "=", "self", ".", "grid", ".", "current_table", "self", ".", "code_array", ".", "set_row_height", "(", "row", ",", "tab", ",", "height", ")", "self", ".", "grid", ".", "SetRowSize", "(", "row", ",", "height", ")" ]
Sets row height and marks grid as changed
[ "Sets", "row", "height", "and", "marks", "grid", "as", "changed" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L668-L677
236,625
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableRowActionsMixin.insert_rows
def insert_rows(self, row, no_rows=1): """Adds no_rows rows before row, appends if row > maxrows and marks grid as changed """ # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) tab = self.grid.current_table self.code_array.insert(row, no_rows, axis=0, tab=tab)
python
def insert_rows(self, row, no_rows=1): """Adds no_rows rows before row, appends if row > maxrows and marks grid as changed """ # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) tab = self.grid.current_table self.code_array.insert(row, no_rows, axis=0, tab=tab)
[ "def", "insert_rows", "(", "self", ",", "row", ",", "no_rows", "=", "1", ")", ":", "# Mark content as changed", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ContentChangedMsg", ")", "tab", "=", "self", ".", "grid", ".", "current_table", "self", ".", "code_array", ".", "insert", "(", "row", ",", "no_rows", ",", "axis", "=", "0", ",", "tab", "=", "tab", ")" ]
Adds no_rows rows before row, appends if row > maxrows and marks grid as changed
[ "Adds", "no_rows", "rows", "before", "row", "appends", "if", "row", ">", "maxrows" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L679-L691
236,626
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableRowActionsMixin.delete_rows
def delete_rows(self, row, no_rows=1): """Deletes no_rows rows and marks grid as changed""" # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) tab = self.grid.current_table try: self.code_array.delete(row, no_rows, axis=0, tab=tab) except ValueError, err: post_command_event(self.main_window, self.StatusBarMsg, text=err.message)
python
def delete_rows(self, row, no_rows=1): """Deletes no_rows rows and marks grid as changed""" # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) tab = self.grid.current_table try: self.code_array.delete(row, no_rows, axis=0, tab=tab) except ValueError, err: post_command_event(self.main_window, self.StatusBarMsg, text=err.message)
[ "def", "delete_rows", "(", "self", ",", "row", ",", "no_rows", "=", "1", ")", ":", "# Mark content as changed", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ContentChangedMsg", ")", "tab", "=", "self", ".", "grid", ".", "current_table", "try", ":", "self", ".", "code_array", ".", "delete", "(", "row", ",", "no_rows", ",", "axis", "=", "0", ",", "tab", "=", "tab", ")", "except", "ValueError", ",", "err", ":", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "StatusBarMsg", ",", "text", "=", "err", ".", "message", ")" ]
Deletes no_rows rows and marks grid as changed
[ "Deletes", "no_rows", "rows", "and", "marks", "grid", "as", "changed" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L693-L706
236,627
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableColumnActionsMixin.set_col_width
def set_col_width(self, col, width): """Sets column width and marks grid as changed""" # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) tab = self.grid.current_table self.code_array.set_col_width(col, tab, width) self.grid.SetColSize(col, width)
python
def set_col_width(self, col, width): """Sets column width and marks grid as changed""" # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) tab = self.grid.current_table self.code_array.set_col_width(col, tab, width) self.grid.SetColSize(col, width)
[ "def", "set_col_width", "(", "self", ",", "col", ",", "width", ")", ":", "# Mark content as changed", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ContentChangedMsg", ")", "tab", "=", "self", ".", "grid", ".", "current_table", "self", ".", "code_array", ".", "set_col_width", "(", "col", ",", "tab", ",", "width", ")", "self", ".", "grid", ".", "SetColSize", "(", "col", ",", "width", ")" ]
Sets column width and marks grid as changed
[ "Sets", "column", "width", "and", "marks", "grid", "as", "changed" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L712-L721
236,628
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableColumnActionsMixin.insert_cols
def insert_cols(self, col, no_cols=1): """Adds no_cols columns before col, appends if col > maxcols and marks grid as changed """ # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) tab = self.grid.current_table self.code_array.insert(col, no_cols, axis=1, tab=tab)
python
def insert_cols(self, col, no_cols=1): """Adds no_cols columns before col, appends if col > maxcols and marks grid as changed """ # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) tab = self.grid.current_table self.code_array.insert(col, no_cols, axis=1, tab=tab)
[ "def", "insert_cols", "(", "self", ",", "col", ",", "no_cols", "=", "1", ")", ":", "# Mark content as changed", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ContentChangedMsg", ")", "tab", "=", "self", ".", "grid", ".", "current_table", "self", ".", "code_array", ".", "insert", "(", "col", ",", "no_cols", ",", "axis", "=", "1", ",", "tab", "=", "tab", ")" ]
Adds no_cols columns before col, appends if col > maxcols and marks grid as changed
[ "Adds", "no_cols", "columns", "before", "col", "appends", "if", "col", ">", "maxcols" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L723-L735
236,629
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableColumnActionsMixin.delete_cols
def delete_cols(self, col, no_cols=1): """Deletes no_cols column and marks grid as changed""" # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) tab = self.grid.current_table try: self.code_array.delete(col, no_cols, axis=1, tab=tab) except ValueError, err: post_command_event(self.main_window, self.StatusBarMsg, text=err.message)
python
def delete_cols(self, col, no_cols=1): """Deletes no_cols column and marks grid as changed""" # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) tab = self.grid.current_table try: self.code_array.delete(col, no_cols, axis=1, tab=tab) except ValueError, err: post_command_event(self.main_window, self.StatusBarMsg, text=err.message)
[ "def", "delete_cols", "(", "self", ",", "col", ",", "no_cols", "=", "1", ")", ":", "# Mark content as changed", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ContentChangedMsg", ")", "tab", "=", "self", ".", "grid", ".", "current_table", "try", ":", "self", ".", "code_array", ".", "delete", "(", "col", ",", "no_cols", ",", "axis", "=", "1", ",", "tab", "=", "tab", ")", "except", "ValueError", ",", "err", ":", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "StatusBarMsg", ",", "text", "=", "err", ".", "message", ")" ]
Deletes no_cols column and marks grid as changed
[ "Deletes", "no_cols", "column", "and", "marks", "grid", "as", "changed" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L737-L750
236,630
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableTabActionsMixin.insert_tabs
def insert_tabs(self, tab, no_tabs=1): """Adds no_tabs tabs before table, appends if tab > maxtabs and marks grid as changed """ # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) self.code_array.insert(tab, no_tabs, axis=2) # Update TableChoiceIntCtrl shape = self.grid.code_array.shape post_command_event(self.main_window, self.ResizeGridMsg, shape=shape)
python
def insert_tabs(self, tab, no_tabs=1): """Adds no_tabs tabs before table, appends if tab > maxtabs and marks grid as changed """ # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) self.code_array.insert(tab, no_tabs, axis=2) # Update TableChoiceIntCtrl shape = self.grid.code_array.shape post_command_event(self.main_window, self.ResizeGridMsg, shape=shape)
[ "def", "insert_tabs", "(", "self", ",", "tab", ",", "no_tabs", "=", "1", ")", ":", "# Mark content as changed", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ContentChangedMsg", ")", "self", ".", "code_array", ".", "insert", "(", "tab", ",", "no_tabs", ",", "axis", "=", "2", ")", "# Update TableChoiceIntCtrl", "shape", "=", "self", ".", "grid", ".", "code_array", ".", "shape", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ResizeGridMsg", ",", "shape", "=", "shape", ")" ]
Adds no_tabs tabs before table, appends if tab > maxtabs and marks grid as changed
[ "Adds", "no_tabs", "tabs", "before", "table", "appends", "if", "tab", ">", "maxtabs" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L756-L770
236,631
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableTabActionsMixin.delete_tabs
def delete_tabs(self, tab, no_tabs=1): """Deletes no_tabs tabs and marks grid as changed""" # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) try: self.code_array.delete(tab, no_tabs, axis=2) # Update TableChoiceIntCtrl shape = self.grid.code_array.shape post_command_event(self.main_window, self.ResizeGridMsg, shape=shape) except ValueError, err: post_command_event(self.main_window, self.StatusBarMsg, text=err.message)
python
def delete_tabs(self, tab, no_tabs=1): """Deletes no_tabs tabs and marks grid as changed""" # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) try: self.code_array.delete(tab, no_tabs, axis=2) # Update TableChoiceIntCtrl shape = self.grid.code_array.shape post_command_event(self.main_window, self.ResizeGridMsg, shape=shape) except ValueError, err: post_command_event(self.main_window, self.StatusBarMsg, text=err.message)
[ "def", "delete_tabs", "(", "self", ",", "tab", ",", "no_tabs", "=", "1", ")", ":", "# Mark content as changed", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ContentChangedMsg", ")", "try", ":", "self", ".", "code_array", ".", "delete", "(", "tab", ",", "no_tabs", ",", "axis", "=", "2", ")", "# Update TableChoiceIntCtrl", "shape", "=", "self", ".", "grid", ".", "code_array", ".", "shape", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ResizeGridMsg", ",", "shape", "=", "shape", ")", "except", "ValueError", ",", "err", ":", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "StatusBarMsg", ",", "text", "=", "err", ".", "message", ")" ]
Deletes no_tabs tabs and marks grid as changed
[ "Deletes", "no_tabs", "tabs", "and", "marks", "grid", "as", "changed" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L772-L788
236,632
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableActions.on_key
def on_key(self, event): """Sets abort if pasting and if escape is pressed""" # If paste is running and Esc is pressed then we need to abort if event.GetKeyCode() == wx.WXK_ESCAPE and \ self.pasting or self.grid.actions.saving: self.need_abort = True event.Skip()
python
def on_key(self, event): """Sets abort if pasting and if escape is pressed""" # If paste is running and Esc is pressed then we need to abort if event.GetKeyCode() == wx.WXK_ESCAPE and \ self.pasting or self.grid.actions.saving: self.need_abort = True event.Skip()
[ "def", "on_key", "(", "self", ",", "event", ")", ":", "# If paste is running and Esc is pressed then we need to abort", "if", "event", ".", "GetKeyCode", "(", ")", "==", "wx", ".", "WXK_ESCAPE", "and", "self", ".", "pasting", "or", "self", ".", "grid", ".", "actions", ".", "saving", ":", "self", ".", "need_abort", "=", "True", "event", ".", "Skip", "(", ")" ]
Sets abort if pasting and if escape is pressed
[ "Sets", "abort", "if", "pasting", "and", "if", "escape", "is", "pressed" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L808-L817
236,633
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableActions._get_full_key
def _get_full_key(self, key): """Returns full key even if table is omitted""" length = len(key) if length == 3: return key elif length == 2: row, col = key tab = self.grid.current_table return row, col, tab else: msg = _("Key length {length} not in (2, 3)").format(length=length) raise ValueError(msg)
python
def _get_full_key(self, key): """Returns full key even if table is omitted""" length = len(key) if length == 3: return key elif length == 2: row, col = key tab = self.grid.current_table return row, col, tab else: msg = _("Key length {length} not in (2, 3)").format(length=length) raise ValueError(msg)
[ "def", "_get_full_key", "(", "self", ",", "key", ")", ":", "length", "=", "len", "(", "key", ")", "if", "length", "==", "3", ":", "return", "key", "elif", "length", "==", "2", ":", "row", ",", "col", "=", "key", "tab", "=", "self", ".", "grid", ".", "current_table", "return", "row", ",", "col", ",", "tab", "else", ":", "msg", "=", "_", "(", "\"Key length {length} not in (2, 3)\"", ")", ".", "format", "(", "length", "=", "length", ")", "raise", "ValueError", "(", "msg", ")" ]
Returns full key even if table is omitted
[ "Returns", "full", "key", "even", "if", "table", "is", "omitted" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L819-L834
236,634
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableActions._show_final_overflow_message
def _show_final_overflow_message(self, row_overflow, col_overflow): """Displays overflow message after import in statusbar""" if row_overflow and col_overflow: overflow_cause = _("rows and columns") elif row_overflow: overflow_cause = _("rows") elif col_overflow: overflow_cause = _("columns") else: raise AssertionError(_("Import cell overflow missing")) statustext = \ _("The imported data did not fit into the grid {cause}. " "It has been truncated. Use a larger grid for full import.").\ format(cause=overflow_cause) post_command_event(self.main_window, self.StatusBarMsg, text=statustext)
python
def _show_final_overflow_message(self, row_overflow, col_overflow): """Displays overflow message after import in statusbar""" if row_overflow and col_overflow: overflow_cause = _("rows and columns") elif row_overflow: overflow_cause = _("rows") elif col_overflow: overflow_cause = _("columns") else: raise AssertionError(_("Import cell overflow missing")) statustext = \ _("The imported data did not fit into the grid {cause}. " "It has been truncated. Use a larger grid for full import.").\ format(cause=overflow_cause) post_command_event(self.main_window, self.StatusBarMsg, text=statustext)
[ "def", "_show_final_overflow_message", "(", "self", ",", "row_overflow", ",", "col_overflow", ")", ":", "if", "row_overflow", "and", "col_overflow", ":", "overflow_cause", "=", "_", "(", "\"rows and columns\"", ")", "elif", "row_overflow", ":", "overflow_cause", "=", "_", "(", "\"rows\"", ")", "elif", "col_overflow", ":", "overflow_cause", "=", "_", "(", "\"columns\"", ")", "else", ":", "raise", "AssertionError", "(", "_", "(", "\"Import cell overflow missing\"", ")", ")", "statustext", "=", "_", "(", "\"The imported data did not fit into the grid {cause}. \"", "\"It has been truncated. Use a larger grid for full import.\"", ")", ".", "format", "(", "cause", "=", "overflow_cause", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "StatusBarMsg", ",", "text", "=", "statustext", ")" ]
Displays overflow message after import in statusbar
[ "Displays", "overflow", "message", "after", "import", "in", "statusbar" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L846-L863
236,635
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableActions._show_final_paste_message
def _show_final_paste_message(self, tl_key, no_pasted_cells): """Show actually pasted number of cells""" plural = "" if no_pasted_cells == 1 else _("s") statustext = _("{ncells} cell{plural} pasted at cell {topleft}").\ format(ncells=no_pasted_cells, plural=plural, topleft=tl_key) post_command_event(self.main_window, self.StatusBarMsg, text=statustext)
python
def _show_final_paste_message(self, tl_key, no_pasted_cells): """Show actually pasted number of cells""" plural = "" if no_pasted_cells == 1 else _("s") statustext = _("{ncells} cell{plural} pasted at cell {topleft}").\ format(ncells=no_pasted_cells, plural=plural, topleft=tl_key) post_command_event(self.main_window, self.StatusBarMsg, text=statustext)
[ "def", "_show_final_paste_message", "(", "self", ",", "tl_key", ",", "no_pasted_cells", ")", ":", "plural", "=", "\"\"", "if", "no_pasted_cells", "==", "1", "else", "_", "(", "\"s\"", ")", "statustext", "=", "_", "(", "\"{ncells} cell{plural} pasted at cell {topleft}\"", ")", ".", "format", "(", "ncells", "=", "no_pasted_cells", ",", "plural", "=", "plural", ",", "topleft", "=", "tl_key", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "StatusBarMsg", ",", "text", "=", "statustext", ")" ]
Show actually pasted number of cells
[ "Show", "actually", "pasted", "number", "of", "cells" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L865-L874
236,636
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableActions.paste_to_current_cell
def paste_to_current_cell(self, tl_key, data, freq=None): """Pastes data into grid from top left cell tl_key Parameters ---------- ul_key: Tuple \key of top left cell of paste area data: iterable of iterables where inner iterable returns string \tThe outer iterable represents rows freq: Integer, defaults to None \tStatus message frequency """ self.pasting = True grid_rows, grid_cols, __ = self.grid.code_array.shape self.need_abort = False tl_row, tl_col, tl_tab = self._get_full_key(tl_key) row_overflow = False col_overflow = False no_pasted_cells = 0 for src_row, row_data in enumerate(data): target_row = tl_row + src_row if self.grid.actions._is_aborted(src_row, _("Pasting cells... "), freq=freq): self._abort_paste() return False # Check if rows fit into grid if target_row >= grid_rows: row_overflow = True break for src_col, cell_data in enumerate(row_data): target_col = tl_col + src_col if target_col >= grid_cols: col_overflow = True break if cell_data is not None: # Is only None if pasting into selection key = target_row, target_col, tl_tab try: CellActions.set_code(self, key, cell_data) no_pasted_cells += 1 except KeyError: pass if row_overflow or col_overflow: self._show_final_overflow_message(row_overflow, col_overflow) else: self._show_final_paste_message(tl_key, no_pasted_cells) self.pasting = False
python
def paste_to_current_cell(self, tl_key, data, freq=None): """Pastes data into grid from top left cell tl_key Parameters ---------- ul_key: Tuple \key of top left cell of paste area data: iterable of iterables where inner iterable returns string \tThe outer iterable represents rows freq: Integer, defaults to None \tStatus message frequency """ self.pasting = True grid_rows, grid_cols, __ = self.grid.code_array.shape self.need_abort = False tl_row, tl_col, tl_tab = self._get_full_key(tl_key) row_overflow = False col_overflow = False no_pasted_cells = 0 for src_row, row_data in enumerate(data): target_row = tl_row + src_row if self.grid.actions._is_aborted(src_row, _("Pasting cells... "), freq=freq): self._abort_paste() return False # Check if rows fit into grid if target_row >= grid_rows: row_overflow = True break for src_col, cell_data in enumerate(row_data): target_col = tl_col + src_col if target_col >= grid_cols: col_overflow = True break if cell_data is not None: # Is only None if pasting into selection key = target_row, target_col, tl_tab try: CellActions.set_code(self, key, cell_data) no_pasted_cells += 1 except KeyError: pass if row_overflow or col_overflow: self._show_final_overflow_message(row_overflow, col_overflow) else: self._show_final_paste_message(tl_key, no_pasted_cells) self.pasting = False
[ "def", "paste_to_current_cell", "(", "self", ",", "tl_key", ",", "data", ",", "freq", "=", "None", ")", ":", "self", ".", "pasting", "=", "True", "grid_rows", ",", "grid_cols", ",", "__", "=", "self", ".", "grid", ".", "code_array", ".", "shape", "self", ".", "need_abort", "=", "False", "tl_row", ",", "tl_col", ",", "tl_tab", "=", "self", ".", "_get_full_key", "(", "tl_key", ")", "row_overflow", "=", "False", "col_overflow", "=", "False", "no_pasted_cells", "=", "0", "for", "src_row", ",", "row_data", "in", "enumerate", "(", "data", ")", ":", "target_row", "=", "tl_row", "+", "src_row", "if", "self", ".", "grid", ".", "actions", ".", "_is_aborted", "(", "src_row", ",", "_", "(", "\"Pasting cells... \"", ")", ",", "freq", "=", "freq", ")", ":", "self", ".", "_abort_paste", "(", ")", "return", "False", "# Check if rows fit into grid", "if", "target_row", ">=", "grid_rows", ":", "row_overflow", "=", "True", "break", "for", "src_col", ",", "cell_data", "in", "enumerate", "(", "row_data", ")", ":", "target_col", "=", "tl_col", "+", "src_col", "if", "target_col", ">=", "grid_cols", ":", "col_overflow", "=", "True", "break", "if", "cell_data", "is", "not", "None", ":", "# Is only None if pasting into selection", "key", "=", "target_row", ",", "target_col", ",", "tl_tab", "try", ":", "CellActions", ".", "set_code", "(", "self", ",", "key", ",", "cell_data", ")", "no_pasted_cells", "+=", "1", "except", "KeyError", ":", "pass", "if", "row_overflow", "or", "col_overflow", ":", "self", ".", "_show_final_overflow_message", "(", "row_overflow", ",", "col_overflow", ")", "else", ":", "self", ".", "_show_final_paste_message", "(", "tl_key", ",", "no_pasted_cells", ")", "self", ".", "pasting", "=", "False" ]
Pastes data into grid from top left cell tl_key Parameters ---------- ul_key: Tuple \key of top left cell of paste area data: iterable of iterables where inner iterable returns string \tThe outer iterable represents rows freq: Integer, defaults to None \tStatus message frequency
[ "Pastes", "data", "into", "grid", "from", "top", "left", "cell", "tl_key" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L876-L940
236,637
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableActions.selection_paste_data_gen
def selection_paste_data_gen(self, selection, data, freq=None): """Generator that yields data for selection paste""" (bb_top, bb_left), (bb_bottom, bb_right) = \ selection.get_grid_bbox(self.grid.code_array.shape) bbox_height = bb_bottom - bb_top + 1 bbox_width = bb_right - bb_left + 1 for row, row_data in enumerate(itertools.cycle(data)): # Break if row is not in selection bbox if row >= bbox_height: break # Duplicate row data if selection is wider than row data row_data = list(row_data) duplicated_row_data = row_data * (bbox_width // len(row_data) + 1) duplicated_row_data = duplicated_row_data[:bbox_width] for col in xrange(len(duplicated_row_data)): if (bb_top, bb_left + col) not in selection: duplicated_row_data[col] = None yield duplicated_row_data
python
def selection_paste_data_gen(self, selection, data, freq=None): """Generator that yields data for selection paste""" (bb_top, bb_left), (bb_bottom, bb_right) = \ selection.get_grid_bbox(self.grid.code_array.shape) bbox_height = bb_bottom - bb_top + 1 bbox_width = bb_right - bb_left + 1 for row, row_data in enumerate(itertools.cycle(data)): # Break if row is not in selection bbox if row >= bbox_height: break # Duplicate row data if selection is wider than row data row_data = list(row_data) duplicated_row_data = row_data * (bbox_width // len(row_data) + 1) duplicated_row_data = duplicated_row_data[:bbox_width] for col in xrange(len(duplicated_row_data)): if (bb_top, bb_left + col) not in selection: duplicated_row_data[col] = None yield duplicated_row_data
[ "def", "selection_paste_data_gen", "(", "self", ",", "selection", ",", "data", ",", "freq", "=", "None", ")", ":", "(", "bb_top", ",", "bb_left", ")", ",", "(", "bb_bottom", ",", "bb_right", ")", "=", "selection", ".", "get_grid_bbox", "(", "self", ".", "grid", ".", "code_array", ".", "shape", ")", "bbox_height", "=", "bb_bottom", "-", "bb_top", "+", "1", "bbox_width", "=", "bb_right", "-", "bb_left", "+", "1", "for", "row", ",", "row_data", "in", "enumerate", "(", "itertools", ".", "cycle", "(", "data", ")", ")", ":", "# Break if row is not in selection bbox", "if", "row", ">=", "bbox_height", ":", "break", "# Duplicate row data if selection is wider than row data", "row_data", "=", "list", "(", "row_data", ")", "duplicated_row_data", "=", "row_data", "*", "(", "bbox_width", "//", "len", "(", "row_data", ")", "+", "1", ")", "duplicated_row_data", "=", "duplicated_row_data", "[", ":", "bbox_width", "]", "for", "col", "in", "xrange", "(", "len", "(", "duplicated_row_data", ")", ")", ":", "if", "(", "bb_top", ",", "bb_left", "+", "col", ")", "not", "in", "selection", ":", "duplicated_row_data", "[", "col", "]", "=", "None", "yield", "duplicated_row_data" ]
Generator that yields data for selection paste
[ "Generator", "that", "yields", "data", "for", "selection", "paste" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L942-L964
236,638
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableActions.paste_to_selection
def paste_to_selection(self, selection, data, freq=None): """Pastes data into grid selection""" (bb_top, bb_left), (bb_bottom, bb_right) = \ selection.get_grid_bbox(self.grid.code_array.shape) adjusted_data = self.selection_paste_data_gen(selection, data) self.paste_to_current_cell((bb_top, bb_left), adjusted_data, freq=freq)
python
def paste_to_selection(self, selection, data, freq=None): """Pastes data into grid selection""" (bb_top, bb_left), (bb_bottom, bb_right) = \ selection.get_grid_bbox(self.grid.code_array.shape) adjusted_data = self.selection_paste_data_gen(selection, data) self.paste_to_current_cell((bb_top, bb_left), adjusted_data, freq=freq)
[ "def", "paste_to_selection", "(", "self", ",", "selection", ",", "data", ",", "freq", "=", "None", ")", ":", "(", "bb_top", ",", "bb_left", ")", ",", "(", "bb_bottom", ",", "bb_right", ")", "=", "selection", ".", "get_grid_bbox", "(", "self", ".", "grid", ".", "code_array", ".", "shape", ")", "adjusted_data", "=", "self", ".", "selection_paste_data_gen", "(", "selection", ",", "data", ")", "self", ".", "paste_to_current_cell", "(", "(", "bb_top", ",", "bb_left", ")", ",", "adjusted_data", ",", "freq", "=", "freq", ")" ]
Pastes data into grid selection
[ "Pastes", "data", "into", "grid", "selection" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L966-L972
236,639
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableActions.paste
def paste(self, tl_key, data, freq=None): """Pastes data into grid, marks grid changed If no selection is present, data is pasted starting with current cell If a selection is present, data is pasted fully if the selection is smaller. If the selection is larger then data is duplicated. Parameters ---------- ul_key: Tuple \key of top left cell of paste area data: iterable of iterables where inner iterable returns string \tThe outer iterable represents rows freq: Integer, defaults to None \tStatus message frequency """ # Get selection bounding box selection = self.get_selection() # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) if selection: # There is a selection. Paste into it self.paste_to_selection(selection, data, freq=freq) else: # There is no selection. Paste from top left cell. self.paste_to_current_cell(tl_key, data, freq=freq)
python
def paste(self, tl_key, data, freq=None): """Pastes data into grid, marks grid changed If no selection is present, data is pasted starting with current cell If a selection is present, data is pasted fully if the selection is smaller. If the selection is larger then data is duplicated. Parameters ---------- ul_key: Tuple \key of top left cell of paste area data: iterable of iterables where inner iterable returns string \tThe outer iterable represents rows freq: Integer, defaults to None \tStatus message frequency """ # Get selection bounding box selection = self.get_selection() # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) if selection: # There is a selection. Paste into it self.paste_to_selection(selection, data, freq=freq) else: # There is no selection. Paste from top left cell. self.paste_to_current_cell(tl_key, data, freq=freq)
[ "def", "paste", "(", "self", ",", "tl_key", ",", "data", ",", "freq", "=", "None", ")", ":", "# Get selection bounding box", "selection", "=", "self", ".", "get_selection", "(", ")", "# Mark content as changed", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ContentChangedMsg", ")", "if", "selection", ":", "# There is a selection. Paste into it", "self", ".", "paste_to_selection", "(", "selection", ",", "data", ",", "freq", "=", "freq", ")", "else", ":", "# There is no selection. Paste from top left cell.", "self", ".", "paste_to_current_cell", "(", "tl_key", ",", "data", ",", "freq", "=", "freq", ")" ]
Pastes data into grid, marks grid changed If no selection is present, data is pasted starting with current cell If a selection is present, data is pasted fully if the selection is smaller. If the selection is larger then data is duplicated. Parameters ---------- ul_key: Tuple \key of top left cell of paste area data: iterable of iterables where inner iterable returns string \tThe outer iterable represents rows freq: Integer, defaults to None \tStatus message frequency
[ "Pastes", "data", "into", "grid", "marks", "grid", "changed" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L974-L1005
236,640
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableActions.change_grid_shape
def change_grid_shape(self, shape): """Grid shape change event handler, marks content as changed""" # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) self.code_array.shape = shape # Update TableChoiceIntCtrl post_command_event(self.main_window, self.ResizeGridMsg, shape=shape) # Change grid table dimensions self.grid.GetTable().ResetView() # Clear caches self.code_array.result_cache.clear()
python
def change_grid_shape(self, shape): """Grid shape change event handler, marks content as changed""" # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) self.code_array.shape = shape # Update TableChoiceIntCtrl post_command_event(self.main_window, self.ResizeGridMsg, shape=shape) # Change grid table dimensions self.grid.GetTable().ResetView() # Clear caches self.code_array.result_cache.clear()
[ "def", "change_grid_shape", "(", "self", ",", "shape", ")", ":", "# Mark content as changed", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ContentChangedMsg", ")", "self", ".", "code_array", ".", "shape", "=", "shape", "# Update TableChoiceIntCtrl", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ResizeGridMsg", ",", "shape", "=", "shape", ")", "# Change grid table dimensions", "self", ".", "grid", ".", "GetTable", "(", ")", ".", "ResetView", "(", ")", "# Clear caches", "self", ".", "code_array", ".", "result_cache", ".", "clear", "(", ")" ]
Grid shape change event handler, marks content as changed
[ "Grid", "shape", "change", "event", "handler", "marks", "content", "as", "changed" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1007-L1022
236,641
manns/pyspread
pyspread/src/actions/_grid_actions.py
TableActions.replace_cells
def replace_cells(self, key, sorted_row_idxs): """Replaces cells in current selection so that they are sorted""" row, col, tab = key new_keys = {} del_keys = [] selection = self.grid.actions.get_selection() for __row, __col, __tab in self.grid.code_array: if __tab == tab and \ (not selection or (__row, __col) in selection): new_row = sorted_row_idxs.index(__row) if __row != new_row: new_keys[(new_row, __col, __tab)] = \ self.grid.code_array((__row, __col, __tab)) del_keys.append((__row, __col, __tab)) for key in del_keys: self.grid.code_array.pop(key) for key in new_keys: CellActions.set_code(self, key, new_keys[key])
python
def replace_cells(self, key, sorted_row_idxs): """Replaces cells in current selection so that they are sorted""" row, col, tab = key new_keys = {} del_keys = [] selection = self.grid.actions.get_selection() for __row, __col, __tab in self.grid.code_array: if __tab == tab and \ (not selection or (__row, __col) in selection): new_row = sorted_row_idxs.index(__row) if __row != new_row: new_keys[(new_row, __col, __tab)] = \ self.grid.code_array((__row, __col, __tab)) del_keys.append((__row, __col, __tab)) for key in del_keys: self.grid.code_array.pop(key) for key in new_keys: CellActions.set_code(self, key, new_keys[key])
[ "def", "replace_cells", "(", "self", ",", "key", ",", "sorted_row_idxs", ")", ":", "row", ",", "col", ",", "tab", "=", "key", "new_keys", "=", "{", "}", "del_keys", "=", "[", "]", "selection", "=", "self", ".", "grid", ".", "actions", ".", "get_selection", "(", ")", "for", "__row", ",", "__col", ",", "__tab", "in", "self", ".", "grid", ".", "code_array", ":", "if", "__tab", "==", "tab", "and", "(", "not", "selection", "or", "(", "__row", ",", "__col", ")", "in", "selection", ")", ":", "new_row", "=", "sorted_row_idxs", ".", "index", "(", "__row", ")", "if", "__row", "!=", "new_row", ":", "new_keys", "[", "(", "new_row", ",", "__col", ",", "__tab", ")", "]", "=", "self", ".", "grid", ".", "code_array", "(", "(", "__row", ",", "__col", ",", "__tab", ")", ")", "del_keys", ".", "append", "(", "(", "__row", ",", "__col", ",", "__tab", ")", ")", "for", "key", "in", "del_keys", ":", "self", ".", "grid", ".", "code_array", ".", "pop", "(", "key", ")", "for", "key", "in", "new_keys", ":", "CellActions", ".", "set_code", "(", "self", ",", "key", ",", "new_keys", "[", "key", "]", ")" ]
Replaces cells in current selection so that they are sorted
[ "Replaces", "cells", "in", "current", "selection", "so", "that", "they", "are", "sorted" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1024-L1047
236,642
manns/pyspread
pyspread/src/actions/_grid_actions.py
GridActions.new
def new(self, event): """Creates a new spreadsheet. Expects code_array in event.""" # Grid table handles interaction to code_array self.grid.actions.clear(event.shape) _grid_table = GridTable(self.grid, self.grid.code_array) self.grid.SetTable(_grid_table, True) # Update toolbars self.grid.update_entry_line() self.grid.update_attribute_toolbar()
python
def new(self, event): """Creates a new spreadsheet. Expects code_array in event.""" # Grid table handles interaction to code_array self.grid.actions.clear(event.shape) _grid_table = GridTable(self.grid, self.grid.code_array) self.grid.SetTable(_grid_table, True) # Update toolbars self.grid.update_entry_line() self.grid.update_attribute_toolbar()
[ "def", "new", "(", "self", ",", "event", ")", ":", "# Grid table handles interaction to code_array", "self", ".", "grid", ".", "actions", ".", "clear", "(", "event", ".", "shape", ")", "_grid_table", "=", "GridTable", "(", "self", ".", "grid", ",", "self", ".", "grid", ".", "code_array", ")", "self", ".", "grid", ".", "SetTable", "(", "_grid_table", ",", "True", ")", "# Update toolbars", "self", ".", "grid", ".", "update_entry_line", "(", ")", "self", ".", "grid", ".", "update_attribute_toolbar", "(", ")" ]
Creates a new spreadsheet. Expects code_array in event.
[ "Creates", "a", "new", "spreadsheet", ".", "Expects", "code_array", "in", "event", "." ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1098-L1110
236,643
manns/pyspread
pyspread/src/actions/_grid_actions.py
GridActions._zoom_rows
def _zoom_rows(self, zoom): """Zooms grid rows""" self.grid.SetDefaultRowSize(self.grid.std_row_size * zoom, resizeExistingRows=True) self.grid.SetRowLabelSize(self.grid.row_label_size * zoom) for row, tab in self.code_array.row_heights: if tab == self.grid.current_table and \ row < self.grid.code_array.shape[0]: base_row_width = self.code_array.row_heights[(row, tab)] if base_row_width is None: base_row_width = self.grid.GetDefaultRowSize() zoomed_row_size = base_row_width * zoom self.grid.SetRowSize(row, zoomed_row_size)
python
def _zoom_rows(self, zoom): """Zooms grid rows""" self.grid.SetDefaultRowSize(self.grid.std_row_size * zoom, resizeExistingRows=True) self.grid.SetRowLabelSize(self.grid.row_label_size * zoom) for row, tab in self.code_array.row_heights: if tab == self.grid.current_table and \ row < self.grid.code_array.shape[0]: base_row_width = self.code_array.row_heights[(row, tab)] if base_row_width is None: base_row_width = self.grid.GetDefaultRowSize() zoomed_row_size = base_row_width * zoom self.grid.SetRowSize(row, zoomed_row_size)
[ "def", "_zoom_rows", "(", "self", ",", "zoom", ")", ":", "self", ".", "grid", ".", "SetDefaultRowSize", "(", "self", ".", "grid", ".", "std_row_size", "*", "zoom", ",", "resizeExistingRows", "=", "True", ")", "self", ".", "grid", ".", "SetRowLabelSize", "(", "self", ".", "grid", ".", "row_label_size", "*", "zoom", ")", "for", "row", ",", "tab", "in", "self", ".", "code_array", ".", "row_heights", ":", "if", "tab", "==", "self", ".", "grid", ".", "current_table", "and", "row", "<", "self", ".", "grid", ".", "code_array", ".", "shape", "[", "0", "]", ":", "base_row_width", "=", "self", ".", "code_array", ".", "row_heights", "[", "(", "row", ",", "tab", ")", "]", "if", "base_row_width", "is", "None", ":", "base_row_width", "=", "self", ".", "grid", ".", "GetDefaultRowSize", "(", ")", "zoomed_row_size", "=", "base_row_width", "*", "zoom", "self", ".", "grid", ".", "SetRowSize", "(", "row", ",", "zoomed_row_size", ")" ]
Zooms grid rows
[ "Zooms", "grid", "rows" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1114-L1128
236,644
manns/pyspread
pyspread/src/actions/_grid_actions.py
GridActions._zoom_cols
def _zoom_cols(self, zoom): """Zooms grid columns""" self.grid.SetDefaultColSize(self.grid.std_col_size * zoom, resizeExistingCols=True) self.grid.SetColLabelSize(self.grid.col_label_size * zoom) for col, tab in self.code_array.col_widths: if tab == self.grid.current_table and \ col < self.grid.code_array.shape[1]: base_col_width = self.code_array.col_widths[(col, tab)] if base_col_width is None: base_col_width = self.grid.GetDefaultColSize() zoomed_col_size = base_col_width * zoom self.grid.SetColSize(col, zoomed_col_size)
python
def _zoom_cols(self, zoom): """Zooms grid columns""" self.grid.SetDefaultColSize(self.grid.std_col_size * zoom, resizeExistingCols=True) self.grid.SetColLabelSize(self.grid.col_label_size * zoom) for col, tab in self.code_array.col_widths: if tab == self.grid.current_table and \ col < self.grid.code_array.shape[1]: base_col_width = self.code_array.col_widths[(col, tab)] if base_col_width is None: base_col_width = self.grid.GetDefaultColSize() zoomed_col_size = base_col_width * zoom self.grid.SetColSize(col, zoomed_col_size)
[ "def", "_zoom_cols", "(", "self", ",", "zoom", ")", ":", "self", ".", "grid", ".", "SetDefaultColSize", "(", "self", ".", "grid", ".", "std_col_size", "*", "zoom", ",", "resizeExistingCols", "=", "True", ")", "self", ".", "grid", ".", "SetColLabelSize", "(", "self", ".", "grid", ".", "col_label_size", "*", "zoom", ")", "for", "col", ",", "tab", "in", "self", ".", "code_array", ".", "col_widths", ":", "if", "tab", "==", "self", ".", "grid", ".", "current_table", "and", "col", "<", "self", ".", "grid", ".", "code_array", ".", "shape", "[", "1", "]", ":", "base_col_width", "=", "self", ".", "code_array", ".", "col_widths", "[", "(", "col", ",", "tab", ")", "]", "if", "base_col_width", "is", "None", ":", "base_col_width", "=", "self", ".", "grid", ".", "GetDefaultColSize", "(", ")", "zoomed_col_size", "=", "base_col_width", "*", "zoom", "self", ".", "grid", ".", "SetColSize", "(", "col", ",", "zoomed_col_size", ")" ]
Zooms grid columns
[ "Zooms", "grid", "columns" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1130-L1144
236,645
manns/pyspread
pyspread/src/actions/_grid_actions.py
GridActions._zoom_labels
def _zoom_labels(self, zoom): """Adjust grid label font to zoom factor""" labelfont = self.grid.GetLabelFont() default_fontsize = get_default_font().GetPointSize() labelfont.SetPointSize(max(1, int(round(default_fontsize * zoom)))) self.grid.SetLabelFont(labelfont)
python
def _zoom_labels(self, zoom): """Adjust grid label font to zoom factor""" labelfont = self.grid.GetLabelFont() default_fontsize = get_default_font().GetPointSize() labelfont.SetPointSize(max(1, int(round(default_fontsize * zoom)))) self.grid.SetLabelFont(labelfont)
[ "def", "_zoom_labels", "(", "self", ",", "zoom", ")", ":", "labelfont", "=", "self", ".", "grid", ".", "GetLabelFont", "(", ")", "default_fontsize", "=", "get_default_font", "(", ")", ".", "GetPointSize", "(", ")", "labelfont", ".", "SetPointSize", "(", "max", "(", "1", ",", "int", "(", "round", "(", "default_fontsize", "*", "zoom", ")", ")", ")", ")", "self", ".", "grid", ".", "SetLabelFont", "(", "labelfont", ")" ]
Adjust grid label font to zoom factor
[ "Adjust", "grid", "label", "font", "to", "zoom", "factor" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1146-L1152
236,646
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
236,647
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
236,648
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
236,649
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
236,650
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
236,651
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
236,652
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
236,653
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
236,654
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
236,655
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
236,656
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
236,657
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
236,658
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
236,659
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
236,660
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
236,661
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
236,662
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
236,663
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
236,664
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
236,665
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
236,666
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
236,667
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
236,668
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
236,669
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
236,670
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
236,671
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
236,672
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
236,673
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
236,674
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
236,675
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
236,676
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
236,677
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
236,678
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
236,679
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
236,680
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
236,681
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
236,682
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
236,683
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
236,684
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
236,685
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
236,686
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
236,687
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
236,688
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
236,689
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
236,690
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
236,691
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
236,692
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
236,693
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
236,694
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
236,695
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
236,696
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
236,697
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
236,698
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
236,699
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