Example #1
0
    def load_file(self, filename):
        if filename is None:
            return []
        try:
            self._parser = InputParser(filename)
            self._parser.parse()
            uipreferences = UIPreferences()
            if uipreferences.get_populate_defaults(True):
                self._parser.validate_merge_defaults()
                self._parser.commit_changes()

            return self._parser.get_section_names()
        except:
            self._parser = None
            raise
Example #2
0
    def new(self):
        try:
            dict = {}
            jsonfile = os.path.join(os.path.dirname(__file__),
                                    'input_template.json')
            with open(jsonfile) as json_file:
                dict = json.load(json_file)

            self._parser = InputParser(dict)
            self._parser.parse()
            uipreferences = UIPreferences()
            if uipreferences.get_populate_defaults(True):
                self._parser.validate_merge_defaults()
                self._parser.commit_changes()

            return self._parser.get_section_names()
        except:
            self._parser = None
            raise
Example #3
0
 def body(self,parent,options):
     preferences = Preferences()
     logging_config = preferences.get_logging_config()
     if logging_config is not None:
         set_logging_config(logging_config)
     
     uipreferences = UIPreferences()
     populate = uipreferences.get_populate_defaults(True)
     self._populateDefaults.set(1 if populate else 0)
     
     qiskitGroup = ttk.LabelFrame(parent,
                                  text='Qiskit Configuration',
                                  padding=(6,6,6,6),
                                  borderwidth=4,
                                  relief=tk.GROOVE)
     qiskitGroup.grid(padx=(7,7),pady=6,row=0, column=0,sticky='nsew')
     self._qconfigview = QconfigView(qiskitGroup)
     
     defaultsGroup = ttk.LabelFrame(parent,
                                  text='Defaults',
                                  padding=(6,6,6,6),
                                  borderwidth=4,
                                  relief=tk.GROOVE)
     defaultsGroup.grid(padx=(7,7),pady=6,row=1, column=0,sticky='nsw')
     defaultsGroup.columnconfigure(1,pad=7)
     
     self._checkButton = ttk.Checkbutton(defaultsGroup,
                                         text="Populate on file new/open",
                                         variable=self._populateDefaults)
     self._checkButton.grid(row=0, column=1,sticky='nsw')
     
     packagesGroup = ttk.LabelFrame(parent,
                                  text='Packages',
                                  padding=(6,6,6,6),
                                  borderwidth=4,
                                  relief=tk.GROOVE)
     packagesGroup.grid(padx=(7,7),pady=6,row=2, column=0,sticky='nsw')
     packagesGroup.columnconfigure(1,pad=7)
     
     frame = ttk.Frame(packagesGroup)
     frame.grid(row=0, column=0,sticky='nsew')
     
     self._packagesPage = PackagesPage(frame,preferences)
     self._packagesPage.pack(side=tk.TOP,fill=tk.BOTH, expand=tk.TRUE)
     self._packagesPage.show_add_button(True)
     self._packagesPage.show_remove_button(self._packagesPage.has_selection())
     self._packagesPage.show_defaults_button(False)
     
     loggingGroup = ttk.LabelFrame(parent,
                                  text='Logging Configuration',
                                  padding=(6,6,6,6),
                                  borderwidth=4,
                                  relief=tk.GROOVE)
     loggingGroup.grid(padx=(7,7),pady=6,row=3, column=0,sticky='nsw')
     loggingGroup.columnconfigure(1,pad=7)
     
     loglevel = get_logging_level()
     
     ttk.Label(loggingGroup,
               text="Level:",
               borderwidth=0,
               anchor=tk.E).grid(row=0, column=0,sticky='nsew')
     self._levelCombo = ttk.Combobox(loggingGroup,
                               exportselection=0,
                               state='readonly',
                               values=list(PreferencesDialog._LOG_LEVELS.values()))
     index = list(PreferencesDialog._LOG_LEVELS.keys()).index(loglevel)
     self._levelCombo.current(index)
     self._levelCombo.grid(row=0, column=1,sticky='nsw')
     
     self.entry = self._qconfigview.initial_focus
     return self.entry # initial focus