Ignore:
Timestamp:
Nov 22, 2018 3:47:13 AM (5 years ago)
Author:
Piotr Rozyczko <piotr.rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
72651df
Parents:
21e71f1
Message:

Allow editing models with corresponding C-files. SASVIEW-1208

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Utilities/TabbedModelEditor.py

    rc5e0d84 rf2e199e  
    117117            return 
    118118 
     119        # remove c-plugin tab, if present. 
     120        if self.tabWidget.count()>1: 
     121            self.tabWidget.removeTab(1) 
    119122        self.loadFile(filename) 
    120123 
     
    130133        self.filename = filename 
    131134        display_name, _ = os.path.splitext(os.path.basename(filename)) 
    132  
    133135        self.setWindowTitle(self.window_title + " - " + display_name) 
     136        # Name the tab with .py filename 
     137        display_name = os.path.basename(filename) 
     138        self.tabWidget.setTabText(0, display_name) 
     139 
     140        # See if there is filename.c present 
     141        c_path = self.filename.replace(".py", ".c") 
     142        if not os.path.isfile(c_path): return 
     143        # add a tab with the same highlighting 
     144        display_name = os.path.basename(c_path) 
     145        self.c_editor_widget = ModelEditor(self, is_python=False) 
     146        self.tabWidget.addTab(self.c_editor_widget, display_name) 
     147        # Read in the file and set in on the widget 
     148        with open(c_path, 'r') as plugin: 
     149            self.c_editor_widget.txtEditor.setPlainText(plugin.read()) 
     150        self.c_editor_widget.modelModified.connect(self.editorModelModified) 
    134151 
    135152    def onModifiedExit(self): 
Note: See TracChangeset for help on using the changeset viewer.