Esempio n. 1
0
    def apply(self):
        level_name = self._levelCombo.get()
        levels = [
            key for key, value in PreferencesDialog._LOG_LEVELS.items()
            if value == level_name
        ]
        loglevel = levels[0]
        logging_config = build_logging_config(['qiskit_acqua'], loglevel)

        token = self._apiToken.get().strip()
        url = self._url.get().strip()
        hub = self._hub.get().strip()
        group = self._group.get().strip()
        project = self._project.get().strip()

        preferences = Preferences()
        preferences.set_token(token if len(token) > 0 else None)
        preferences.set_url(url if len(url) > 0 else None)
        preferences.set_hub(hub if len(hub) > 0 else None)
        preferences.set_group(group if len(group) > 0 else None)
        preferences.set_project(project if len(project) > 0 else None)
        preferences.set_logging_config(logging_config)
        preferences.save()
        set_logger_config(logging_config)

        uipreferences = UIPreferences()
        populate = self._populateDefaults.get()
        uipreferences.set_populate_defaults(False if populate == 0 else True)
        uipreferences.save()

        self._controller.get_available_backends()
Esempio n. 2
0
    def apply(self):
        try:
            level_name = self._levelCombo.get()
            levels = [
                key for key, value in PreferencesDialog._LOG_LEVELS.items()
                if value == level_name
            ]
            loglevel = levels[0]
            logging_config = build_logging_config(['qiskit_acqua'], loglevel)

            preferences = Preferences()
            self._qconfigview.apply(preferences)
            self._packagesPage.apply(preferences)
            preferences.set_logging_config(logging_config)
            preferences.save()
            set_logger_config(logging_config)

            uipreferences = UIPreferences()
            populate = self._populateDefaults.get()
            uipreferences.set_populate_defaults(False if populate ==
                                                0 else True)
            uipreferences.save()

            self._controller.get_available_backends()
        except Exception as e:
            self.controller.outputview.write_line(str(e))
Esempio n. 3
0
    def quit(self):
        if tkmb.askyesno('Verify quit', 'Are you sure you want to quit?'):
            preferences = UIPreferences()
            preferences.set_browser_geometry(self.master.winfo_geometry())
            preferences.save()
            ttk.Frame.quit(self)
            return True

        return False
Esempio n. 4
0
 def _open_file(self):
     preferences = UIPreferences()
     filename = tkfd.askopenfilename(
         parent=self,
         title='Open Chemistry File',
         initialdir=preferences.get_openfile_initialdir())
     if filename and self._controller.open_file(filename):
         preferences.add_recent_file(filename)
         preferences.set_openfile_initialdir(os.path.dirname(filename))
         preferences.save()
Esempio n. 5
0
    def _save_file_as(self):
        if self._controller.is_empty():
            self._controller._outputView.write_line("No data to save.")
            return

        preferences = UIPreferences()
        filename = tkfd.asksaveasfilename(
            parent=self,
            title='Save Chemistry File',
            initialdir=preferences.get_savefile_initialdir())
        if filename and self._controller.save_file_as(filename):
            preferences.add_recent_file(filename)
            preferences.set_savefile_initialdir(os.path.dirname(filename))
            preferences.save()
Esempio n. 6
0
def main():
    if sys.platform == 'darwin':
        from Foundation import NSBundle
        bundle = NSBundle.mainBundle()
        if bundle:
            info = bundle.localizedInfoDictionary() or bundle.infoDictionary()
            info['CFBundleName'] = 'QISKit ACQUA'

    root = tk.Tk()
    root.withdraw()
    root.update_idletasks()

    preferences = UIPreferences()
    geometry = preferences.get_browser_geometry()
    if geometry is None:
        ws = root.winfo_screenwidth()
        hs = root.winfo_screenheight()
        w = int(ws / 1.2)
        h = int(hs / 1.3)
        x = int(ws / 2 - w / 2)
        y = int(hs / 2 - h / 2)
        geometry = '{}x{}+{}+{}'.format(w, h, x, y)
        preferences.set_browser_geometry(geometry)
        preferences.save()

    root.geometry(geometry)

    preferences = Preferences()
    if preferences.get_logging_config() is None:
        logging_config = build_logging_config(['qiskit_acqua'], logging.INFO)
        preferences.set_logging_config(logging_config)
        preferences.save()

    set_logger_config(preferences.get_logging_config())

    MainView(root)
    root.after(0, root.deiconify)
    root.mainloop()
Esempio n. 7
0
 def _clear_recent(self):
     preferences = UIPreferences()
     preferences.clear_recent_files()
     preferences.save()