idx int64 0 252k | question stringlengths 48 5.28k | target stringlengths 5 1.23k |
|---|---|---|
231,400 | def OnNew ( self , event ) : if undo . stack ( ) . haschanged ( ) : save_choice = self . interfaces . get_save_request_from_user ( ) if save_choice is None : return elif save_choice : post_command_event ( self . main_window , self . main_window . SaveMsg ) shape = self . interfaces . get_dimensions_from_user ( no_dim =... | New grid event handler |
231,401 | def OnOpen ( self , event ) : if undo . stack ( ) . haschanged ( ) : save_choice = self . interfaces . get_save_request_from_user ( ) if save_choice is None : return elif save_choice : post_command_event ( self . main_window , self . main_window . SaveMsg ) f2w = get_filetypes2wildcards ( [ "pys" , "pysu" , "xls" , "xl... | File open event handler |
231,402 | 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" , ... | File save event handler |
231,403 | def OnSaveAs ( self , event ) : 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 : def... | File save as event handler |
231,404 | def OnImport ( self , event ) : 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 N... | File import event handler |
231,405 | 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 selection_bbox = selection . get_bbox ( ) f2w = get_filetypes2wildcards ( [ "csv" , "pdf" , "svg" ] ) filters = f2w . keys ( ) wildcards =... | File export event handler |
231,406 | def OnExportPDF ( self , event ) : wildcards = get_filetypes2wildcards ( [ "pdf" ] ) . values ( ) if not wildcards : return wildcard = "|" . join ( wildcards ) message = _ ( "Choose file path for PDF export." ) style = wx . SAVE filepath , filterindex = self . interfaces . get_filepath_findex_from_user ( wildcard , mes... | Export PDF event handler |
231,407 | 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\np... | File approve event handler |
231,408 | 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_global... | Clear globals event handler |
231,409 | 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 |
231,410 | def _get_print_area ( self ) : selection = self . main_window . grid . selection print_area = selection . get_bbox ( ) 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 |
231,411 | 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 |
231,412 | 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 |
231,413 | 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 cut event handler |
231,414 | def OnCopy ( self , event ) : focus = self . main_window . FindFocus ( ) if isinstance ( focus , wx . TextCtrl ) : 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 |
231,415 | def OnCopyResult ( self , event ) : selection = self . main_window . grid . selection data = self . main_window . actions . copy_result ( selection ) if type ( data ) is wx . _gdi . Bitmap : self . main_window . clipboard . set_clipboard ( data , datatype = "bitmap" ) else : self . main_window . clipboard . set_clipboa... | Clipboard copy results event handler |
231,416 | def OnPaste ( self , event ) : data = self . main_window . clipboard . get_clipboard ( ) focus = self . main_window . FindFocus ( ) if isinstance ( focus , wx . TextCtrl ) : focus . WriteText ( data ) else : key = self . main_window . grid . actions . cursor with undo . group ( _ ( "Paste" ) ) : self . main_window . ac... | Clipboard paste event handler |
231,417 | 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 |
231,418 | 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 |
231,419 | def OnFontDialog ( self , event ) : 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 ( siz... | Event handler for launching font dialog |
231,420 | def OnTextColorDialog ( self , event ) : dlg = wx . ColourDialog ( self . main_window ) dlg . GetColourData ( ) . SetChooseFull ( True ) if dlg . ShowModal ( ) == wx . ID_OK : data = dlg . GetColourData ( ) color = data . GetColour ( ) . GetRGB ( ) post_command_event ( self . main_window , self . main_window . TextColo... | Event handler for launching text color dialog |
231,421 | def OnMacroListLoad ( self , event ) : 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... | Macro list load event handler |
231,422 | def OnMacroListSave ( self , event ) : 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... | Macro list save event handler |
231,423 | def OnDependencies ( self , event ) : dlg = DependencyDialog ( self . main_window ) dlg . ShowModal ( ) dlg . Destroy ( ) | Display dependency dialog |
231,424 | 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 ,... | Adds items in data as a submenu to parent |
231,425 | def OnMenu ( self , event ) : msgtype = self . ids_msgs [ event . GetId ( ) ] post_command_event ( self . parent , msgtype ) | Menu event handler |
231,426 | 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 ( ) ) even... | Menu state update |
231,427 | def OnFont ( self , event ) : font_data = wx . FontData ( ) 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_d... | Check event handler |
231,428 | 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 |
231,429 | def OnSecondaryCheckbox ( self , event ) : self . attrs [ "top" ] = event . IsChecked ( ) self . attrs [ "right" ] = event . IsChecked ( ) post_command_event ( self , self . DrawChartMsg ) | Top Checkbox event handler |
231,430 | def OnPadIntCtrl ( self , event ) : self . attrs [ "pad" ] = event . GetValue ( ) post_command_event ( self , self . DrawChartMsg ) | Pad IntCtrl event handler |
231,431 | def OnLabelSizeIntCtrl ( self , event ) : self . attrs [ "labelsize" ] = event . GetValue ( ) post_command_event ( self , self . DrawChartMsg ) | Label size IntCtrl event handler |
231,432 | def get_code ( self ) : selection = self . GetSelection ( ) if selection == wx . NOT_FOUND : selection = 0 return self . styles [ selection ] [ 1 ] | Returns code representation of value of widget |
231,433 | 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 |
231,434 | 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 |
231,435 | 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 |
231,436 | def update ( self , series_list ) : if not series_list : self . series_notebook . AddPage ( wx . Panel ( self , - 1 ) , _ ( "+" ) ) return self . updating = True self . series_notebook . DeleteAllPages ( ) for page , attrdict in enumerate ( series_list ) : series_panel = SeriesPanel ( self . grid , attrdict ) name = "S... | Updates widget content from series_list |
231,437 | def OnSeriesChanged ( self , event ) : selection = event . GetSelection ( ) if not self . updating and selection == self . series_notebook . GetPageCount ( ) - 1 : new_panel = SeriesPanel ( self , { "type" : "plot" } ) self . series_notebook . InsertPage ( selection , new_panel , _ ( "Series" ) ) event . Skip ( ) | FlatNotebook change event handler |
231,438 | 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 .... | Updates figure on data change |
231,439 | def get_figure ( self , code ) : if code == self . figure_code_old and self . figure_cache : return self . figure_cache self . figure_code_old = code key = self . grid . actions . cursor cell_result = self . grid . code_array . _eval_cell ( key , code ) if isinstance ( cell_result , matplotlib . pyplot . Figure ) : sel... | Returns figure from executing code in grid |
231,440 | def set_code ( self , 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 ( a... | Update widgets from code |
231,441 | def get_code ( self ) : def dict2str ( attr_dict ) : 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 [ ... | Returns code that generates figure from widgets |
231,442 | 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 |
231,443 | def parameters ( self ) : return self . block_tl , self . block_br , self . rows , self . cols , self . cells | Returns tuple of selection parameters of self |
231,444 | def get_access_string ( self , shape , table ) : rows , columns , tables = shape assert all ( dim > 0 for dim in shape ) assert 0 <= table < tables string_list = [ ] templ = "[(r, c, {}) for r in xrange({}, {}) for c in xrange({}, {})]" for ( top , left ) , ( bottom , right ) in izip ( self . block_tl , self . block_br... | Returns a string with which the selection can be accessed |
231,445 | 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_c... | Returns a new selection that is shifted by rows and cols . |
231,446 | 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... | Selects cells of grid with selection content |
231,447 | 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 |
231,448 | 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 : figure . tight_layout ( pad = 1.0 / zoom ) except ValueE... | Returns wx . Bitmap from matplotlib chart |
231,449 | def fig2x ( figure , format ) : io = StringIO ( ) figure . savefig ( io , format = format ) io . seek ( 0 ) data = io . getvalue ( ) io . close ( ) return data | Returns svg from matplotlib chart |
231,450 | def _xdate_setter ( self , xdate_format = '%Y-%m-%d' ) : if xdate_format : 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 . xax... | Makes x axis a date axis with auto format |
231,451 | 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 . __... | Sets up axes for drawing chart |
231,452 | def draw_chart ( self ) : if not hasattr ( self , "attributes" ) : return self . _setup_axes ( self . attributes [ 0 ] ) for attribute in self . attributes [ 1 : ] : series = copy ( attribute ) chart_type_string = series . pop ( "type" ) x_str , y_str = self . plot_type_xy_mapping [ chart_type_string ] if x_str in seri... | Plots chart from self . attributes |
231,453 | 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 |
231,454 | def GetValue ( self , row , col , table = None ) : if table is None : table = self . grid . current_table try : cell_code = self . code_array ( ( row , col , table ) ) except IndexError : cell_code = None maxlength = int ( config [ "max_textctrl_length" ] ) if cell_code is not None and len ( cell_code ) > maxlength : c... | Return the result value of a cell line split if too much data |
231,455 | def SetValue ( self , row , col , value , refresh = True ) : value = "" . join ( value . split ( "\n" ) ) key = row , col , self . grid . current_table old_code = self . grid . code_array ( key ) if old_code is None : old_code = "" if value != old_code : self . grid . actions . set_code ( key , value ) | Set the value of a cell merge line breaks |
231,456 | def UpdateValues ( self ) : msg = wx . grid . GridTableMessage ( self , wx . grid . GRIDTABLE_REQUEST_VIEW_GET_VALUES ) self . grid . ProcessTableMessage ( msg ) | Update all displayed values |
231,457 | def post_command_event ( target , msg_cls , ** kwargs ) : msg = msg_cls ( id = - 1 , ** kwargs ) wx . PostEvent ( target , msg ) | Posts command event to main window |
231,458 | def _convert_clipboard ( self , datastring = None , sep = '\t' ) : if datastring is None : datastring = self . get_clipboard ( ) data_it = ( ( ele for ele in line . split ( sep ) ) for line in datastring . splitlines ( ) ) return data_it | Converts data string to iterable . |
231,459 | def get_clipboard ( self ) : bmpdata = wx . BitmapDataObject ( ) textdata = wx . TextDataObject ( ) if self . clipboard . Open ( ) : is_bmp_present = self . clipboard . GetData ( bmpdata ) self . clipboard . GetData ( textdata ) self . clipboard . Close ( ) else : wx . MessageBox ( _ ( "Can't open the clipboard" ) , _ ... | Returns the clipboard content |
231,460 | def set_clipboard ( self , data , datatype = "text" ) : error_log = [ ] if datatype == "text" : clip_data = wx . TextDataObject ( text = data ) elif datatype == "bitmap" : clip_data = wx . BitmapDataObject ( bitmap = data ) else : msg = _ ( "Datatype {type} unknown" ) . format ( type = datatype ) raise ValueError ( msg... | Writes data to the clipboard |
231,461 | def draw_rect ( grid , attr , dc , rect ) : dc . SetBrush ( wx . Brush ( wx . Colour ( 15 , 255 , 127 ) , wx . SOLID ) ) dc . SetPen ( wx . Pen ( wx . BLUE , 1 , wx . SOLID ) ) dc . DrawRectangleRect ( rect ) | Draws a rect |
231,462 | def _is_aborted ( self , cycle , statustext , total_elements = None , freq = None ) : if total_elements is None : statustext += _ ( "{nele} elements processed. Press <Esc> to abort." ) else : statustext += _ ( "{nele} of {totalele} elements processed. " "Press <Esc> to abort." ) if freq is None : show_msg = False freq ... | Displays progress and returns True if abort |
231,463 | def validate_signature ( self , filename ) : if not GPG_PRESENT : return False sigfilename = filename + '.sig' try : with open ( sigfilename ) : pass except IOError : return False return verify ( sigfilename , filename ) | Returns True if a valid signature is present for filename |
231,464 | def leave_safe_mode ( self ) : self . code_array . safe_mode = False self . code_array . result_cache . clear ( ) self . main_window . actions . execute_macros ( ) post_command_event ( self . main_window , self . SafeModeExitMsg ) | Leaves safe mode |
231,465 | def approve ( self , filepath ) : try : signature_valid = self . validate_signature ( filepath ) except ValueError : signature_valid = False if signature_valid : self . leave_safe_mode ( ) post_command_event ( self . main_window , self . SafeModeExitMsg ) statustext = _ ( "Valid signature found. File is trusted." ) pos... | Sets safe mode if signature missing of invalid |
231,466 | def clear_globals_reload_modules ( self ) : self . code_array . clear_globals ( ) self . code_array . reload_modules ( ) self . code_array . result_cache . clear ( ) | Clears globals and reloads modules |
231,467 | def _get_file_version ( self , infile ) : for line1 in infile : if line1 . strip ( ) != "[Pyspread save file version]" : raise ValueError ( _ ( "File format unsupported." ) ) break for line2 in infile : return line2 . strip ( ) | Returns infile version string . |
231,468 | def clear ( self , shape = None ) : self . grid . actions . cursor = 0 , 0 , 0 self . grid . current_table = 0 post_command_event ( self . main_window . grid , self . GotoCellMsg , key = ( 0 , 0 , 0 ) ) self . code_array . dict_grid . clear ( ) del self . code_array . dict_grid . cell_attributes [ : ] if shape is not N... | Empties grid and sets shape to shape |
231,469 | def open ( self , event ) : filepath = event . attr [ "filepath" ] try : filetype = event . attr [ "filetype" ] except KeyError : try : file_ext = filepath . strip ( ) . split ( "." ) [ - 1 ] except : file_ext = None if file_ext in [ "pys" , "pysu" , "xls" , "xlsx" , "ods" ] : filetype = file_ext else : filetype = "pys... | Opens a file that is specified in event . attr |
231,470 | def sign_file ( self , filepath ) : if not GPG_PRESENT : return signed_data = sign ( filepath ) signature = signed_data . data if signature is None or not signature : statustext = _ ( 'Error signing file. ' ) + signed_data . stderr try : post_command_event ( self . main_window , self . StatusBarMsg , text = statustext ... | Signs file if possible |
231,471 | def _set_save_states ( self ) : wx . BeginBusyCursor ( ) self . saving = True self . grid . Disable ( ) | Sets application save states |
231,472 | def _release_save_states ( self ) : self . saving = False self . grid . Enable ( ) wx . EndBusyCursor ( ) try : post_command_event ( self . main_window , self . ContentChangedMsg ) except TypeError : pass | Releases application save states |
231,473 | def _move_tmp_file ( self , tmpfilepath , filepath ) : try : shutil . move ( tmpfilepath , filepath ) except OSError , err : post_command_event ( self . main_window , self . StatusBarMsg , text = err ) | Moves tmpfile over file after saving is finished |
231,474 | def _save_xls ( self , filepath ) : Interface = self . type2interface [ "xls" ] workbook = xlwt . Workbook ( ) interface = Interface ( self . grid . code_array , workbook ) interface . from_code_array ( ) try : workbook . save ( filepath ) except IOError , err : try : post_command_event ( self . main_window , self . St... | Saves file as xls workbook |
231,475 | def _save_pys ( self , filepath ) : try : with Bz2AOpen ( filepath , "wb" , main_window = self . main_window ) as outfile : interface = Pys ( self . grid . code_array , outfile ) interface . from_code_array ( ) except ( IOError , ValueError ) , err : try : post_command_event ( self . main_window , self . StatusBarMsg ,... | Saves file as pys file and returns True if save success |
231,476 | def _save_sign ( self , filepath ) : if self . code_array . safe_mode : msg = _ ( "File saved but not signed because it is unapproved." ) try : post_command_event ( self . main_window , self . StatusBarMsg , text = msg ) except TypeError : pass else : try : self . sign_file ( filepath ) except ValueError , err : msg = ... | Sign so that the new file may be retrieved without safe mode |
231,477 | def save ( self , event ) : filepath = event . attr [ "filepath" ] try : filetype = event . attr [ "filetype" ] except KeyError : filetype = "pys" if self . saving : return __ , tmpfilepath = tempfile . mkstemp ( ) if filetype == "xls" : self . _set_save_states ( ) self . _save_xls ( tmpfilepath ) self . _move_tmp_file... | Saves a file that is specified in event . attr |
231,478 | def set_row_height ( self , row , height ) : post_command_event ( self . main_window , self . ContentChangedMsg ) tab = self . grid . current_table self . code_array . set_row_height ( row , tab , height ) self . grid . SetRowSize ( row , height ) | Sets row height and marks grid as changed |
231,479 | def insert_rows ( self , row , no_rows = 1 ) : post_command_event ( self . main_window , self . ContentChangedMsg ) tab = self . grid . current_table self . code_array . insert ( row , no_rows , axis = 0 , tab = tab ) | Adds no_rows rows before row appends if row > maxrows |
231,480 | def delete_rows ( self , row , no_rows = 1 ) : post_command_event ( self . main_window , self . ContentChangedMsg ) tab = self . grid . current_table try : self . code_array . delete ( row , no_rows , axis = 0 , tab = tab ) except ValueError , err : post_command_event ( self . main_window , self . StatusBarMsg , text =... | Deletes no_rows rows and marks grid as changed |
231,481 | def set_col_width ( self , col , width ) : post_command_event ( self . main_window , self . ContentChangedMsg ) tab = self . grid . current_table self . code_array . set_col_width ( col , tab , width ) self . grid . SetColSize ( col , width ) | Sets column width and marks grid as changed |
231,482 | def insert_cols ( self , col , no_cols = 1 ) : post_command_event ( self . main_window , self . ContentChangedMsg ) tab = self . grid . current_table self . code_array . insert ( col , no_cols , axis = 1 , tab = tab ) | Adds no_cols columns before col appends if col > maxcols |
231,483 | def delete_cols ( self , col , no_cols = 1 ) : post_command_event ( self . main_window , self . ContentChangedMsg ) tab = self . grid . current_table try : self . code_array . delete ( col , no_cols , axis = 1 , tab = tab ) except ValueError , err : post_command_event ( self . main_window , self . StatusBarMsg , text =... | Deletes no_cols column and marks grid as changed |
231,484 | def insert_tabs ( self , tab , no_tabs = 1 ) : post_command_event ( self . main_window , self . ContentChangedMsg ) self . code_array . insert ( tab , no_tabs , axis = 2 ) shape = self . grid . code_array . shape post_command_event ( self . main_window , self . ResizeGridMsg , shape = shape ) | Adds no_tabs tabs before table appends if tab > maxtabs |
231,485 | def delete_tabs ( self , tab , no_tabs = 1 ) : post_command_event ( self . main_window , self . ContentChangedMsg ) try : self . code_array . delete ( tab , no_tabs , axis = 2 ) shape = self . grid . code_array . shape post_command_event ( self . main_window , self . ResizeGridMsg , shape = shape ) except ValueError , ... | Deletes no_tabs tabs and marks grid as changed |
231,486 | def on_key ( self , event ) : if event . GetKeyCode ( ) == wx . WXK_ESCAPE and self . pasting or self . grid . actions . saving : self . need_abort = True event . Skip ( ) | Sets abort if pasting and if escape is pressed |
231,487 | def _get_full_key ( self , key ) : length = len ( key ) if length == 3 : return key elif length == 2 : row , col = key tab = self . grid . current_table return row , col , tab else : msg = _ ( "Key length {length} not in (2, 3)" ) . format ( length = length ) raise ValueError ( msg ) | Returns full key even if table is omitted |
231,488 | def _show_final_overflow_message ( self , row_overflow , col_overflow ) : if row_overflow and col_overflow : overflow_cause = _ ( "rows and columns" ) elif row_overflow : overflow_cause = _ ( "rows" ) elif col_overflow : overflow_cause = _ ( "columns" ) else : raise AssertionError ( _ ( "Import cell overflow missing" )... | Displays overflow message after import in statusbar |
231,489 | def _show_final_paste_message ( self , tl_key , no_pasted_cells ) : plural = "" if no_pasted_cells == 1 else _ ( "s" ) statustext = _ ( "{ncells} cell{plural} pasted at cell {topleft}" ) . format ( ncells = no_pasted_cells , plural = plural , topleft = tl_key ) post_command_event ( self . main_window , self . StatusBar... | Show actually pasted number of cells |
231,490 | def paste_to_current_cell ( self , tl_key , data , freq = None ) : self . pasting = True grid_rows , grid_cols , __ = self . grid . code_array . shape self . need_abort = False tl_row , tl_col , tl_tab = self . _get_full_key ( tl_key ) row_overflow = False col_overflow = False no_pasted_cells = 0 for src_row , row_data... | Pastes data into grid from top left cell tl_key |
231,491 | def selection_paste_data_gen ( self , selection , data , freq = None ) : ( bb_top , bb_left ) , ( bb_bottom , bb_right ) = selection . get_grid_bbox ( self . grid . code_array . shape ) bbox_height = bb_bottom - bb_top + 1 bbox_width = bb_right - bb_left + 1 for row , row_data in enumerate ( itertools . cycle ( data ) ... | Generator that yields data for selection paste |
231,492 | def paste_to_selection ( self , selection , data , freq = None ) : ( bb_top , bb_left ) , ( bb_bottom , bb_right ) = selection . get_grid_bbox ( self . grid . code_array . shape ) adjusted_data = self . selection_paste_data_gen ( selection , data ) self . paste_to_current_cell ( ( bb_top , bb_left ) , adjusted_data , f... | Pastes data into grid selection |
231,493 | def paste ( self , tl_key , data , freq = None ) : selection = self . get_selection ( ) post_command_event ( self . main_window , self . ContentChangedMsg ) if selection : self . paste_to_selection ( selection , data , freq = freq ) else : self . paste_to_current_cell ( tl_key , data , freq = freq ) | Pastes data into grid marks grid changed |
231,494 | def change_grid_shape ( self , shape ) : post_command_event ( self . main_window , self . ContentChangedMsg ) self . code_array . shape = shape post_command_event ( self . main_window , self . ResizeGridMsg , shape = shape ) self . grid . GetTable ( ) . ResetView ( ) self . code_array . result_cache . clear ( ) | Grid shape change event handler marks content as changed |
231,495 | def replace_cells ( self , key , sorted_row_idxs ) : row , col , tab = key new_keys = { } del_keys = [ ] selection = self . grid . actions . get_selection ( ) for __row , __col , __tab in self . grid . code_array : if __tab == tab and ( not selection or ( __row , __col ) in selection ) : new_row = sorted_row_idxs . ind... | Replaces cells in current selection so that they are sorted |
231,496 | def new ( self , event ) : self . grid . actions . clear ( event . shape ) _grid_table = GridTable ( self . grid , self . grid . code_array ) self . grid . SetTable ( _grid_table , True ) self . grid . update_entry_line ( ) self . grid . update_attribute_toolbar ( ) | Creates a new spreadsheet . Expects code_array in event . |
231,497 | def _zoom_rows ( self , zoom ) : self . grid . SetDefaultRowSize ( self . grid . std_row_size * zoom , resizeExistingRows = True ) self . grid . SetRowLabelSize ( self . grid . row_label_size * zoom ) for row , tab in self . code_array . row_heights : if tab == self . grid . current_table and row < self . grid . code_a... | Zooms grid rows |
231,498 | def _zoom_cols ( self , zoom ) : self . grid . SetDefaultColSize ( self . grid . std_col_size * zoom , resizeExistingCols = True ) self . grid . SetColLabelSize ( self . grid . col_label_size * zoom ) for col , tab in self . code_array . col_widths : if tab == self . grid . current_table and col < self . grid . code_ar... | Zooms grid columns |
231,499 | def _zoom_labels ( self , zoom ) : labelfont = self . grid . GetLabelFont ( ) default_fontsize = get_default_font ( ) . GetPointSize ( ) labelfont . SetPointSize ( max ( 1 , int ( round ( default_fontsize * zoom ) ) ) ) self . grid . SetLabelFont ( labelfont ) | Adjust grid label font to zoom factor |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.