コード例 #1
0
 def body(self,parent,options):
     preferences = Preferences()
     logging_config = preferences.get_logging_config()
     if logging_config is not None:
         set_logger_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')
     
     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=2, column=0,sticky='nsw')
     loggingGroup.columnconfigure(1,pad=7)
     
     levels = get_logger_levels_for_names(['qiskit_acqua'])
     loglevel = levels[0]
     
     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
コード例 #2
0
ファイル: _model.py プロジェクト: ajavadia/qiskit-aqua
 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
コード例 #3
0
ファイル: _model.py プロジェクト: ajavadia/qiskit-aqua
 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
コード例 #4
0
    def body(self, parent, options):
        preferences = Preferences()
        logging_config = preferences.get_logging_config()
        if logging_config is not None:
            set_logger_config(logging_config)

        self._apiToken.set(preferences.get_token(''))
        self._url.set(preferences.get_url(Preferences.URL))
        self._hub.set(preferences.get_hub(''))
        self._group.set(preferences.get_group(''))
        self._project.set(preferences.get_project(''))
        self._config_path.set(preferences.get_qconfig_path(''))
        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')
        qiskitGroup.columnconfigure(0, weight=1)
        qiskitGroup.columnconfigure(1, pad=7)
        ttk.Label(qiskitGroup, text="Token:", borderwidth=0,
                  anchor=tk.E).grid(row=0, column=0, sticky='nsew')
        self._apiTokenEntry = EntryCustom(qiskitGroup,
                                          textvariable=self._apiToken,
                                          width=120,
                                          state=tk.NORMAL)
        self._apiTokenEntry.grid(row=0, column=1, sticky='nsew')
        ttk.Label(qiskitGroup, text="URL:", borderwidth=0,
                  anchor=tk.E).grid(row=1, column=0, sticky='nsew')
        self._urlEntry = EntryCustom(qiskitGroup,
                                     textvariable=self._url,
                                     width=60,
                                     state=tk.NORMAL)
        self._urlEntry.grid(row=1, column=1, sticky='nsw')
        ttk.Label(qiskitGroup, text="Hub:", borderwidth=0,
                  anchor=tk.E).grid(row=2, column=0, sticky='nsew')
        self._hubEntry = EntryCustom(qiskitGroup,
                                     textvariable=self._hub,
                                     state=tk.NORMAL)
        self._hubEntry.grid(row=2, column=1, sticky='nsw')
        ttk.Label(qiskitGroup, text="Group:", borderwidth=0,
                  anchor=tk.E).grid(row=3, column=0, sticky='nsew')
        self._groupEntry = EntryCustom(qiskitGroup,
                                       textvariable=self._group,
                                       state=tk.NORMAL)
        self._groupEntry.grid(row=3, column=1, sticky='nsw')
        ttk.Label(qiskitGroup, text="Project:", borderwidth=0,
                  anchor=tk.E).grid(row=4, column=0, sticky='nsew')
        self._projectEntry = EntryCustom(qiskitGroup,
                                         textvariable=self._project,
                                         state=tk.NORMAL)
        self._projectEntry.grid(row=4, column=1, sticky='nsw')
        ttk.Label(qiskitGroup, text="Path:", borderwidth=0,
                  anchor=tk.E).grid(row=5, column=0, sticky='nsew')
        ttk.Label(qiskitGroup,
                  textvariable=self._config_path,
                  borderwidth=0,
                  anchor=tk.W).grid(row=5, column=1, sticky='nsw')

        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')

        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=2, column=0, sticky='nsw')
        loggingGroup.columnconfigure(1, pad=7)

        levels = get_logger_levels_for_names(['qiskit_acqua'])
        loglevel = levels[0]

        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._label_text = tk.StringVar()
        self._label = ttk.Label(parent,
                                foreground='red',
                                textvariable=self._label_text,
                                borderwidth=0)
        self._label.grid(padx=(7, 7), pady=6, row=2, column=0)
        self._label.grid_remove()

        self.entry = self._apiTokenEntry
        return self.entry  # initial focus