idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
42,500 | def OnDrawBackground ( self , dc , rect , item , flags ) : 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 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 |
42,501 | 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 |
42,502 | 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 |
42,503 | 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 setattr ( self , "GetToolState" , lambda x : self . state ) | Toggles state to next bitmap |
42,504 | 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 |
42,505 | 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 |
42,506 | 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 |
42,507 | 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 |
42,508 | def OnChar ( self , event ) : if not self . ignore_changes : keycode = event . GetKeyCode ( ) if keycode == 13 and not self . GetStringSelection ( ) : self . main_window . grid . SetFocus ( ) if event . ControlDown ( ) : self . SetValue ( quote ( self . GetValue ( ) ) ) return elif keycode == 13 and self . GetStringSelection ( ) : selection_start , selection_stop = self . Selection self . SetSelection ( selection_stop , selection_stop ) return elif keycode == 9 and jedi is None : return elif keycode == 9 and jedi is not None : tiptext = "" code = "" . join ( self . GetValue ( ) . split ( "\n" ) ) position = self . GetInsertionPoint ( ) 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 : 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 ] : 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 : 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 : 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 self . SetToolTip ( wx . ToolTip ( tiptext [ : MAX_TOOLTIP_LENGTH ] ) ) return event . Skip ( ) | Key event method |
42,509 | def Reposition ( self ) : rect = self . GetFieldRect ( 1 ) self . safemode_staticbmp . SetPosition ( ( rect . x , rect . y ) ) self . size_changed = False | Reposition the checkbox |
42,510 | 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 |
42,511 | def _fromGUI ( self , value ) : 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 . |
42,512 | 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 |
42,513 | 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 |
42,514 | def OnResizeGrid ( self , event ) : shape = min ( event . shape [ 2 ] , 2 ** 30 ) self . SetItemCount ( shape ) event . Skip ( ) | Event handler for grid resizing |
42,515 | def OnMouseUp ( self , event ) : if not self . IsInControl : self . IsDrag = False elif self . IsDrag : if not self . IsDrag : self . hitIndex = self . HitTest ( event . GetPosition ( ) ) self . dropIndex = self . hitIndex [ 0 ] if not ( self . dropIndex == self . startIndex or self . dropIndex == - 1 ) : 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 ] ) self . IsDrag = False event . Skip ( ) | Generate a dropIndex . |
42,516 | def _set_properties ( self ) : self . set_icon ( icons [ "PyspreadLogo" ] ) self . minSizeSet = False post_command_event ( self , self . SafeModeExitMsg ) | Setup title icon size scale statusbar main grid |
42,517 | 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 : pane = self . _mgr . GetPane ( pane_name ) toggle_id = self . menubar . FindMenuItem ( _ ( "View" ) , toggle_label ) if toggle_id != - 1 : toggle_item = self . menubar . FindItemById ( toggle_id ) toggle_item . Check ( pane . IsShown ( ) ) | Enable menu bar view item checkmarks |
42,518 | def set_icon ( self , bmp ) : _icon = wx . EmptyIcon ( ) _icon . CopyFromBitmap ( bmp ) self . SetIcon ( _icon ) | Sets main window icon to given wx . Bitmap |
42,519 | def OnToggleFullscreen ( self , event ) : is_full_screen = self . main_window . IsFullScreen ( ) 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 try : self . main_window . _mgr . LoadPerspective ( self . aui_windowed ) except AttributeError : pass else : self . aui_windowed = self . main_window . _mgr . SavePerspective ( ) 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 |
42,520 | def OnContentChanged ( self , event ) : self . main_window . grid . update_attribute_toolbar ( ) title = self . main_window . GetTitle ( ) if undo . stack ( ) . haschanged ( ) : if title [ : 2 ] != "* " : new_title = "* " + title post_command_event ( self . main_window , self . main_window . TitleMsg , text = new_title ) elif title [ : 2 ] == "* " : new_title = title [ 2 : ] post_command_event ( self . main_window , self . main_window . TitleMsg , text = new_title ) | Titlebar star adjustment event handler |
42,521 | def OnSafeModeEntry ( self , event ) : self . main_window . main_menu . enable_file_approve ( True ) self . main_window . grid . Refresh ( ) event . Skip ( ) | Safe mode entry event handler |
42,522 | def OnSafeModeExit ( self , event ) : self . main_window . main_menu . enable_file_approve ( False ) self . main_window . grid . Refresh ( ) event . Skip ( ) | Safe mode exit event handler |
42,523 | def OnClose ( 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 ) config [ "window_layout" ] = repr ( self . main_window . _mgr . SavePerspective ( ) ) self . main_window . _mgr . UnInit ( ) config . save ( ) self . main_window . Destroy ( ) 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 |
42,524 | 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 |
42,525 | 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 |
42,526 | def OnNewGpgKey ( self , event ) : if gnupg is None : return if genkey is None : self . interfaces . display_warning ( _ ( "Python gnupg not found. No key selected." ) , _ ( "Key selection failed." ) ) else : genkey ( ) | New GPG key event handler . |
42,527 | def _toggle_pane ( self , pane ) : if pane . IsShown ( ) : pane . Hide ( ) else : pane . Show ( ) self . main_window . _mgr . Update ( ) | Toggles visibility of given aui pane |
42,528 | 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 |
42,529 | 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 |
42,530 | 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 |
42,531 | 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 |
42,532 | 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 |
42,533 | 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 |
42,534 | 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 |
42,535 | 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 = 3 ) if shape is None : return self . main_window . filepath = None post_command_event ( self . main_window , self . main_window . TitleMsg , text = "pyspread" ) self . main_window . grid . actions . clear_globals_reload_modules ( ) post_command_event ( self . main_window , self . main_window . GridActionNewMsg , shape = shape ) 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 ( ) 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 undo . stack ( ) . clear ( ) undo . stack ( ) . savepoint ( ) try : post_command_event ( self . main_window , self . ContentChangedMsg ) except TypeError : pass | New grid event handler |
42,536 | 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" , "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 : 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 ] self . main_window . filepath = filepath post_command_event ( self . main_window , self . main_window . GridActionOpenMsg , attr = { "filepath" : filepath , "filetype" : filetype } ) 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 undo . stack ( ) . clear ( ) undo . stack ( ) . savepoint ( ) try : post_command_event ( self . main_window , self . ContentChangedMsg ) except TypeError : pass | File open event handler |
42,537 | 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 ( ) for __filetype in __filetypes : if splitext ( filepath ) [ - 1 ] [ 1 : ] == __filetype : filetype = __filetype break if self . main_window . filepath is None or filetype is None : post_command_event ( self . main_window , self . main_window . SaveAsMsg ) return post_command_event ( self . main_window , self . main_window . GridActionSaveMsg , attr = { "filepath" : self . main_window . filepath , "filetype" : filetype } ) undo . stack ( ) . savepoint ( ) statustext = self . main_window . filepath . split ( "/" ) [ - 1 ] + " saved." post_command_event ( self . main_window , self . main_window . StatusBarMsg , text = statustext ) | File save event handler |
42,538 | 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 : default_filterindex = filetypes . index ( default_filetype ) except ValueError : 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 ] if os . path . exists ( filepath ) : if not os . path . isfile ( filepath ) : statustext = _ ( "Directory present. Save aborted." ) post_command_event ( self . main_window , self . main_window . StatusBarMsg , text = statustext ) return 0 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 if filterindex == 0 and filepath [ - 4 : ] != ".pys" : filepath += ".pys" self . main_window . filepath = filepath title_text = filepath . split ( "/" ) [ - 1 ] + " - pyspread" post_command_event ( self . main_window , self . main_window . TitleMsg , text = title_text ) post_command_event ( self . main_window , self . main_window . SaveMsg , attr = { "filetype" : filetype } ) | File save as event handler |
42,539 | 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 None : return import_data = self . main_window . actions . import_file ( filepath , filterindex ) if import_data is None : return 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 |
42,540 | 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 = f2w . values ( ) wildcard = "|" . join ( wildcards ) if selection_bbox is None : maxrow , maxcol , __ = code_array . get_last_filled_cell ( tab ) ( top , left ) , ( bottom , right ) = ( 0 , 0 ) , ( maxrow , maxcol ) else : ( top , left ) , ( bottom , right ) = selection_bbox __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 ) 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 filters [ filterindex ] . startswith ( "cell_" ) : data = figure self . main_window . actions . export_file ( path , filters [ filterindex ] , data , preview_data ) | File export event handler |
42,541 | 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 , message , style ) if filepath is None : return self . main_window . actions . export_cairo ( filepath , "pdf" ) event . Skip ( ) | Export PDF event handler |
42,542 | 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 ) : self . main_window . grid . actions . leave_safe_mode ( ) statustext = _ ( "Safe mode deactivated." ) post_command_event ( self . main_window , self . main_window . StatusBarMsg , text = statustext ) | File approve event handler |
42,543 | 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 |
42,544 | 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 |
42,545 | 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 |
42,546 | 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 |
42,547 | 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 |
42,548 | 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 |
42,549 | 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 |
42,550 | 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_clipboard ( data , datatype = "text" ) event . Skip ( ) | Clipboard copy results event handler |
42,551 | 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 . actions . paste ( key , data ) self . main_window . grid . ForceRefresh ( ) event . Skip ( ) | Clipboard paste event handler |
42,552 | 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 |
42,553 | 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 |
42,554 | 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 ( size ) , - 1 , style , weight , 0 , font ) 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 |
42,555 | 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 . TextColorMsg , color = color ) dlg . Destroy ( ) | Event handler for launching text color dialog |
42,556 | 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 None : return post_command_event ( self . main_window , self . main_window . SafeModeEntryMsg ) self . main_window . actions . open_macros ( filepath ) event . Skip ( ) | Macro list load event handler |
42,557 | 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 None : return macros = self . main_window . grid . code_array . macros self . main_window . actions . save_macros ( filepath , macros ) event . Skip ( ) | Macro list save event handler |
42,558 | def OnDependencies ( self , event ) : dlg = DependencyDialog ( self . main_window ) dlg . ShowModal ( ) dlg . Destroy ( ) | Display dependency dialog |
42,559 | 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 |
42,560 | def OnMenu ( self , event ) : msgtype = self . ids_msgs [ event . GetId ( ) ] post_command_event ( self . parent , msgtype ) | Menu event handler |
42,561 | 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 |
42,562 | 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_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 |
42,563 | 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 |
42,564 | def OnSecondaryCheckbox ( self , event ) : self . attrs [ "top" ] = event . IsChecked ( ) self . attrs [ "right" ] = event . IsChecked ( ) post_command_event ( self , self . DrawChartMsg ) | Top Checkbox event handler |
42,565 | def OnPadIntCtrl ( self , event ) : self . attrs [ "pad" ] = event . GetValue ( ) post_command_event ( self , self . DrawChartMsg ) | Pad IntCtrl event handler |
42,566 | def OnLabelSizeIntCtrl ( self , event ) : self . attrs [ "labelsize" ] = event . GetValue ( ) post_command_event ( self , self . DrawChartMsg ) | Label size IntCtrl event handler |
42,567 | 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 |
42,568 | 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 |
42,569 | 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 |
42,570 | 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 |
42,571 | 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 = "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 |
42,572 | 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 |
42,573 | 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 |
42,574 | 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 ) : self . figure_cache = cell_result return cell_result else : self . figure_cache = charts . ChartFigure ( ) return self . figure_cache | Returns figure from executing code in grid |
42,575 | 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 ( attrs [ : : 2 ] , attrs [ 1 : : 2 ] ) ) ) if not attributes : return 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 ) self . all_series_panel . update ( attributes [ 1 : ] ) | Update widgets from code |
42,576 | 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 [ "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 = "charts." + charts . ChartFigure . __name__ attr_dicts = [ ] attr_dict = { } 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 ) 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 |
42,577 | 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 |
42,578 | def parameters ( self ) : return self . block_tl , self . block_br , self . rows , self . cols , self . cells | Returns tuple of selection parameters of self |
42,579 | 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 ) : string_list += [ templ . format ( table , top , bottom + 1 , left , right + 1 ) ] template = "[({}, c, {}) for c in xrange({})]" for row in self . rows : string_list += [ template . format ( row , table , columns ) ] template = "[(r, {}, {}) for r in xrange({})]" for column in self . cols : string_list += [ template . format ( column , table , rows ) ] 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 |
42,580 | 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 . |
42,581 | 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 |
42,582 | 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 |
42,583 | 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 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 |
42,584 | 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 |
42,585 | 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 . xaxis . set_major_formatter ( formatter ) | Makes x axis a date axis with auto format |
42,586 | 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" : kwargs [ "y" ] = 1.08 key2setter [ key ] ( axes_data [ key ] , ** kwargs ) | Sets up axes for drawing chart |
42,587 | 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 series and len ( series [ x_str ] ) != len ( series [ y_str ] ) : series [ x_str ] = range ( len ( series [ y_str ] ) ) else : 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 ] : try : fixed_attrs . append ( tuple ( series . pop ( attr ) ) ) except KeyError : fixed_attrs . append ( ( ) ) 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 ) 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 ) : 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 ) 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 try : if cl_attrs . pop ( "contour_labels" ) : self . __axes . clabel ( plot , ** cl_attrs ) except KeyError : pass self . _setup_legend ( self . attributes [ 0 ] ) | Plots chart from self . attributes |
42,588 | 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 |
42,589 | 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 : chunk = 80 cell_code = "\n" . join ( cell_code [ i : i + chunk ] for i in xrange ( 0 , len ( cell_code ) , chunk ) ) return cell_code | Return the result value of a cell line split if too much data |
42,590 | 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 |
42,591 | def UpdateValues ( self ) : msg = wx . grid . GridTableMessage ( self , wx . grid . GRIDTABLE_REQUEST_VIEW_GET_VALUES ) self . grid . ProcessTableMessage ( msg ) | Update all displayed values |
42,592 | def post_command_event ( target , msg_cls , ** kwargs ) : msg = msg_cls ( id = - 1 , ** kwargs ) wx . PostEvent ( target , msg ) | Posts command event to main window |
42,593 | 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 . |
42,594 | def get_clipboard ( self ) : bmpdata = wx . BitmapDataObject ( ) textdata = wx . TextDataObject ( ) if self . clipboard . Open ( ) : is_bmp_present = self . clipboard . GetData ( bmpdata ) self . clipboard . GetData ( textdata ) self . clipboard . Close ( ) else : wx . MessageBox ( _ ( "Can't open the clipboard" ) , _ ( "Error" ) ) if is_bmp_present : return bmpdata . GetBitmap ( ) else : return textdata . GetText ( ) | Returns the clipboard content |
42,595 | def set_clipboard ( self , data , datatype = "text" ) : error_log = [ ] if datatype == "text" : clip_data = wx . TextDataObject ( text = data ) elif datatype == "bitmap" : clip_data = wx . BitmapDataObject ( bitmap = data ) else : msg = _ ( "Datatype {type} unknown" ) . format ( type = datatype ) raise ValueError ( msg ) if self . clipboard . Open ( ) : self . clipboard . SetData ( clip_data ) self . clipboard . Close ( ) else : wx . MessageBox ( _ ( "Can't open the clipboard" ) , _ ( "Error" ) ) return error_log | Writes data to the clipboard |
42,596 | 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 |
42,597 | def _is_aborted ( self , cycle , statustext , total_elements = None , freq = None ) : if total_elements is None : statustext += _ ( "{nele} elements processed. Press <Esc> to abort." ) else : statustext += _ ( "{nele} of {totalele} elements processed. " "Press <Esc> to abort." ) if freq is None : show_msg = False freq = 1000 else : show_msg = True if cycle % freq == 0 : if show_msg : text = statustext . format ( nele = cycle , totalele = total_elements ) try : post_command_event ( self . main_window , self . StatusBarMsg , text = text ) except TypeError : pass if is_gtk ( ) : try : wx . Yield ( ) except : pass if self . need_abort : return True return False | Displays progress and returns True if abort |
42,598 | 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 |
42,599 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.