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,500
manns/pyspread
pyspread/src/interfaces/pys.py
Pys._col_widths2pys
def _col_widths2pys(self): """Writes col_widths to pys file Format: <col>\t<tab>\t<value>\n """ for col, tab in self.code_array.dict_grid.col_widths: if col < self.code_array.shape[1] and \ tab < self.code_array.shape[2]: width = self.code_array.dict_grid.col_widths[(col, tab)] width_strings = map(repr, [col, tab, width]) self.pys_file.write(u"\t".join(width_strings) + u"\n")
python
def _col_widths2pys(self): """Writes col_widths to pys file Format: <col>\t<tab>\t<value>\n """ for col, tab in self.code_array.dict_grid.col_widths: if col < self.code_array.shape[1] and \ tab < self.code_array.shape[2]: width = self.code_array.dict_grid.col_widths[(col, tab)] width_strings = map(repr, [col, tab, width]) self.pys_file.write(u"\t".join(width_strings) + u"\n")
[ "def", "_col_widths2pys", "(", "self", ")", ":", "for", "col", ",", "tab", "in", "self", ".", "code_array", ".", "dict_grid", ".", "col_widths", ":", "if", "col", "<", "self", ".", "code_array", ".", "shape", "[", "1", "]", "and", "tab", "<", "self", ".", "code_array", ".", "shape", "[", "2", "]", ":", "width", "=", "self", ".", "code_array", ".", "dict_grid", ".", "col_widths", "[", "(", "col", ",", "tab", ")", "]", "width_strings", "=", "map", "(", "repr", ",", "[", "col", ",", "tab", ",", "width", "]", ")", "self", ".", "pys_file", ".", "write", "(", "u\"\\t\"", ".", "join", "(", "width_strings", ")", "+", "u\"\\n\"", ")" ]
Writes col_widths to pys file Format: <col>\t<tab>\t<value>\n
[ "Writes", "col_widths", "to", "pys", "file" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/interfaces/pys.py#L266-L278
236,501
manns/pyspread
pyspread/src/interfaces/pys.py
Pys._macros2pys
def _macros2pys(self): """Writes macros to pys file Format: <macro code line>\n """ macros = self.code_array.dict_grid.macros pys_macros = macros.encode("utf-8") self.pys_file.write(pys_macros)
python
def _macros2pys(self): """Writes macros to pys file Format: <macro code line>\n """ macros = self.code_array.dict_grid.macros pys_macros = macros.encode("utf-8") self.pys_file.write(pys_macros)
[ "def", "_macros2pys", "(", "self", ")", ":", "macros", "=", "self", ".", "code_array", ".", "dict_grid", ".", "macros", "pys_macros", "=", "macros", ".", "encode", "(", "\"utf-8\"", ")", "self", ".", "pys_file", ".", "write", "(", "pys_macros", ")" ]
Writes macros to pys file Format: <macro code line>\n
[ "Writes", "macros", "to", "pys", "file" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/interfaces/pys.py#L297-L306
236,502
manns/pyspread
pyspread/src/interfaces/pys.py
Pys._pys2macros
def _pys2macros(self, line): """Updates macros in code_array""" if self.code_array.dict_grid.macros and \ self.code_array.dict_grid.macros[-1] != "\n": # The last macro line does not end with \n # Therefore, if not new line is inserted, the codeis broken self.code_array.dict_grid.macros += "\n" self.code_array.dict_grid.macros += line.decode("utf-8")
python
def _pys2macros(self, line): """Updates macros in code_array""" if self.code_array.dict_grid.macros and \ self.code_array.dict_grid.macros[-1] != "\n": # The last macro line does not end with \n # Therefore, if not new line is inserted, the codeis broken self.code_array.dict_grid.macros += "\n" self.code_array.dict_grid.macros += line.decode("utf-8")
[ "def", "_pys2macros", "(", "self", ",", "line", ")", ":", "if", "self", ".", "code_array", ".", "dict_grid", ".", "macros", "and", "self", ".", "code_array", ".", "dict_grid", ".", "macros", "[", "-", "1", "]", "!=", "\"\\n\"", ":", "# The last macro line does not end with \\n", "# Therefore, if not new line is inserted, the codeis broken", "self", ".", "code_array", ".", "dict_grid", ".", "macros", "+=", "\"\\n\"", "self", ".", "code_array", ".", "dict_grid", ".", "macros", "+=", "line", ".", "decode", "(", "\"utf-8\"", ")" ]
Updates macros in code_array
[ "Updates", "macros", "in", "code_array" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/interfaces/pys.py#L308-L317
236,503
manns/pyspread
pyspread/src/interfaces/pys.py
Pys._fonts2pys
def _fonts2pys(self): """Writes fonts to pys file""" # Get mapping from fonts to fontfiles system_fonts = font_manager.findSystemFonts() font_name2font_file = {} for sys_font in system_fonts: font_name = font_manager.FontProperties(fname=sys_font).get_name() if font_name in self.fonts_used: font_name2font_file[font_name] = sys_font # Only include fonts that have been used in the attributes for font_name in font_name2font_file: # Serialize font with open(font_name2font_file[font_name]) as fontfile: font_data = fontfile.read() ascii_font_data = base64.b64encode(font_data) # Store font in pys file font_line_list = [font_name, ascii_font_data] self.pys_file.write(u"\t".join(font_line_list) + u"\n")
python
def _fonts2pys(self): """Writes fonts to pys file""" # Get mapping from fonts to fontfiles system_fonts = font_manager.findSystemFonts() font_name2font_file = {} for sys_font in system_fonts: font_name = font_manager.FontProperties(fname=sys_font).get_name() if font_name in self.fonts_used: font_name2font_file[font_name] = sys_font # Only include fonts that have been used in the attributes for font_name in font_name2font_file: # Serialize font with open(font_name2font_file[font_name]) as fontfile: font_data = fontfile.read() ascii_font_data = base64.b64encode(font_data) # Store font in pys file font_line_list = [font_name, ascii_font_data] self.pys_file.write(u"\t".join(font_line_list) + u"\n")
[ "def", "_fonts2pys", "(", "self", ")", ":", "# Get mapping from fonts to fontfiles", "system_fonts", "=", "font_manager", ".", "findSystemFonts", "(", ")", "font_name2font_file", "=", "{", "}", "for", "sys_font", "in", "system_fonts", ":", "font_name", "=", "font_manager", ".", "FontProperties", "(", "fname", "=", "sys_font", ")", ".", "get_name", "(", ")", "if", "font_name", "in", "self", ".", "fonts_used", ":", "font_name2font_file", "[", "font_name", "]", "=", "sys_font", "# Only include fonts that have been used in the attributes", "for", "font_name", "in", "font_name2font_file", ":", "# Serialize font", "with", "open", "(", "font_name2font_file", "[", "font_name", "]", ")", "as", "fontfile", ":", "font_data", "=", "fontfile", ".", "read", "(", ")", "ascii_font_data", "=", "base64", ".", "b64encode", "(", "font_data", ")", "# Store font in pys file", "font_line_list", "=", "[", "font_name", ",", "ascii_font_data", "]", "self", ".", "pys_file", ".", "write", "(", "u\"\\t\"", ".", "join", "(", "font_line_list", ")", "+", "u\"\\n\"", ")" ]
Writes fonts to pys file
[ "Writes", "fonts", "to", "pys", "file" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/interfaces/pys.py#L319-L341
236,504
manns/pyspread
pyspread/src/interfaces/pys.py
Pys._pys2fonts
def _pys2fonts(self, line): """Updates custom font list""" font_name, ascii_font_data = self._split_tidy(line) font_data = base64.b64decode(ascii_font_data) # Get system font names system_fonts = font_manager.findSystemFonts() system_font_names = [] for sys_font in system_fonts: system_font_names.append( font_manager.FontProperties(fname=sys_font).get_name() ) # Use the system font if applicable if font_name not in system_font_names: self.code_array.custom_fonts[font_name] = font_data with open(self.temp_fontdir + os.sep + font_name, "wb") as font_file: font_file.write(font_data) with tempfile.NamedTemporaryFile() as fontsconf_tmpfile: fontsconf_tmpfile_name = fontsconf_tmpfile.name fontsconf_tmpfile.write(self.temp_fontdir) os.environ["FONTCONFIG_FILE"] = fontsconf_tmpfile_name
python
def _pys2fonts(self, line): """Updates custom font list""" font_name, ascii_font_data = self._split_tidy(line) font_data = base64.b64decode(ascii_font_data) # Get system font names system_fonts = font_manager.findSystemFonts() system_font_names = [] for sys_font in system_fonts: system_font_names.append( font_manager.FontProperties(fname=sys_font).get_name() ) # Use the system font if applicable if font_name not in system_font_names: self.code_array.custom_fonts[font_name] = font_data with open(self.temp_fontdir + os.sep + font_name, "wb") as font_file: font_file.write(font_data) with tempfile.NamedTemporaryFile() as fontsconf_tmpfile: fontsconf_tmpfile_name = fontsconf_tmpfile.name fontsconf_tmpfile.write(self.temp_fontdir) os.environ["FONTCONFIG_FILE"] = fontsconf_tmpfile_name
[ "def", "_pys2fonts", "(", "self", ",", "line", ")", ":", "font_name", ",", "ascii_font_data", "=", "self", ".", "_split_tidy", "(", "line", ")", "font_data", "=", "base64", ".", "b64decode", "(", "ascii_font_data", ")", "# Get system font names", "system_fonts", "=", "font_manager", ".", "findSystemFonts", "(", ")", "system_font_names", "=", "[", "]", "for", "sys_font", "in", "system_fonts", ":", "system_font_names", ".", "append", "(", "font_manager", ".", "FontProperties", "(", "fname", "=", "sys_font", ")", ".", "get_name", "(", ")", ")", "# Use the system font if applicable", "if", "font_name", "not", "in", "system_font_names", ":", "self", ".", "code_array", ".", "custom_fonts", "[", "font_name", "]", "=", "font_data", "with", "open", "(", "self", ".", "temp_fontdir", "+", "os", ".", "sep", "+", "font_name", ",", "\"wb\"", ")", "as", "font_file", ":", "font_file", ".", "write", "(", "font_data", ")", "with", "tempfile", ".", "NamedTemporaryFile", "(", ")", "as", "fontsconf_tmpfile", ":", "fontsconf_tmpfile_name", "=", "fontsconf_tmpfile", ".", "name", "fontsconf_tmpfile", ".", "write", "(", "self", ".", "temp_fontdir", ")", "os", ".", "environ", "[", "\"FONTCONFIG_FILE\"", "]", "=", "fontsconf_tmpfile_name" ]
Updates custom font list
[ "Updates", "custom", "font", "list" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/interfaces/pys.py#L343-L369
236,505
manns/pyspread
pyspread/src/interfaces/pys.py
Pys.from_code_array
def from_code_array(self): """Replaces everything in pys_file from code_array""" for key in self._section2writer: self.pys_file.write(key) self._section2writer[key]() try: if self.pys_file.aborted: break except AttributeError: # pys_file is not opened via fileio.BZAopen pass if config["font_save_enabled"]: # Clean up fonts used info self.fonts_used = []
python
def from_code_array(self): """Replaces everything in pys_file from code_array""" for key in self._section2writer: self.pys_file.write(key) self._section2writer[key]() try: if self.pys_file.aborted: break except AttributeError: # pys_file is not opened via fileio.BZAopen pass if config["font_save_enabled"]: # Clean up fonts used info self.fonts_used = []
[ "def", "from_code_array", "(", "self", ")", ":", "for", "key", "in", "self", ".", "_section2writer", ":", "self", ".", "pys_file", ".", "write", "(", "key", ")", "self", ".", "_section2writer", "[", "key", "]", "(", ")", "try", ":", "if", "self", ".", "pys_file", ".", "aborted", ":", "break", "except", "AttributeError", ":", "# pys_file is not opened via fileio.BZAopen", "pass", "if", "config", "[", "\"font_save_enabled\"", "]", ":", "# Clean up fonts used info", "self", ".", "fonts_used", "=", "[", "]" ]
Replaces everything in pys_file from code_array
[ "Replaces", "everything", "in", "pys_file", "from", "code_array" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/interfaces/pys.py#L374-L390
236,506
manns/pyspread
pyspread/src/interfaces/pys.py
Pys.to_code_array
def to_code_array(self): """Replaces everything in code_array from pys_file""" state = None # Check if version section starts with first line first_line = True # Reset pys_file to start to enable multiple calls of this method self.pys_file.seek(0) for line in self.pys_file: if first_line: # If Version section does not start with first line then # the file is invalid. if line == "[Pyspread save file version]\n": first_line = False else: raise ValueError(_("File format unsupported.")) if line in self._section2reader: state = line elif state is not None: self._section2reader[state](line)
python
def to_code_array(self): """Replaces everything in code_array from pys_file""" state = None # Check if version section starts with first line first_line = True # Reset pys_file to start to enable multiple calls of this method self.pys_file.seek(0) for line in self.pys_file: if first_line: # If Version section does not start with first line then # the file is invalid. if line == "[Pyspread save file version]\n": first_line = False else: raise ValueError(_("File format unsupported.")) if line in self._section2reader: state = line elif state is not None: self._section2reader[state](line)
[ "def", "to_code_array", "(", "self", ")", ":", "state", "=", "None", "# Check if version section starts with first line", "first_line", "=", "True", "# Reset pys_file to start to enable multiple calls of this method", "self", ".", "pys_file", ".", "seek", "(", "0", ")", "for", "line", "in", "self", ".", "pys_file", ":", "if", "first_line", ":", "# If Version section does not start with first line then", "# the file is invalid.", "if", "line", "==", "\"[Pyspread save file version]\\n\"", ":", "first_line", "=", "False", "else", ":", "raise", "ValueError", "(", "_", "(", "\"File format unsupported.\"", ")", ")", "if", "line", "in", "self", ".", "_section2reader", ":", "state", "=", "line", "elif", "state", "is", "not", "None", ":", "self", ".", "_section2reader", "[", "state", "]", "(", "line", ")" ]
Replaces everything in code_array from pys_file
[ "Replaces", "everything", "in", "code_array", "from", "pys_file" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/interfaces/pys.py#L392-L416
236,507
manns/pyspread
pyspread/src/gui/_widgets.py
PythonSTC._style
def _style(self): """Set editor style""" self.fold_symbols = 2 """ Fold symbols ------------ The following styles are pre-defined: "arrows" Arrow pointing right for contracted folders, arrow pointing down for expanded "plusminus" Plus for contracted folders, minus for expanded "circletree" Like a flattened tree control using circular headers and curved joins "squaretree" Like a flattened tree control using square headers """ self.faces = { 'times': 'Times', 'mono': 'Courier', 'helv': wx.SystemSettings.GetFont( wx.SYS_DEFAULT_GUI_FONT).GetFaceName(), 'other': 'new century schoolbook', 'size': 10, 'size2': 8, } white = "white" gray = "#404040" # Fold circle tree symbol style from demo.py self.fold_symbol_style = [ (stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_CIRCLEMINUS, white, gray), (stc.STC_MARKNUM_FOLDER, stc.STC_MARK_CIRCLEPLUS, white, gray), (stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_VLINE, white, gray), (stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_LCORNERCURVE, white, gray), (stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_CIRCLEPLUSCONNECTED, white, gray), (stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_CIRCLEMINUSCONNECTED, white, gray), (stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_TCORNERCURVE, white, gray), ] """ Text styles ----------- The lexer defines what each style is used for, we just have to define what each style looks like. The Python style set is adapted from Scintilla sample property files. """ self.text_styles = [ (stc.STC_STYLE_DEFAULT, "face:%(helv)s,size:%(size)d" % self.faces), (stc.STC_STYLE_LINENUMBER, "back:#C0C0C0,face:%(helv)s,size:%(size2)d" % self.faces), (stc.STC_STYLE_CONTROLCHAR, "face:%(other)s" % self.faces), (stc.STC_STYLE_BRACELIGHT, "fore:#FFFFFF,back:#0000FF,bold"), (stc.STC_STYLE_BRACEBAD, "fore:#000000,back:#FF0000,bold"), # Python styles # ------------- # Default (stc.STC_P_DEFAULT, "fore:#000000,face:%(helv)s,size:%(size)d" % self.faces), # Comments (stc.STC_P_COMMENTLINE, "fore:#007F00,face:%(other)s,size:%(size)d" % self.faces), # Number (stc.STC_P_NUMBER, "fore:#007F7F,size:%(size)d" % self.faces), # String (stc.STC_P_STRING, "fore:#7F007F,face:%(helv)s,size:%(size)d" % self.faces), # Single quoted string (stc.STC_P_CHARACTER, "fore:#7F007F,face:%(helv)s,size:%(size)d" % self.faces), # Keyword (stc.STC_P_WORD, "fore:#00007F,bold,size:%(size)d" % self.faces), # Triple quotes (stc.STC_P_TRIPLE, "fore:#7F0000,size:%(size)d" % self.faces), # Triple double quotes (stc.STC_P_TRIPLEDOUBLE, "fore:#7F0000,size:%(size)d" % self.faces), # Class name definition (stc.STC_P_CLASSNAME, "fore:#0000FF,bold,underline,size:%(size)d" % self.faces), # Function or method name definition (stc.STC_P_DEFNAME, "fore:#007F7F,bold,size:%(size)d" % self.faces), # Operators (stc.STC_P_OPERATOR, "bold,size:%(size)d" % self.faces), # Identifiers (stc.STC_P_IDENTIFIER, "fore:#000000,face:%(helv)s,size:%(size)d" % self.faces), # Comment-blocks (stc.STC_P_COMMENTBLOCK, "fore:#7F7F7F,size:%(size)d" % self.faces), # End of line where string is not closed (stc.STC_P_STRINGEOL, "fore:#000000,face:%(mono)s,back:#E0C0E0,eol,size:%(size)d" % self.faces), ]
python
def _style(self): """Set editor style""" self.fold_symbols = 2 """ Fold symbols ------------ The following styles are pre-defined: "arrows" Arrow pointing right for contracted folders, arrow pointing down for expanded "plusminus" Plus for contracted folders, minus for expanded "circletree" Like a flattened tree control using circular headers and curved joins "squaretree" Like a flattened tree control using square headers """ self.faces = { 'times': 'Times', 'mono': 'Courier', 'helv': wx.SystemSettings.GetFont( wx.SYS_DEFAULT_GUI_FONT).GetFaceName(), 'other': 'new century schoolbook', 'size': 10, 'size2': 8, } white = "white" gray = "#404040" # Fold circle tree symbol style from demo.py self.fold_symbol_style = [ (stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_CIRCLEMINUS, white, gray), (stc.STC_MARKNUM_FOLDER, stc.STC_MARK_CIRCLEPLUS, white, gray), (stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_VLINE, white, gray), (stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_LCORNERCURVE, white, gray), (stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_CIRCLEPLUSCONNECTED, white, gray), (stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_CIRCLEMINUSCONNECTED, white, gray), (stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_TCORNERCURVE, white, gray), ] """ Text styles ----------- The lexer defines what each style is used for, we just have to define what each style looks like. The Python style set is adapted from Scintilla sample property files. """ self.text_styles = [ (stc.STC_STYLE_DEFAULT, "face:%(helv)s,size:%(size)d" % self.faces), (stc.STC_STYLE_LINENUMBER, "back:#C0C0C0,face:%(helv)s,size:%(size2)d" % self.faces), (stc.STC_STYLE_CONTROLCHAR, "face:%(other)s" % self.faces), (stc.STC_STYLE_BRACELIGHT, "fore:#FFFFFF,back:#0000FF,bold"), (stc.STC_STYLE_BRACEBAD, "fore:#000000,back:#FF0000,bold"), # Python styles # ------------- # Default (stc.STC_P_DEFAULT, "fore:#000000,face:%(helv)s,size:%(size)d" % self.faces), # Comments (stc.STC_P_COMMENTLINE, "fore:#007F00,face:%(other)s,size:%(size)d" % self.faces), # Number (stc.STC_P_NUMBER, "fore:#007F7F,size:%(size)d" % self.faces), # String (stc.STC_P_STRING, "fore:#7F007F,face:%(helv)s,size:%(size)d" % self.faces), # Single quoted string (stc.STC_P_CHARACTER, "fore:#7F007F,face:%(helv)s,size:%(size)d" % self.faces), # Keyword (stc.STC_P_WORD, "fore:#00007F,bold,size:%(size)d" % self.faces), # Triple quotes (stc.STC_P_TRIPLE, "fore:#7F0000,size:%(size)d" % self.faces), # Triple double quotes (stc.STC_P_TRIPLEDOUBLE, "fore:#7F0000,size:%(size)d" % self.faces), # Class name definition (stc.STC_P_CLASSNAME, "fore:#0000FF,bold,underline,size:%(size)d" % self.faces), # Function or method name definition (stc.STC_P_DEFNAME, "fore:#007F7F,bold,size:%(size)d" % self.faces), # Operators (stc.STC_P_OPERATOR, "bold,size:%(size)d" % self.faces), # Identifiers (stc.STC_P_IDENTIFIER, "fore:#000000,face:%(helv)s,size:%(size)d" % self.faces), # Comment-blocks (stc.STC_P_COMMENTBLOCK, "fore:#7F7F7F,size:%(size)d" % self.faces), # End of line where string is not closed (stc.STC_P_STRINGEOL, "fore:#000000,face:%(mono)s,back:#E0C0E0,eol,size:%(size)d" % self.faces), ]
[ "def", "_style", "(", "self", ")", ":", "self", ".", "fold_symbols", "=", "2", "\"\"\"\n Fold symbols\n ------------\n\n The following styles are pre-defined:\n \"arrows\" Arrow pointing right for contracted folders,\n arrow pointing down for expanded\n \"plusminus\" Plus for contracted folders, minus for expanded\n \"circletree\" Like a flattened tree control using circular headers\n and curved joins\n \"squaretree\" Like a flattened tree control using square headers\n\n \"\"\"", "self", ".", "faces", "=", "{", "'times'", ":", "'Times'", ",", "'mono'", ":", "'Courier'", ",", "'helv'", ":", "wx", ".", "SystemSettings", ".", "GetFont", "(", "wx", ".", "SYS_DEFAULT_GUI_FONT", ")", ".", "GetFaceName", "(", ")", ",", "'other'", ":", "'new century schoolbook'", ",", "'size'", ":", "10", ",", "'size2'", ":", "8", ",", "}", "white", "=", "\"white\"", "gray", "=", "\"#404040\"", "# Fold circle tree symbol style from demo.py", "self", ".", "fold_symbol_style", "=", "[", "(", "stc", ".", "STC_MARKNUM_FOLDEROPEN", ",", "stc", ".", "STC_MARK_CIRCLEMINUS", ",", "white", ",", "gray", ")", ",", "(", "stc", ".", "STC_MARKNUM_FOLDER", ",", "stc", ".", "STC_MARK_CIRCLEPLUS", ",", "white", ",", "gray", ")", ",", "(", "stc", ".", "STC_MARKNUM_FOLDERSUB", ",", "stc", ".", "STC_MARK_VLINE", ",", "white", ",", "gray", ")", ",", "(", "stc", ".", "STC_MARKNUM_FOLDERTAIL", ",", "stc", ".", "STC_MARK_LCORNERCURVE", ",", "white", ",", "gray", ")", ",", "(", "stc", ".", "STC_MARKNUM_FOLDEREND", ",", "stc", ".", "STC_MARK_CIRCLEPLUSCONNECTED", ",", "white", ",", "gray", ")", ",", "(", "stc", ".", "STC_MARKNUM_FOLDEROPENMID", ",", "stc", ".", "STC_MARK_CIRCLEMINUSCONNECTED", ",", "white", ",", "gray", ")", ",", "(", "stc", ".", "STC_MARKNUM_FOLDERMIDTAIL", ",", "stc", ".", "STC_MARK_TCORNERCURVE", ",", "white", ",", "gray", ")", ",", "]", "\"\"\"\n Text styles\n -----------\n\n The lexer defines what each style is used for, we just have to define\n what each style looks like. The Python style set is adapted from\n Scintilla sample property files.\n\n \"\"\"", "self", ".", "text_styles", "=", "[", "(", "stc", ".", "STC_STYLE_DEFAULT", ",", "\"face:%(helv)s,size:%(size)d\"", "%", "self", ".", "faces", ")", ",", "(", "stc", ".", "STC_STYLE_LINENUMBER", ",", "\"back:#C0C0C0,face:%(helv)s,size:%(size2)d\"", "%", "self", ".", "faces", ")", ",", "(", "stc", ".", "STC_STYLE_CONTROLCHAR", ",", "\"face:%(other)s\"", "%", "self", ".", "faces", ")", ",", "(", "stc", ".", "STC_STYLE_BRACELIGHT", ",", "\"fore:#FFFFFF,back:#0000FF,bold\"", ")", ",", "(", "stc", ".", "STC_STYLE_BRACEBAD", ",", "\"fore:#000000,back:#FF0000,bold\"", ")", ",", "# Python styles", "# -------------", "# Default", "(", "stc", ".", "STC_P_DEFAULT", ",", "\"fore:#000000,face:%(helv)s,size:%(size)d\"", "%", "self", ".", "faces", ")", ",", "# Comments", "(", "stc", ".", "STC_P_COMMENTLINE", ",", "\"fore:#007F00,face:%(other)s,size:%(size)d\"", "%", "self", ".", "faces", ")", ",", "# Number", "(", "stc", ".", "STC_P_NUMBER", ",", "\"fore:#007F7F,size:%(size)d\"", "%", "self", ".", "faces", ")", ",", "# String", "(", "stc", ".", "STC_P_STRING", ",", "\"fore:#7F007F,face:%(helv)s,size:%(size)d\"", "%", "self", ".", "faces", ")", ",", "# Single quoted string", "(", "stc", ".", "STC_P_CHARACTER", ",", "\"fore:#7F007F,face:%(helv)s,size:%(size)d\"", "%", "self", ".", "faces", ")", ",", "# Keyword", "(", "stc", ".", "STC_P_WORD", ",", "\"fore:#00007F,bold,size:%(size)d\"", "%", "self", ".", "faces", ")", ",", "# Triple quotes", "(", "stc", ".", "STC_P_TRIPLE", ",", "\"fore:#7F0000,size:%(size)d\"", "%", "self", ".", "faces", ")", ",", "# Triple double quotes", "(", "stc", ".", "STC_P_TRIPLEDOUBLE", ",", "\"fore:#7F0000,size:%(size)d\"", "%", "self", ".", "faces", ")", ",", "# Class name definition", "(", "stc", ".", "STC_P_CLASSNAME", ",", "\"fore:#0000FF,bold,underline,size:%(size)d\"", "%", "self", ".", "faces", ")", ",", "# Function or method name definition", "(", "stc", ".", "STC_P_DEFNAME", ",", "\"fore:#007F7F,bold,size:%(size)d\"", "%", "self", ".", "faces", ")", ",", "# Operators", "(", "stc", ".", "STC_P_OPERATOR", ",", "\"bold,size:%(size)d\"", "%", "self", ".", "faces", ")", ",", "# Identifiers", "(", "stc", ".", "STC_P_IDENTIFIER", ",", "\"fore:#000000,face:%(helv)s,size:%(size)d\"", "%", "self", ".", "faces", ")", ",", "# Comment-blocks", "(", "stc", ".", "STC_P_COMMENTBLOCK", ",", "\"fore:#7F7F7F,size:%(size)d\"", "%", "self", ".", "faces", ")", ",", "# End of line where string is not closed", "(", "stc", ".", "STC_P_STRINGEOL", ",", "\"fore:#000000,face:%(mono)s,back:#E0C0E0,eol,size:%(size)d\"", "%", "self", ".", "faces", ")", ",", "]" ]
Set editor style
[ "Set", "editor", "style" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L140-L270
236,508
manns/pyspread
pyspread/src/gui/_widgets.py
PythonSTC.OnUpdateUI
def OnUpdateUI(self, evt): """Syntax highlighting while editing""" # check for matching braces brace_at_caret = -1 brace_opposite = -1 char_before = None caret_pos = self.GetCurrentPos() if caret_pos > 0: char_before = self.GetCharAt(caret_pos - 1) style_before = self.GetStyleAt(caret_pos - 1) # check before if char_before and chr(char_before) in "[]{}()" and \ style_before == stc.STC_P_OPERATOR: brace_at_caret = caret_pos - 1 # check after if brace_at_caret < 0: char_after = self.GetCharAt(caret_pos) style_after = self.GetStyleAt(caret_pos) if char_after and chr(char_after) in "[]{}()" and \ style_after == stc.STC_P_OPERATOR: brace_at_caret = caret_pos if brace_at_caret >= 0: brace_opposite = self.BraceMatch(brace_at_caret) if brace_at_caret != -1 and brace_opposite == -1: self.BraceBadLight(brace_at_caret) else: self.BraceHighlight(brace_at_caret, brace_opposite)
python
def OnUpdateUI(self, evt): """Syntax highlighting while editing""" # check for matching braces brace_at_caret = -1 brace_opposite = -1 char_before = None caret_pos = self.GetCurrentPos() if caret_pos > 0: char_before = self.GetCharAt(caret_pos - 1) style_before = self.GetStyleAt(caret_pos - 1) # check before if char_before and chr(char_before) in "[]{}()" and \ style_before == stc.STC_P_OPERATOR: brace_at_caret = caret_pos - 1 # check after if brace_at_caret < 0: char_after = self.GetCharAt(caret_pos) style_after = self.GetStyleAt(caret_pos) if char_after and chr(char_after) in "[]{}()" and \ style_after == stc.STC_P_OPERATOR: brace_at_caret = caret_pos if brace_at_caret >= 0: brace_opposite = self.BraceMatch(brace_at_caret) if brace_at_caret != -1 and brace_opposite == -1: self.BraceBadLight(brace_at_caret) else: self.BraceHighlight(brace_at_caret, brace_opposite)
[ "def", "OnUpdateUI", "(", "self", ",", "evt", ")", ":", "# check for matching braces", "brace_at_caret", "=", "-", "1", "brace_opposite", "=", "-", "1", "char_before", "=", "None", "caret_pos", "=", "self", ".", "GetCurrentPos", "(", ")", "if", "caret_pos", ">", "0", ":", "char_before", "=", "self", ".", "GetCharAt", "(", "caret_pos", "-", "1", ")", "style_before", "=", "self", ".", "GetStyleAt", "(", "caret_pos", "-", "1", ")", "# check before", "if", "char_before", "and", "chr", "(", "char_before", ")", "in", "\"[]{}()\"", "and", "style_before", "==", "stc", ".", "STC_P_OPERATOR", ":", "brace_at_caret", "=", "caret_pos", "-", "1", "# check after", "if", "brace_at_caret", "<", "0", ":", "char_after", "=", "self", ".", "GetCharAt", "(", "caret_pos", ")", "style_after", "=", "self", ".", "GetStyleAt", "(", "caret_pos", ")", "if", "char_after", "and", "chr", "(", "char_after", ")", "in", "\"[]{}()\"", "and", "style_after", "==", "stc", ".", "STC_P_OPERATOR", ":", "brace_at_caret", "=", "caret_pos", "if", "brace_at_caret", ">=", "0", ":", "brace_opposite", "=", "self", ".", "BraceMatch", "(", "brace_at_caret", ")", "if", "brace_at_caret", "!=", "-", "1", "and", "brace_opposite", "==", "-", "1", ":", "self", ".", "BraceBadLight", "(", "brace_at_caret", ")", "else", ":", "self", ".", "BraceHighlight", "(", "brace_at_caret", ",", "brace_opposite", ")" ]
Syntax highlighting while editing
[ "Syntax", "highlighting", "while", "editing" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L272-L305
236,509
manns/pyspread
pyspread/src/gui/_widgets.py
PythonSTC.OnMarginClick
def OnMarginClick(self, evt): """When clicked, old and unfold as needed""" if evt.GetMargin() == 2: if evt.GetShift() and evt.GetControl(): self.fold_all() else: line_clicked = self.LineFromPosition(evt.GetPosition()) if self.GetFoldLevel(line_clicked) & \ stc.STC_FOLDLEVELHEADERFLAG: if evt.GetShift(): self.SetFoldExpanded(line_clicked, True) self.expand(line_clicked, True, True, 1) elif evt.GetControl(): if self.GetFoldExpanded(line_clicked): self.SetFoldExpanded(line_clicked, False) self.expand(line_clicked, False, True, 0) else: self.SetFoldExpanded(line_clicked, True) self.expand(line_clicked, True, True, 100) else: self.ToggleFold(line_clicked)
python
def OnMarginClick(self, evt): """When clicked, old and unfold as needed""" if evt.GetMargin() == 2: if evt.GetShift() and evt.GetControl(): self.fold_all() else: line_clicked = self.LineFromPosition(evt.GetPosition()) if self.GetFoldLevel(line_clicked) & \ stc.STC_FOLDLEVELHEADERFLAG: if evt.GetShift(): self.SetFoldExpanded(line_clicked, True) self.expand(line_clicked, True, True, 1) elif evt.GetControl(): if self.GetFoldExpanded(line_clicked): self.SetFoldExpanded(line_clicked, False) self.expand(line_clicked, False, True, 0) else: self.SetFoldExpanded(line_clicked, True) self.expand(line_clicked, True, True, 100) else: self.ToggleFold(line_clicked)
[ "def", "OnMarginClick", "(", "self", ",", "evt", ")", ":", "if", "evt", ".", "GetMargin", "(", ")", "==", "2", ":", "if", "evt", ".", "GetShift", "(", ")", "and", "evt", ".", "GetControl", "(", ")", ":", "self", ".", "fold_all", "(", ")", "else", ":", "line_clicked", "=", "self", ".", "LineFromPosition", "(", "evt", ".", "GetPosition", "(", ")", ")", "if", "self", ".", "GetFoldLevel", "(", "line_clicked", ")", "&", "stc", ".", "STC_FOLDLEVELHEADERFLAG", ":", "if", "evt", ".", "GetShift", "(", ")", ":", "self", ".", "SetFoldExpanded", "(", "line_clicked", ",", "True", ")", "self", ".", "expand", "(", "line_clicked", ",", "True", ",", "True", ",", "1", ")", "elif", "evt", ".", "GetControl", "(", ")", ":", "if", "self", ".", "GetFoldExpanded", "(", "line_clicked", ")", ":", "self", ".", "SetFoldExpanded", "(", "line_clicked", ",", "False", ")", "self", ".", "expand", "(", "line_clicked", ",", "False", ",", "True", ",", "0", ")", "else", ":", "self", ".", "SetFoldExpanded", "(", "line_clicked", ",", "True", ")", "self", ".", "expand", "(", "line_clicked", ",", "True", ",", "True", ",", "100", ")", "else", ":", "self", ".", "ToggleFold", "(", "line_clicked", ")" ]
When clicked, old and unfold as needed
[ "When", "clicked", "old", "and", "unfold", "as", "needed" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L307-L329
236,510
manns/pyspread
pyspread/src/gui/_widgets.py
PythonSTC.expand
def expand(self, line, do_expand, force=False, vislevels=0, level=-1): """Multi-purpose expand method from original STC class""" lastchild = self.GetLastChild(line, level) line += 1 while line <= lastchild: if force: if vislevels > 0: self.ShowLines(line, line) else: self.HideLines(line, line) elif do_expand: self.ShowLines(line, line) if level == -1: level = self.GetFoldLevel(line) if level & stc.STC_FOLDLEVELHEADERFLAG: if force: self.SetFoldExpanded(line, vislevels - 1) line = self.expand(line, do_expand, force, vislevels - 1) else: expandsub = do_expand and self.GetFoldExpanded(line) line = self.expand(line, expandsub, force, vislevels - 1) else: line += 1 return line
python
def expand(self, line, do_expand, force=False, vislevels=0, level=-1): """Multi-purpose expand method from original STC class""" lastchild = self.GetLastChild(line, level) line += 1 while line <= lastchild: if force: if vislevels > 0: self.ShowLines(line, line) else: self.HideLines(line, line) elif do_expand: self.ShowLines(line, line) if level == -1: level = self.GetFoldLevel(line) if level & stc.STC_FOLDLEVELHEADERFLAG: if force: self.SetFoldExpanded(line, vislevels - 1) line = self.expand(line, do_expand, force, vislevels - 1) else: expandsub = do_expand and self.GetFoldExpanded(line) line = self.expand(line, expandsub, force, vislevels - 1) else: line += 1 return line
[ "def", "expand", "(", "self", ",", "line", ",", "do_expand", ",", "force", "=", "False", ",", "vislevels", "=", "0", ",", "level", "=", "-", "1", ")", ":", "lastchild", "=", "self", ".", "GetLastChild", "(", "line", ",", "level", ")", "line", "+=", "1", "while", "line", "<=", "lastchild", ":", "if", "force", ":", "if", "vislevels", ">", "0", ":", "self", ".", "ShowLines", "(", "line", ",", "line", ")", "else", ":", "self", ".", "HideLines", "(", "line", ",", "line", ")", "elif", "do_expand", ":", "self", ".", "ShowLines", "(", "line", ",", "line", ")", "if", "level", "==", "-", "1", ":", "level", "=", "self", ".", "GetFoldLevel", "(", "line", ")", "if", "level", "&", "stc", ".", "STC_FOLDLEVELHEADERFLAG", ":", "if", "force", ":", "self", ".", "SetFoldExpanded", "(", "line", ",", "vislevels", "-", "1", ")", "line", "=", "self", ".", "expand", "(", "line", ",", "do_expand", ",", "force", ",", "vislevels", "-", "1", ")", "else", ":", "expandsub", "=", "do_expand", "and", "self", ".", "GetFoldExpanded", "(", "line", ")", "line", "=", "self", ".", "expand", "(", "line", ",", "expandsub", ",", "force", ",", "vislevels", "-", "1", ")", "else", ":", "line", "+=", "1", "return", "line" ]
Multi-purpose expand method from original STC class
[ "Multi", "-", "purpose", "expand", "method", "from", "original", "STC", "class" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L363-L392
236,511
manns/pyspread
pyspread/src/gui/_widgets.py
ImageComboBox.OnDrawBackground
def OnDrawBackground(self, dc, rect, item, flags): """Called for drawing the background area of each item Overridden from OwnerDrawnComboBox """ # If the item is selected, or its item is even, # or if we are painting the combo control itself # then use the default rendering. if (item & 1 == 0 or flags & (wx.combo.ODCB_PAINTING_CONTROL | wx.combo.ODCB_PAINTING_SELECTED)): try: wx.combo.OwnerDrawnComboBox.OnDrawBackground(self, dc, rect, item, flags) finally: return # Otherwise, draw every other background with # different color. bg_color = get_color(config["label_color"]) dc.SetBrush(wx.Brush(bg_color)) dc.SetPen(wx.Pen(bg_color)) dc.DrawRectangleRect(rect)
python
def OnDrawBackground(self, dc, rect, item, flags): """Called for drawing the background area of each item Overridden from OwnerDrawnComboBox """ # If the item is selected, or its item is even, # or if we are painting the combo control itself # then use the default rendering. if (item & 1 == 0 or flags & (wx.combo.ODCB_PAINTING_CONTROL | wx.combo.ODCB_PAINTING_SELECTED)): try: wx.combo.OwnerDrawnComboBox.OnDrawBackground(self, dc, rect, item, flags) finally: return # Otherwise, draw every other background with # different color. bg_color = get_color(config["label_color"]) dc.SetBrush(wx.Brush(bg_color)) dc.SetPen(wx.Pen(bg_color)) dc.DrawRectangleRect(rect)
[ "def", "OnDrawBackground", "(", "self", ",", "dc", ",", "rect", ",", "item", ",", "flags", ")", ":", "# If the item is selected, or its item is even,", "# or if we are painting the combo control itself", "# then use the default rendering.", "if", "(", "item", "&", "1", "==", "0", "or", "flags", "&", "(", "wx", ".", "combo", ".", "ODCB_PAINTING_CONTROL", "|", "wx", ".", "combo", ".", "ODCB_PAINTING_SELECTED", ")", ")", ":", "try", ":", "wx", ".", "combo", ".", "OwnerDrawnComboBox", ".", "OnDrawBackground", "(", "self", ",", "dc", ",", "rect", ",", "item", ",", "flags", ")", "finally", ":", "return", "# Otherwise, draw every other background with", "# different color.", "bg_color", "=", "get_color", "(", "config", "[", "\"label_color\"", "]", ")", "dc", ".", "SetBrush", "(", "wx", ".", "Brush", "(", "bg_color", ")", ")", "dc", ".", "SetPen", "(", "wx", ".", "Pen", "(", "bg_color", ")", ")", "dc", ".", "DrawRectangleRect", "(", "rect", ")" ]
Called for drawing the background area of each item Overridden from OwnerDrawnComboBox
[ "Called", "for", "drawing", "the", "background", "area", "of", "each", "item" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L404-L429
236,512
manns/pyspread
pyspread/src/gui/_widgets.py
MatplotlibStyleChoice.get_style_code
def get_style_code(self, label): """Returns code for given label string Inverse of get_code Parameters ---------- label: String \tLlabel string, field 0 of style tuple """ for style in self.styles: if style[0] == label: return style[1] msg = _("Label {label} is invalid.").format(label=label) raise ValueError(msg)
python
def get_style_code(self, label): """Returns code for given label string Inverse of get_code Parameters ---------- label: String \tLlabel string, field 0 of style tuple """ for style in self.styles: if style[0] == label: return style[1] msg = _("Label {label} is invalid.").format(label=label) raise ValueError(msg)
[ "def", "get_style_code", "(", "self", ",", "label", ")", ":", "for", "style", "in", "self", ".", "styles", ":", "if", "style", "[", "0", "]", "==", "label", ":", "return", "style", "[", "1", "]", "msg", "=", "_", "(", "\"Label {label} is invalid.\"", ")", ".", "format", "(", "label", "=", "label", ")", "raise", "ValueError", "(", "msg", ")" ]
Returns code for given label string Inverse of get_code Parameters ---------- label: String \tLlabel string, field 0 of style tuple
[ "Returns", "code", "for", "given", "label", "string" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L471-L488
236,513
manns/pyspread
pyspread/src/gui/_widgets.py
MatplotlibStyleChoice.get_label
def get_label(self, code): """Returns string label for given code string Inverse of get_code Parameters ---------- code: String \tCode string, field 1 of style tuple """ for style in self.styles: if style[1] == code: return style[0] msg = _("Code {code} is invalid.").format(code=code) raise ValueError(msg)
python
def get_label(self, code): """Returns string label for given code string Inverse of get_code Parameters ---------- code: String \tCode string, field 1 of style tuple """ for style in self.styles: if style[1] == code: return style[0] msg = _("Code {code} is invalid.").format(code=code) raise ValueError(msg)
[ "def", "get_label", "(", "self", ",", "code", ")", ":", "for", "style", "in", "self", ".", "styles", ":", "if", "style", "[", "1", "]", "==", "code", ":", "return", "style", "[", "0", "]", "msg", "=", "_", "(", "\"Code {code} is invalid.\"", ")", ".", "format", "(", "code", "=", "code", ")", "raise", "ValueError", "(", "msg", ")" ]
Returns string label for given code string Inverse of get_code Parameters ---------- code: String \tCode string, field 1 of style tuple
[ "Returns", "string", "label", "for", "given", "code", "string" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L490-L507
236,514
manns/pyspread
pyspread/src/gui/_widgets.py
BitmapToggleButton.toggle
def toggle(self, event): """Toggles state to next bitmap""" if self.state < len(self.bitmap_list) - 1: self.state += 1 else: self.state = 0 self.SetBitmapLabel(self.bitmap_list[self.state]) try: event.Skip() except AttributeError: pass """For compatibility with toggle buttons""" setattr(self, "GetToolState", lambda x: self.state)
python
def toggle(self, event): """Toggles state to next bitmap""" if self.state < len(self.bitmap_list) - 1: self.state += 1 else: self.state = 0 self.SetBitmapLabel(self.bitmap_list[self.state]) try: event.Skip() except AttributeError: pass """For compatibility with toggle buttons""" setattr(self, "GetToolState", lambda x: self.state)
[ "def", "toggle", "(", "self", ",", "event", ")", ":", "if", "self", ".", "state", "<", "len", "(", "self", ".", "bitmap_list", ")", "-", "1", ":", "self", ".", "state", "+=", "1", "else", ":", "self", ".", "state", "=", "0", "self", ".", "SetBitmapLabel", "(", "self", ".", "bitmap_list", "[", "self", ".", "state", "]", ")", "try", ":", "event", ".", "Skip", "(", ")", "except", "AttributeError", ":", "pass", "\"\"\"For compatibility with toggle buttons\"\"\"", "setattr", "(", "self", ",", "\"GetToolState\"", ",", "lambda", "x", ":", "self", ".", "state", ")" ]
Toggles state to next bitmap
[ "Toggles", "state", "to", "next", "bitmap" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L686-L702
236,515
manns/pyspread
pyspread/src/gui/_widgets.py
EntryLinePanel.OnToggle
def OnToggle(self, event): """Toggle button event handler""" if self.selection_toggle_button.GetValue(): self.entry_line.last_selection = self.entry_line.GetSelection() self.entry_line.last_selection_string = \ self.entry_line.GetStringSelection() self.entry_line.last_table = self.main_window.grid.current_table self.entry_line.Disable() post_command_event(self, self.EnterSelectionModeMsg) else: self.entry_line.Enable() post_command_event(self, self.GridActionTableSwitchMsg, newtable=self.entry_line.last_table) post_command_event(self, self.ExitSelectionModeMsg)
python
def OnToggle(self, event): """Toggle button event handler""" if self.selection_toggle_button.GetValue(): self.entry_line.last_selection = self.entry_line.GetSelection() self.entry_line.last_selection_string = \ self.entry_line.GetStringSelection() self.entry_line.last_table = self.main_window.grid.current_table self.entry_line.Disable() post_command_event(self, self.EnterSelectionModeMsg) else: self.entry_line.Enable() post_command_event(self, self.GridActionTableSwitchMsg, newtable=self.entry_line.last_table) post_command_event(self, self.ExitSelectionModeMsg)
[ "def", "OnToggle", "(", "self", ",", "event", ")", ":", "if", "self", ".", "selection_toggle_button", ".", "GetValue", "(", ")", ":", "self", ".", "entry_line", ".", "last_selection", "=", "self", ".", "entry_line", ".", "GetSelection", "(", ")", "self", ".", "entry_line", ".", "last_selection_string", "=", "self", ".", "entry_line", ".", "GetStringSelection", "(", ")", "self", ".", "entry_line", ".", "last_table", "=", "self", ".", "main_window", ".", "grid", ".", "current_table", "self", ".", "entry_line", ".", "Disable", "(", ")", "post_command_event", "(", "self", ",", "self", ".", "EnterSelectionModeMsg", ")", "else", ":", "self", ".", "entry_line", ".", "Enable", "(", ")", "post_command_event", "(", "self", ",", "self", ".", "GridActionTableSwitchMsg", ",", "newtable", "=", "self", ".", "entry_line", ".", "last_table", ")", "post_command_event", "(", "self", ",", "self", ".", "ExitSelectionModeMsg", ")" ]
Toggle button event handler
[ "Toggle", "button", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L792-L807
236,516
manns/pyspread
pyspread/src/gui/_widgets.py
EntryLine.OnContentChange
def OnContentChange(self, event): """Event handler for updating the content""" self.ignore_changes = True self.SetValue(u"" if event.text is None else event.text) self.ignore_changes = False event.Skip()
python
def OnContentChange(self, event): """Event handler for updating the content""" self.ignore_changes = True self.SetValue(u"" if event.text is None else event.text) self.ignore_changes = False event.Skip()
[ "def", "OnContentChange", "(", "self", ",", "event", ")", ":", "self", ".", "ignore_changes", "=", "True", "self", ".", "SetValue", "(", "u\"\"", "if", "event", ".", "text", "is", "None", "else", "event", ".", "text", ")", "self", ".", "ignore_changes", "=", "False", "event", ".", "Skip", "(", ")" ]
Event handler for updating the content
[ "Event", "handler", "for", "updating", "the", "content" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L854-L862
236,517
manns/pyspread
pyspread/src/gui/_widgets.py
EntryLine.OnGridSelection
def OnGridSelection(self, event): """Event handler for grid selection in selection mode adds text""" current_table = copy(self.main_window.grid.current_table) post_command_event(self, self.GridActionTableSwitchMsg, newtable=self.last_table) if is_gtk(): try: wx.Yield() except: pass sel_start, sel_stop = self.last_selection shape = self.main_window.grid.code_array.shape selection_string = event.selection.get_access_string(shape, current_table) self.Replace(sel_start, sel_stop, selection_string) self.last_selection = sel_start, sel_start + len(selection_string) post_command_event(self, self.GridActionTableSwitchMsg, newtable=current_table)
python
def OnGridSelection(self, event): """Event handler for grid selection in selection mode adds text""" current_table = copy(self.main_window.grid.current_table) post_command_event(self, self.GridActionTableSwitchMsg, newtable=self.last_table) if is_gtk(): try: wx.Yield() except: pass sel_start, sel_stop = self.last_selection shape = self.main_window.grid.code_array.shape selection_string = event.selection.get_access_string(shape, current_table) self.Replace(sel_start, sel_stop, selection_string) self.last_selection = sel_start, sel_start + len(selection_string) post_command_event(self, self.GridActionTableSwitchMsg, newtable=current_table)
[ "def", "OnGridSelection", "(", "self", ",", "event", ")", ":", "current_table", "=", "copy", "(", "self", ".", "main_window", ".", "grid", ".", "current_table", ")", "post_command_event", "(", "self", ",", "self", ".", "GridActionTableSwitchMsg", ",", "newtable", "=", "self", ".", "last_table", ")", "if", "is_gtk", "(", ")", ":", "try", ":", "wx", ".", "Yield", "(", ")", "except", ":", "pass", "sel_start", ",", "sel_stop", "=", "self", ".", "last_selection", "shape", "=", "self", ".", "main_window", ".", "grid", ".", "code_array", ".", "shape", "selection_string", "=", "event", ".", "selection", ".", "get_access_string", "(", "shape", ",", "current_table", ")", "self", ".", "Replace", "(", "sel_start", ",", "sel_stop", ",", "selection_string", ")", "self", ".", "last_selection", "=", "sel_start", ",", "sel_start", "+", "len", "(", "selection_string", ")", "post_command_event", "(", "self", ",", "self", ".", "GridActionTableSwitchMsg", ",", "newtable", "=", "current_table", ")" ]
Event handler for grid selection in selection mode adds text
[ "Event", "handler", "for", "grid", "selection", "in", "selection", "mode", "adds", "text" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L864-L887
236,518
manns/pyspread
pyspread/src/gui/_widgets.py
EntryLine.OnText
def OnText(self, event): """Text event method evals the cell and updates the grid""" if not self.ignore_changes: post_command_event(self, self.CodeEntryMsg, code=event.GetString()) self.main_window.grid.grid_renderer.cell_cache.clear() event.Skip()
python
def OnText(self, event): """Text event method evals the cell and updates the grid""" if not self.ignore_changes: post_command_event(self, self.CodeEntryMsg, code=event.GetString()) self.main_window.grid.grid_renderer.cell_cache.clear() event.Skip()
[ "def", "OnText", "(", "self", ",", "event", ")", ":", "if", "not", "self", ".", "ignore_changes", ":", "post_command_event", "(", "self", ",", "self", ".", "CodeEntryMsg", ",", "code", "=", "event", ".", "GetString", "(", ")", ")", "self", ".", "main_window", ".", "grid", ".", "grid_renderer", ".", "cell_cache", ".", "clear", "(", ")", "event", ".", "Skip", "(", ")" ]
Text event method evals the cell and updates the grid
[ "Text", "event", "method", "evals", "the", "cell", "and", "updates", "the", "grid" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L894-L902
236,519
manns/pyspread
pyspread/src/gui/_widgets.py
EntryLine.OnChar
def OnChar(self, event): """Key event method * Forces grid update on <Enter> key * Handles insertion of cell access code """ if not self.ignore_changes: # Handle special keys keycode = event.GetKeyCode() if keycode == 13 and not self.GetStringSelection(): # <Enter> pressed and no selection --> Focus on grid self.main_window.grid.SetFocus() # Ignore <Ctrl> + <Enter> and Quote content if event.ControlDown(): self.SetValue(quote(self.GetValue())) # Do not process <Enter> return elif keycode == 13 and self.GetStringSelection(): # <Enter> pressed and selection # --> Place cursor at end of selection and clear selection selection_start, selection_stop = self.Selection self.SetSelection(selection_stop, selection_stop) # Do not process <Enter> return elif keycode == 9 and jedi is None: # Ignore the <Tab> return elif keycode == 9 and jedi is not None: # If auto completion library jedi is present # <Tab> pressed --> show docstring tooltip tiptext = "" code = "".join(self.GetValue().split("\n")) position = self.GetInsertionPoint() # Get the docstring code_array = self.parent.parent.parent.grid.code_array env = code_array.get_globals() try: script = jedi.Interpreter(code, [env], line=1, column=position) except ValueError: # Jedi has thrown an error event.Skip() return completions = script.completions() completes = [completion.complete for completion in completions] complete = common_start(completes) if complete and \ not self.GetSelection()[1] > self.GetSelection()[0]: # There is a non-empty completion insertion_point = self.GetInsertionPoint() self.write(complete) if len(completes) > 1: self.SetSelection(insertion_point, insertion_point + len(complete)) words = [completion.name for completion in completions] docs = [] for completion in completions: doc = completion.docstring(fast=False) if not doc and code: # Is the completion part of a module? code_segment = \ code[:position+1].split()[-1] module_name = code_segment.rsplit(".", 1)[0] try: module = env[module_name] doc = getattr(module, completion.name).__doc__ except (KeyError, AttributeError): pass if not doc: name = completion.name try: # Is the completion a builtin? doc = getattr(__builtin__, name).__doc__ except AttributeError: pass docs.append(doc) try: dws = [": ".join([w, d]) for w, d in zip(words, docs)] tiptext = "\n \n".join(dws) except TypeError: pass # Cut tiptext length because Tooltip fails for long strings self.SetToolTip(wx.ToolTip(tiptext[:MAX_TOOLTIP_LENGTH])) # Do not process <Tab> return event.Skip()
python
def OnChar(self, event): """Key event method * Forces grid update on <Enter> key * Handles insertion of cell access code """ if not self.ignore_changes: # Handle special keys keycode = event.GetKeyCode() if keycode == 13 and not self.GetStringSelection(): # <Enter> pressed and no selection --> Focus on grid self.main_window.grid.SetFocus() # Ignore <Ctrl> + <Enter> and Quote content if event.ControlDown(): self.SetValue(quote(self.GetValue())) # Do not process <Enter> return elif keycode == 13 and self.GetStringSelection(): # <Enter> pressed and selection # --> Place cursor at end of selection and clear selection selection_start, selection_stop = self.Selection self.SetSelection(selection_stop, selection_stop) # Do not process <Enter> return elif keycode == 9 and jedi is None: # Ignore the <Tab> return elif keycode == 9 and jedi is not None: # If auto completion library jedi is present # <Tab> pressed --> show docstring tooltip tiptext = "" code = "".join(self.GetValue().split("\n")) position = self.GetInsertionPoint() # Get the docstring code_array = self.parent.parent.parent.grid.code_array env = code_array.get_globals() try: script = jedi.Interpreter(code, [env], line=1, column=position) except ValueError: # Jedi has thrown an error event.Skip() return completions = script.completions() completes = [completion.complete for completion in completions] complete = common_start(completes) if complete and \ not self.GetSelection()[1] > self.GetSelection()[0]: # There is a non-empty completion insertion_point = self.GetInsertionPoint() self.write(complete) if len(completes) > 1: self.SetSelection(insertion_point, insertion_point + len(complete)) words = [completion.name for completion in completions] docs = [] for completion in completions: doc = completion.docstring(fast=False) if not doc and code: # Is the completion part of a module? code_segment = \ code[:position+1].split()[-1] module_name = code_segment.rsplit(".", 1)[0] try: module = env[module_name] doc = getattr(module, completion.name).__doc__ except (KeyError, AttributeError): pass if not doc: name = completion.name try: # Is the completion a builtin? doc = getattr(__builtin__, name).__doc__ except AttributeError: pass docs.append(doc) try: dws = [": ".join([w, d]) for w, d in zip(words, docs)] tiptext = "\n \n".join(dws) except TypeError: pass # Cut tiptext length because Tooltip fails for long strings self.SetToolTip(wx.ToolTip(tiptext[:MAX_TOOLTIP_LENGTH])) # Do not process <Tab> return event.Skip()
[ "def", "OnChar", "(", "self", ",", "event", ")", ":", "if", "not", "self", ".", "ignore_changes", ":", "# Handle special keys", "keycode", "=", "event", ".", "GetKeyCode", "(", ")", "if", "keycode", "==", "13", "and", "not", "self", ".", "GetStringSelection", "(", ")", ":", "# <Enter> pressed and no selection --> Focus on grid", "self", ".", "main_window", ".", "grid", ".", "SetFocus", "(", ")", "# Ignore <Ctrl> + <Enter> and Quote content", "if", "event", ".", "ControlDown", "(", ")", ":", "self", ".", "SetValue", "(", "quote", "(", "self", ".", "GetValue", "(", ")", ")", ")", "# Do not process <Enter>", "return", "elif", "keycode", "==", "13", "and", "self", ".", "GetStringSelection", "(", ")", ":", "# <Enter> pressed and selection", "# --> Place cursor at end of selection and clear selection", "selection_start", ",", "selection_stop", "=", "self", ".", "Selection", "self", ".", "SetSelection", "(", "selection_stop", ",", "selection_stop", ")", "# Do not process <Enter>", "return", "elif", "keycode", "==", "9", "and", "jedi", "is", "None", ":", "# Ignore the <Tab>", "return", "elif", "keycode", "==", "9", "and", "jedi", "is", "not", "None", ":", "# If auto completion library jedi is present", "# <Tab> pressed --> show docstring tooltip", "tiptext", "=", "\"\"", "code", "=", "\"\"", ".", "join", "(", "self", ".", "GetValue", "(", ")", ".", "split", "(", "\"\\n\"", ")", ")", "position", "=", "self", ".", "GetInsertionPoint", "(", ")", "# Get the docstring", "code_array", "=", "self", ".", "parent", ".", "parent", ".", "parent", ".", "grid", ".", "code_array", "env", "=", "code_array", ".", "get_globals", "(", ")", "try", ":", "script", "=", "jedi", ".", "Interpreter", "(", "code", ",", "[", "env", "]", ",", "line", "=", "1", ",", "column", "=", "position", ")", "except", "ValueError", ":", "# Jedi has thrown an error", "event", ".", "Skip", "(", ")", "return", "completions", "=", "script", ".", "completions", "(", ")", "completes", "=", "[", "completion", ".", "complete", "for", "completion", "in", "completions", "]", "complete", "=", "common_start", "(", "completes", ")", "if", "complete", "and", "not", "self", ".", "GetSelection", "(", ")", "[", "1", "]", ">", "self", ".", "GetSelection", "(", ")", "[", "0", "]", ":", "# There is a non-empty completion", "insertion_point", "=", "self", ".", "GetInsertionPoint", "(", ")", "self", ".", "write", "(", "complete", ")", "if", "len", "(", "completes", ")", ">", "1", ":", "self", ".", "SetSelection", "(", "insertion_point", ",", "insertion_point", "+", "len", "(", "complete", ")", ")", "words", "=", "[", "completion", ".", "name", "for", "completion", "in", "completions", "]", "docs", "=", "[", "]", "for", "completion", "in", "completions", ":", "doc", "=", "completion", ".", "docstring", "(", "fast", "=", "False", ")", "if", "not", "doc", "and", "code", ":", "# Is the completion part of a module?", "code_segment", "=", "code", "[", ":", "position", "+", "1", "]", ".", "split", "(", ")", "[", "-", "1", "]", "module_name", "=", "code_segment", ".", "rsplit", "(", "\".\"", ",", "1", ")", "[", "0", "]", "try", ":", "module", "=", "env", "[", "module_name", "]", "doc", "=", "getattr", "(", "module", ",", "completion", ".", "name", ")", ".", "__doc__", "except", "(", "KeyError", ",", "AttributeError", ")", ":", "pass", "if", "not", "doc", ":", "name", "=", "completion", ".", "name", "try", ":", "# Is the completion a builtin?", "doc", "=", "getattr", "(", "__builtin__", ",", "name", ")", ".", "__doc__", "except", "AttributeError", ":", "pass", "docs", ".", "append", "(", "doc", ")", "try", ":", "dws", "=", "[", "\": \"", ".", "join", "(", "[", "w", ",", "d", "]", ")", "for", "w", ",", "d", "in", "zip", "(", "words", ",", "docs", ")", "]", "tiptext", "=", "\"\\n \\n\"", ".", "join", "(", "dws", ")", "except", "TypeError", ":", "pass", "# Cut tiptext length because Tooltip fails for long strings", "self", ".", "SetToolTip", "(", "wx", ".", "ToolTip", "(", "tiptext", "[", ":", "MAX_TOOLTIP_LENGTH", "]", ")", ")", "# Do not process <Tab>", "return", "event", ".", "Skip", "(", ")" ]
Key event method * Forces grid update on <Enter> key * Handles insertion of cell access code
[ "Key", "event", "method" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L904-L1013
236,520
manns/pyspread
pyspread/src/gui/_widgets.py
StatusBar.Reposition
def Reposition(self): """Reposition the checkbox""" rect = self.GetFieldRect(1) self.safemode_staticbmp.SetPosition((rect.x, rect.y)) self.size_changed = False
python
def Reposition(self): """Reposition the checkbox""" rect = self.GetFieldRect(1) self.safemode_staticbmp.SetPosition((rect.x, rect.y)) self.size_changed = False
[ "def", "Reposition", "(", "self", ")", ":", "rect", "=", "self", ".", "GetFieldRect", "(", "1", ")", "self", ".", "safemode_staticbmp", ".", "SetPosition", "(", "(", "rect", ".", "x", ",", "rect", ".", "y", ")", ")", "self", ".", "size_changed", "=", "False" ]
Reposition the checkbox
[ "Reposition", "the", "checkbox" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L1088-L1093
236,521
manns/pyspread
pyspread/src/gui/_widgets.py
TableChoiceIntCtrl.change_max
def change_max(self, no_tabs): """Updates to a new number of tables Fixes current table if out of bounds. Parameters ---------- no_tabs: Integer \tNumber of tables for choice """ self.no_tabs = no_tabs if self.GetValue() >= no_tabs: self.SetValue(no_tabs - 1)
python
def change_max(self, no_tabs): """Updates to a new number of tables Fixes current table if out of bounds. Parameters ---------- no_tabs: Integer \tNumber of tables for choice """ self.no_tabs = no_tabs if self.GetValue() >= no_tabs: self.SetValue(no_tabs - 1)
[ "def", "change_max", "(", "self", ",", "no_tabs", ")", ":", "self", ".", "no_tabs", "=", "no_tabs", "if", "self", ".", "GetValue", "(", ")", ">=", "no_tabs", ":", "self", ".", "SetValue", "(", "no_tabs", "-", "1", ")" ]
Updates to a new number of tables Fixes current table if out of bounds. Parameters ---------- no_tabs: Integer \tNumber of tables for choice
[ "Updates", "to", "a", "new", "number", "of", "tables" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L1139-L1154
236,522
manns/pyspread
pyspread/src/gui/_widgets.py
TableChoiceIntCtrl._fromGUI
def _fromGUI(self, value): """ Conversion function used in getting the value of the control. """ # One or more of the underlying text control implementations # issue an intermediate EVT_TEXT when replacing the control's # value, where the intermediate value is an empty string. # So, to ensure consistency and to prevent spurious ValueErrors, # we make the following test, and react accordingly: # if value == '': if not self.IsNoneAllowed(): return 0 else: return else: try: return int(value) except ValueError: if self.IsLongAllowed(): try: return long(value) except ValueError: wx.TextCtrl.SetValue(self, "0") return 0 else: raise
python
def _fromGUI(self, value): """ Conversion function used in getting the value of the control. """ # One or more of the underlying text control implementations # issue an intermediate EVT_TEXT when replacing the control's # value, where the intermediate value is an empty string. # So, to ensure consistency and to prevent spurious ValueErrors, # we make the following test, and react accordingly: # if value == '': if not self.IsNoneAllowed(): return 0 else: return else: try: return int(value) except ValueError: if self.IsLongAllowed(): try: return long(value) except ValueError: wx.TextCtrl.SetValue(self, "0") return 0 else: raise
[ "def", "_fromGUI", "(", "self", ",", "value", ")", ":", "# One or more of the underlying text control implementations", "# issue an intermediate EVT_TEXT when replacing the control's", "# value, where the intermediate value is an empty string.", "# So, to ensure consistency and to prevent spurious ValueErrors,", "# we make the following test, and react accordingly:", "#", "if", "value", "==", "''", ":", "if", "not", "self", ".", "IsNoneAllowed", "(", ")", ":", "return", "0", "else", ":", "return", "else", ":", "try", ":", "return", "int", "(", "value", ")", "except", "ValueError", ":", "if", "self", ".", "IsLongAllowed", "(", ")", ":", "try", ":", "return", "long", "(", "value", ")", "except", "ValueError", ":", "wx", ".", "TextCtrl", ".", "SetValue", "(", "self", ",", "\"0\"", ")", "return", "0", "else", ":", "raise" ]
Conversion function used in getting the value of the control.
[ "Conversion", "function", "used", "in", "getting", "the", "value", "of", "the", "control", "." ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L1163-L1191
236,523
manns/pyspread
pyspread/src/gui/_widgets.py
TableChoiceIntCtrl.OnInt
def OnInt(self, event): """IntCtrl event method that updates the current table""" value = event.GetValue() current_time = time.clock() if current_time < self.last_change_s + 0.01: return self.last_change_s = current_time self.cursor_pos = wx.TextCtrl.GetInsertionPoint(self) + 1 if event.GetValue() > self.no_tabs - 1: value = self.no_tabs - 1 self.switching = True post_command_event(self, self.GridActionTableSwitchMsg, newtable=value) self.switching = False
python
def OnInt(self, event): """IntCtrl event method that updates the current table""" value = event.GetValue() current_time = time.clock() if current_time < self.last_change_s + 0.01: return self.last_change_s = current_time self.cursor_pos = wx.TextCtrl.GetInsertionPoint(self) + 1 if event.GetValue() > self.no_tabs - 1: value = self.no_tabs - 1 self.switching = True post_command_event(self, self.GridActionTableSwitchMsg, newtable=value) self.switching = False
[ "def", "OnInt", "(", "self", ",", "event", ")", ":", "value", "=", "event", ".", "GetValue", "(", ")", "current_time", "=", "time", ".", "clock", "(", ")", "if", "current_time", "<", "self", ".", "last_change_s", "+", "0.01", ":", "return", "self", ".", "last_change_s", "=", "current_time", "self", ".", "cursor_pos", "=", "wx", ".", "TextCtrl", ".", "GetInsertionPoint", "(", "self", ")", "+", "1", "if", "event", ".", "GetValue", "(", ")", ">", "self", ".", "no_tabs", "-", "1", ":", "value", "=", "self", ".", "no_tabs", "-", "1", "self", ".", "switching", "=", "True", "post_command_event", "(", "self", ",", "self", ".", "GridActionTableSwitchMsg", ",", "newtable", "=", "value", ")", "self", ".", "switching", "=", "False" ]
IntCtrl event method that updates the current table
[ "IntCtrl", "event", "method", "that", "updates", "the", "current", "table" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L1193-L1210
236,524
manns/pyspread
pyspread/src/gui/_widgets.py
TableChoiceListCtrl.OnItemSelected
def OnItemSelected(self, event): """Item selection event handler""" value = event.m_itemIndex self.startIndex = value self.switching = True post_command_event(self, self.GridActionTableSwitchMsg, newtable=value) self.switching = False event.Skip()
python
def OnItemSelected(self, event): """Item selection event handler""" value = event.m_itemIndex self.startIndex = value self.switching = True post_command_event(self, self.GridActionTableSwitchMsg, newtable=value) self.switching = False event.Skip()
[ "def", "OnItemSelected", "(", "self", ",", "event", ")", ":", "value", "=", "event", ".", "m_itemIndex", "self", ".", "startIndex", "=", "value", "self", ".", "switching", "=", "True", "post_command_event", "(", "self", ",", "self", ".", "GridActionTableSwitchMsg", ",", "newtable", "=", "value", ")", "self", ".", "switching", "=", "False", "event", ".", "Skip", "(", ")" ]
Item selection event handler
[ "Item", "selection", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L1302-L1312
236,525
manns/pyspread
pyspread/src/gui/_widgets.py
TableChoiceListCtrl.OnResizeGrid
def OnResizeGrid(self, event): """Event handler for grid resizing""" shape = min(event.shape[2], 2**30) self.SetItemCount(shape) event.Skip()
python
def OnResizeGrid(self, event): """Event handler for grid resizing""" shape = min(event.shape[2], 2**30) self.SetItemCount(shape) event.Skip()
[ "def", "OnResizeGrid", "(", "self", ",", "event", ")", ":", "shape", "=", "min", "(", "event", ".", "shape", "[", "2", "]", ",", "2", "**", "30", ")", "self", ".", "SetItemCount", "(", "shape", ")", "event", ".", "Skip", "(", ")" ]
Event handler for grid resizing
[ "Event", "handler", "for", "grid", "resizing" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L1314-L1319
236,526
manns/pyspread
pyspread/src/gui/_widgets.py
TableChoiceListCtrl.OnMouseUp
def OnMouseUp(self, event): """Generate a dropIndex. Process: check self.IsInControl, check self.IsDrag, HitTest, compare HitTest value The mouse can end up in 5 different places: Outside the Control On itself Above its starting point and on another item Below its starting point and on another item Below its starting point and not on another item """ if not self.IsInControl: # 1. Outside the control : Do Nothing self.IsDrag = False elif self.IsDrag: if not self.IsDrag: # In control and is a drag event : Determine Location self.hitIndex = self.HitTest(event.GetPosition()) self.dropIndex = self.hitIndex[0] # Drop index indicates where the drop location is; # what index number # Determine dropIndex and its validity # 2. On itself or below control : Do Nothing if not (self.dropIndex == self.startIndex or self.dropIndex == -1): # Now that dropIndex has been established do 3 things # 1. gather item data # 2. delete item in list # 3. insert item & it's data into the list at the new index # dropList is a list of field values from the list control dropList = [] thisItem = self.GetItem(self.startIndex) for x in xrange(self.GetColumnCount()): dropList.append( self.GetItem(self.startIndex, x).GetText()) thisItem.SetId(self.dropIndex) self.DeleteItem(self.startIndex) self.InsertItem(thisItem) for x in range(self.GetColumnCount()): self.SetStringItem(self.dropIndex, x, dropList[x]) # If in control but not a drag event : Do Nothing self.IsDrag = False event.Skip()
python
def OnMouseUp(self, event): """Generate a dropIndex. Process: check self.IsInControl, check self.IsDrag, HitTest, compare HitTest value The mouse can end up in 5 different places: Outside the Control On itself Above its starting point and on another item Below its starting point and on another item Below its starting point and not on another item """ if not self.IsInControl: # 1. Outside the control : Do Nothing self.IsDrag = False elif self.IsDrag: if not self.IsDrag: # In control and is a drag event : Determine Location self.hitIndex = self.HitTest(event.GetPosition()) self.dropIndex = self.hitIndex[0] # Drop index indicates where the drop location is; # what index number # Determine dropIndex and its validity # 2. On itself or below control : Do Nothing if not (self.dropIndex == self.startIndex or self.dropIndex == -1): # Now that dropIndex has been established do 3 things # 1. gather item data # 2. delete item in list # 3. insert item & it's data into the list at the new index # dropList is a list of field values from the list control dropList = [] thisItem = self.GetItem(self.startIndex) for x in xrange(self.GetColumnCount()): dropList.append( self.GetItem(self.startIndex, x).GetText()) thisItem.SetId(self.dropIndex) self.DeleteItem(self.startIndex) self.InsertItem(thisItem) for x in range(self.GetColumnCount()): self.SetStringItem(self.dropIndex, x, dropList[x]) # If in control but not a drag event : Do Nothing self.IsDrag = False event.Skip()
[ "def", "OnMouseUp", "(", "self", ",", "event", ")", ":", "if", "not", "self", ".", "IsInControl", ":", "# 1. Outside the control : Do Nothing", "self", ".", "IsDrag", "=", "False", "elif", "self", ".", "IsDrag", ":", "if", "not", "self", ".", "IsDrag", ":", "# In control and is a drag event : Determine Location", "self", ".", "hitIndex", "=", "self", ".", "HitTest", "(", "event", ".", "GetPosition", "(", ")", ")", "self", ".", "dropIndex", "=", "self", ".", "hitIndex", "[", "0", "]", "# Drop index indicates where the drop location is;", "# what index number", "# Determine dropIndex and its validity", "# 2. On itself or below control : Do Nothing", "if", "not", "(", "self", ".", "dropIndex", "==", "self", ".", "startIndex", "or", "self", ".", "dropIndex", "==", "-", "1", ")", ":", "# Now that dropIndex has been established do 3 things", "# 1. gather item data", "# 2. delete item in list", "# 3. insert item & it's data into the list at the new index", "# dropList is a list of field values from the list control", "dropList", "=", "[", "]", "thisItem", "=", "self", ".", "GetItem", "(", "self", ".", "startIndex", ")", "for", "x", "in", "xrange", "(", "self", ".", "GetColumnCount", "(", ")", ")", ":", "dropList", ".", "append", "(", "self", ".", "GetItem", "(", "self", ".", "startIndex", ",", "x", ")", ".", "GetText", "(", ")", ")", "thisItem", ".", "SetId", "(", "self", ".", "dropIndex", ")", "self", ".", "DeleteItem", "(", "self", ".", "startIndex", ")", "self", ".", "InsertItem", "(", "thisItem", ")", "for", "x", "in", "range", "(", "self", ".", "GetColumnCount", "(", ")", ")", ":", "self", ".", "SetStringItem", "(", "self", ".", "dropIndex", ",", "x", ",", "dropList", "[", "x", "]", ")", "# If in control but not a drag event : Do Nothing", "self", ".", "IsDrag", "=", "False", "event", ".", "Skip", "(", ")" ]
Generate a dropIndex. Process: check self.IsInControl, check self.IsDrag, HitTest, compare HitTest value The mouse can end up in 5 different places: Outside the Control On itself Above its starting point and on another item Below its starting point and on another item Below its starting point and not on another item
[ "Generate", "a", "dropIndex", "." ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L1352-L1401
236,527
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindow._set_properties
def _set_properties(self): """Setup title, icon, size, scale, statusbar, main grid""" self.set_icon(icons["PyspreadLogo"]) # Without minimum size, initial size is minimum size in wxGTK self.minSizeSet = False # Leave save mode post_command_event(self, self.SafeModeExitMsg)
python
def _set_properties(self): """Setup title, icon, size, scale, statusbar, main grid""" self.set_icon(icons["PyspreadLogo"]) # Without minimum size, initial size is minimum size in wxGTK self.minSizeSet = False # Leave save mode post_command_event(self, self.SafeModeExitMsg)
[ "def", "_set_properties", "(", "self", ")", ":", "self", ".", "set_icon", "(", "icons", "[", "\"PyspreadLogo\"", "]", ")", "# Without minimum size, initial size is minimum size in wxGTK", "self", ".", "minSizeSet", "=", "False", "# Leave save mode", "post_command_event", "(", "self", ",", "self", ".", "SafeModeExitMsg", ")" ]
Setup title, icon, size, scale, statusbar, main grid
[ "Setup", "title", "icon", "size", "scale", "statusbar", "main", "grid" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L203-L212
236,528
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindow._set_menu_toggles
def _set_menu_toggles(self): """Enable menu bar view item checkmarks""" toggles = [ (self.main_toolbar, "main_window_toolbar", _("Main toolbar")), (self.macro_toolbar, "macro_toolbar", _("Macro toolbar")), (self.macro_panel, "macro_panel", _("Macro panel")), (self.attributes_toolbar, "attributes_toolbar", _("Format toolbar")), (self.find_toolbar, "find_toolbar", _("Find toolbar")), (self.widget_toolbar, "widget_toolbar", _("Widget toolbar")), (self.entry_line_panel, "entry_line_panel", _("Entry line")), (self.table_list_panel, "table_list_panel", _("Table list")), ] for toolbar, pane_name, toggle_label in toggles: # Get pane from aui manager pane = self._mgr.GetPane(pane_name) # Get menu item to toggle toggle_id = self.menubar.FindMenuItem(_("View"), toggle_label) if toggle_id != -1: # Check may fail if translation is incomplete toggle_item = self.menubar.FindItemById(toggle_id) # Adjust toggle to pane visibility toggle_item.Check(pane.IsShown())
python
def _set_menu_toggles(self): """Enable menu bar view item checkmarks""" toggles = [ (self.main_toolbar, "main_window_toolbar", _("Main toolbar")), (self.macro_toolbar, "macro_toolbar", _("Macro toolbar")), (self.macro_panel, "macro_panel", _("Macro panel")), (self.attributes_toolbar, "attributes_toolbar", _("Format toolbar")), (self.find_toolbar, "find_toolbar", _("Find toolbar")), (self.widget_toolbar, "widget_toolbar", _("Widget toolbar")), (self.entry_line_panel, "entry_line_panel", _("Entry line")), (self.table_list_panel, "table_list_panel", _("Table list")), ] for toolbar, pane_name, toggle_label in toggles: # Get pane from aui manager pane = self._mgr.GetPane(pane_name) # Get menu item to toggle toggle_id = self.menubar.FindMenuItem(_("View"), toggle_label) if toggle_id != -1: # Check may fail if translation is incomplete toggle_item = self.menubar.FindItemById(toggle_id) # Adjust toggle to pane visibility toggle_item.Check(pane.IsShown())
[ "def", "_set_menu_toggles", "(", "self", ")", ":", "toggles", "=", "[", "(", "self", ".", "main_toolbar", ",", "\"main_window_toolbar\"", ",", "_", "(", "\"Main toolbar\"", ")", ")", ",", "(", "self", ".", "macro_toolbar", ",", "\"macro_toolbar\"", ",", "_", "(", "\"Macro toolbar\"", ")", ")", ",", "(", "self", ".", "macro_panel", ",", "\"macro_panel\"", ",", "_", "(", "\"Macro panel\"", ")", ")", ",", "(", "self", ".", "attributes_toolbar", ",", "\"attributes_toolbar\"", ",", "_", "(", "\"Format toolbar\"", ")", ")", ",", "(", "self", ".", "find_toolbar", ",", "\"find_toolbar\"", ",", "_", "(", "\"Find toolbar\"", ")", ")", ",", "(", "self", ".", "widget_toolbar", ",", "\"widget_toolbar\"", ",", "_", "(", "\"Widget toolbar\"", ")", ")", ",", "(", "self", ".", "entry_line_panel", ",", "\"entry_line_panel\"", ",", "_", "(", "\"Entry line\"", ")", ")", ",", "(", "self", ".", "table_list_panel", ",", "\"table_list_panel\"", ",", "_", "(", "\"Table list\"", ")", ")", ",", "]", "for", "toolbar", ",", "pane_name", ",", "toggle_label", "in", "toggles", ":", "# Get pane from aui manager", "pane", "=", "self", ".", "_mgr", ".", "GetPane", "(", "pane_name", ")", "# Get menu item to toggle", "toggle_id", "=", "self", ".", "menubar", ".", "FindMenuItem", "(", "_", "(", "\"View\"", ")", ",", "toggle_label", ")", "if", "toggle_id", "!=", "-", "1", ":", "# Check may fail if translation is incomplete", "toggle_item", "=", "self", ".", "menubar", ".", "FindItemById", "(", "toggle_id", ")", "# Adjust toggle to pane visibility", "toggle_item", ".", "Check", "(", "pane", ".", "IsShown", "(", ")", ")" ]
Enable menu bar view item checkmarks
[ "Enable", "menu", "bar", "view", "item", "checkmarks" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L214-L240
236,529
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindow.set_icon
def set_icon(self, bmp): """Sets main window icon to given wx.Bitmap""" _icon = wx.EmptyIcon() _icon.CopyFromBitmap(bmp) self.SetIcon(_icon)
python
def set_icon(self, bmp): """Sets main window icon to given wx.Bitmap""" _icon = wx.EmptyIcon() _icon.CopyFromBitmap(bmp) self.SetIcon(_icon)
[ "def", "set_icon", "(", "self", ",", "bmp", ")", ":", "_icon", "=", "wx", ".", "EmptyIcon", "(", ")", "_icon", ".", "CopyFromBitmap", "(", "bmp", ")", "self", ".", "SetIcon", "(", "_icon", ")" ]
Sets main window icon to given wx.Bitmap
[ "Sets", "main", "window", "icon", "to", "given", "wx", ".", "Bitmap" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L412-L417
236,530
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnToggleFullscreen
def OnToggleFullscreen(self, event): """Fullscreen event handler""" is_full_screen = self.main_window.IsFullScreen() # Make sure that only the grid is shown in fullscreen mode if is_full_screen: try: self.main_window.grid.SetRowLabelSize(self.row_label_size) self.main_window.grid.SetColLabelSize(self.col_label_size) except AttributeError: pass # Restore toolbars from before fullscreen mode try: self.main_window._mgr.LoadPerspective(self.aui_windowed) except AttributeError: pass else: # Save the perspective of the AUI manager self.aui_windowed = self.main_window._mgr.SavePerspective() # Hide toolbars for pane in self.main_window._mgr.GetAllPanes(): if pane.name != "grid": pane.Hide() self.main_window._mgr.Update() self.row_label_size = self.main_window.grid.GetRowLabelSize() self.col_label_size = self.main_window.grid.GetColLabelSize() self.main_window.grid.SetRowLabelSize(0) self.main_window.grid.SetColLabelSize(0) self.main_window.ShowFullScreen(not is_full_screen)
python
def OnToggleFullscreen(self, event): """Fullscreen event handler""" is_full_screen = self.main_window.IsFullScreen() # Make sure that only the grid is shown in fullscreen mode if is_full_screen: try: self.main_window.grid.SetRowLabelSize(self.row_label_size) self.main_window.grid.SetColLabelSize(self.col_label_size) except AttributeError: pass # Restore toolbars from before fullscreen mode try: self.main_window._mgr.LoadPerspective(self.aui_windowed) except AttributeError: pass else: # Save the perspective of the AUI manager self.aui_windowed = self.main_window._mgr.SavePerspective() # Hide toolbars for pane in self.main_window._mgr.GetAllPanes(): if pane.name != "grid": pane.Hide() self.main_window._mgr.Update() self.row_label_size = self.main_window.grid.GetRowLabelSize() self.col_label_size = self.main_window.grid.GetColLabelSize() self.main_window.grid.SetRowLabelSize(0) self.main_window.grid.SetColLabelSize(0) self.main_window.ShowFullScreen(not is_full_screen)
[ "def", "OnToggleFullscreen", "(", "self", ",", "event", ")", ":", "is_full_screen", "=", "self", ".", "main_window", ".", "IsFullScreen", "(", ")", "# Make sure that only the grid is shown in fullscreen mode", "if", "is_full_screen", ":", "try", ":", "self", ".", "main_window", ".", "grid", ".", "SetRowLabelSize", "(", "self", ".", "row_label_size", ")", "self", ".", "main_window", ".", "grid", ".", "SetColLabelSize", "(", "self", ".", "col_label_size", ")", "except", "AttributeError", ":", "pass", "# Restore toolbars from before fullscreen mode", "try", ":", "self", ".", "main_window", ".", "_mgr", ".", "LoadPerspective", "(", "self", ".", "aui_windowed", ")", "except", "AttributeError", ":", "pass", "else", ":", "# Save the perspective of the AUI manager", "self", ".", "aui_windowed", "=", "self", ".", "main_window", ".", "_mgr", ".", "SavePerspective", "(", ")", "# Hide toolbars", "for", "pane", "in", "self", ".", "main_window", ".", "_mgr", ".", "GetAllPanes", "(", ")", ":", "if", "pane", ".", "name", "!=", "\"grid\"", ":", "pane", ".", "Hide", "(", ")", "self", ".", "main_window", ".", "_mgr", ".", "Update", "(", ")", "self", ".", "row_label_size", "=", "self", ".", "main_window", ".", "grid", ".", "GetRowLabelSize", "(", ")", "self", ".", "col_label_size", "=", "self", ".", "main_window", ".", "grid", ".", "GetColLabelSize", "(", ")", "self", ".", "main_window", ".", "grid", ".", "SetRowLabelSize", "(", "0", ")", "self", ".", "main_window", ".", "grid", ".", "SetColLabelSize", "(", "0", ")", "self", ".", "main_window", ".", "ShowFullScreen", "(", "not", "is_full_screen", ")" ]
Fullscreen event handler
[ "Fullscreen", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L455-L491
236,531
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnContentChanged
def OnContentChanged(self, event): """Titlebar star adjustment event handler""" self.main_window.grid.update_attribute_toolbar() title = self.main_window.GetTitle() if undo.stack().haschanged(): # Put * in front of title if title[:2] != "* ": new_title = "* " + title post_command_event(self.main_window, self.main_window.TitleMsg, text=new_title) elif title[:2] == "* ": # Remove * in front of title new_title = title[2:] post_command_event(self.main_window, self.main_window.TitleMsg, text=new_title)
python
def OnContentChanged(self, event): """Titlebar star adjustment event handler""" self.main_window.grid.update_attribute_toolbar() title = self.main_window.GetTitle() if undo.stack().haschanged(): # Put * in front of title if title[:2] != "* ": new_title = "* " + title post_command_event(self.main_window, self.main_window.TitleMsg, text=new_title) elif title[:2] == "* ": # Remove * in front of title new_title = title[2:] post_command_event(self.main_window, self.main_window.TitleMsg, text=new_title)
[ "def", "OnContentChanged", "(", "self", ",", "event", ")", ":", "self", ".", "main_window", ".", "grid", ".", "update_attribute_toolbar", "(", ")", "title", "=", "self", ".", "main_window", ".", "GetTitle", "(", ")", "if", "undo", ".", "stack", "(", ")", ".", "haschanged", "(", ")", ":", "# Put * in front of title", "if", "title", "[", ":", "2", "]", "!=", "\"* \"", ":", "new_title", "=", "\"* \"", "+", "title", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "TitleMsg", ",", "text", "=", "new_title", ")", "elif", "title", "[", ":", "2", "]", "==", "\"* \"", ":", "# Remove * in front of title", "new_title", "=", "title", "[", "2", ":", "]", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "TitleMsg", ",", "text", "=", "new_title", ")" ]
Titlebar star adjustment event handler
[ "Titlebar", "star", "adjustment", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L493-L511
236,532
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnSafeModeEntry
def OnSafeModeEntry(self, event): """Safe mode entry event handler""" # Enable menu item for leaving safe mode self.main_window.main_menu.enable_file_approve(True) self.main_window.grid.Refresh() event.Skip()
python
def OnSafeModeEntry(self, event): """Safe mode entry event handler""" # Enable menu item for leaving safe mode self.main_window.main_menu.enable_file_approve(True) self.main_window.grid.Refresh() event.Skip()
[ "def", "OnSafeModeEntry", "(", "self", ",", "event", ")", ":", "# Enable menu item for leaving safe mode", "self", ".", "main_window", ".", "main_menu", ".", "enable_file_approve", "(", "True", ")", "self", ".", "main_window", ".", "grid", ".", "Refresh", "(", ")", "event", ".", "Skip", "(", ")" ]
Safe mode entry event handler
[ "Safe", "mode", "entry", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L518-L527
236,533
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnSafeModeExit
def OnSafeModeExit(self, event): """Safe mode exit event handler""" # Run macros # self.MainGrid.model.pysgrid.sgrid.execute_macros(safe_mode=False) # Disable menu item for leaving safe mode self.main_window.main_menu.enable_file_approve(False) self.main_window.grid.Refresh() event.Skip()
python
def OnSafeModeExit(self, event): """Safe mode exit event handler""" # Run macros # self.MainGrid.model.pysgrid.sgrid.execute_macros(safe_mode=False) # Disable menu item for leaving safe mode self.main_window.main_menu.enable_file_approve(False) self.main_window.grid.Refresh() event.Skip()
[ "def", "OnSafeModeExit", "(", "self", ",", "event", ")", ":", "# Run macros", "# self.MainGrid.model.pysgrid.sgrid.execute_macros(safe_mode=False)", "# Disable menu item for leaving safe mode", "self", ".", "main_window", ".", "main_menu", ".", "enable_file_approve", "(", "False", ")", "self", ".", "main_window", ".", "grid", ".", "Refresh", "(", ")", "event", ".", "Skip", "(", ")" ]
Safe mode exit event handler
[ "Safe", "mode", "exit", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L529-L542
236,534
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnClose
def OnClose(self, event): """Program exit event handler""" # If changes have taken place save of old grid if undo.stack().haschanged(): save_choice = self.interfaces.get_save_request_from_user() if save_choice is None: # Cancelled close operation return elif save_choice: # User wants to save content post_command_event(self.main_window, self.main_window.SaveMsg) # Save the AUI state config["window_layout"] = repr(self.main_window._mgr.SavePerspective()) # Uninit the AUI stuff self.main_window._mgr.UnInit() # Save config config.save() # Close main_window self.main_window.Destroy() # Set file mode to 600 to protect GPG passwd a bit sp = wx.StandardPaths.Get() pyspreadrc_path = sp.GetUserConfigDir() + "/." + config.config_filename try: os.chmod(pyspreadrc_path, 0600) except OSError: dummyfile = open(pyspreadrc_path, "w") dummyfile.close() os.chmod(pyspreadrc_path, 0600)
python
def OnClose(self, event): """Program exit event handler""" # If changes have taken place save of old grid if undo.stack().haschanged(): save_choice = self.interfaces.get_save_request_from_user() if save_choice is None: # Cancelled close operation return elif save_choice: # User wants to save content post_command_event(self.main_window, self.main_window.SaveMsg) # Save the AUI state config["window_layout"] = repr(self.main_window._mgr.SavePerspective()) # Uninit the AUI stuff self.main_window._mgr.UnInit() # Save config config.save() # Close main_window self.main_window.Destroy() # Set file mode to 600 to protect GPG passwd a bit sp = wx.StandardPaths.Get() pyspreadrc_path = sp.GetUserConfigDir() + "/." + config.config_filename try: os.chmod(pyspreadrc_path, 0600) except OSError: dummyfile = open(pyspreadrc_path, "w") dummyfile.close() os.chmod(pyspreadrc_path, 0600)
[ "def", "OnClose", "(", "self", ",", "event", ")", ":", "# If changes have taken place save of old grid", "if", "undo", ".", "stack", "(", ")", ".", "haschanged", "(", ")", ":", "save_choice", "=", "self", ".", "interfaces", ".", "get_save_request_from_user", "(", ")", "if", "save_choice", "is", "None", ":", "# Cancelled close operation", "return", "elif", "save_choice", ":", "# User wants to save content", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "SaveMsg", ")", "# Save the AUI state", "config", "[", "\"window_layout\"", "]", "=", "repr", "(", "self", ".", "main_window", ".", "_mgr", ".", "SavePerspective", "(", ")", ")", "# Uninit the AUI stuff", "self", ".", "main_window", ".", "_mgr", ".", "UnInit", "(", ")", "# Save config", "config", ".", "save", "(", ")", "# Close main_window", "self", ".", "main_window", ".", "Destroy", "(", ")", "# Set file mode to 600 to protect GPG passwd a bit", "sp", "=", "wx", ".", "StandardPaths", ".", "Get", "(", ")", "pyspreadrc_path", "=", "sp", ".", "GetUserConfigDir", "(", ")", "+", "\"/.\"", "+", "config", ".", "config_filename", "try", ":", "os", ".", "chmod", "(", "pyspreadrc_path", ",", "0600", ")", "except", "OSError", ":", "dummyfile", "=", "open", "(", "pyspreadrc_path", ",", "\"w\"", ")", "dummyfile", ".", "close", "(", ")", "os", ".", "chmod", "(", "pyspreadrc_path", ",", "0600", ")" ]
Program exit event handler
[ "Program", "exit", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L544-L583
236,535
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnSpellCheckToggle
def OnSpellCheckToggle(self, event): """Spell checking toggle event handler""" spelltoolid = self.main_window.main_toolbar.label2id["CheckSpelling"] self.main_window.main_toolbar.ToggleTool(spelltoolid, not config["check_spelling"]) config["check_spelling"] = repr(not config["check_spelling"]) self.main_window.grid.grid_renderer.cell_cache.clear() self.main_window.grid.ForceRefresh()
python
def OnSpellCheckToggle(self, event): """Spell checking toggle event handler""" spelltoolid = self.main_window.main_toolbar.label2id["CheckSpelling"] self.main_window.main_toolbar.ToggleTool(spelltoolid, not config["check_spelling"]) config["check_spelling"] = repr(not config["check_spelling"]) self.main_window.grid.grid_renderer.cell_cache.clear() self.main_window.grid.ForceRefresh()
[ "def", "OnSpellCheckToggle", "(", "self", ",", "event", ")", ":", "spelltoolid", "=", "self", ".", "main_window", ".", "main_toolbar", ".", "label2id", "[", "\"CheckSpelling\"", "]", "self", ".", "main_window", ".", "main_toolbar", ".", "ToggleTool", "(", "spelltoolid", ",", "not", "config", "[", "\"check_spelling\"", "]", ")", "config", "[", "\"check_spelling\"", "]", "=", "repr", "(", "not", "config", "[", "\"check_spelling\"", "]", ")", "self", ".", "main_window", ".", "grid", ".", "grid_renderer", ".", "cell_cache", ".", "clear", "(", ")", "self", ".", "main_window", ".", "grid", ".", "ForceRefresh", "(", ")" ]
Spell checking toggle event handler
[ "Spell", "checking", "toggle", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L585-L595
236,536
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnPreferences
def OnPreferences(self, event): """Preferences event handler that launches preferences dialog""" preferences = self.interfaces.get_preferences_from_user() if preferences: for key in preferences: if type(config[key]) in (type(u""), type("")): config[key] = preferences[key] else: config[key] = ast.literal_eval(preferences[key]) self.main_window.grid.grid_renderer.cell_cache.clear() self.main_window.grid.ForceRefresh()
python
def OnPreferences(self, event): """Preferences event handler that launches preferences dialog""" preferences = self.interfaces.get_preferences_from_user() if preferences: for key in preferences: if type(config[key]) in (type(u""), type("")): config[key] = preferences[key] else: config[key] = ast.literal_eval(preferences[key]) self.main_window.grid.grid_renderer.cell_cache.clear() self.main_window.grid.ForceRefresh()
[ "def", "OnPreferences", "(", "self", ",", "event", ")", ":", "preferences", "=", "self", ".", "interfaces", ".", "get_preferences_from_user", "(", ")", "if", "preferences", ":", "for", "key", "in", "preferences", ":", "if", "type", "(", "config", "[", "key", "]", ")", "in", "(", "type", "(", "u\"\"", ")", ",", "type", "(", "\"\"", ")", ")", ":", "config", "[", "key", "]", "=", "preferences", "[", "key", "]", "else", ":", "config", "[", "key", "]", "=", "ast", ".", "literal_eval", "(", "preferences", "[", "key", "]", ")", "self", ".", "main_window", ".", "grid", ".", "grid_renderer", ".", "cell_cache", ".", "clear", "(", ")", "self", ".", "main_window", ".", "grid", ".", "ForceRefresh", "(", ")" ]
Preferences event handler that launches preferences dialog
[ "Preferences", "event", "handler", "that", "launches", "preferences", "dialog" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L599-L612
236,537
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnNewGpgKey
def OnNewGpgKey(self, event): """New GPG key event handler. Launches GPG choice and creation dialog """ if gnupg is None: return if genkey is None: # gnupg is not present self.interfaces.display_warning( _("Python gnupg not found. No key selected."), _("Key selection failed.")) else: # gnupg is present genkey()
python
def OnNewGpgKey(self, event): """New GPG key event handler. Launches GPG choice and creation dialog """ if gnupg is None: return if genkey is None: # gnupg is not present self.interfaces.display_warning( _("Python gnupg not found. No key selected."), _("Key selection failed.")) else: # gnupg is present genkey()
[ "def", "OnNewGpgKey", "(", "self", ",", "event", ")", ":", "if", "gnupg", "is", "None", ":", "return", "if", "genkey", "is", "None", ":", "# gnupg is not present", "self", ".", "interfaces", ".", "display_warning", "(", "_", "(", "\"Python gnupg not found. No key selected.\"", ")", ",", "_", "(", "\"Key selection failed.\"", ")", ")", "else", ":", "# gnupg is present", "genkey", "(", ")" ]
New GPG key event handler. Launches GPG choice and creation dialog
[ "New", "GPG", "key", "event", "handler", "." ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L614-L631
236,538
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers._toggle_pane
def _toggle_pane(self, pane): """Toggles visibility of given aui pane Parameters ---------- pane: String \tPane name """ if pane.IsShown(): pane.Hide() else: pane.Show() self.main_window._mgr.Update()
python
def _toggle_pane(self, pane): """Toggles visibility of given aui pane Parameters ---------- pane: String \tPane name """ if pane.IsShown(): pane.Hide() else: pane.Show() self.main_window._mgr.Update()
[ "def", "_toggle_pane", "(", "self", ",", "pane", ")", ":", "if", "pane", ".", "IsShown", "(", ")", ":", "pane", ".", "Hide", "(", ")", "else", ":", "pane", ".", "Show", "(", ")", "self", ".", "main_window", ".", "_mgr", ".", "Update", "(", ")" ]
Toggles visibility of given aui pane Parameters ---------- pane: String \tPane name
[ "Toggles", "visibility", "of", "given", "aui", "pane" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L635-L651
236,539
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnMainToolbarToggle
def OnMainToolbarToggle(self, event): """Main window toolbar toggle event handler""" self.main_window.main_toolbar.SetGripperVisible(True) main_toolbar_info = \ self.main_window._mgr.GetPane("main_window_toolbar") self._toggle_pane(main_toolbar_info) event.Skip()
python
def OnMainToolbarToggle(self, event): """Main window toolbar toggle event handler""" self.main_window.main_toolbar.SetGripperVisible(True) main_toolbar_info = \ self.main_window._mgr.GetPane("main_window_toolbar") self._toggle_pane(main_toolbar_info) event.Skip()
[ "def", "OnMainToolbarToggle", "(", "self", ",", "event", ")", ":", "self", ".", "main_window", ".", "main_toolbar", ".", "SetGripperVisible", "(", "True", ")", "main_toolbar_info", "=", "self", ".", "main_window", ".", "_mgr", ".", "GetPane", "(", "\"main_window_toolbar\"", ")", "self", ".", "_toggle_pane", "(", "main_toolbar_info", ")", "event", ".", "Skip", "(", ")" ]
Main window toolbar toggle event handler
[ "Main", "window", "toolbar", "toggle", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L653-L662
236,540
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnMacroToolbarToggle
def OnMacroToolbarToggle(self, event): """Macro toolbar toggle event handler""" self.main_window.macro_toolbar.SetGripperVisible(True) macro_toolbar_info = self.main_window._mgr.GetPane("macro_toolbar") self._toggle_pane(macro_toolbar_info) event.Skip()
python
def OnMacroToolbarToggle(self, event): """Macro toolbar toggle event handler""" self.main_window.macro_toolbar.SetGripperVisible(True) macro_toolbar_info = self.main_window._mgr.GetPane("macro_toolbar") self._toggle_pane(macro_toolbar_info) event.Skip()
[ "def", "OnMacroToolbarToggle", "(", "self", ",", "event", ")", ":", "self", ".", "main_window", ".", "macro_toolbar", ".", "SetGripperVisible", "(", "True", ")", "macro_toolbar_info", "=", "self", ".", "main_window", ".", "_mgr", ".", "GetPane", "(", "\"macro_toolbar\"", ")", "self", ".", "_toggle_pane", "(", "macro_toolbar_info", ")", "event", ".", "Skip", "(", ")" ]
Macro toolbar toggle event handler
[ "Macro", "toolbar", "toggle", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L664-L672
236,541
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnWidgetToolbarToggle
def OnWidgetToolbarToggle(self, event): """Widget toolbar toggle event handler""" self.main_window.widget_toolbar.SetGripperVisible(True) widget_toolbar_info = self.main_window._mgr.GetPane("widget_toolbar") self._toggle_pane(widget_toolbar_info) event.Skip()
python
def OnWidgetToolbarToggle(self, event): """Widget toolbar toggle event handler""" self.main_window.widget_toolbar.SetGripperVisible(True) widget_toolbar_info = self.main_window._mgr.GetPane("widget_toolbar") self._toggle_pane(widget_toolbar_info) event.Skip()
[ "def", "OnWidgetToolbarToggle", "(", "self", ",", "event", ")", ":", "self", ".", "main_window", ".", "widget_toolbar", ".", "SetGripperVisible", "(", "True", ")", "widget_toolbar_info", "=", "self", ".", "main_window", ".", "_mgr", ".", "GetPane", "(", "\"widget_toolbar\"", ")", "self", ".", "_toggle_pane", "(", "widget_toolbar_info", ")", "event", ".", "Skip", "(", ")" ]
Widget toolbar toggle event handler
[ "Widget", "toolbar", "toggle", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L674-L682
236,542
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnAttributesToolbarToggle
def OnAttributesToolbarToggle(self, event): """Format toolbar toggle event handler""" self.main_window.attributes_toolbar.SetGripperVisible(True) attributes_toolbar_info = \ self.main_window._mgr.GetPane("attributes_toolbar") self._toggle_pane(attributes_toolbar_info) event.Skip()
python
def OnAttributesToolbarToggle(self, event): """Format toolbar toggle event handler""" self.main_window.attributes_toolbar.SetGripperVisible(True) attributes_toolbar_info = \ self.main_window._mgr.GetPane("attributes_toolbar") self._toggle_pane(attributes_toolbar_info) event.Skip()
[ "def", "OnAttributesToolbarToggle", "(", "self", ",", "event", ")", ":", "self", ".", "main_window", ".", "attributes_toolbar", ".", "SetGripperVisible", "(", "True", ")", "attributes_toolbar_info", "=", "self", ".", "main_window", ".", "_mgr", ".", "GetPane", "(", "\"attributes_toolbar\"", ")", "self", ".", "_toggle_pane", "(", "attributes_toolbar_info", ")", "event", ".", "Skip", "(", ")" ]
Format toolbar toggle event handler
[ "Format", "toolbar", "toggle", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L684-L693
236,543
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnFindToolbarToggle
def OnFindToolbarToggle(self, event): """Search toolbar toggle event handler""" self.main_window.find_toolbar.SetGripperVisible(True) find_toolbar_info = self.main_window._mgr.GetPane("find_toolbar") self._toggle_pane(find_toolbar_info) event.Skip()
python
def OnFindToolbarToggle(self, event): """Search toolbar toggle event handler""" self.main_window.find_toolbar.SetGripperVisible(True) find_toolbar_info = self.main_window._mgr.GetPane("find_toolbar") self._toggle_pane(find_toolbar_info) event.Skip()
[ "def", "OnFindToolbarToggle", "(", "self", ",", "event", ")", ":", "self", ".", "main_window", ".", "find_toolbar", ".", "SetGripperVisible", "(", "True", ")", "find_toolbar_info", "=", "self", ".", "main_window", ".", "_mgr", ".", "GetPane", "(", "\"find_toolbar\"", ")", "self", ".", "_toggle_pane", "(", "find_toolbar_info", ")", "event", ".", "Skip", "(", ")" ]
Search toolbar toggle event handler
[ "Search", "toolbar", "toggle", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L695-L704
236,544
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnEntryLineToggle
def OnEntryLineToggle(self, event): """Entry line toggle event handler""" entry_line_panel_info = \ self.main_window._mgr.GetPane("entry_line_panel") self._toggle_pane(entry_line_panel_info) event.Skip()
python
def OnEntryLineToggle(self, event): """Entry line toggle event handler""" entry_line_panel_info = \ self.main_window._mgr.GetPane("entry_line_panel") self._toggle_pane(entry_line_panel_info) event.Skip()
[ "def", "OnEntryLineToggle", "(", "self", ",", "event", ")", ":", "entry_line_panel_info", "=", "self", ".", "main_window", ".", "_mgr", ".", "GetPane", "(", "\"entry_line_panel\"", ")", "self", ".", "_toggle_pane", "(", "entry_line_panel_info", ")", "event", ".", "Skip", "(", ")" ]
Entry line toggle event handler
[ "Entry", "line", "toggle", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L706-L714
236,545
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnTableListToggle
def OnTableListToggle(self, event): """Table list toggle event handler""" table_list_panel_info = \ self.main_window._mgr.GetPane("table_list_panel") self._toggle_pane(table_list_panel_info) event.Skip()
python
def OnTableListToggle(self, event): """Table list toggle event handler""" table_list_panel_info = \ self.main_window._mgr.GetPane("table_list_panel") self._toggle_pane(table_list_panel_info) event.Skip()
[ "def", "OnTableListToggle", "(", "self", ",", "event", ")", ":", "table_list_panel_info", "=", "self", ".", "main_window", ".", "_mgr", ".", "GetPane", "(", "\"table_list_panel\"", ")", "self", ".", "_toggle_pane", "(", "table_list_panel_info", ")", "event", ".", "Skip", "(", ")" ]
Table list toggle event handler
[ "Table", "list", "toggle", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L726-L734
236,546
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnNew
def OnNew(self, event): """New grid event handler""" # If changes have taken place save of old grid if undo.stack().haschanged(): save_choice = self.interfaces.get_save_request_from_user() if save_choice is None: # Cancelled close operation return elif save_choice: # User wants to save content post_command_event(self.main_window, self.main_window.SaveMsg) # Get grid dimensions shape = self.interfaces.get_dimensions_from_user(no_dim=3) if shape is None: return # Set new filepath and post it to the title bar self.main_window.filepath = None post_command_event(self.main_window, self.main_window.TitleMsg, text="pyspread") # Clear globals self.main_window.grid.actions.clear_globals_reload_modules() # Create new grid post_command_event(self.main_window, self.main_window.GridActionNewMsg, shape=shape) # Update TableChoiceIntCtrl post_command_event(self.main_window, self.main_window.ResizeGridMsg, shape=shape) if is_gtk(): try: wx.Yield() except: pass self.main_window.grid.actions.change_grid_shape(shape) self.main_window.grid.GetTable().ResetView() self.main_window.grid.ForceRefresh() # Display grid creation in status bar msg = _("New grid with dimensions {dim} created.").format(dim=shape) post_command_event(self.main_window, self.main_window.StatusBarMsg, text=msg) self.main_window.grid.ForceRefresh() if is_gtk(): try: wx.Yield() except: pass # Update undo stack savepoint and clear undo stack undo.stack().clear() undo.stack().savepoint() # Update content changed state try: post_command_event(self.main_window, self.ContentChangedMsg) except TypeError: # The main window does not exist any more pass
python
def OnNew(self, event): """New grid event handler""" # If changes have taken place save of old grid if undo.stack().haschanged(): save_choice = self.interfaces.get_save_request_from_user() if save_choice is None: # Cancelled close operation return elif save_choice: # User wants to save content post_command_event(self.main_window, self.main_window.SaveMsg) # Get grid dimensions shape = self.interfaces.get_dimensions_from_user(no_dim=3) if shape is None: return # Set new filepath and post it to the title bar self.main_window.filepath = None post_command_event(self.main_window, self.main_window.TitleMsg, text="pyspread") # Clear globals self.main_window.grid.actions.clear_globals_reload_modules() # Create new grid post_command_event(self.main_window, self.main_window.GridActionNewMsg, shape=shape) # Update TableChoiceIntCtrl post_command_event(self.main_window, self.main_window.ResizeGridMsg, shape=shape) if is_gtk(): try: wx.Yield() except: pass self.main_window.grid.actions.change_grid_shape(shape) self.main_window.grid.GetTable().ResetView() self.main_window.grid.ForceRefresh() # Display grid creation in status bar msg = _("New grid with dimensions {dim} created.").format(dim=shape) post_command_event(self.main_window, self.main_window.StatusBarMsg, text=msg) self.main_window.grid.ForceRefresh() if is_gtk(): try: wx.Yield() except: pass # Update undo stack savepoint and clear undo stack undo.stack().clear() undo.stack().savepoint() # Update content changed state try: post_command_event(self.main_window, self.ContentChangedMsg) except TypeError: # The main window does not exist any more pass
[ "def", "OnNew", "(", "self", ",", "event", ")", ":", "# If changes have taken place save of old grid", "if", "undo", ".", "stack", "(", ")", ".", "haschanged", "(", ")", ":", "save_choice", "=", "self", ".", "interfaces", ".", "get_save_request_from_user", "(", ")", "if", "save_choice", "is", "None", ":", "# Cancelled close operation", "return", "elif", "save_choice", ":", "# User wants to save content", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "SaveMsg", ")", "# Get grid dimensions", "shape", "=", "self", ".", "interfaces", ".", "get_dimensions_from_user", "(", "no_dim", "=", "3", ")", "if", "shape", "is", "None", ":", "return", "# Set new filepath and post it to the title bar", "self", ".", "main_window", ".", "filepath", "=", "None", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "TitleMsg", ",", "text", "=", "\"pyspread\"", ")", "# Clear globals", "self", ".", "main_window", ".", "grid", ".", "actions", ".", "clear_globals_reload_modules", "(", ")", "# Create new grid", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "GridActionNewMsg", ",", "shape", "=", "shape", ")", "# Update TableChoiceIntCtrl", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "ResizeGridMsg", ",", "shape", "=", "shape", ")", "if", "is_gtk", "(", ")", ":", "try", ":", "wx", ".", "Yield", "(", ")", "except", ":", "pass", "self", ".", "main_window", ".", "grid", ".", "actions", ".", "change_grid_shape", "(", "shape", ")", "self", ".", "main_window", ".", "grid", ".", "GetTable", "(", ")", ".", "ResetView", "(", ")", "self", ".", "main_window", ".", "grid", ".", "ForceRefresh", "(", ")", "# Display grid creation in status bar", "msg", "=", "_", "(", "\"New grid with dimensions {dim} created.\"", ")", ".", "format", "(", "dim", "=", "shape", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "StatusBarMsg", ",", "text", "=", "msg", ")", "self", ".", "main_window", ".", "grid", ".", "ForceRefresh", "(", ")", "if", "is_gtk", "(", ")", ":", "try", ":", "wx", ".", "Yield", "(", ")", "except", ":", "pass", "# Update undo stack savepoint and clear undo stack", "undo", ".", "stack", "(", ")", ".", "clear", "(", ")", "undo", ".", "stack", "(", ")", ".", "savepoint", "(", ")", "# Update content changed state", "try", ":", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ContentChangedMsg", ")", "except", "TypeError", ":", "# The main window does not exist any more", "pass" ]
New grid event handler
[ "New", "grid", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L757-L830
236,547
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnOpen
def OnOpen(self, event): """File open event handler""" # If changes have taken place save of old grid if undo.stack().haschanged(): save_choice = self.interfaces.get_save_request_from_user() if save_choice is None: # Cancelled close operation return elif save_choice: # User wants to save content post_command_event(self.main_window, self.main_window.SaveMsg) # Get filepath from user f2w = get_filetypes2wildcards( ["pys", "pysu", "xls", "xlsx", "ods", "all"]) filetypes = f2w.keys() wildcards = f2w.values() wildcard = "|".join(wildcards) message = _("Choose file to open.") style = wx.OPEN default_filetype = config["default_open_filetype"] try: default_filterindex = filetypes.index(default_filetype) except ValueError: # Be graceful if the user has entered an unkown filetype default_filterindex = 0 get_fp_fidx = self.interfaces.get_filepath_findex_from_user filepath, filterindex = get_fp_fidx(wildcard, message, style, filterindex=default_filterindex) if filepath is None: return filetype = filetypes[filterindex] # Change the main window filepath state self.main_window.filepath = filepath # Load file into grid post_command_event(self.main_window, self.main_window.GridActionOpenMsg, attr={"filepath": filepath, "filetype": filetype}) # Set Window title to new filepath title_text = filepath.split("/")[-1] + " - pyspread" post_command_event(self.main_window, self.main_window.TitleMsg, text=title_text) self.main_window.grid.ForceRefresh() if is_gtk(): try: wx.Yield() except: pass # Update savepoint and clear the undo stack undo.stack().clear() undo.stack().savepoint() # Update content changed state try: post_command_event(self.main_window, self.ContentChangedMsg) except TypeError: # The main window does not exist any more pass
python
def OnOpen(self, event): """File open event handler""" # If changes have taken place save of old grid if undo.stack().haschanged(): save_choice = self.interfaces.get_save_request_from_user() if save_choice is None: # Cancelled close operation return elif save_choice: # User wants to save content post_command_event(self.main_window, self.main_window.SaveMsg) # Get filepath from user f2w = get_filetypes2wildcards( ["pys", "pysu", "xls", "xlsx", "ods", "all"]) filetypes = f2w.keys() wildcards = f2w.values() wildcard = "|".join(wildcards) message = _("Choose file to open.") style = wx.OPEN default_filetype = config["default_open_filetype"] try: default_filterindex = filetypes.index(default_filetype) except ValueError: # Be graceful if the user has entered an unkown filetype default_filterindex = 0 get_fp_fidx = self.interfaces.get_filepath_findex_from_user filepath, filterindex = get_fp_fidx(wildcard, message, style, filterindex=default_filterindex) if filepath is None: return filetype = filetypes[filterindex] # Change the main window filepath state self.main_window.filepath = filepath # Load file into grid post_command_event(self.main_window, self.main_window.GridActionOpenMsg, attr={"filepath": filepath, "filetype": filetype}) # Set Window title to new filepath title_text = filepath.split("/")[-1] + " - pyspread" post_command_event(self.main_window, self.main_window.TitleMsg, text=title_text) self.main_window.grid.ForceRefresh() if is_gtk(): try: wx.Yield() except: pass # Update savepoint and clear the undo stack undo.stack().clear() undo.stack().savepoint() # Update content changed state try: post_command_event(self.main_window, self.ContentChangedMsg) except TypeError: # The main window does not exist any more pass
[ "def", "OnOpen", "(", "self", ",", "event", ")", ":", "# If changes have taken place save of old grid", "if", "undo", ".", "stack", "(", ")", ".", "haschanged", "(", ")", ":", "save_choice", "=", "self", ".", "interfaces", ".", "get_save_request_from_user", "(", ")", "if", "save_choice", "is", "None", ":", "# Cancelled close operation", "return", "elif", "save_choice", ":", "# User wants to save content", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "SaveMsg", ")", "# Get filepath from user", "f2w", "=", "get_filetypes2wildcards", "(", "[", "\"pys\"", ",", "\"pysu\"", ",", "\"xls\"", ",", "\"xlsx\"", ",", "\"ods\"", ",", "\"all\"", "]", ")", "filetypes", "=", "f2w", ".", "keys", "(", ")", "wildcards", "=", "f2w", ".", "values", "(", ")", "wildcard", "=", "\"|\"", ".", "join", "(", "wildcards", ")", "message", "=", "_", "(", "\"Choose file to open.\"", ")", "style", "=", "wx", ".", "OPEN", "default_filetype", "=", "config", "[", "\"default_open_filetype\"", "]", "try", ":", "default_filterindex", "=", "filetypes", ".", "index", "(", "default_filetype", ")", "except", "ValueError", ":", "# Be graceful if the user has entered an unkown filetype", "default_filterindex", "=", "0", "get_fp_fidx", "=", "self", ".", "interfaces", ".", "get_filepath_findex_from_user", "filepath", ",", "filterindex", "=", "get_fp_fidx", "(", "wildcard", ",", "message", ",", "style", ",", "filterindex", "=", "default_filterindex", ")", "if", "filepath", "is", "None", ":", "return", "filetype", "=", "filetypes", "[", "filterindex", "]", "# Change the main window filepath state", "self", ".", "main_window", ".", "filepath", "=", "filepath", "# Load file into grid", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "GridActionOpenMsg", ",", "attr", "=", "{", "\"filepath\"", ":", "filepath", ",", "\"filetype\"", ":", "filetype", "}", ")", "# Set Window title to new filepath", "title_text", "=", "filepath", ".", "split", "(", "\"/\"", ")", "[", "-", "1", "]", "+", "\" - pyspread\"", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "TitleMsg", ",", "text", "=", "title_text", ")", "self", ".", "main_window", ".", "grid", ".", "ForceRefresh", "(", ")", "if", "is_gtk", "(", ")", ":", "try", ":", "wx", ".", "Yield", "(", ")", "except", ":", "pass", "# Update savepoint and clear the undo stack", "undo", ".", "stack", "(", ")", ".", "clear", "(", ")", "undo", ".", "stack", "(", ")", ".", "savepoint", "(", ")", "# Update content changed state", "try", ":", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ContentChangedMsg", ")", "except", "TypeError", ":", "# The main window does not exist any more", "pass" ]
File open event handler
[ "File", "open", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L832-L905
236,548
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnSave
def OnSave(self, event): """File save event handler""" try: filetype = event.attr["filetype"] except (KeyError, AttributeError): filetype = None filepath = self.main_window.filepath if filepath is None: filetype = config["default_save_filetype"] if filetype is None: f2w = get_filetypes2wildcards(["pys", "pysu", "xls", "all"]) __filetypes = f2w.keys() # Check if the file extension matches any valid save filetype for __filetype in __filetypes: if splitext(filepath)[-1][1:] == __filetype: filetype = __filetype break # If there is no filepath or no filetype is found then jump to save as if self.main_window.filepath is None or filetype is None: post_command_event(self.main_window, self.main_window.SaveAsMsg) return # Save the grid post_command_event(self.main_window, self.main_window.GridActionSaveMsg, attr={"filepath": self.main_window.filepath, "filetype": filetype}) # Update undo stack savepoint undo.stack().savepoint() # Display file save in status bar statustext = self.main_window.filepath.split("/")[-1] + " saved." post_command_event(self.main_window, self.main_window.StatusBarMsg, text=statustext)
python
def OnSave(self, event): """File save event handler""" try: filetype = event.attr["filetype"] except (KeyError, AttributeError): filetype = None filepath = self.main_window.filepath if filepath is None: filetype = config["default_save_filetype"] if filetype is None: f2w = get_filetypes2wildcards(["pys", "pysu", "xls", "all"]) __filetypes = f2w.keys() # Check if the file extension matches any valid save filetype for __filetype in __filetypes: if splitext(filepath)[-1][1:] == __filetype: filetype = __filetype break # If there is no filepath or no filetype is found then jump to save as if self.main_window.filepath is None or filetype is None: post_command_event(self.main_window, self.main_window.SaveAsMsg) return # Save the grid post_command_event(self.main_window, self.main_window.GridActionSaveMsg, attr={"filepath": self.main_window.filepath, "filetype": filetype}) # Update undo stack savepoint undo.stack().savepoint() # Display file save in status bar statustext = self.main_window.filepath.split("/")[-1] + " saved." post_command_event(self.main_window, self.main_window.StatusBarMsg, text=statustext)
[ "def", "OnSave", "(", "self", ",", "event", ")", ":", "try", ":", "filetype", "=", "event", ".", "attr", "[", "\"filetype\"", "]", "except", "(", "KeyError", ",", "AttributeError", ")", ":", "filetype", "=", "None", "filepath", "=", "self", ".", "main_window", ".", "filepath", "if", "filepath", "is", "None", ":", "filetype", "=", "config", "[", "\"default_save_filetype\"", "]", "if", "filetype", "is", "None", ":", "f2w", "=", "get_filetypes2wildcards", "(", "[", "\"pys\"", ",", "\"pysu\"", ",", "\"xls\"", ",", "\"all\"", "]", ")", "__filetypes", "=", "f2w", ".", "keys", "(", ")", "# Check if the file extension matches any valid save filetype", "for", "__filetype", "in", "__filetypes", ":", "if", "splitext", "(", "filepath", ")", "[", "-", "1", "]", "[", "1", ":", "]", "==", "__filetype", ":", "filetype", "=", "__filetype", "break", "# If there is no filepath or no filetype is found then jump to save as", "if", "self", ".", "main_window", ".", "filepath", "is", "None", "or", "filetype", "is", "None", ":", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "SaveAsMsg", ")", "return", "# Save the grid", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "GridActionSaveMsg", ",", "attr", "=", "{", "\"filepath\"", ":", "self", ".", "main_window", ".", "filepath", ",", "\"filetype\"", ":", "filetype", "}", ")", "# Update undo stack savepoint", "undo", ".", "stack", "(", ")", ".", "savepoint", "(", ")", "# Display file save in status bar", "statustext", "=", "self", ".", "main_window", ".", "filepath", ".", "split", "(", "\"/\"", ")", "[", "-", "1", "]", "+", "\" saved.\"", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "StatusBarMsg", ",", "text", "=", "statustext", ")" ]
File save event handler
[ "File", "save", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L908-L954
236,549
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnSaveAs
def OnSaveAs(self, event): """File save as event handler""" # Get filepath from user f2w = get_filetypes2wildcards(["pys", "pysu", "xls", "all"]) filetypes = f2w.keys() wildcards = f2w.values() wildcard = "|".join(wildcards) message = _("Choose filename for saving.") style = wx.SAVE default_filetype = config["default_save_filetype"] try: default_filterindex = filetypes.index(default_filetype) except ValueError: # Be graceful if the user has entered an unkown filetype default_filterindex = 0 get_fp_fidx = self.interfaces.get_filepath_findex_from_user filepath, filterindex = get_fp_fidx(wildcard, message, style, filterindex=default_filterindex) if filepath is None: return 0 filetype = filetypes[filterindex] # Look if path is already present if os.path.exists(filepath): if not os.path.isfile(filepath): # There is a directory with the same path statustext = _("Directory present. Save aborted.") post_command_event(self.main_window, self.main_window.StatusBarMsg, text=statustext) return 0 # There is a file with the same path message = \ _("The file {filepath} is already present.\nOverwrite?")\ .format(filepath=filepath) short_msg = _("File collision") if not self.main_window.interfaces.get_warning_choice(message, short_msg): statustext = _("File present. Save aborted by user.") post_command_event(self.main_window, self.main_window.StatusBarMsg, text=statustext) return 0 # Put pys suffix if wildcard choice is 0 if filterindex == 0 and filepath[-4:] != ".pys": filepath += ".pys" # Set the filepath state self.main_window.filepath = filepath # Set Window title to new filepath title_text = filepath.split("/")[-1] + " - pyspread" post_command_event(self.main_window, self.main_window.TitleMsg, text=title_text) # Now jump to save post_command_event(self.main_window, self.main_window.SaveMsg, attr={"filetype": filetype})
python
def OnSaveAs(self, event): """File save as event handler""" # Get filepath from user f2w = get_filetypes2wildcards(["pys", "pysu", "xls", "all"]) filetypes = f2w.keys() wildcards = f2w.values() wildcard = "|".join(wildcards) message = _("Choose filename for saving.") style = wx.SAVE default_filetype = config["default_save_filetype"] try: default_filterindex = filetypes.index(default_filetype) except ValueError: # Be graceful if the user has entered an unkown filetype default_filterindex = 0 get_fp_fidx = self.interfaces.get_filepath_findex_from_user filepath, filterindex = get_fp_fidx(wildcard, message, style, filterindex=default_filterindex) if filepath is None: return 0 filetype = filetypes[filterindex] # Look if path is already present if os.path.exists(filepath): if not os.path.isfile(filepath): # There is a directory with the same path statustext = _("Directory present. Save aborted.") post_command_event(self.main_window, self.main_window.StatusBarMsg, text=statustext) return 0 # There is a file with the same path message = \ _("The file {filepath} is already present.\nOverwrite?")\ .format(filepath=filepath) short_msg = _("File collision") if not self.main_window.interfaces.get_warning_choice(message, short_msg): statustext = _("File present. Save aborted by user.") post_command_event(self.main_window, self.main_window.StatusBarMsg, text=statustext) return 0 # Put pys suffix if wildcard choice is 0 if filterindex == 0 and filepath[-4:] != ".pys": filepath += ".pys" # Set the filepath state self.main_window.filepath = filepath # Set Window title to new filepath title_text = filepath.split("/")[-1] + " - pyspread" post_command_event(self.main_window, self.main_window.TitleMsg, text=title_text) # Now jump to save post_command_event(self.main_window, self.main_window.SaveMsg, attr={"filetype": filetype})
[ "def", "OnSaveAs", "(", "self", ",", "event", ")", ":", "# Get filepath from user", "f2w", "=", "get_filetypes2wildcards", "(", "[", "\"pys\"", ",", "\"pysu\"", ",", "\"xls\"", ",", "\"all\"", "]", ")", "filetypes", "=", "f2w", ".", "keys", "(", ")", "wildcards", "=", "f2w", ".", "values", "(", ")", "wildcard", "=", "\"|\"", ".", "join", "(", "wildcards", ")", "message", "=", "_", "(", "\"Choose filename for saving.\"", ")", "style", "=", "wx", ".", "SAVE", "default_filetype", "=", "config", "[", "\"default_save_filetype\"", "]", "try", ":", "default_filterindex", "=", "filetypes", ".", "index", "(", "default_filetype", ")", "except", "ValueError", ":", "# Be graceful if the user has entered an unkown filetype", "default_filterindex", "=", "0", "get_fp_fidx", "=", "self", ".", "interfaces", ".", "get_filepath_findex_from_user", "filepath", ",", "filterindex", "=", "get_fp_fidx", "(", "wildcard", ",", "message", ",", "style", ",", "filterindex", "=", "default_filterindex", ")", "if", "filepath", "is", "None", ":", "return", "0", "filetype", "=", "filetypes", "[", "filterindex", "]", "# Look if path is already present", "if", "os", ".", "path", ".", "exists", "(", "filepath", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "filepath", ")", ":", "# There is a directory with the same path", "statustext", "=", "_", "(", "\"Directory present. Save aborted.\"", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "StatusBarMsg", ",", "text", "=", "statustext", ")", "return", "0", "# There is a file with the same path", "message", "=", "_", "(", "\"The file {filepath} is already present.\\nOverwrite?\"", ")", ".", "format", "(", "filepath", "=", "filepath", ")", "short_msg", "=", "_", "(", "\"File collision\"", ")", "if", "not", "self", ".", "main_window", ".", "interfaces", ".", "get_warning_choice", "(", "message", ",", "short_msg", ")", ":", "statustext", "=", "_", "(", "\"File present. Save aborted by user.\"", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "StatusBarMsg", ",", "text", "=", "statustext", ")", "return", "0", "# Put pys suffix if wildcard choice is 0", "if", "filterindex", "==", "0", "and", "filepath", "[", "-", "4", ":", "]", "!=", "\".pys\"", ":", "filepath", "+=", "\".pys\"", "# Set the filepath state", "self", ".", "main_window", ".", "filepath", "=", "filepath", "# Set Window title to new filepath", "title_text", "=", "filepath", ".", "split", "(", "\"/\"", ")", "[", "-", "1", "]", "+", "\" - pyspread\"", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "TitleMsg", ",", "text", "=", "title_text", ")", "# Now jump to save", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "SaveMsg", ",", "attr", "=", "{", "\"filetype\"", ":", "filetype", "}", ")" ]
File save as event handler
[ "File", "save", "as", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L956-L1025
236,550
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnImport
def OnImport(self, event): """File import event handler""" # Get filepath from user wildcards = get_filetypes2wildcards(["csv", "txt"]).values() wildcard = "|".join(wildcards) message = _("Choose file to import.") style = wx.OPEN filepath, filterindex = \ self.interfaces.get_filepath_findex_from_user(wildcard, message, style) if filepath is None: return # Get generator of import data import_data = self.main_window.actions.import_file(filepath, filterindex) if import_data is None: return # Paste import data to grid grid = self.main_window.grid tl_cell = grid.GetGridCursorRow(), grid.GetGridCursorCol() grid.actions.paste(tl_cell, import_data) self.main_window.grid.ForceRefresh()
python
def OnImport(self, event): """File import event handler""" # Get filepath from user wildcards = get_filetypes2wildcards(["csv", "txt"]).values() wildcard = "|".join(wildcards) message = _("Choose file to import.") style = wx.OPEN filepath, filterindex = \ self.interfaces.get_filepath_findex_from_user(wildcard, message, style) if filepath is None: return # Get generator of import data import_data = self.main_window.actions.import_file(filepath, filterindex) if import_data is None: return # Paste import data to grid grid = self.main_window.grid tl_cell = grid.GetGridCursorRow(), grid.GetGridCursorCol() grid.actions.paste(tl_cell, import_data) self.main_window.grid.ForceRefresh()
[ "def", "OnImport", "(", "self", ",", "event", ")", ":", "# Get filepath from user", "wildcards", "=", "get_filetypes2wildcards", "(", "[", "\"csv\"", ",", "\"txt\"", "]", ")", ".", "values", "(", ")", "wildcard", "=", "\"|\"", ".", "join", "(", "wildcards", ")", "message", "=", "_", "(", "\"Choose file to import.\"", ")", "style", "=", "wx", ".", "OPEN", "filepath", ",", "filterindex", "=", "self", ".", "interfaces", ".", "get_filepath_findex_from_user", "(", "wildcard", ",", "message", ",", "style", ")", "if", "filepath", "is", "None", ":", "return", "# Get generator of import data", "import_data", "=", "self", ".", "main_window", ".", "actions", ".", "import_file", "(", "filepath", ",", "filterindex", ")", "if", "import_data", "is", "None", ":", "return", "# Paste import data to grid", "grid", "=", "self", ".", "main_window", ".", "grid", "tl_cell", "=", "grid", ".", "GetGridCursorRow", "(", ")", ",", "grid", ".", "GetGridCursorCol", "(", ")", "grid", ".", "actions", ".", "paste", "(", "tl_cell", ",", "import_data", ")", "self", ".", "main_window", ".", "grid", ".", "ForceRefresh", "(", ")" ]
File import event handler
[ "File", "import", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1027-L1057
236,551
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnExport
def OnExport(self, event): """File export event handler Currently, only CSV export is supported """ code_array = self.main_window.grid.code_array tab = self.main_window.grid.current_table selection = self.main_window.grid.selection # Check if no selection is present selection_bbox = selection.get_bbox() f2w = get_filetypes2wildcards(["csv", "pdf", "svg"]) filters = f2w.keys() wildcards = f2w.values() wildcard = "|".join(wildcards) if selection_bbox is None: # No selection --> Use smallest filled area for bottom right edge maxrow, maxcol, __ = code_array.get_last_filled_cell(tab) (top, left), (bottom, right) = (0, 0), (maxrow, maxcol) else: (top, left), (bottom, right) = selection_bbox # Generator of row and column keys in correct order __top = 0 if top is None else top __bottom = code_array.shape[0] if bottom is None else bottom + 1 __left = 0 if left is None else left __right = code_array.shape[1] if right is None else right + 1 def data_gen(top, bottom, left, right): for row in xrange(top, bottom): yield (code_array[row, col, tab] for col in xrange(left, right)) data = data_gen(__top, __bottom, __left, __right) preview_data = data_gen(__top, __bottom, __left, __right) # Get target filepath from user # No selection --> Provide svg export of current cell # if current cell is a matplotlib figure if selection_bbox is None: cursor = self.main_window.grid.actions.cursor figure = code_array[cursor] if Figure is not None and isinstance(figure, Figure): wildcard += \ "|" + _("SVG of current cell") + " (*.svg)|*.svg" + \ "|" + _("EPS of current cell") + " (*.eps)|*.eps" + \ "|" + _("PS of current cell") + " (*.ps)|*.ps" + \ "|" + _("PDF of current cell") + " (*.pdf)|*.pdf" + \ "|" + _("PNG of current cell") + " (*.png)|*.png" filters.append("cell_svg") filters.append("cell_eps") filters.append("cell_ps") filters.append("cell_pdf") filters.append("cell_png") message = _("Choose filename for export.") style = wx.SAVE path, filterindex = \ self.interfaces.get_filepath_findex_from_user(wildcard, message, style) if path is None: return # If an single cell is exported then the selection bbox # has to be changed to the current cell if filters[filterindex].startswith("cell_"): data = figure # Export file # ----------- self.main_window.actions.export_file(path, filters[filterindex], data, preview_data)
python
def OnExport(self, event): """File export event handler Currently, only CSV export is supported """ code_array = self.main_window.grid.code_array tab = self.main_window.grid.current_table selection = self.main_window.grid.selection # Check if no selection is present selection_bbox = selection.get_bbox() f2w = get_filetypes2wildcards(["csv", "pdf", "svg"]) filters = f2w.keys() wildcards = f2w.values() wildcard = "|".join(wildcards) if selection_bbox is None: # No selection --> Use smallest filled area for bottom right edge maxrow, maxcol, __ = code_array.get_last_filled_cell(tab) (top, left), (bottom, right) = (0, 0), (maxrow, maxcol) else: (top, left), (bottom, right) = selection_bbox # Generator of row and column keys in correct order __top = 0 if top is None else top __bottom = code_array.shape[0] if bottom is None else bottom + 1 __left = 0 if left is None else left __right = code_array.shape[1] if right is None else right + 1 def data_gen(top, bottom, left, right): for row in xrange(top, bottom): yield (code_array[row, col, tab] for col in xrange(left, right)) data = data_gen(__top, __bottom, __left, __right) preview_data = data_gen(__top, __bottom, __left, __right) # Get target filepath from user # No selection --> Provide svg export of current cell # if current cell is a matplotlib figure if selection_bbox is None: cursor = self.main_window.grid.actions.cursor figure = code_array[cursor] if Figure is not None and isinstance(figure, Figure): wildcard += \ "|" + _("SVG of current cell") + " (*.svg)|*.svg" + \ "|" + _("EPS of current cell") + " (*.eps)|*.eps" + \ "|" + _("PS of current cell") + " (*.ps)|*.ps" + \ "|" + _("PDF of current cell") + " (*.pdf)|*.pdf" + \ "|" + _("PNG of current cell") + " (*.png)|*.png" filters.append("cell_svg") filters.append("cell_eps") filters.append("cell_ps") filters.append("cell_pdf") filters.append("cell_png") message = _("Choose filename for export.") style = wx.SAVE path, filterindex = \ self.interfaces.get_filepath_findex_from_user(wildcard, message, style) if path is None: return # If an single cell is exported then the selection bbox # has to be changed to the current cell if filters[filterindex].startswith("cell_"): data = figure # Export file # ----------- self.main_window.actions.export_file(path, filters[filterindex], data, preview_data)
[ "def", "OnExport", "(", "self", ",", "event", ")", ":", "code_array", "=", "self", ".", "main_window", ".", "grid", ".", "code_array", "tab", "=", "self", ".", "main_window", ".", "grid", ".", "current_table", "selection", "=", "self", ".", "main_window", ".", "grid", ".", "selection", "# Check if no selection is present", "selection_bbox", "=", "selection", ".", "get_bbox", "(", ")", "f2w", "=", "get_filetypes2wildcards", "(", "[", "\"csv\"", ",", "\"pdf\"", ",", "\"svg\"", "]", ")", "filters", "=", "f2w", ".", "keys", "(", ")", "wildcards", "=", "f2w", ".", "values", "(", ")", "wildcard", "=", "\"|\"", ".", "join", "(", "wildcards", ")", "if", "selection_bbox", "is", "None", ":", "# No selection --> Use smallest filled area for bottom right edge", "maxrow", ",", "maxcol", ",", "__", "=", "code_array", ".", "get_last_filled_cell", "(", "tab", ")", "(", "top", ",", "left", ")", ",", "(", "bottom", ",", "right", ")", "=", "(", "0", ",", "0", ")", ",", "(", "maxrow", ",", "maxcol", ")", "else", ":", "(", "top", ",", "left", ")", ",", "(", "bottom", ",", "right", ")", "=", "selection_bbox", "# Generator of row and column keys in correct order", "__top", "=", "0", "if", "top", "is", "None", "else", "top", "__bottom", "=", "code_array", ".", "shape", "[", "0", "]", "if", "bottom", "is", "None", "else", "bottom", "+", "1", "__left", "=", "0", "if", "left", "is", "None", "else", "left", "__right", "=", "code_array", ".", "shape", "[", "1", "]", "if", "right", "is", "None", "else", "right", "+", "1", "def", "data_gen", "(", "top", ",", "bottom", ",", "left", ",", "right", ")", ":", "for", "row", "in", "xrange", "(", "top", ",", "bottom", ")", ":", "yield", "(", "code_array", "[", "row", ",", "col", ",", "tab", "]", "for", "col", "in", "xrange", "(", "left", ",", "right", ")", ")", "data", "=", "data_gen", "(", "__top", ",", "__bottom", ",", "__left", ",", "__right", ")", "preview_data", "=", "data_gen", "(", "__top", ",", "__bottom", ",", "__left", ",", "__right", ")", "# Get target filepath from user", "# No selection --> Provide svg export of current cell", "# if current cell is a matplotlib figure", "if", "selection_bbox", "is", "None", ":", "cursor", "=", "self", ".", "main_window", ".", "grid", ".", "actions", ".", "cursor", "figure", "=", "code_array", "[", "cursor", "]", "if", "Figure", "is", "not", "None", "and", "isinstance", "(", "figure", ",", "Figure", ")", ":", "wildcard", "+=", "\"|\"", "+", "_", "(", "\"SVG of current cell\"", ")", "+", "\" (*.svg)|*.svg\"", "+", "\"|\"", "+", "_", "(", "\"EPS of current cell\"", ")", "+", "\" (*.eps)|*.eps\"", "+", "\"|\"", "+", "_", "(", "\"PS of current cell\"", ")", "+", "\" (*.ps)|*.ps\"", "+", "\"|\"", "+", "_", "(", "\"PDF of current cell\"", ")", "+", "\" (*.pdf)|*.pdf\"", "+", "\"|\"", "+", "_", "(", "\"PNG of current cell\"", ")", "+", "\" (*.png)|*.png\"", "filters", ".", "append", "(", "\"cell_svg\"", ")", "filters", ".", "append", "(", "\"cell_eps\"", ")", "filters", ".", "append", "(", "\"cell_ps\"", ")", "filters", ".", "append", "(", "\"cell_pdf\"", ")", "filters", ".", "append", "(", "\"cell_png\"", ")", "message", "=", "_", "(", "\"Choose filename for export.\"", ")", "style", "=", "wx", ".", "SAVE", "path", ",", "filterindex", "=", "self", ".", "interfaces", ".", "get_filepath_findex_from_user", "(", "wildcard", ",", "message", ",", "style", ")", "if", "path", "is", "None", ":", "return", "# If an single cell is exported then the selection bbox", "# has to be changed to the current cell", "if", "filters", "[", "filterindex", "]", ".", "startswith", "(", "\"cell_\"", ")", ":", "data", "=", "figure", "# Export file", "# -----------", "self", ".", "main_window", ".", "actions", ".", "export_file", "(", "path", ",", "filters", "[", "filterindex", "]", ",", "data", ",", "preview_data", ")" ]
File export event handler Currently, only CSV export is supported
[ "File", "export", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1059-L1143
236,552
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnExportPDF
def OnExportPDF(self, event): """Export PDF event handler""" wildcards = get_filetypes2wildcards(["pdf"]).values() if not wildcards: return wildcard = "|".join(wildcards) # Get filepath from user message = _("Choose file path for PDF export.") style = wx.SAVE filepath, filterindex = \ self.interfaces.get_filepath_findex_from_user(wildcard, message, style) if filepath is None: return self.main_window.actions.export_cairo(filepath, "pdf") event.Skip()
python
def OnExportPDF(self, event): """Export PDF event handler""" wildcards = get_filetypes2wildcards(["pdf"]).values() if not wildcards: return wildcard = "|".join(wildcards) # Get filepath from user message = _("Choose file path for PDF export.") style = wx.SAVE filepath, filterindex = \ self.interfaces.get_filepath_findex_from_user(wildcard, message, style) if filepath is None: return self.main_window.actions.export_cairo(filepath, "pdf") event.Skip()
[ "def", "OnExportPDF", "(", "self", ",", "event", ")", ":", "wildcards", "=", "get_filetypes2wildcards", "(", "[", "\"pdf\"", "]", ")", ".", "values", "(", ")", "if", "not", "wildcards", ":", "return", "wildcard", "=", "\"|\"", ".", "join", "(", "wildcards", ")", "# Get filepath from user", "message", "=", "_", "(", "\"Choose file path for PDF export.\"", ")", "style", "=", "wx", ".", "SAVE", "filepath", ",", "filterindex", "=", "self", ".", "interfaces", ".", "get_filepath_findex_from_user", "(", "wildcard", ",", "message", ",", "style", ")", "if", "filepath", "is", "None", ":", "return", "self", ".", "main_window", ".", "actions", ".", "export_cairo", "(", "filepath", ",", "\"pdf\"", ")", "event", ".", "Skip", "(", ")" ]
Export PDF event handler
[ "Export", "PDF", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1145-L1168
236,553
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnApprove
def OnApprove(self, event): """File approve event handler""" if not self.main_window.safe_mode: return msg = _(u"You are going to approve and trust a file that\n" u"you have not created yourself.\n" u"After proceeding, the file is executed.\n \n" u"It may harm your system as any program can.\n" u"Please check all cells thoroughly before\nproceeding.\n \n" u"Proceed and sign this file as trusted?") short_msg = _("Security warning") if self.main_window.interfaces.get_warning_choice(msg, short_msg): # Leave safe mode self.main_window.grid.actions.leave_safe_mode() # Display safe mode end in status bar statustext = _("Safe mode deactivated.") post_command_event(self.main_window, self.main_window.StatusBarMsg, text=statustext)
python
def OnApprove(self, event): """File approve event handler""" if not self.main_window.safe_mode: return msg = _(u"You are going to approve and trust a file that\n" u"you have not created yourself.\n" u"After proceeding, the file is executed.\n \n" u"It may harm your system as any program can.\n" u"Please check all cells thoroughly before\nproceeding.\n \n" u"Proceed and sign this file as trusted?") short_msg = _("Security warning") if self.main_window.interfaces.get_warning_choice(msg, short_msg): # Leave safe mode self.main_window.grid.actions.leave_safe_mode() # Display safe mode end in status bar statustext = _("Safe mode deactivated.") post_command_event(self.main_window, self.main_window.StatusBarMsg, text=statustext)
[ "def", "OnApprove", "(", "self", ",", "event", ")", ":", "if", "not", "self", ".", "main_window", ".", "safe_mode", ":", "return", "msg", "=", "_", "(", "u\"You are going to approve and trust a file that\\n\"", "u\"you have not created yourself.\\n\"", "u\"After proceeding, the file is executed.\\n \\n\"", "u\"It may harm your system as any program can.\\n\"", "u\"Please check all cells thoroughly before\\nproceeding.\\n \\n\"", "u\"Proceed and sign this file as trusted?\"", ")", "short_msg", "=", "_", "(", "\"Security warning\"", ")", "if", "self", ".", "main_window", ".", "interfaces", ".", "get_warning_choice", "(", "msg", ",", "short_msg", ")", ":", "# Leave safe mode", "self", ".", "main_window", ".", "grid", ".", "actions", ".", "leave_safe_mode", "(", ")", "# Display safe mode end in status bar", "statustext", "=", "_", "(", "\"Safe mode deactivated.\"", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "StatusBarMsg", ",", "text", "=", "statustext", ")" ]
File approve event handler
[ "File", "approve", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1170-L1193
236,554
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnClearGlobals
def OnClearGlobals(self, event): """Clear globals event handler""" msg = _("Deleting globals and reloading modules cannot be undone." " Proceed?") short_msg = _("Really delete globals and modules?") choice = self.main_window.interfaces.get_warning_choice(msg, short_msg) if choice: self.main_window.grid.actions.clear_globals_reload_modules() statustext = _("Globals cleared and base modules reloaded.") post_command_event(self.main_window, self.main_window.StatusBarMsg, text=statustext)
python
def OnClearGlobals(self, event): """Clear globals event handler""" msg = _("Deleting globals and reloading modules cannot be undone." " Proceed?") short_msg = _("Really delete globals and modules?") choice = self.main_window.interfaces.get_warning_choice(msg, short_msg) if choice: self.main_window.grid.actions.clear_globals_reload_modules() statustext = _("Globals cleared and base modules reloaded.") post_command_event(self.main_window, self.main_window.StatusBarMsg, text=statustext)
[ "def", "OnClearGlobals", "(", "self", ",", "event", ")", ":", "msg", "=", "_", "(", "\"Deleting globals and reloading modules cannot be undone.\"", "\" Proceed?\"", ")", "short_msg", "=", "_", "(", "\"Really delete globals and modules?\"", ")", "choice", "=", "self", ".", "main_window", ".", "interfaces", ".", "get_warning_choice", "(", "msg", ",", "short_msg", ")", "if", "choice", ":", "self", ".", "main_window", ".", "grid", ".", "actions", ".", "clear_globals_reload_modules", "(", ")", "statustext", "=", "_", "(", "\"Globals cleared and base modules reloaded.\"", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "StatusBarMsg", ",", "text", "=", "statustext", ")" ]
Clear globals event handler
[ "Clear", "globals", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1195-L1209
236,555
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnPageSetup
def OnPageSetup(self, event): """Page setup handler for printing framework""" print_data = self.main_window.print_data new_print_data = \ self.main_window.interfaces.get_print_setup(print_data) self.main_window.print_data = new_print_data
python
def OnPageSetup(self, event): """Page setup handler for printing framework""" print_data = self.main_window.print_data new_print_data = \ self.main_window.interfaces.get_print_setup(print_data) self.main_window.print_data = new_print_data
[ "def", "OnPageSetup", "(", "self", ",", "event", ")", ":", "print_data", "=", "self", ".", "main_window", ".", "print_data", "new_print_data", "=", "self", ".", "main_window", ".", "interfaces", ".", "get_print_setup", "(", "print_data", ")", "self", ".", "main_window", ".", "print_data", "=", "new_print_data" ]
Page setup handler for printing framework
[ "Page", "setup", "handler", "for", "printing", "framework" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1213-L1219
236,556
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers._get_print_area
def _get_print_area(self): """Returns selection bounding box or visible area""" # Get print area from current selection selection = self.main_window.grid.selection print_area = selection.get_bbox() # If there is no selection use the visible area on the screen if print_area is None: print_area = self.main_window.grid.actions.get_visible_area() return print_area
python
def _get_print_area(self): """Returns selection bounding box or visible area""" # Get print area from current selection selection = self.main_window.grid.selection print_area = selection.get_bbox() # If there is no selection use the visible area on the screen if print_area is None: print_area = self.main_window.grid.actions.get_visible_area() return print_area
[ "def", "_get_print_area", "(", "self", ")", ":", "# Get print area from current selection", "selection", "=", "self", ".", "main_window", ".", "grid", ".", "selection", "print_area", "=", "selection", ".", "get_bbox", "(", ")", "# If there is no selection use the visible area on the screen", "if", "print_area", "is", "None", ":", "print_area", "=", "self", ".", "main_window", ".", "grid", ".", "actions", ".", "get_visible_area", "(", ")", "return", "print_area" ]
Returns selection bounding box or visible area
[ "Returns", "selection", "bounding", "box", "or", "visible", "area" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1221-L1232
236,557
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnPrintPreview
def OnPrintPreview(self, event): """Print preview handler""" print_area = self._get_print_area() print_data = self.main_window.print_data self.main_window.actions.print_preview(print_area, print_data)
python
def OnPrintPreview(self, event): """Print preview handler""" print_area = self._get_print_area() print_data = self.main_window.print_data self.main_window.actions.print_preview(print_area, print_data)
[ "def", "OnPrintPreview", "(", "self", ",", "event", ")", ":", "print_area", "=", "self", ".", "_get_print_area", "(", ")", "print_data", "=", "self", ".", "main_window", ".", "print_data", "self", ".", "main_window", ".", "actions", ".", "print_preview", "(", "print_area", ",", "print_data", ")" ]
Print preview handler
[ "Print", "preview", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1234-L1240
236,558
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnPrint
def OnPrint(self, event): """Print event handler""" print_area = self._get_print_area() print_data = self.main_window.print_data self.main_window.actions.printout(print_area, print_data)
python
def OnPrint(self, event): """Print event handler""" print_area = self._get_print_area() print_data = self.main_window.print_data self.main_window.actions.printout(print_area, print_data)
[ "def", "OnPrint", "(", "self", ",", "event", ")", ":", "print_area", "=", "self", ".", "_get_print_area", "(", ")", "print_data", "=", "self", ".", "main_window", ".", "print_data", "self", ".", "main_window", ".", "actions", ".", "printout", "(", "print_area", ",", "print_data", ")" ]
Print event handler
[ "Print", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1242-L1248
236,559
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnCut
def OnCut(self, event): """Clipboard cut event handler""" entry_line = \ self.main_window.entry_line_panel.entry_line_panel.entry_line if wx.Window.FindFocus() != entry_line: selection = self.main_window.grid.selection with undo.group(_("Cut")): data = self.main_window.actions.cut(selection) self.main_window.clipboard.set_clipboard(data) self.main_window.grid.ForceRefresh() else: entry_line.Cut() event.Skip()
python
def OnCut(self, event): """Clipboard cut event handler""" entry_line = \ self.main_window.entry_line_panel.entry_line_panel.entry_line if wx.Window.FindFocus() != entry_line: selection = self.main_window.grid.selection with undo.group(_("Cut")): data = self.main_window.actions.cut(selection) self.main_window.clipboard.set_clipboard(data) self.main_window.grid.ForceRefresh() else: entry_line.Cut() event.Skip()
[ "def", "OnCut", "(", "self", ",", "event", ")", ":", "entry_line", "=", "self", ".", "main_window", ".", "entry_line_panel", ".", "entry_line_panel", ".", "entry_line", "if", "wx", ".", "Window", ".", "FindFocus", "(", ")", "!=", "entry_line", ":", "selection", "=", "self", ".", "main_window", ".", "grid", ".", "selection", "with", "undo", ".", "group", "(", "_", "(", "\"Cut\"", ")", ")", ":", "data", "=", "self", ".", "main_window", ".", "actions", ".", "cut", "(", "selection", ")", "self", ".", "main_window", ".", "clipboard", ".", "set_clipboard", "(", "data", ")", "self", ".", "main_window", ".", "grid", ".", "ForceRefresh", "(", ")", "else", ":", "entry_line", ".", "Cut", "(", ")", "event", ".", "Skip", "(", ")" ]
Clipboard cut event handler
[ "Clipboard", "cut", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1252-L1271
236,560
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnCopy
def OnCopy(self, event): """Clipboard copy event handler""" focus = self.main_window.FindFocus() if isinstance(focus, wx.TextCtrl): # Copy selection from TextCtrl if in focus focus.Copy() else: selection = self.main_window.grid.selection data = self.main_window.actions.copy(selection) self.main_window.clipboard.set_clipboard(data) event.Skip()
python
def OnCopy(self, event): """Clipboard copy event handler""" focus = self.main_window.FindFocus() if isinstance(focus, wx.TextCtrl): # Copy selection from TextCtrl if in focus focus.Copy() else: selection = self.main_window.grid.selection data = self.main_window.actions.copy(selection) self.main_window.clipboard.set_clipboard(data) event.Skip()
[ "def", "OnCopy", "(", "self", ",", "event", ")", ":", "focus", "=", "self", ".", "main_window", ".", "FindFocus", "(", ")", "if", "isinstance", "(", "focus", ",", "wx", ".", "TextCtrl", ")", ":", "# Copy selection from TextCtrl if in focus", "focus", ".", "Copy", "(", ")", "else", ":", "selection", "=", "self", ".", "main_window", ".", "grid", ".", "selection", "data", "=", "self", ".", "main_window", ".", "actions", ".", "copy", "(", "selection", ")", "self", ".", "main_window", ".", "clipboard", ".", "set_clipboard", "(", "data", ")", "event", ".", "Skip", "(", ")" ]
Clipboard copy event handler
[ "Clipboard", "copy", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1273-L1287
236,561
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnCopyResult
def OnCopyResult(self, event): """Clipboard copy results event handler""" selection = self.main_window.grid.selection data = self.main_window.actions.copy_result(selection) # Check if result is a bitmap if type(data) is wx._gdi.Bitmap: # Copy bitmap to clipboard self.main_window.clipboard.set_clipboard(data, datatype="bitmap") else: # Copy string representation of result to clipboard self.main_window.clipboard.set_clipboard(data, datatype="text") event.Skip()
python
def OnCopyResult(self, event): """Clipboard copy results event handler""" selection = self.main_window.grid.selection data = self.main_window.actions.copy_result(selection) # Check if result is a bitmap if type(data) is wx._gdi.Bitmap: # Copy bitmap to clipboard self.main_window.clipboard.set_clipboard(data, datatype="bitmap") else: # Copy string representation of result to clipboard self.main_window.clipboard.set_clipboard(data, datatype="text") event.Skip()
[ "def", "OnCopyResult", "(", "self", ",", "event", ")", ":", "selection", "=", "self", ".", "main_window", ".", "grid", ".", "selection", "data", "=", "self", ".", "main_window", ".", "actions", ".", "copy_result", "(", "selection", ")", "# Check if result is a bitmap", "if", "type", "(", "data", ")", "is", "wx", ".", "_gdi", ".", "Bitmap", ":", "# Copy bitmap to clipboard", "self", ".", "main_window", ".", "clipboard", ".", "set_clipboard", "(", "data", ",", "datatype", "=", "\"bitmap\"", ")", "else", ":", "# Copy string representation of result to clipboard", "self", ".", "main_window", ".", "clipboard", ".", "set_clipboard", "(", "data", ",", "datatype", "=", "\"text\"", ")", "event", ".", "Skip", "(", ")" ]
Clipboard copy results event handler
[ "Clipboard", "copy", "results", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1289-L1305
236,562
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnPaste
def OnPaste(self, event): """Clipboard paste event handler""" data = self.main_window.clipboard.get_clipboard() focus = self.main_window.FindFocus() if isinstance(focus, wx.TextCtrl): # Paste into TextCtrl if in focus focus.WriteText(data) else: # We got a grid selection key = self.main_window.grid.actions.cursor with undo.group(_("Paste")): self.main_window.actions.paste(key, data) self.main_window.grid.ForceRefresh() event.Skip()
python
def OnPaste(self, event): """Clipboard paste event handler""" data = self.main_window.clipboard.get_clipboard() focus = self.main_window.FindFocus() if isinstance(focus, wx.TextCtrl): # Paste into TextCtrl if in focus focus.WriteText(data) else: # We got a grid selection key = self.main_window.grid.actions.cursor with undo.group(_("Paste")): self.main_window.actions.paste(key, data) self.main_window.grid.ForceRefresh() event.Skip()
[ "def", "OnPaste", "(", "self", ",", "event", ")", ":", "data", "=", "self", ".", "main_window", ".", "clipboard", ".", "get_clipboard", "(", ")", "focus", "=", "self", ".", "main_window", ".", "FindFocus", "(", ")", "if", "isinstance", "(", "focus", ",", "wx", ".", "TextCtrl", ")", ":", "# Paste into TextCtrl if in focus", "focus", ".", "WriteText", "(", "data", ")", "else", ":", "# We got a grid selection", "key", "=", "self", ".", "main_window", ".", "grid", ".", "actions", ".", "cursor", "with", "undo", ".", "group", "(", "_", "(", "\"Paste\"", ")", ")", ":", "self", ".", "main_window", ".", "actions", ".", "paste", "(", "key", ",", "data", ")", "self", ".", "main_window", ".", "grid", ".", "ForceRefresh", "(", ")", "event", ".", "Skip", "(", ")" ]
Clipboard paste event handler
[ "Clipboard", "paste", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1307-L1327
236,563
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnPasteAs
def OnPasteAs(self, event): """Clipboard paste as event handler""" data = self.main_window.clipboard.get_clipboard() key = self.main_window.grid.actions.cursor with undo.group(_("Paste As...")): self.main_window.actions.paste_as(key, data) self.main_window.grid.ForceRefresh() event.Skip()
python
def OnPasteAs(self, event): """Clipboard paste as event handler""" data = self.main_window.clipboard.get_clipboard() key = self.main_window.grid.actions.cursor with undo.group(_("Paste As...")): self.main_window.actions.paste_as(key, data) self.main_window.grid.ForceRefresh() event.Skip()
[ "def", "OnPasteAs", "(", "self", ",", "event", ")", ":", "data", "=", "self", ".", "main_window", ".", "clipboard", ".", "get_clipboard", "(", ")", "key", "=", "self", ".", "main_window", ".", "grid", ".", "actions", ".", "cursor", "with", "undo", ".", "group", "(", "_", "(", "\"Paste As...\"", ")", ")", ":", "self", ".", "main_window", ".", "actions", ".", "paste_as", "(", "key", ",", "data", ")", "self", ".", "main_window", ".", "grid", ".", "ForceRefresh", "(", ")", "event", ".", "Skip", "(", ")" ]
Clipboard paste as event handler
[ "Clipboard", "paste", "as", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1329-L1340
236,564
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnSelectAll
def OnSelectAll(self, event): """Select all cells event handler""" entry_line = \ self.main_window.entry_line_panel.entry_line_panel.entry_line if wx.Window.FindFocus() != entry_line: self.main_window.grid.SelectAll() else: entry_line.SelectAll()
python
def OnSelectAll(self, event): """Select all cells event handler""" entry_line = \ self.main_window.entry_line_panel.entry_line_panel.entry_line if wx.Window.FindFocus() != entry_line: self.main_window.grid.SelectAll() else: entry_line.SelectAll()
[ "def", "OnSelectAll", "(", "self", ",", "event", ")", ":", "entry_line", "=", "self", ".", "main_window", ".", "entry_line_panel", ".", "entry_line_panel", ".", "entry_line", "if", "wx", ".", "Window", ".", "FindFocus", "(", ")", "!=", "entry_line", ":", "self", ".", "main_window", ".", "grid", ".", "SelectAll", "(", ")", "else", ":", "entry_line", ".", "SelectAll", "(", ")" ]
Select all cells event handler
[ "Select", "all", "cells", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1343-L1353
236,565
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnFontDialog
def OnFontDialog(self, event): """Event handler for launching font dialog""" # Get current font data from current cell cursor = self.main_window.grid.actions.cursor attr = self.main_window.grid.code_array.cell_attributes[cursor] size, style, weight, font = \ [attr[name] for name in ["pointsize", "fontstyle", "fontweight", "textfont"]] current_font = wx.Font(int(size), -1, style, weight, 0, font) # Get Font from dialog fontdata = wx.FontData() fontdata.EnableEffects(True) fontdata.SetInitialFont(current_font) dlg = wx.FontDialog(self.main_window, fontdata) if dlg.ShowModal() == wx.ID_OK: fontdata = dlg.GetFontData() font = fontdata.GetChosenFont() post_command_event(self.main_window, self.main_window.FontMsg, font=font.FaceName) post_command_event(self.main_window, self.main_window.FontSizeMsg, size=font.GetPointSize()) post_command_event(self.main_window, self.main_window.FontBoldMsg, weight=font.GetWeightString()) post_command_event(self.main_window, self.main_window.FontItalicsMsg, style=font.GetStyleString()) if is_gtk(): try: wx.Yield() except: pass self.main_window.grid.update_attribute_toolbar()
python
def OnFontDialog(self, event): """Event handler for launching font dialog""" # Get current font data from current cell cursor = self.main_window.grid.actions.cursor attr = self.main_window.grid.code_array.cell_attributes[cursor] size, style, weight, font = \ [attr[name] for name in ["pointsize", "fontstyle", "fontweight", "textfont"]] current_font = wx.Font(int(size), -1, style, weight, 0, font) # Get Font from dialog fontdata = wx.FontData() fontdata.EnableEffects(True) fontdata.SetInitialFont(current_font) dlg = wx.FontDialog(self.main_window, fontdata) if dlg.ShowModal() == wx.ID_OK: fontdata = dlg.GetFontData() font = fontdata.GetChosenFont() post_command_event(self.main_window, self.main_window.FontMsg, font=font.FaceName) post_command_event(self.main_window, self.main_window.FontSizeMsg, size=font.GetPointSize()) post_command_event(self.main_window, self.main_window.FontBoldMsg, weight=font.GetWeightString()) post_command_event(self.main_window, self.main_window.FontItalicsMsg, style=font.GetStyleString()) if is_gtk(): try: wx.Yield() except: pass self.main_window.grid.update_attribute_toolbar()
[ "def", "OnFontDialog", "(", "self", ",", "event", ")", ":", "# Get current font data from current cell", "cursor", "=", "self", ".", "main_window", ".", "grid", ".", "actions", ".", "cursor", "attr", "=", "self", ".", "main_window", ".", "grid", ".", "code_array", ".", "cell_attributes", "[", "cursor", "]", "size", ",", "style", ",", "weight", ",", "font", "=", "[", "attr", "[", "name", "]", "for", "name", "in", "[", "\"pointsize\"", ",", "\"fontstyle\"", ",", "\"fontweight\"", ",", "\"textfont\"", "]", "]", "current_font", "=", "wx", ".", "Font", "(", "int", "(", "size", ")", ",", "-", "1", ",", "style", ",", "weight", ",", "0", ",", "font", ")", "# Get Font from dialog", "fontdata", "=", "wx", ".", "FontData", "(", ")", "fontdata", ".", "EnableEffects", "(", "True", ")", "fontdata", ".", "SetInitialFont", "(", "current_font", ")", "dlg", "=", "wx", ".", "FontDialog", "(", "self", ".", "main_window", ",", "fontdata", ")", "if", "dlg", ".", "ShowModal", "(", ")", "==", "wx", ".", "ID_OK", ":", "fontdata", "=", "dlg", ".", "GetFontData", "(", ")", "font", "=", "fontdata", ".", "GetChosenFont", "(", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "FontMsg", ",", "font", "=", "font", ".", "FaceName", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "FontSizeMsg", ",", "size", "=", "font", ".", "GetPointSize", "(", ")", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "FontBoldMsg", ",", "weight", "=", "font", ".", "GetWeightString", "(", ")", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "FontItalicsMsg", ",", "style", "=", "font", ".", "GetStyleString", "(", ")", ")", "if", "is_gtk", "(", ")", ":", "try", ":", "wx", ".", "Yield", "(", ")", "except", ":", "pass", "self", ".", "main_window", ".", "grid", ".", "update_attribute_toolbar", "(", ")" ]
Event handler for launching font dialog
[ "Event", "handler", "for", "launching", "font", "dialog" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1364-L1405
236,566
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnTextColorDialog
def OnTextColorDialog(self, event): """Event handler for launching text color dialog""" dlg = wx.ColourDialog(self.main_window) # Ensure the full colour dialog is displayed, # not the abbreviated version. dlg.GetColourData().SetChooseFull(True) if dlg.ShowModal() == wx.ID_OK: # Fetch color data data = dlg.GetColourData() color = data.GetColour().GetRGB() post_command_event(self.main_window, self.main_window.TextColorMsg, color=color) dlg.Destroy()
python
def OnTextColorDialog(self, event): """Event handler for launching text color dialog""" dlg = wx.ColourDialog(self.main_window) # Ensure the full colour dialog is displayed, # not the abbreviated version. dlg.GetColourData().SetChooseFull(True) if dlg.ShowModal() == wx.ID_OK: # Fetch color data data = dlg.GetColourData() color = data.GetColour().GetRGB() post_command_event(self.main_window, self.main_window.TextColorMsg, color=color) dlg.Destroy()
[ "def", "OnTextColorDialog", "(", "self", ",", "event", ")", ":", "dlg", "=", "wx", ".", "ColourDialog", "(", "self", ".", "main_window", ")", "# Ensure the full colour dialog is displayed,", "# not the abbreviated version.", "dlg", ".", "GetColourData", "(", ")", ".", "SetChooseFull", "(", "True", ")", "if", "dlg", ".", "ShowModal", "(", ")", "==", "wx", ".", "ID_OK", ":", "# Fetch color data", "data", "=", "dlg", ".", "GetColourData", "(", ")", "color", "=", "data", ".", "GetColour", "(", ")", ".", "GetRGB", "(", ")", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "TextColorMsg", ",", "color", "=", "color", ")", "dlg", ".", "Destroy", "(", ")" ]
Event handler for launching text color dialog
[ "Event", "handler", "for", "launching", "text", "color", "dialog" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1407-L1425
236,567
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnMacroListLoad
def OnMacroListLoad(self, event): """Macro list load event handler""" # Get filepath from user wildcards = get_filetypes2wildcards(["py", "all"]).values() wildcard = "|".join(wildcards) message = _("Choose macro file.") style = wx.OPEN filepath, filterindex = \ self.interfaces.get_filepath_findex_from_user(wildcard, message, style) if filepath is None: return # Enter safe mode because macro file could be harmful post_command_event(self.main_window, self.main_window.SafeModeEntryMsg) # Load macros from file self.main_window.actions.open_macros(filepath) event.Skip()
python
def OnMacroListLoad(self, event): """Macro list load event handler""" # Get filepath from user wildcards = get_filetypes2wildcards(["py", "all"]).values() wildcard = "|".join(wildcards) message = _("Choose macro file.") style = wx.OPEN filepath, filterindex = \ self.interfaces.get_filepath_findex_from_user(wildcard, message, style) if filepath is None: return # Enter safe mode because macro file could be harmful post_command_event(self.main_window, self.main_window.SafeModeEntryMsg) # Load macros from file self.main_window.actions.open_macros(filepath) event.Skip()
[ "def", "OnMacroListLoad", "(", "self", ",", "event", ")", ":", "# Get filepath from user", "wildcards", "=", "get_filetypes2wildcards", "(", "[", "\"py\"", ",", "\"all\"", "]", ")", ".", "values", "(", ")", "wildcard", "=", "\"|\"", ".", "join", "(", "wildcards", ")", "message", "=", "_", "(", "\"Choose macro file.\"", ")", "style", "=", "wx", ".", "OPEN", "filepath", ",", "filterindex", "=", "self", ".", "interfaces", ".", "get_filepath_findex_from_user", "(", "wildcard", ",", "message", ",", "style", ")", "if", "filepath", "is", "None", ":", "return", "# Enter safe mode because macro file could be harmful", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "main_window", ".", "SafeModeEntryMsg", ")", "# Load macros from file", "self", ".", "main_window", ".", "actions", ".", "open_macros", "(", "filepath", ")", "event", ".", "Skip", "(", ")" ]
Macro list load event handler
[ "Macro", "list", "load", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1460-L1487
236,568
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnMacroListSave
def OnMacroListSave(self, event): """Macro list save event handler""" # Get filepath from user wildcards = get_filetypes2wildcards(["py", "all"]).values() wildcard = "|".join(wildcards) message = _("Choose macro file.") style = wx.SAVE filepath, filterindex = \ self.interfaces.get_filepath_findex_from_user(wildcard, message, style) if filepath is None: return # Save macros to file macros = self.main_window.grid.code_array.macros self.main_window.actions.save_macros(filepath, macros) event.Skip()
python
def OnMacroListSave(self, event): """Macro list save event handler""" # Get filepath from user wildcards = get_filetypes2wildcards(["py", "all"]).values() wildcard = "|".join(wildcards) message = _("Choose macro file.") style = wx.SAVE filepath, filterindex = \ self.interfaces.get_filepath_findex_from_user(wildcard, message, style) if filepath is None: return # Save macros to file macros = self.main_window.grid.code_array.macros self.main_window.actions.save_macros(filepath, macros) event.Skip()
[ "def", "OnMacroListSave", "(", "self", ",", "event", ")", ":", "# Get filepath from user", "wildcards", "=", "get_filetypes2wildcards", "(", "[", "\"py\"", ",", "\"all\"", "]", ")", ".", "values", "(", ")", "wildcard", "=", "\"|\"", ".", "join", "(", "wildcards", ")", "message", "=", "_", "(", "\"Choose macro file.\"", ")", "style", "=", "wx", ".", "SAVE", "filepath", ",", "filterindex", "=", "self", ".", "interfaces", ".", "get_filepath_findex_from_user", "(", "wildcard", ",", "message", ",", "style", ")", "if", "filepath", "is", "None", ":", "return", "# Save macros to file", "macros", "=", "self", ".", "main_window", ".", "grid", ".", "code_array", ".", "macros", "self", ".", "main_window", ".", "actions", ".", "save_macros", "(", "filepath", ",", "macros", ")", "event", ".", "Skip", "(", ")" ]
Macro list save event handler
[ "Macro", "list", "save", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1489-L1513
236,569
manns/pyspread
pyspread/src/gui/_main_window.py
MainWindowEventHandlers.OnDependencies
def OnDependencies(self, event): """Display dependency dialog""" dlg = DependencyDialog(self.main_window) dlg.ShowModal() dlg.Destroy()
python
def OnDependencies(self, event): """Display dependency dialog""" dlg = DependencyDialog(self.main_window) dlg.ShowModal() dlg.Destroy()
[ "def", "OnDependencies", "(", "self", ",", "event", ")", ":", "dlg", "=", "DependencyDialog", "(", "self", ".", "main_window", ")", "dlg", ".", "ShowModal", "(", ")", "dlg", ".", "Destroy", "(", ")" ]
Display dependency dialog
[ "Display", "dependency", "dialog" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1540-L1545
236,570
manns/pyspread
pyspread/src/gui/_menubars.py
_filledMenu._add_submenu
def _add_submenu(self, parent, data): """Adds items in data as a submenu to parent""" for item in data: obj = item[0] if obj == wx.Menu: try: __, menuname, submenu, menu_id = item except ValueError: __, menuname, submenu = item menu_id = -1 menu = obj() self._add_submenu(menu, submenu) if parent == self: self.menubar.Append(menu, menuname) else: parent.AppendMenu(menu_id, menuname, menu) elif obj == wx.MenuItem: try: msgtype, shortcut, helptext, item_id = item[1] except ValueError: msgtype, shortcut, helptext = item[1] item_id = wx.NewId() try: style = item[2] except IndexError: style = wx.ITEM_NORMAL menuitem = obj(parent, item_id, shortcut, helptext, style) self.shortcut2menuitem[shortcut] = menuitem self.id2menuitem[item_id] = menuitem parent.AppendItem(menuitem) self.ids_msgs[item_id] = msgtype self.parent.Bind(wx.EVT_MENU, self.OnMenu, id=item_id) elif obj == "Separator": parent.AppendSeparator() else: raise TypeError(_("Menu item unknown"))
python
def _add_submenu(self, parent, data): """Adds items in data as a submenu to parent""" for item in data: obj = item[0] if obj == wx.Menu: try: __, menuname, submenu, menu_id = item except ValueError: __, menuname, submenu = item menu_id = -1 menu = obj() self._add_submenu(menu, submenu) if parent == self: self.menubar.Append(menu, menuname) else: parent.AppendMenu(menu_id, menuname, menu) elif obj == wx.MenuItem: try: msgtype, shortcut, helptext, item_id = item[1] except ValueError: msgtype, shortcut, helptext = item[1] item_id = wx.NewId() try: style = item[2] except IndexError: style = wx.ITEM_NORMAL menuitem = obj(parent, item_id, shortcut, helptext, style) self.shortcut2menuitem[shortcut] = menuitem self.id2menuitem[item_id] = menuitem parent.AppendItem(menuitem) self.ids_msgs[item_id] = msgtype self.parent.Bind(wx.EVT_MENU, self.OnMenu, id=item_id) elif obj == "Separator": parent.AppendSeparator() else: raise TypeError(_("Menu item unknown"))
[ "def", "_add_submenu", "(", "self", ",", "parent", ",", "data", ")", ":", "for", "item", "in", "data", ":", "obj", "=", "item", "[", "0", "]", "if", "obj", "==", "wx", ".", "Menu", ":", "try", ":", "__", ",", "menuname", ",", "submenu", ",", "menu_id", "=", "item", "except", "ValueError", ":", "__", ",", "menuname", ",", "submenu", "=", "item", "menu_id", "=", "-", "1", "menu", "=", "obj", "(", ")", "self", ".", "_add_submenu", "(", "menu", ",", "submenu", ")", "if", "parent", "==", "self", ":", "self", ".", "menubar", ".", "Append", "(", "menu", ",", "menuname", ")", "else", ":", "parent", ".", "AppendMenu", "(", "menu_id", ",", "menuname", ",", "menu", ")", "elif", "obj", "==", "wx", ".", "MenuItem", ":", "try", ":", "msgtype", ",", "shortcut", ",", "helptext", ",", "item_id", "=", "item", "[", "1", "]", "except", "ValueError", ":", "msgtype", ",", "shortcut", ",", "helptext", "=", "item", "[", "1", "]", "item_id", "=", "wx", ".", "NewId", "(", ")", "try", ":", "style", "=", "item", "[", "2", "]", "except", "IndexError", ":", "style", "=", "wx", ".", "ITEM_NORMAL", "menuitem", "=", "obj", "(", "parent", ",", "item_id", ",", "shortcut", ",", "helptext", ",", "style", ")", "self", ".", "shortcut2menuitem", "[", "shortcut", "]", "=", "menuitem", "self", ".", "id2menuitem", "[", "item_id", "]", "=", "menuitem", "parent", ".", "AppendItem", "(", "menuitem", ")", "self", ".", "ids_msgs", "[", "item_id", "]", "=", "msgtype", "self", ".", "parent", ".", "Bind", "(", "wx", ".", "EVT_MENU", ",", "self", ".", "OnMenu", ",", "id", "=", "item_id", ")", "elif", "obj", "==", "\"Separator\"", ":", "parent", ".", "AppendSeparator", "(", ")", "else", ":", "raise", "TypeError", "(", "_", "(", "\"Menu item unknown\"", ")", ")" ]
Adds items in data as a submenu to parent
[ "Adds", "items", "in", "data", "as", "a", "submenu", "to", "parent" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_menubars.py#L96-L142
236,571
manns/pyspread
pyspread/src/gui/_menubars.py
_filledMenu.OnMenu
def OnMenu(self, event): """Menu event handler""" msgtype = self.ids_msgs[event.GetId()] post_command_event(self.parent, msgtype)
python
def OnMenu(self, event): """Menu event handler""" msgtype = self.ids_msgs[event.GetId()] post_command_event(self.parent, msgtype)
[ "def", "OnMenu", "(", "self", ",", "event", ")", ":", "msgtype", "=", "self", ".", "ids_msgs", "[", "event", ".", "GetId", "(", ")", "]", "post_command_event", "(", "self", ".", "parent", ",", "msgtype", ")" ]
Menu event handler
[ "Menu", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_menubars.py#L144-L148
236,572
manns/pyspread
pyspread/src/gui/_menubars.py
_filledMenu.OnUpdate
def OnUpdate(self, event): """Menu state update""" if wx.ID_UNDO in self.id2menuitem: undo_item = self.id2menuitem[wx.ID_UNDO] undo_item.Enable(undo.stack().canundo()) if wx.ID_REDO in self.id2menuitem: redo_item = self.id2menuitem[wx.ID_REDO] redo_item.Enable(undo.stack().canredo()) event.Skip()
python
def OnUpdate(self, event): """Menu state update""" if wx.ID_UNDO in self.id2menuitem: undo_item = self.id2menuitem[wx.ID_UNDO] undo_item.Enable(undo.stack().canundo()) if wx.ID_REDO in self.id2menuitem: redo_item = self.id2menuitem[wx.ID_REDO] redo_item.Enable(undo.stack().canredo()) event.Skip()
[ "def", "OnUpdate", "(", "self", ",", "event", ")", ":", "if", "wx", ".", "ID_UNDO", "in", "self", ".", "id2menuitem", ":", "undo_item", "=", "self", ".", "id2menuitem", "[", "wx", ".", "ID_UNDO", "]", "undo_item", ".", "Enable", "(", "undo", ".", "stack", "(", ")", ".", "canundo", "(", ")", ")", "if", "wx", ".", "ID_REDO", "in", "self", ".", "id2menuitem", ":", "redo_item", "=", "self", ".", "id2menuitem", "[", "wx", ".", "ID_REDO", "]", "redo_item", ".", "Enable", "(", "undo", ".", "stack", "(", ")", ".", "canredo", "(", ")", ")", "event", ".", "Skip", "(", ")" ]
Menu state update
[ "Menu", "state", "update" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_menubars.py#L150-L161
236,573
manns/pyspread
pyspread/src/gui/_chart_dialog.py
TextEditor.OnFont
def OnFont(self, event): """Check event handler""" font_data = wx.FontData() # Disable color chooser on Windows font_data.EnableEffects(False) if self.chosen_font: font_data.SetInitialFont(self.chosen_font) dlg = wx.FontDialog(self, font_data) if dlg.ShowModal() == wx.ID_OK: font_data = dlg.GetFontData() font = self.chosen_font = font_data.GetChosenFont() self.font_face = font.GetFaceName() self.font_size = font.GetPointSize() self.font_style = font.GetStyle() self.font_weight = font.GetWeight() dlg.Destroy() post_command_event(self, self.DrawChartMsg)
python
def OnFont(self, event): """Check event handler""" font_data = wx.FontData() # Disable color chooser on Windows font_data.EnableEffects(False) if self.chosen_font: font_data.SetInitialFont(self.chosen_font) dlg = wx.FontDialog(self, font_data) if dlg.ShowModal() == wx.ID_OK: font_data = dlg.GetFontData() font = self.chosen_font = font_data.GetChosenFont() self.font_face = font.GetFaceName() self.font_size = font.GetPointSize() self.font_style = font.GetStyle() self.font_weight = font.GetWeight() dlg.Destroy() post_command_event(self, self.DrawChartMsg)
[ "def", "OnFont", "(", "self", ",", "event", ")", ":", "font_data", "=", "wx", ".", "FontData", "(", ")", "# Disable color chooser on Windows", "font_data", ".", "EnableEffects", "(", "False", ")", "if", "self", ".", "chosen_font", ":", "font_data", ".", "SetInitialFont", "(", "self", ".", "chosen_font", ")", "dlg", "=", "wx", ".", "FontDialog", "(", "self", ",", "font_data", ")", "if", "dlg", ".", "ShowModal", "(", ")", "==", "wx", ".", "ID_OK", ":", "font_data", "=", "dlg", ".", "GetFontData", "(", ")", "font", "=", "self", ".", "chosen_font", "=", "font_data", ".", "GetChosenFont", "(", ")", "self", ".", "font_face", "=", "font", ".", "GetFaceName", "(", ")", "self", ".", "font_size", "=", "font", ".", "GetPointSize", "(", ")", "self", ".", "font_style", "=", "font", ".", "GetStyle", "(", ")", "self", ".", "font_weight", "=", "font", ".", "GetWeight", "(", ")", "dlg", ".", "Destroy", "(", ")", "post_command_event", "(", "self", ",", "self", ".", "DrawChartMsg", ")" ]
Check event handler
[ "Check", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L445-L470
236,574
manns/pyspread
pyspread/src/gui/_chart_dialog.py
TickParamsEditor.OnDirectionChoice
def OnDirectionChoice(self, event): """Direction choice event handler""" label = self.direction_choicectrl.GetItems()[event.GetSelection()] param = self.choice_label2param[label] self.attrs["direction"] = param post_command_event(self, self.DrawChartMsg)
python
def OnDirectionChoice(self, event): """Direction choice event handler""" label = self.direction_choicectrl.GetItems()[event.GetSelection()] param = self.choice_label2param[label] self.attrs["direction"] = param post_command_event(self, self.DrawChartMsg)
[ "def", "OnDirectionChoice", "(", "self", ",", "event", ")", ":", "label", "=", "self", ".", "direction_choicectrl", ".", "GetItems", "(", ")", "[", "event", ".", "GetSelection", "(", ")", "]", "param", "=", "self", ".", "choice_label2param", "[", "label", "]", "self", ".", "attrs", "[", "\"direction\"", "]", "=", "param", "post_command_event", "(", "self", ",", "self", ".", "DrawChartMsg", ")" ]
Direction choice event handler
[ "Direction", "choice", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L630-L637
236,575
manns/pyspread
pyspread/src/gui/_chart_dialog.py
TickParamsEditor.OnSecondaryCheckbox
def OnSecondaryCheckbox(self, event): """Top Checkbox event handler""" self.attrs["top"] = event.IsChecked() self.attrs["right"] = event.IsChecked() post_command_event(self, self.DrawChartMsg)
python
def OnSecondaryCheckbox(self, event): """Top Checkbox event handler""" self.attrs["top"] = event.IsChecked() self.attrs["right"] = event.IsChecked() post_command_event(self, self.DrawChartMsg)
[ "def", "OnSecondaryCheckbox", "(", "self", ",", "event", ")", ":", "self", ".", "attrs", "[", "\"top\"", "]", "=", "event", ".", "IsChecked", "(", ")", "self", ".", "attrs", "[", "\"right\"", "]", "=", "event", ".", "IsChecked", "(", ")", "post_command_event", "(", "self", ",", "self", ".", "DrawChartMsg", ")" ]
Top Checkbox event handler
[ "Top", "Checkbox", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L639-L645
236,576
manns/pyspread
pyspread/src/gui/_chart_dialog.py
TickParamsEditor.OnPadIntCtrl
def OnPadIntCtrl(self, event): """Pad IntCtrl event handler""" self.attrs["pad"] = event.GetValue() post_command_event(self, self.DrawChartMsg)
python
def OnPadIntCtrl(self, event): """Pad IntCtrl event handler""" self.attrs["pad"] = event.GetValue() post_command_event(self, self.DrawChartMsg)
[ "def", "OnPadIntCtrl", "(", "self", ",", "event", ")", ":", "self", ".", "attrs", "[", "\"pad\"", "]", "=", "event", ".", "GetValue", "(", ")", "post_command_event", "(", "self", ",", "self", ".", "DrawChartMsg", ")" ]
Pad IntCtrl event handler
[ "Pad", "IntCtrl", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L647-L652
236,577
manns/pyspread
pyspread/src/gui/_chart_dialog.py
TickParamsEditor.OnLabelSizeIntCtrl
def OnLabelSizeIntCtrl(self, event): """Label size IntCtrl event handler""" self.attrs["labelsize"] = event.GetValue() post_command_event(self, self.DrawChartMsg)
python
def OnLabelSizeIntCtrl(self, event): """Label size IntCtrl event handler""" self.attrs["labelsize"] = event.GetValue() post_command_event(self, self.DrawChartMsg)
[ "def", "OnLabelSizeIntCtrl", "(", "self", ",", "event", ")", ":", "self", ".", "attrs", "[", "\"labelsize\"", "]", "=", "event", ".", "GetValue", "(", ")", "post_command_event", "(", "self", ",", "self", ".", "DrawChartMsg", ")" ]
Label size IntCtrl event handler
[ "Label", "size", "IntCtrl", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L654-L659
236,578
manns/pyspread
pyspread/src/gui/_chart_dialog.py
StyleEditorMixin.get_code
def get_code(self): """Returns code representation of value of widget""" selection = self.GetSelection() if selection == wx.NOT_FOUND: selection = 0 # Return code string return self.styles[selection][1]
python
def get_code(self): """Returns code representation of value of widget""" selection = self.GetSelection() if selection == wx.NOT_FOUND: selection = 0 # Return code string return self.styles[selection][1]
[ "def", "get_code", "(", "self", ")", ":", "selection", "=", "self", ".", "GetSelection", "(", ")", "if", "selection", "==", "wx", ".", "NOT_FOUND", ":", "selection", "=", "0", "# Return code string", "return", "self", ".", "styles", "[", "selection", "]", "[", "1", "]" ]
Returns code representation of value of widget
[ "Returns", "code", "representation", "of", "value", "of", "widget" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L712-L721
236,579
manns/pyspread
pyspread/src/gui/_chart_dialog.py
SeriesAttributesPanelBase.update
def update(self, series_data): """Updates self.data from series data Parameters ---------- * series_data: dict \tKey value pairs for self.data, which correspond to chart attributes """ for key in series_data: try: data_list = list(self.data[key]) data_list[2] = str(series_data[key]) self.data[key] = tuple(data_list) except KeyError: pass
python
def update(self, series_data): """Updates self.data from series data Parameters ---------- * series_data: dict \tKey value pairs for self.data, which correspond to chart attributes """ for key in series_data: try: data_list = list(self.data[key]) data_list[2] = str(series_data[key]) self.data[key] = tuple(data_list) except KeyError: pass
[ "def", "update", "(", "self", ",", "series_data", ")", ":", "for", "key", "in", "series_data", ":", "try", ":", "data_list", "=", "list", "(", "self", ".", "data", "[", "key", "]", ")", "data_list", "[", "2", "]", "=", "str", "(", "series_data", "[", "key", "]", ")", "self", ".", "data", "[", "key", "]", "=", "tuple", "(", "data_list", ")", "except", "KeyError", ":", "pass" ]
Updates self.data from series data Parameters ---------- * series_data: dict \tKey value pairs for self.data, which correspond to chart attributes
[ "Updates", "self", ".", "data", "from", "series", "data" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L894-L910
236,580
manns/pyspread
pyspread/src/gui/_chart_dialog.py
SeriesPanel.get_plot_panel
def get_plot_panel(self): """Returns current plot_panel""" plot_type_no = self.chart_type_book.GetSelection() return self.chart_type_book.GetPage(plot_type_no)
python
def get_plot_panel(self): """Returns current plot_panel""" plot_type_no = self.chart_type_book.GetSelection() return self.chart_type_book.GetPage(plot_type_no)
[ "def", "get_plot_panel", "(", "self", ")", ":", "plot_type_no", "=", "self", ".", "chart_type_book", ".", "GetSelection", "(", ")", "return", "self", ".", "chart_type_book", ".", "GetPage", "(", "plot_type_no", ")" ]
Returns current plot_panel
[ "Returns", "current", "plot_panel" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L1423-L1427
236,581
manns/pyspread
pyspread/src/gui/_chart_dialog.py
SeriesPanel.set_plot_type
def set_plot_type(self, plot_type): """Sets plot type""" ptypes = [pt["type"] for pt in self.plot_types] self.plot_panel = ptypes.index(plot_type)
python
def set_plot_type(self, plot_type): """Sets plot type""" ptypes = [pt["type"] for pt in self.plot_types] self.plot_panel = ptypes.index(plot_type)
[ "def", "set_plot_type", "(", "self", ",", "plot_type", ")", ":", "ptypes", "=", "[", "pt", "[", "\"type\"", "]", "for", "pt", "in", "self", ".", "plot_types", "]", "self", ".", "plot_panel", "=", "ptypes", ".", "index", "(", "plot_type", ")" ]
Sets plot type
[ "Sets", "plot", "type" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L1441-L1445
236,582
manns/pyspread
pyspread/src/gui/_chart_dialog.py
AllSeriesPanel.update
def update(self, series_list): """Updates widget content from series_list Parameters ---------- series_list: List of dict \tList of dicts with data from all series """ if not series_list: self.series_notebook.AddPage(wx.Panel(self, -1), _("+")) return self.updating = True # Delete all tabs in the notebook self.series_notebook.DeleteAllPages() # Add as many tabs as there are series in code for page, attrdict in enumerate(series_list): series_panel = SeriesPanel(self.grid, attrdict) name = "Series" self.series_notebook.InsertPage(page, series_panel, name) self.series_notebook.AddPage(wx.Panel(self, -1), _("+")) self.updating = False
python
def update(self, series_list): """Updates widget content from series_list Parameters ---------- series_list: List of dict \tList of dicts with data from all series """ if not series_list: self.series_notebook.AddPage(wx.Panel(self, -1), _("+")) return self.updating = True # Delete all tabs in the notebook self.series_notebook.DeleteAllPages() # Add as many tabs as there are series in code for page, attrdict in enumerate(series_list): series_panel = SeriesPanel(self.grid, attrdict) name = "Series" self.series_notebook.InsertPage(page, series_panel, name) self.series_notebook.AddPage(wx.Panel(self, -1), _("+")) self.updating = False
[ "def", "update", "(", "self", ",", "series_list", ")", ":", "if", "not", "series_list", ":", "self", ".", "series_notebook", ".", "AddPage", "(", "wx", ".", "Panel", "(", "self", ",", "-", "1", ")", ",", "_", "(", "\"+\"", ")", ")", "return", "self", ".", "updating", "=", "True", "# Delete all tabs in the notebook", "self", ".", "series_notebook", ".", "DeleteAllPages", "(", ")", "# Add as many tabs as there are series in code", "for", "page", ",", "attrdict", "in", "enumerate", "(", "series_list", ")", ":", "series_panel", "=", "SeriesPanel", "(", "self", ".", "grid", ",", "attrdict", ")", "name", "=", "\"Series\"", "self", ".", "series_notebook", ".", "InsertPage", "(", "page", ",", "series_panel", ",", "name", ")", "self", ".", "series_notebook", ".", "AddPage", "(", "wx", ".", "Panel", "(", "self", ",", "-", "1", ")", ",", "_", "(", "\"+\"", ")", ")", "self", ".", "updating", "=", "False" ]
Updates widget content from series_list Parameters ---------- series_list: List of dict \tList of dicts with data from all series
[ "Updates", "widget", "content", "from", "series_list" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L1494-L1523
236,583
manns/pyspread
pyspread/src/gui/_chart_dialog.py
AllSeriesPanel.OnSeriesChanged
def OnSeriesChanged(self, event): """FlatNotebook change event handler""" selection = event.GetSelection() if not self.updating and \ selection == self.series_notebook.GetPageCount() - 1: # Add new series new_panel = SeriesPanel(self, {"type": "plot"}) self.series_notebook.InsertPage(selection, new_panel, _("Series")) event.Skip()
python
def OnSeriesChanged(self, event): """FlatNotebook change event handler""" selection = event.GetSelection() if not self.updating and \ selection == self.series_notebook.GetPageCount() - 1: # Add new series new_panel = SeriesPanel(self, {"type": "plot"}) self.series_notebook.InsertPage(selection, new_panel, _("Series")) event.Skip()
[ "def", "OnSeriesChanged", "(", "self", ",", "event", ")", ":", "selection", "=", "event", ".", "GetSelection", "(", ")", "if", "not", "self", ".", "updating", "and", "selection", "==", "self", ".", "series_notebook", ".", "GetPageCount", "(", ")", "-", "1", ":", "# Add new series", "new_panel", "=", "SeriesPanel", "(", "self", ",", "{", "\"type\"", ":", "\"plot\"", "}", ")", "self", ".", "series_notebook", ".", "InsertPage", "(", "selection", ",", "new_panel", ",", "_", "(", "\"Series\"", ")", ")", "event", ".", "Skip", "(", ")" ]
FlatNotebook change event handler
[ "FlatNotebook", "change", "event", "handler" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L1528-L1539
236,584
manns/pyspread
pyspread/src/gui/_chart_dialog.py
FigurePanel.update
def update(self, figure): """Updates figure on data change Parameters ---------- * figure: matplotlib.figure.Figure \tMatplotlib figure object that is displayed in self """ if hasattr(self, "figure_canvas"): self.figure_canvas.Destroy() self.figure_canvas = self._get_figure_canvas(figure) self.figure_canvas.SetSize(self.GetSize()) figure.subplots_adjust() self.main_sizer.Add(self.figure_canvas, 1, wx.EXPAND | wx.FIXED_MINSIZE, 0) self.Layout() self.figure_canvas.draw()
python
def update(self, figure): """Updates figure on data change Parameters ---------- * figure: matplotlib.figure.Figure \tMatplotlib figure object that is displayed in self """ if hasattr(self, "figure_canvas"): self.figure_canvas.Destroy() self.figure_canvas = self._get_figure_canvas(figure) self.figure_canvas.SetSize(self.GetSize()) figure.subplots_adjust() self.main_sizer.Add(self.figure_canvas, 1, wx.EXPAND | wx.FIXED_MINSIZE, 0) self.Layout() self.figure_canvas.draw()
[ "def", "update", "(", "self", ",", "figure", ")", ":", "if", "hasattr", "(", "self", ",", "\"figure_canvas\"", ")", ":", "self", ".", "figure_canvas", ".", "Destroy", "(", ")", "self", ".", "figure_canvas", "=", "self", ".", "_get_figure_canvas", "(", "figure", ")", "self", ".", "figure_canvas", ".", "SetSize", "(", "self", ".", "GetSize", "(", ")", ")", "figure", ".", "subplots_adjust", "(", ")", "self", ".", "main_sizer", ".", "Add", "(", "self", ".", "figure_canvas", ",", "1", ",", "wx", ".", "EXPAND", "|", "wx", ".", "FIXED_MINSIZE", ",", "0", ")", "self", ".", "Layout", "(", ")", "self", ".", "figure_canvas", ".", "draw", "(", ")" ]
Updates figure on data change Parameters ---------- * figure: matplotlib.figure.Figure \tMatplotlib figure object that is displayed in self
[ "Updates", "figure", "on", "data", "change" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L1573-L1595
236,585
manns/pyspread
pyspread/src/gui/_chart_dialog.py
ChartDialog.get_figure
def get_figure(self, code): """Returns figure from executing code in grid Returns an empty matplotlib figure if code does not eval to a matplotlib figure instance. Parameters ---------- code: Unicode \tUnicode string which contains Python code that should yield a figure """ # Caching for fast response if there are no changes if code == self.figure_code_old and self.figure_cache: return self.figure_cache self.figure_code_old = code # key is the current cursor cell of the grid key = self.grid.actions.cursor cell_result = self.grid.code_array._eval_cell(key, code) # If cell_result is matplotlib figure if isinstance(cell_result, matplotlib.pyplot.Figure): # Return it self.figure_cache = cell_result return cell_result else: # Otherwise return empty figure self.figure_cache = charts.ChartFigure() return self.figure_cache
python
def get_figure(self, code): """Returns figure from executing code in grid Returns an empty matplotlib figure if code does not eval to a matplotlib figure instance. Parameters ---------- code: Unicode \tUnicode string which contains Python code that should yield a figure """ # Caching for fast response if there are no changes if code == self.figure_code_old and self.figure_cache: return self.figure_cache self.figure_code_old = code # key is the current cursor cell of the grid key = self.grid.actions.cursor cell_result = self.grid.code_array._eval_cell(key, code) # If cell_result is matplotlib figure if isinstance(cell_result, matplotlib.pyplot.Figure): # Return it self.figure_cache = cell_result return cell_result else: # Otherwise return empty figure self.figure_cache = charts.ChartFigure() return self.figure_cache
[ "def", "get_figure", "(", "self", ",", "code", ")", ":", "# Caching for fast response if there are no changes", "if", "code", "==", "self", ".", "figure_code_old", "and", "self", ".", "figure_cache", ":", "return", "self", ".", "figure_cache", "self", ".", "figure_code_old", "=", "code", "# key is the current cursor cell of the grid", "key", "=", "self", ".", "grid", ".", "actions", ".", "cursor", "cell_result", "=", "self", ".", "grid", ".", "code_array", ".", "_eval_cell", "(", "key", ",", "code", ")", "# If cell_result is matplotlib figure", "if", "isinstance", "(", "cell_result", ",", "matplotlib", ".", "pyplot", ".", "Figure", ")", ":", "# Return it", "self", ".", "figure_cache", "=", "cell_result", "return", "cell_result", "else", ":", "# Otherwise return empty figure", "self", ".", "figure_cache", "=", "charts", ".", "ChartFigure", "(", ")", "return", "self", ".", "figure_cache" ]
Returns figure from executing code in grid Returns an empty matplotlib figure if code does not eval to a matplotlib figure instance. Parameters ---------- code: Unicode \tUnicode string which contains Python code that should yield a figure
[ "Returns", "figure", "from", "executing", "code", "in", "grid" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L1668-L1701
236,586
manns/pyspread
pyspread/src/gui/_chart_dialog.py
ChartDialog.set_code
def set_code(self, code): """Update widgets from code""" # Get attributes from code attributes = [] strip = lambda s: s.strip('u').strip("'").strip('"') for attr_dict in parse_dict_strings(unicode(code).strip()[19:-1]): attrs = list(strip(s) for s in parse_dict_strings(attr_dict[1:-1])) attributes.append(dict(zip(attrs[::2], attrs[1::2]))) if not attributes: return # Set widgets from attributes # --------------------------- # Figure attributes figure_attributes = attributes[0] for key, widget in self.figure_attributes_panel: try: obj = figure_attributes[key] kwargs_key = key + "_kwargs" if kwargs_key in figure_attributes: widget.set_kwargs(figure_attributes[kwargs_key]) except KeyError: obj = "" widget.code = charts.object2code(key, obj) # Series attributes self.all_series_panel.update(attributes[1:])
python
def set_code(self, code): """Update widgets from code""" # Get attributes from code attributes = [] strip = lambda s: s.strip('u').strip("'").strip('"') for attr_dict in parse_dict_strings(unicode(code).strip()[19:-1]): attrs = list(strip(s) for s in parse_dict_strings(attr_dict[1:-1])) attributes.append(dict(zip(attrs[::2], attrs[1::2]))) if not attributes: return # Set widgets from attributes # --------------------------- # Figure attributes figure_attributes = attributes[0] for key, widget in self.figure_attributes_panel: try: obj = figure_attributes[key] kwargs_key = key + "_kwargs" if kwargs_key in figure_attributes: widget.set_kwargs(figure_attributes[kwargs_key]) except KeyError: obj = "" widget.code = charts.object2code(key, obj) # Series attributes self.all_series_panel.update(attributes[1:])
[ "def", "set_code", "(", "self", ",", "code", ")", ":", "# Get attributes from code", "attributes", "=", "[", "]", "strip", "=", "lambda", "s", ":", "s", ".", "strip", "(", "'u'", ")", ".", "strip", "(", "\"'\"", ")", ".", "strip", "(", "'\"'", ")", "for", "attr_dict", "in", "parse_dict_strings", "(", "unicode", "(", "code", ")", ".", "strip", "(", ")", "[", "19", ":", "-", "1", "]", ")", ":", "attrs", "=", "list", "(", "strip", "(", "s", ")", "for", "s", "in", "parse_dict_strings", "(", "attr_dict", "[", "1", ":", "-", "1", "]", ")", ")", "attributes", ".", "append", "(", "dict", "(", "zip", "(", "attrs", "[", ":", ":", "2", "]", ",", "attrs", "[", "1", ":", ":", "2", "]", ")", ")", ")", "if", "not", "attributes", ":", "return", "# Set widgets from attributes", "# ---------------------------", "# Figure attributes", "figure_attributes", "=", "attributes", "[", "0", "]", "for", "key", ",", "widget", "in", "self", ".", "figure_attributes_panel", ":", "try", ":", "obj", "=", "figure_attributes", "[", "key", "]", "kwargs_key", "=", "key", "+", "\"_kwargs\"", "if", "kwargs_key", "in", "figure_attributes", ":", "widget", ".", "set_kwargs", "(", "figure_attributes", "[", "kwargs_key", "]", ")", "except", "KeyError", ":", "obj", "=", "\"\"", "widget", ".", "code", "=", "charts", ".", "object2code", "(", "key", ",", "obj", ")", "# Series attributes", "self", ".", "all_series_panel", ".", "update", "(", "attributes", "[", "1", ":", "]", ")" ]
Update widgets from code
[ "Update", "widgets", "from", "code" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L1718-L1751
236,587
manns/pyspread
pyspread/src/gui/_chart_dialog.py
ChartDialog.get_code
def get_code(self): """Returns code that generates figure from widgets""" def dict2str(attr_dict): """Returns string with dict content with values as code Code means that string identifiers are removed """ result = u"{" for key in attr_dict: code = attr_dict[key] if key in self.string_keys: code = repr(code) elif code and key in self.tuple_keys and \ not (code[0] in ["[", "("] and code[-1] in ["]", ")"]): code = "(" + code + ")" elif key in ["xscale", "yscale"]: if code: code = '"log"' else: code = '"linear"' elif key in ["legend"]: if code: code = '1' else: code = '0' elif key in ["xtick_params"]: code = '"x"' elif key in ["ytick_params"]: code = '"y"' if not code: if key in self.empty_none_keys: code = "None" else: code = 'u""' result += repr(key) + ": " + code + ", " result = result[:-2] + u"}" return result # cls_name inludes full class name incl. charts cls_name = "charts." + charts.ChartFigure.__name__ attr_dicts = [] # Figure attributes attr_dict = {} # figure_attributes is a dict key2code for key, widget in self.figure_attributes_panel: if key == "type": attr_dict[key] = widget else: attr_dict[key] = widget.code try: attr_dict[key+"_kwargs"] = widget.get_kwargs() except AttributeError: pass attr_dicts.append(attr_dict) # Series_attributes is a list of dicts key2code for series_panel in self.all_series_panel: attr_dict = {} for key, widget in series_panel: if key == "type": attr_dict[key] = widget else: attr_dict[key] = widget.code attr_dicts.append(attr_dict) code = cls_name + "(" for attr_dict in attr_dicts: code += dict2str(attr_dict) + ", " code = code[:-2] + ")" return code
python
def get_code(self): """Returns code that generates figure from widgets""" def dict2str(attr_dict): """Returns string with dict content with values as code Code means that string identifiers are removed """ result = u"{" for key in attr_dict: code = attr_dict[key] if key in self.string_keys: code = repr(code) elif code and key in self.tuple_keys and \ not (code[0] in ["[", "("] and code[-1] in ["]", ")"]): code = "(" + code + ")" elif key in ["xscale", "yscale"]: if code: code = '"log"' else: code = '"linear"' elif key in ["legend"]: if code: code = '1' else: code = '0' elif key in ["xtick_params"]: code = '"x"' elif key in ["ytick_params"]: code = '"y"' if not code: if key in self.empty_none_keys: code = "None" else: code = 'u""' result += repr(key) + ": " + code + ", " result = result[:-2] + u"}" return result # cls_name inludes full class name incl. charts cls_name = "charts." + charts.ChartFigure.__name__ attr_dicts = [] # Figure attributes attr_dict = {} # figure_attributes is a dict key2code for key, widget in self.figure_attributes_panel: if key == "type": attr_dict[key] = widget else: attr_dict[key] = widget.code try: attr_dict[key+"_kwargs"] = widget.get_kwargs() except AttributeError: pass attr_dicts.append(attr_dict) # Series_attributes is a list of dicts key2code for series_panel in self.all_series_panel: attr_dict = {} for key, widget in series_panel: if key == "type": attr_dict[key] = widget else: attr_dict[key] = widget.code attr_dicts.append(attr_dict) code = cls_name + "(" for attr_dict in attr_dicts: code += dict2str(attr_dict) + ", " code = code[:-2] + ")" return code
[ "def", "get_code", "(", "self", ")", ":", "def", "dict2str", "(", "attr_dict", ")", ":", "\"\"\"Returns string with dict content with values as code\n\n Code means that string identifiers are removed\n\n \"\"\"", "result", "=", "u\"{\"", "for", "key", "in", "attr_dict", ":", "code", "=", "attr_dict", "[", "key", "]", "if", "key", "in", "self", ".", "string_keys", ":", "code", "=", "repr", "(", "code", ")", "elif", "code", "and", "key", "in", "self", ".", "tuple_keys", "and", "not", "(", "code", "[", "0", "]", "in", "[", "\"[\"", ",", "\"(\"", "]", "and", "code", "[", "-", "1", "]", "in", "[", "\"]\"", ",", "\")\"", "]", ")", ":", "code", "=", "\"(\"", "+", "code", "+", "\")\"", "elif", "key", "in", "[", "\"xscale\"", ",", "\"yscale\"", "]", ":", "if", "code", ":", "code", "=", "'\"log\"'", "else", ":", "code", "=", "'\"linear\"'", "elif", "key", "in", "[", "\"legend\"", "]", ":", "if", "code", ":", "code", "=", "'1'", "else", ":", "code", "=", "'0'", "elif", "key", "in", "[", "\"xtick_params\"", "]", ":", "code", "=", "'\"x\"'", "elif", "key", "in", "[", "\"ytick_params\"", "]", ":", "code", "=", "'\"y\"'", "if", "not", "code", ":", "if", "key", "in", "self", ".", "empty_none_keys", ":", "code", "=", "\"None\"", "else", ":", "code", "=", "'u\"\"'", "result", "+=", "repr", "(", "key", ")", "+", "\": \"", "+", "code", "+", "\", \"", "result", "=", "result", "[", ":", "-", "2", "]", "+", "u\"}\"", "return", "result", "# cls_name inludes full class name incl. charts", "cls_name", "=", "\"charts.\"", "+", "charts", ".", "ChartFigure", ".", "__name__", "attr_dicts", "=", "[", "]", "# Figure attributes", "attr_dict", "=", "{", "}", "# figure_attributes is a dict key2code", "for", "key", ",", "widget", "in", "self", ".", "figure_attributes_panel", ":", "if", "key", "==", "\"type\"", ":", "attr_dict", "[", "key", "]", "=", "widget", "else", ":", "attr_dict", "[", "key", "]", "=", "widget", ".", "code", "try", ":", "attr_dict", "[", "key", "+", "\"_kwargs\"", "]", "=", "widget", ".", "get_kwargs", "(", ")", "except", "AttributeError", ":", "pass", "attr_dicts", ".", "append", "(", "attr_dict", ")", "# Series_attributes is a list of dicts key2code", "for", "series_panel", "in", "self", ".", "all_series_panel", ":", "attr_dict", "=", "{", "}", "for", "key", ",", "widget", "in", "series_panel", ":", "if", "key", "==", "\"type\"", ":", "attr_dict", "[", "key", "]", "=", "widget", "else", ":", "attr_dict", "[", "key", "]", "=", "widget", ".", "code", "attr_dicts", ".", "append", "(", "attr_dict", ")", "code", "=", "cls_name", "+", "\"(\"", "for", "attr_dict", "in", "attr_dicts", ":", "code", "+=", "dict2str", "(", "attr_dict", ")", "+", "\", \"", "code", "=", "code", "[", ":", "-", "2", "]", "+", "\")\"", "return", "code" ]
Returns code that generates figure from widgets
[ "Returns", "code", "that", "generates", "figure", "from", "widgets" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L1753-L1844
236,588
manns/pyspread
pyspread/src/gui/_chart_dialog.py
ChartDialog.OnUpdateFigurePanel
def OnUpdateFigurePanel(self, event): """Redraw event handler for the figure panel""" if self.updating: return self.updating = True self.figure_panel.update(self.get_figure(self.code)) self.updating = False
python
def OnUpdateFigurePanel(self, event): """Redraw event handler for the figure panel""" if self.updating: return self.updating = True self.figure_panel.update(self.get_figure(self.code)) self.updating = False
[ "def", "OnUpdateFigurePanel", "(", "self", ",", "event", ")", ":", "if", "self", ".", "updating", ":", "return", "self", ".", "updating", "=", "True", "self", ".", "figure_panel", ".", "update", "(", "self", ".", "get_figure", "(", "self", ".", "code", ")", ")", "self", ".", "updating", "=", "False" ]
Redraw event handler for the figure panel
[ "Redraw", "event", "handler", "for", "the", "figure", "panel" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L1854-L1862
236,589
manns/pyspread
pyspread/src/lib/selection.py
Selection.parameters
def parameters(self): """Returns tuple of selection parameters of self (self.block_tl, self.block_br, self.rows, self.cols, self.cells) """ return self.block_tl, self.block_br, self.rows, self.cols, self.cells
python
def parameters(self): """Returns tuple of selection parameters of self (self.block_tl, self.block_br, self.rows, self.cols, self.cells) """ return self.block_tl, self.block_br, self.rows, self.cols, self.cells
[ "def", "parameters", "(", "self", ")", ":", "return", "self", ".", "block_tl", ",", "self", ".", "block_br", ",", "self", ".", "rows", ",", "self", ".", "cols", ",", "self", ".", "cells" ]
Returns tuple of selection parameters of self (self.block_tl, self.block_br, self.rows, self.cols, self.cells)
[ "Returns", "tuple", "of", "selection", "parameters", "of", "self" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/selection.py#L245-L252
236,590
manns/pyspread
pyspread/src/lib/selection.py
Selection.get_access_string
def get_access_string(self, shape, table): """Returns a string, with which the selection can be accessed Parameters ---------- shape: 3-tuple of Integer \tShape of grid, for which the generated keys are valid table: Integer \tThird component of all returned keys. Must be in dimensions """ rows, columns, tables = shape # Negative dimensions cannot be assert all(dim > 0 for dim in shape) # Current table has to be in dimensions assert 0 <= table < tables string_list = [] # Block selections templ = "[(r, c, {}) for r in xrange({}, {}) for c in xrange({}, {})]" for (top, left), (bottom, right) in izip(self.block_tl, self.block_br): string_list += [templ.format(table, top, bottom + 1, left, right + 1)] # Fully selected rows template = "[({}, c, {}) for c in xrange({})]" for row in self.rows: string_list += [template.format(row, table, columns)] # Fully selected columns template = "[(r, {}, {}) for r in xrange({})]" for column in self.cols: string_list += [template.format(column, table, rows)] # Single cells for row, column in self.cells: string_list += [repr([(row, column, table)])] key_string = " + ".join(string_list) if len(string_list) == 0: return "" elif len(self.cells) == 1 and len(string_list) == 1: return "S[{}]".format(string_list[0][1:-1]) else: template = "[S[key] for key in {} if S[key] is not None]" return template.format(key_string)
python
def get_access_string(self, shape, table): """Returns a string, with which the selection can be accessed Parameters ---------- shape: 3-tuple of Integer \tShape of grid, for which the generated keys are valid table: Integer \tThird component of all returned keys. Must be in dimensions """ rows, columns, tables = shape # Negative dimensions cannot be assert all(dim > 0 for dim in shape) # Current table has to be in dimensions assert 0 <= table < tables string_list = [] # Block selections templ = "[(r, c, {}) for r in xrange({}, {}) for c in xrange({}, {})]" for (top, left), (bottom, right) in izip(self.block_tl, self.block_br): string_list += [templ.format(table, top, bottom + 1, left, right + 1)] # Fully selected rows template = "[({}, c, {}) for c in xrange({})]" for row in self.rows: string_list += [template.format(row, table, columns)] # Fully selected columns template = "[(r, {}, {}) for r in xrange({})]" for column in self.cols: string_list += [template.format(column, table, rows)] # Single cells for row, column in self.cells: string_list += [repr([(row, column, table)])] key_string = " + ".join(string_list) if len(string_list) == 0: return "" elif len(self.cells) == 1 and len(string_list) == 1: return "S[{}]".format(string_list[0][1:-1]) else: template = "[S[key] for key in {} if S[key] is not None]" return template.format(key_string)
[ "def", "get_access_string", "(", "self", ",", "shape", ",", "table", ")", ":", "rows", ",", "columns", ",", "tables", "=", "shape", "# Negative dimensions cannot be", "assert", "all", "(", "dim", ">", "0", "for", "dim", "in", "shape", ")", "# Current table has to be in dimensions", "assert", "0", "<=", "table", "<", "tables", "string_list", "=", "[", "]", "# Block selections", "templ", "=", "\"[(r, c, {}) for r in xrange({}, {}) for c in xrange({}, {})]\"", "for", "(", "top", ",", "left", ")", ",", "(", "bottom", ",", "right", ")", "in", "izip", "(", "self", ".", "block_tl", ",", "self", ".", "block_br", ")", ":", "string_list", "+=", "[", "templ", ".", "format", "(", "table", ",", "top", ",", "bottom", "+", "1", ",", "left", ",", "right", "+", "1", ")", "]", "# Fully selected rows", "template", "=", "\"[({}, c, {}) for c in xrange({})]\"", "for", "row", "in", "self", ".", "rows", ":", "string_list", "+=", "[", "template", ".", "format", "(", "row", ",", "table", ",", "columns", ")", "]", "# Fully selected columns", "template", "=", "\"[(r, {}, {}) for r in xrange({})]\"", "for", "column", "in", "self", ".", "cols", ":", "string_list", "+=", "[", "template", ".", "format", "(", "column", ",", "table", ",", "rows", ")", "]", "# Single cells", "for", "row", ",", "column", "in", "self", ".", "cells", ":", "string_list", "+=", "[", "repr", "(", "[", "(", "row", ",", "column", ",", "table", ")", "]", ")", "]", "key_string", "=", "\" + \"", ".", "join", "(", "string_list", ")", "if", "len", "(", "string_list", ")", "==", "0", ":", "return", "\"\"", "elif", "len", "(", "self", ".", "cells", ")", "==", "1", "and", "len", "(", "string_list", ")", "==", "1", ":", "return", "\"S[{}]\"", ".", "format", "(", "string_list", "[", "0", "]", "[", "1", ":", "-", "1", "]", ")", "else", ":", "template", "=", "\"[S[key] for key in {} if S[key] is not None]\"", "return", "template", ".", "format", "(", "key_string", ")" ]
Returns a string, with which the selection can be accessed Parameters ---------- shape: 3-tuple of Integer \tShape of grid, for which the generated keys are valid table: Integer \tThird component of all returned keys. Must be in dimensions
[ "Returns", "a", "string", "with", "which", "the", "selection", "can", "be", "accessed" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/selection.py#L381-L433
236,591
manns/pyspread
pyspread/src/lib/selection.py
Selection.shifted
def shifted(self, rows, cols): """Returns a new selection that is shifted by rows and cols. Negative values for rows and cols may result in a selection that addresses negative cells. Parameters ---------- rows: Integer \tNumber of rows that the new selection is shifted down cols: Integer \tNumber of columns that the new selection is shifted right """ shifted_block_tl = \ [(row + rows, col + cols) for row, col in self.block_tl] shifted_block_br = \ [(row + rows, col + cols) for row, col in self.block_br] shifted_rows = [row + rows for row in self.rows] shifted_cols = [col + cols for col in self.cols] shifted_cells = [(row + rows, col + cols) for row, col in self.cells] return Selection(shifted_block_tl, shifted_block_br, shifted_rows, shifted_cols, shifted_cells)
python
def shifted(self, rows, cols): """Returns a new selection that is shifted by rows and cols. Negative values for rows and cols may result in a selection that addresses negative cells. Parameters ---------- rows: Integer \tNumber of rows that the new selection is shifted down cols: Integer \tNumber of columns that the new selection is shifted right """ shifted_block_tl = \ [(row + rows, col + cols) for row, col in self.block_tl] shifted_block_br = \ [(row + rows, col + cols) for row, col in self.block_br] shifted_rows = [row + rows for row in self.rows] shifted_cols = [col + cols for col in self.cols] shifted_cells = [(row + rows, col + cols) for row, col in self.cells] return Selection(shifted_block_tl, shifted_block_br, shifted_rows, shifted_cols, shifted_cells)
[ "def", "shifted", "(", "self", ",", "rows", ",", "cols", ")", ":", "shifted_block_tl", "=", "[", "(", "row", "+", "rows", ",", "col", "+", "cols", ")", "for", "row", ",", "col", "in", "self", ".", "block_tl", "]", "shifted_block_br", "=", "[", "(", "row", "+", "rows", ",", "col", "+", "cols", ")", "for", "row", ",", "col", "in", "self", ".", "block_br", "]", "shifted_rows", "=", "[", "row", "+", "rows", "for", "row", "in", "self", ".", "rows", "]", "shifted_cols", "=", "[", "col", "+", "cols", "for", "col", "in", "self", ".", "cols", "]", "shifted_cells", "=", "[", "(", "row", "+", "rows", ",", "col", "+", "cols", ")", "for", "row", ",", "col", "in", "self", ".", "cells", "]", "return", "Selection", "(", "shifted_block_tl", ",", "shifted_block_br", ",", "shifted_rows", ",", "shifted_cols", ",", "shifted_cells", ")" ]
Returns a new selection that is shifted by rows and cols. Negative values for rows and cols may result in a selection that addresses negative cells. Parameters ---------- rows: Integer \tNumber of rows that the new selection is shifted down cols: Integer \tNumber of columns that the new selection is shifted right
[ "Returns", "a", "new", "selection", "that", "is", "shifted", "by", "rows", "and", "cols", "." ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/selection.py#L435-L459
236,592
manns/pyspread
pyspread/src/lib/selection.py
Selection.grid_select
def grid_select(self, grid, clear_selection=True): """Selects cells of grid with selection content""" if clear_selection: grid.ClearSelection() for (tl, br) in zip(self.block_tl, self.block_br): grid.SelectBlock(tl[0], tl[1], br[0], br[1], addToSelected=True) for row in self.rows: grid.SelectRow(row, addToSelected=True) for col in self.cols: grid.SelectCol(col, addToSelected=True) for cell in self.cells: grid.SelectBlock(cell[0], cell[1], cell[0], cell[1], addToSelected=True)
python
def grid_select(self, grid, clear_selection=True): """Selects cells of grid with selection content""" if clear_selection: grid.ClearSelection() for (tl, br) in zip(self.block_tl, self.block_br): grid.SelectBlock(tl[0], tl[1], br[0], br[1], addToSelected=True) for row in self.rows: grid.SelectRow(row, addToSelected=True) for col in self.cols: grid.SelectCol(col, addToSelected=True) for cell in self.cells: grid.SelectBlock(cell[0], cell[1], cell[0], cell[1], addToSelected=True)
[ "def", "grid_select", "(", "self", ",", "grid", ",", "clear_selection", "=", "True", ")", ":", "if", "clear_selection", ":", "grid", ".", "ClearSelection", "(", ")", "for", "(", "tl", ",", "br", ")", "in", "zip", "(", "self", ".", "block_tl", ",", "self", ".", "block_br", ")", ":", "grid", ".", "SelectBlock", "(", "tl", "[", "0", "]", ",", "tl", "[", "1", "]", ",", "br", "[", "0", "]", ",", "br", "[", "1", "]", ",", "addToSelected", "=", "True", ")", "for", "row", "in", "self", ".", "rows", ":", "grid", ".", "SelectRow", "(", "row", ",", "addToSelected", "=", "True", ")", "for", "col", "in", "self", ".", "cols", ":", "grid", ".", "SelectCol", "(", "col", ",", "addToSelected", "=", "True", ")", "for", "cell", "in", "self", ".", "cells", ":", "grid", ".", "SelectBlock", "(", "cell", "[", "0", "]", ",", "cell", "[", "1", "]", ",", "cell", "[", "0", "]", ",", "cell", "[", "1", "]", ",", "addToSelected", "=", "True", ")" ]
Selects cells of grid with selection content
[ "Selects", "cells", "of", "grid", "with", "selection", "content" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/selection.py#L461-L478
236,593
manns/pyspread
pyspread/src/lib/charts.py
object2code
def object2code(key, code): """Returns code for widget from dict object""" if key in ["xscale", "yscale"]: if code == "log": code = True else: code = False else: code = unicode(code) return code
python
def object2code(key, code): """Returns code for widget from dict object""" if key in ["xscale", "yscale"]: if code == "log": code = True else: code = False else: code = unicode(code) return code
[ "def", "object2code", "(", "key", ",", "code", ")", ":", "if", "key", "in", "[", "\"xscale\"", ",", "\"yscale\"", "]", ":", "if", "code", "==", "\"log\"", ":", "code", "=", "True", "else", ":", "code", "=", "False", "else", ":", "code", "=", "unicode", "(", "code", ")", "return", "code" ]
Returns code for widget from dict object
[ "Returns", "code", "for", "widget", "from", "dict", "object" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/charts.py#L56-L68
236,594
manns/pyspread
pyspread/src/lib/charts.py
fig2bmp
def fig2bmp(figure, width, height, dpi, zoom): """Returns wx.Bitmap from matplotlib chart Parameters ---------- fig: Object \tMatplotlib figure width: Integer \tImage width in pixels height: Integer \tImage height in pixels dpi = Float \tDC resolution """ dpi *= float(zoom) figure.set_figwidth(width / dpi) figure.set_figheight(height / dpi) figure.subplots_adjust() with warnings.catch_warnings(): warnings.simplefilter("ignore") try: # The padding is too small for small sizes. This fixes it. figure.tight_layout(pad=1.0/zoom) except ValueError: pass figure.set_canvas(FigureCanvas(figure)) png_stream = StringIO() figure.savefig(png_stream, format='png', dpi=(dpi)) png_stream.seek(0) img = wx.ImageFromStream(png_stream, type=wx.BITMAP_TYPE_PNG) return wx.BitmapFromImage(img)
python
def fig2bmp(figure, width, height, dpi, zoom): """Returns wx.Bitmap from matplotlib chart Parameters ---------- fig: Object \tMatplotlib figure width: Integer \tImage width in pixels height: Integer \tImage height in pixels dpi = Float \tDC resolution """ dpi *= float(zoom) figure.set_figwidth(width / dpi) figure.set_figheight(height / dpi) figure.subplots_adjust() with warnings.catch_warnings(): warnings.simplefilter("ignore") try: # The padding is too small for small sizes. This fixes it. figure.tight_layout(pad=1.0/zoom) except ValueError: pass figure.set_canvas(FigureCanvas(figure)) png_stream = StringIO() figure.savefig(png_stream, format='png', dpi=(dpi)) png_stream.seek(0) img = wx.ImageFromStream(png_stream, type=wx.BITMAP_TYPE_PNG) return wx.BitmapFromImage(img)
[ "def", "fig2bmp", "(", "figure", ",", "width", ",", "height", ",", "dpi", ",", "zoom", ")", ":", "dpi", "*=", "float", "(", "zoom", ")", "figure", ".", "set_figwidth", "(", "width", "/", "dpi", ")", "figure", ".", "set_figheight", "(", "height", "/", "dpi", ")", "figure", ".", "subplots_adjust", "(", ")", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", "simplefilter", "(", "\"ignore\"", ")", "try", ":", "# The padding is too small for small sizes. This fixes it.", "figure", ".", "tight_layout", "(", "pad", "=", "1.0", "/", "zoom", ")", "except", "ValueError", ":", "pass", "figure", ".", "set_canvas", "(", "FigureCanvas", "(", "figure", ")", ")", "png_stream", "=", "StringIO", "(", ")", "figure", ".", "savefig", "(", "png_stream", ",", "format", "=", "'png'", ",", "dpi", "=", "(", "dpi", ")", ")", "png_stream", ".", "seek", "(", "0", ")", "img", "=", "wx", ".", "ImageFromStream", "(", "png_stream", ",", "type", "=", "wx", ".", "BITMAP_TYPE_PNG", ")", "return", "wx", ".", "BitmapFromImage", "(", "img", ")" ]
Returns wx.Bitmap from matplotlib chart Parameters ---------- fig: Object \tMatplotlib figure width: Integer \tImage width in pixels height: Integer \tImage height in pixels dpi = Float \tDC resolution
[ "Returns", "wx", ".", "Bitmap", "from", "matplotlib", "chart" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/charts.py#L71-L110
236,595
manns/pyspread
pyspread/src/lib/charts.py
fig2x
def fig2x(figure, format): """Returns svg from matplotlib chart""" # Save svg to file like object svg_io io = StringIO() figure.savefig(io, format=format) # Rewind the file like object io.seek(0) data = io.getvalue() io.close() return data
python
def fig2x(figure, format): """Returns svg from matplotlib chart""" # Save svg to file like object svg_io io = StringIO() figure.savefig(io, format=format) # Rewind the file like object io.seek(0) data = io.getvalue() io.close() return data
[ "def", "fig2x", "(", "figure", ",", "format", ")", ":", "# Save svg to file like object svg_io", "io", "=", "StringIO", "(", ")", "figure", ".", "savefig", "(", "io", ",", "format", "=", "format", ")", "# Rewind the file like object", "io", ".", "seek", "(", "0", ")", "data", "=", "io", ".", "getvalue", "(", ")", "io", ".", "close", "(", ")", "return", "data" ]
Returns svg from matplotlib chart
[ "Returns", "svg", "from", "matplotlib", "chart" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/charts.py#L113-L126
236,596
manns/pyspread
pyspread/src/lib/charts.py
ChartFigure._xdate_setter
def _xdate_setter(self, xdate_format='%Y-%m-%d'): """Makes x axis a date axis with auto format Parameters ---------- xdate_format: String \tSets date formatting """ if xdate_format: # We have to validate xdate_format. If wrong then bail out. try: self.autofmt_xdate() datetime.date(2000, 1, 1).strftime(xdate_format) except ValueError: self.autofmt_xdate() return self.__axes.xaxis_date() formatter = dates.DateFormatter(xdate_format) self.__axes.xaxis.set_major_formatter(formatter)
python
def _xdate_setter(self, xdate_format='%Y-%m-%d'): """Makes x axis a date axis with auto format Parameters ---------- xdate_format: String \tSets date formatting """ if xdate_format: # We have to validate xdate_format. If wrong then bail out. try: self.autofmt_xdate() datetime.date(2000, 1, 1).strftime(xdate_format) except ValueError: self.autofmt_xdate() return self.__axes.xaxis_date() formatter = dates.DateFormatter(xdate_format) self.__axes.xaxis.set_major_formatter(formatter)
[ "def", "_xdate_setter", "(", "self", ",", "xdate_format", "=", "'%Y-%m-%d'", ")", ":", "if", "xdate_format", ":", "# We have to validate xdate_format. If wrong then bail out.", "try", ":", "self", ".", "autofmt_xdate", "(", ")", "datetime", ".", "date", "(", "2000", ",", "1", ",", "1", ")", ".", "strftime", "(", "xdate_format", ")", "except", "ValueError", ":", "self", ".", "autofmt_xdate", "(", ")", "return", "self", ".", "__axes", ".", "xaxis_date", "(", ")", "formatter", "=", "dates", ".", "DateFormatter", "(", "xdate_format", ")", "self", ".", "__axes", ".", "xaxis", ".", "set_major_formatter", "(", "formatter", ")" ]
Makes x axis a date axis with auto format Parameters ---------- xdate_format: String \tSets date formatting
[ "Makes", "x", "axis", "a", "date", "axis", "with", "auto", "format" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/charts.py#L180-L203
236,597
manns/pyspread
pyspread/src/lib/charts.py
ChartFigure._setup_axes
def _setup_axes(self, axes_data): """Sets up axes for drawing chart""" self.__axes.clear() key_setter = [ ("title", self.__axes.set_title), ("xlabel", self.__axes.set_xlabel), ("ylabel", self.__axes.set_ylabel), ("xscale", self.__axes.set_xscale), ("yscale", self.__axes.set_yscale), ("xticks", self.__axes.set_xticks), ("xtick_labels", self.__axes.set_xticklabels), ("xtick_params", self.__axes.tick_params), ("yticks", self.__axes.set_yticks), ("ytick_labels", self.__axes.set_yticklabels), ("ytick_params", self.__axes.tick_params), ("xlim", self.__axes.set_xlim), ("ylim", self.__axes.set_ylim), ("xgrid", self.__axes.xaxis.grid), ("ygrid", self.__axes.yaxis.grid), ("xdate_format", self._xdate_setter), ] key2setter = OrderedDict(key_setter) for key in key2setter: if key in axes_data and axes_data[key]: try: kwargs_key = key + "_kwargs" kwargs = axes_data[kwargs_key] except KeyError: kwargs = {} if key == "title": # Shift title up kwargs["y"] = 1.08 key2setter[key](axes_data[key], **kwargs)
python
def _setup_axes(self, axes_data): """Sets up axes for drawing chart""" self.__axes.clear() key_setter = [ ("title", self.__axes.set_title), ("xlabel", self.__axes.set_xlabel), ("ylabel", self.__axes.set_ylabel), ("xscale", self.__axes.set_xscale), ("yscale", self.__axes.set_yscale), ("xticks", self.__axes.set_xticks), ("xtick_labels", self.__axes.set_xticklabels), ("xtick_params", self.__axes.tick_params), ("yticks", self.__axes.set_yticks), ("ytick_labels", self.__axes.set_yticklabels), ("ytick_params", self.__axes.tick_params), ("xlim", self.__axes.set_xlim), ("ylim", self.__axes.set_ylim), ("xgrid", self.__axes.xaxis.grid), ("ygrid", self.__axes.yaxis.grid), ("xdate_format", self._xdate_setter), ] key2setter = OrderedDict(key_setter) for key in key2setter: if key in axes_data and axes_data[key]: try: kwargs_key = key + "_kwargs" kwargs = axes_data[kwargs_key] except KeyError: kwargs = {} if key == "title": # Shift title up kwargs["y"] = 1.08 key2setter[key](axes_data[key], **kwargs)
[ "def", "_setup_axes", "(", "self", ",", "axes_data", ")", ":", "self", ".", "__axes", ".", "clear", "(", ")", "key_setter", "=", "[", "(", "\"title\"", ",", "self", ".", "__axes", ".", "set_title", ")", ",", "(", "\"xlabel\"", ",", "self", ".", "__axes", ".", "set_xlabel", ")", ",", "(", "\"ylabel\"", ",", "self", ".", "__axes", ".", "set_ylabel", ")", ",", "(", "\"xscale\"", ",", "self", ".", "__axes", ".", "set_xscale", ")", ",", "(", "\"yscale\"", ",", "self", ".", "__axes", ".", "set_yscale", ")", ",", "(", "\"xticks\"", ",", "self", ".", "__axes", ".", "set_xticks", ")", ",", "(", "\"xtick_labels\"", ",", "self", ".", "__axes", ".", "set_xticklabels", ")", ",", "(", "\"xtick_params\"", ",", "self", ".", "__axes", ".", "tick_params", ")", ",", "(", "\"yticks\"", ",", "self", ".", "__axes", ".", "set_yticks", ")", ",", "(", "\"ytick_labels\"", ",", "self", ".", "__axes", ".", "set_yticklabels", ")", ",", "(", "\"ytick_params\"", ",", "self", ".", "__axes", ".", "tick_params", ")", ",", "(", "\"xlim\"", ",", "self", ".", "__axes", ".", "set_xlim", ")", ",", "(", "\"ylim\"", ",", "self", ".", "__axes", ".", "set_ylim", ")", ",", "(", "\"xgrid\"", ",", "self", ".", "__axes", ".", "xaxis", ".", "grid", ")", ",", "(", "\"ygrid\"", ",", "self", ".", "__axes", ".", "yaxis", ".", "grid", ")", ",", "(", "\"xdate_format\"", ",", "self", ".", "_xdate_setter", ")", ",", "]", "key2setter", "=", "OrderedDict", "(", "key_setter", ")", "for", "key", "in", "key2setter", ":", "if", "key", "in", "axes_data", "and", "axes_data", "[", "key", "]", ":", "try", ":", "kwargs_key", "=", "key", "+", "\"_kwargs\"", "kwargs", "=", "axes_data", "[", "kwargs_key", "]", "except", "KeyError", ":", "kwargs", "=", "{", "}", "if", "key", "==", "\"title\"", ":", "# Shift title up", "kwargs", "[", "\"y\"", "]", "=", "1.08", "key2setter", "[", "key", "]", "(", "axes_data", "[", "key", "]", ",", "*", "*", "kwargs", ")" ]
Sets up axes for drawing chart
[ "Sets", "up", "axes", "for", "drawing", "chart" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/charts.py#L208-L247
236,598
manns/pyspread
pyspread/src/lib/charts.py
ChartFigure.draw_chart
def draw_chart(self): """Plots chart from self.attributes""" if not hasattr(self, "attributes"): return # The first element is always axes data self._setup_axes(self.attributes[0]) for attribute in self.attributes[1:]: series = copy(attribute) # Extract chart type chart_type_string = series.pop("type") x_str, y_str = self.plot_type_xy_mapping[chart_type_string] # Check xdata length if x_str in series and \ len(series[x_str]) != len(series[y_str]): # Wrong length --> ignore xdata series[x_str] = range(len(series[y_str])) else: # Solve the problem that the series data may contain utf-8 data series_list = list(series[x_str]) series_unicode_list = [] for ele in series_list: if isinstance(ele, types.StringType): try: series_unicode_list.append(ele.decode('utf-8')) except Exception: series_unicode_list.append(ele) else: series_unicode_list.append(ele) series[x_str] = tuple(series_unicode_list) fixed_attrs = [] if chart_type_string in self.plot_type_fixed_attrs: for attr in self.plot_type_fixed_attrs[chart_type_string]: # Remove attr if it is a fixed (non-kwd) attr # If a fixed attr is missing, insert a dummy try: fixed_attrs.append(tuple(series.pop(attr))) except KeyError: fixed_attrs.append(()) # Remove contour chart label info from series cl_attrs = {} for contour_label_attr in self.contour_label_attrs: if contour_label_attr in series: cl_attrs[self.contour_label_attrs[contour_label_attr]] = \ series.pop(contour_label_attr) # Remove contourf attributes from series cf_attrs = {} for contourf_attr in self.contourf_attrs: if contourf_attr in series: cf_attrs[self.contourf_attrs[contourf_attr]] = \ series.pop(contourf_attr) if not fixed_attrs or all(fixed_attrs): # Draw series to axes # Do we have a Sankey plot --> build it if chart_type_string == "Sankey": Sankey(self.__axes, **series).finish() else: chart_method = getattr(self.__axes, chart_type_string) plot = chart_method(*fixed_attrs, **series) # Do we have a filled contour? try: if cf_attrs.pop("contour_fill"): cf_attrs.update(series) if "linewidths" in cf_attrs: cf_attrs.pop("linewidths") if "linestyles" in cf_attrs: cf_attrs.pop("linestyles") if not cf_attrs["hatches"]: cf_attrs.pop("hatches") self.__axes.contourf(plot, **cf_attrs) except KeyError: pass # Do we have a contour chart label? try: if cl_attrs.pop("contour_labels"): self.__axes.clabel(plot, **cl_attrs) except KeyError: pass # The legend has to be set up after all series are drawn self._setup_legend(self.attributes[0])
python
def draw_chart(self): """Plots chart from self.attributes""" if not hasattr(self, "attributes"): return # The first element is always axes data self._setup_axes(self.attributes[0]) for attribute in self.attributes[1:]: series = copy(attribute) # Extract chart type chart_type_string = series.pop("type") x_str, y_str = self.plot_type_xy_mapping[chart_type_string] # Check xdata length if x_str in series and \ len(series[x_str]) != len(series[y_str]): # Wrong length --> ignore xdata series[x_str] = range(len(series[y_str])) else: # Solve the problem that the series data may contain utf-8 data series_list = list(series[x_str]) series_unicode_list = [] for ele in series_list: if isinstance(ele, types.StringType): try: series_unicode_list.append(ele.decode('utf-8')) except Exception: series_unicode_list.append(ele) else: series_unicode_list.append(ele) series[x_str] = tuple(series_unicode_list) fixed_attrs = [] if chart_type_string in self.plot_type_fixed_attrs: for attr in self.plot_type_fixed_attrs[chart_type_string]: # Remove attr if it is a fixed (non-kwd) attr # If a fixed attr is missing, insert a dummy try: fixed_attrs.append(tuple(series.pop(attr))) except KeyError: fixed_attrs.append(()) # Remove contour chart label info from series cl_attrs = {} for contour_label_attr in self.contour_label_attrs: if contour_label_attr in series: cl_attrs[self.contour_label_attrs[contour_label_attr]] = \ series.pop(contour_label_attr) # Remove contourf attributes from series cf_attrs = {} for contourf_attr in self.contourf_attrs: if contourf_attr in series: cf_attrs[self.contourf_attrs[contourf_attr]] = \ series.pop(contourf_attr) if not fixed_attrs or all(fixed_attrs): # Draw series to axes # Do we have a Sankey plot --> build it if chart_type_string == "Sankey": Sankey(self.__axes, **series).finish() else: chart_method = getattr(self.__axes, chart_type_string) plot = chart_method(*fixed_attrs, **series) # Do we have a filled contour? try: if cf_attrs.pop("contour_fill"): cf_attrs.update(series) if "linewidths" in cf_attrs: cf_attrs.pop("linewidths") if "linestyles" in cf_attrs: cf_attrs.pop("linestyles") if not cf_attrs["hatches"]: cf_attrs.pop("hatches") self.__axes.contourf(plot, **cf_attrs) except KeyError: pass # Do we have a contour chart label? try: if cl_attrs.pop("contour_labels"): self.__axes.clabel(plot, **cl_attrs) except KeyError: pass # The legend has to be set up after all series are drawn self._setup_legend(self.attributes[0])
[ "def", "draw_chart", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"attributes\"", ")", ":", "return", "# The first element is always axes data", "self", ".", "_setup_axes", "(", "self", ".", "attributes", "[", "0", "]", ")", "for", "attribute", "in", "self", ".", "attributes", "[", "1", ":", "]", ":", "series", "=", "copy", "(", "attribute", ")", "# Extract chart type", "chart_type_string", "=", "series", ".", "pop", "(", "\"type\"", ")", "x_str", ",", "y_str", "=", "self", ".", "plot_type_xy_mapping", "[", "chart_type_string", "]", "# Check xdata length", "if", "x_str", "in", "series", "and", "len", "(", "series", "[", "x_str", "]", ")", "!=", "len", "(", "series", "[", "y_str", "]", ")", ":", "# Wrong length --> ignore xdata", "series", "[", "x_str", "]", "=", "range", "(", "len", "(", "series", "[", "y_str", "]", ")", ")", "else", ":", "# Solve the problem that the series data may contain utf-8 data", "series_list", "=", "list", "(", "series", "[", "x_str", "]", ")", "series_unicode_list", "=", "[", "]", "for", "ele", "in", "series_list", ":", "if", "isinstance", "(", "ele", ",", "types", ".", "StringType", ")", ":", "try", ":", "series_unicode_list", ".", "append", "(", "ele", ".", "decode", "(", "'utf-8'", ")", ")", "except", "Exception", ":", "series_unicode_list", ".", "append", "(", "ele", ")", "else", ":", "series_unicode_list", ".", "append", "(", "ele", ")", "series", "[", "x_str", "]", "=", "tuple", "(", "series_unicode_list", ")", "fixed_attrs", "=", "[", "]", "if", "chart_type_string", "in", "self", ".", "plot_type_fixed_attrs", ":", "for", "attr", "in", "self", ".", "plot_type_fixed_attrs", "[", "chart_type_string", "]", ":", "# Remove attr if it is a fixed (non-kwd) attr", "# If a fixed attr is missing, insert a dummy", "try", ":", "fixed_attrs", ".", "append", "(", "tuple", "(", "series", ".", "pop", "(", "attr", ")", ")", ")", "except", "KeyError", ":", "fixed_attrs", ".", "append", "(", "(", ")", ")", "# Remove contour chart label info from series", "cl_attrs", "=", "{", "}", "for", "contour_label_attr", "in", "self", ".", "contour_label_attrs", ":", "if", "contour_label_attr", "in", "series", ":", "cl_attrs", "[", "self", ".", "contour_label_attrs", "[", "contour_label_attr", "]", "]", "=", "series", ".", "pop", "(", "contour_label_attr", ")", "# Remove contourf attributes from series", "cf_attrs", "=", "{", "}", "for", "contourf_attr", "in", "self", ".", "contourf_attrs", ":", "if", "contourf_attr", "in", "series", ":", "cf_attrs", "[", "self", ".", "contourf_attrs", "[", "contourf_attr", "]", "]", "=", "series", ".", "pop", "(", "contourf_attr", ")", "if", "not", "fixed_attrs", "or", "all", "(", "fixed_attrs", ")", ":", "# Draw series to axes", "# Do we have a Sankey plot --> build it", "if", "chart_type_string", "==", "\"Sankey\"", ":", "Sankey", "(", "self", ".", "__axes", ",", "*", "*", "series", ")", ".", "finish", "(", ")", "else", ":", "chart_method", "=", "getattr", "(", "self", ".", "__axes", ",", "chart_type_string", ")", "plot", "=", "chart_method", "(", "*", "fixed_attrs", ",", "*", "*", "series", ")", "# Do we have a filled contour?", "try", ":", "if", "cf_attrs", ".", "pop", "(", "\"contour_fill\"", ")", ":", "cf_attrs", ".", "update", "(", "series", ")", "if", "\"linewidths\"", "in", "cf_attrs", ":", "cf_attrs", ".", "pop", "(", "\"linewidths\"", ")", "if", "\"linestyles\"", "in", "cf_attrs", ":", "cf_attrs", ".", "pop", "(", "\"linestyles\"", ")", "if", "not", "cf_attrs", "[", "\"hatches\"", "]", ":", "cf_attrs", ".", "pop", "(", "\"hatches\"", ")", "self", ".", "__axes", ".", "contourf", "(", "plot", ",", "*", "*", "cf_attrs", ")", "except", "KeyError", ":", "pass", "# Do we have a contour chart label?", "try", ":", "if", "cl_attrs", ".", "pop", "(", "\"contour_labels\"", ")", ":", "self", ".", "__axes", ".", "clabel", "(", "plot", ",", "*", "*", "cl_attrs", ")", "except", "KeyError", ":", "pass", "# The legend has to be set up after all series are drawn", "self", ".", "_setup_legend", "(", "self", ".", "attributes", "[", "0", "]", ")" ]
Plots chart from self.attributes
[ "Plots", "chart", "from", "self", ".", "attributes" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/charts.py#L255-L347
236,599
manns/pyspread
pyspread/src/gui/_grid_table.py
GridTable.GetSource
def GetSource(self, row, col, table=None): """Return the source string of a cell""" if table is None: table = self.grid.current_table value = self.code_array((row, col, table)) if value is None: return u"" else: return value
python
def GetSource(self, row, col, table=None): """Return the source string of a cell""" if table is None: table = self.grid.current_table value = self.code_array((row, col, table)) if value is None: return u"" else: return value
[ "def", "GetSource", "(", "self", ",", "row", ",", "col", ",", "table", "=", "None", ")", ":", "if", "table", "is", "None", ":", "table", "=", "self", ".", "grid", ".", "current_table", "value", "=", "self", ".", "code_array", "(", "(", "row", ",", "col", ",", "table", ")", ")", "if", "value", "is", "None", ":", "return", "u\"\"", "else", ":", "return", "value" ]
Return the source string of a cell
[ "Return", "the", "source", "string", "of", "a", "cell" ]
0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid_table.py#L69-L80