Beispiel #1
0
    def _post_initialisations(self):
        """ Do some extra initializations.

        Display the version if a labelVersion is found.
        Set defaults (try to load them from a configuration file):
            - Window size and state (width, height and if maximized)
        Load saved custom settings.
        """
        # Init the settings module.
        self.dummy_for_settings = SectionConfig(self.app.id,
                                                self.__class__.__name__)
        global settings
        settings = self.dummy_for_settings

        self.dummy_for_options = OptionConfig(self.app.id)
        global options
        options = self.dummy_for_options

        # Bind message boxes.
        self.MessageBox = MessageBox(self)
        self.msg = self.MessageBox.Message
        self.are_you_sure = self.MessageBox.are_you_sure

        # Set previous size and state.
        width = settings.get('width', 350)
        height = settings.get('height', 350)
        self.set_title(self.app.localizedname)
        self.resize(width, height)
        if settings.get_bool('maximized', False):
            self.maximize()
        # Load any other settings here.

        self.synaptics_device = None
    def _post_initialisations(self):
        """ Do some extra initializations.

        Display the version if a labelVersion is found.
        Set defaults (try to load them from a configuration file):
            - Window size and state (width, height and if maximized)
        Load any custom settings from a configuration file.
        """
        if 'trigger_before_exit' in self.passed_args:
            # must be a function on calling class
            self.trigger_before_exit = self.passed_args['trigger_before_exit']
            self.return_parameters = None

        # Bind message boxes.
        self.MessageBox = MessageBox(self.OptionsWindow, self.Application)
        self.msg = self.MessageBox.Message
        self.are_you_sure = self.MessageBox.are_you_sure

        # Reset MainWindow to a default or previous size and state.
        width = settings.get('width', 350)
        height = settings.get('height', 350)
        self.OptionsWindow.set_title(self.Application.MyArgs.localizedname + " - " + _('Options'))
        self.OptionsWindow.resize(width, height)
        self.OptionsWindow.set_icon(self.Application.icon)
        if settings.get_bool('maximized', False):
            self.OptionsWindow.maximize()

        # Set the label for labelVersion
        self.labelVersion.set_label(self.Application.MyArgs.version)
        self.labelVersion.set_tooltip_text(_("Version of this window:") + "\n" + VERSIONSTR)

        # Load any other settings here.
        self.current_dict_name = 'standard'
        self.thedicts['custom'] = self.thedicts['standard'].copy()
        tmpcustomdict = options.get('custom_dict', '').split(',')
        if len(tmpcustomdict) == 10 and tmpcustomdict[0].strip() == '':
            self.thedicts['custom'] = ['']
            for x in range (1, 10):
                self.thedicts['custom'].append(tmpcustomdict[x].strip())
        self.show_dicts()
        self.OptionsWindow.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("#228b22"))#forest green

        simple = options.get('show_simple', False )
        self.checkbuttonShowPieces.set_active(not simple and options.get('show_pieces', False))
        self.checkbuttonShowTimer.set_active(not simple and options.get('show_timer', True))
        self.checkbuttonShowOnlyBoard.set_active(simple)
        scale = options.get('font_scale', 100)
        self.adjustment1.set_value(scale / 100)
        self.fontaspect = self.adjustment1.get_value()
        self.fontfamily = options.get('font', self.fontbutton1.get_font_name())
        self.fontbutton1.set_font_name(self.fontfamily)
        #print('self.fontbutton1.get_font_name()', self.fontbutton1.get_font_name())

        digits_dict = options.get('dict_to_use', 'standard')
        for b in self.gridDictionaries.get_children():
            if hasattr(b, 'tag') and b.tag == digits_dict:
                b.set_active(True)
                break

        self.picker = self.AppArgs.picker
Beispiel #3
0
    def _post_initialisations(self):
        """ Do some extra initializations.

        Display the version if a labelVersion is found.
        Set defaults (try to load them from a configuration file):
            - Window size and state (width, height and if maximized)
        Load any custom settings from a configuration file.
        """
        if 'parent' in self.custom_args:#Is a child window, get the parent window
            self.myparent = self.custom_args['parent']

        if 'transient_for' in self.custom_args:
            self.set_transient_for(self.custom_args['transient_for'])
            # but modality can be false, and parent may not be present
            if 'is_modal' in self.custom_args:
                self.set_modal(self.custom_args['is_modal'])

        if 'trigger_before_exit' in self.custom_args:
            # must be a function on calling class
            self.trigger_before_exit = self.custom_args['trigger_before_exit']
            self.return_parameters = None

        # Bind message boxes.
        self.MessageBox = MessageBox(self.StartWindow, self.Application)
        self.msg = self.MessageBox.Message
        self.are_you_sure = self.MessageBox.are_you_sure

        # Reset MainWindow to a default or previous size and state.
        width = settings.get('width', 350)
        height = settings.get('height', 350)
        self.StartWindow.set_title(self.AppArgs.localizedname + " - " + _('Home'))
        self.StartWindow.resize(width, height)
        self.StartWindow.set_icon(self.Application.icon)
        if settings.get_bool('maximized', False):
            self.StartWindow.maximize()

        # Set the label for labelVersion
        self.labelVersion.set_label(self.AppArgs.version)
        self.labelVersion.set_tooltip_text(_("Version of this window:") + "\n" + VERSIONSTR)

        # Load any other settings here.
        self.reload_options()
        self.create_picker()
    def _post_initialisations(self):
        """ Do some extra initializations.

        Display the version if a labelVersion is found.
        Set defaults (try to load them from a configuration file):
            - Window size and state (width, height and if maximized)
        Load any custom settings from a configuration file.
        """
        if 'trigger_before_exit' in self.passed_args:
            # must be a function on calling class
            self.trigger_before_exit = self.passed_args['trigger_before_exit']
            self.return_parameters = None

        # Bind message boxes.
        self.MessageBox = MessageBox(self.PuzzleWindow, self.Application)
        self.msg = self.MessageBox.Message
        self.are_you_sure = self.MessageBox.are_you_sure

        # Reset MainWindow to a default or previous size and state.
        width = settings.get('width', 350)
        height = settings.get('height', 350)
        self.PuzzleWindow.set_title(self.AppArgs.localizedname)
        self.PuzzleWindow.resize(width, height)
        self.PuzzleWindow.set_icon(self.Application.icon)
        if settings.get_bool('maximized', False):
            self.PuzzleWindow.maximize()

        # Set the label for labelVersion
        self.labelVersion.set_label(self.AppArgs.version)
        self.labelVersion.set_tooltip_text(
            _("Version of this window:") + "\n" + VERSIONSTR)

        # Load any other settings here.
        self.exiting = False
        self.playing_history = False
        self.previous_sel = None

        self.AppArgs.picker.PickerWindow.set_transient_for(self.PuzzleWindow)
        self.AppArgs.picker.response_from_picker = self.response_from_picker
        self.listboxPieces.set_visible(self.AppArgs.show_pieces)
        self.boxTimer.set_visible(self.AppArgs.show_timer)

        self.eventboxPuzzle.drag_dest_set(0, [], 0)
Beispiel #5
0
    def __init__(self, app):
        # Set the app
        self.app = app

        # Basic initializations.
        self.we_can_exit_now = False
        self.return_parameter = (False, "00:00")
        self.picker = None
        self.picker_size = 10.
        self.previous_sel = None
        self.timer_started = None
        self.history_counter = 0
        self.playing_history = False

        #self.strings_to_use = [' ','α','β','γ','δ','ε','ς','ζ','η','θ']
        #self.strings_to_use = [' ','1','2','3','4','5','6','7','8','9']

        # Init the settings module.
        self.dummy_for_settings = SectionConfig(self.app.name,
                                                self.__class__.__name__)
        global settings
        settings = self.dummy_for_settings

        self.dummy_for_options = OptionConfig(self.app.name)
        global options
        options = self.dummy_for_options

        Gtk.Window.__init__(self)
        self.set_title(self.app.localizedname)

        # Initializations required before loading glade file.

        # Bind the locale.
        locale.bindtextdomain(self.app.domain,
                              os.path.join(self.app.BASE_DIR, 'locale'))
        locale.textdomain(self.app.domain)

        # Load app and window icon.
        self.set_icon(self.app.icon)

        # Bind message boxes.
        self.MessageBox = MessageBox(self)
        self.msg = self.MessageBox.Message

        # Glade stuff
        # Load Glade file to self
        self.builder = Gtk.Builder()
        try:
            self.builder.add_from_file(
                os.path.join(self.app.BASE_DIR, 'ui', 'puzzlewindow.glade'))
        except Exception as ex:
            print(str(ex))
            print('\n{}:\n{}\n{}'.format(
                _('Error loading from Glade file'),
                os.path.join(self.app.BASE_DIR, 'ui', 'puzzlewindow.glade'),
                repr(ex)))
            sys.exit(ERROR_INVALID_GLADE_FILE)

        # Get gui objects
        self.MainBox = self.builder.get_object('MainBox')
        self.boxTimer = self.builder.get_object('boxTimer')
        self.boxMenu = self.builder.get_object('boxMenu')
        self.buttonHome = self.builder.get_object('buttonHome')
        self.drawingareaPuzzle = self.builder.get_object('drawingareaPuzzle')
        self.eventboxPuzzle = self.builder.get_object('eventboxPuzzle')
        self.imageClock = self.builder.get_object('imageClock')
        self.labelClock = self.builder.get_object('labelClock')
        self.labelVersion = self.builder.get_object('labelVersion')
        self.listboxPieces = self.builder.get_object('listboxPieces')

        # Connect signals existing in the Glade file
        self.builder.connect_signals(self)

        # Reparent our main container from glader file,
        # this way we have all Gtk.Window functionality using "self"
        thechild = self.builder.get_object('PuzzleWindow').get_child()
        thechild.get_parent().remove(thechild)
        self.add(thechild)

        # Connect generated signals.
        self.buttonHome.connect('clicked', self.on_buttonHome_clicked)
        self.connect('delete-event', self.on_PuzzleWindow_delete_event)
        self.connect('destroy', self.on_PuzzleWindow_destroy)
        self.connect('key-release-event',
                     self.on_PuzzleWindow_key_release_event)
        self.connect('size-allocate', self.on_PuzzleWindow_size_allocate)
        self.connect('window-state-event',
                     self.on_PuzzleWindow_window_state_event)

        # Get any properties of top window.
        # Set the label for labelVersion
        self.labelVersion.set_label(VERSIONSTR)
        self.can_focus = 'False'

        # Load any settings or run extra initializations
        self.post_initialisations()
Beispiel #6
0
    def __init__(self, app):
        # Set the app
        self.app = app
        self.app.thehistory = None

        # Basic initializations.
        self.we_can_exit_now = False
        self.return_parameter = None

        self.thedicts = THEDICTS

        # Init the settings module.
        self.dummy_for_settings = SectionConfig(self.app.name,
                                                self.__class__.__name__)
        global settings
        settings = self.dummy_for_settings

        self.dummy_for_options = OptionConfig(self.app.name)
        global options
        options = self.dummy_for_options

        Gtk.Window.__init__(self)

        # Initializations required before loading glade file.

        # Bind the locale.
        locale.bindtextdomain(self.app.domain,
                              os.path.join(self.app.BASE_DIR, 'locale'))
        locale.textdomain(self.app.domain)

        # Load app and window icon.
        self.set_icon(self.app.icon)

        # Bind message boxes.
        self.MessageBox = MessageBox(self)
        self.msg = self.MessageBox.Message

        # Glade stuff.
        # Load Glade file to self.
        self.builder = Gtk.Builder()
        try:
            self.builder.add_from_file(
                os.path.join(self.app.BASE_DIR, 'ui', 'sudokugtk.glade'))
        except Exception as ex:
            print(str(ex))
            print('\n{}:\n{}\n{}'.format(
                _('Error loading from Glade file'),
                os.path.join(self.app.BASE_DIR, 'ui', 'sudokugtk.glade'),
                repr(ex)))
            sys.exit(ERROR_INVALID_GLADE_FILE)

        # Get gui objects.
        self.MainBox = self.builder.get_object('MainBox')
        self.boxForFooter = self.builder.get_object('boxForFooter')
        self.buttonAbout = self.builder.get_object('buttonAbout')
        self.buttonContinue = self.builder.get_object('buttonContinue')
        self.buttonExit = self.builder.get_object('buttonExit')
        self.buttonNewPuzzle = self.builder.get_object('buttonNewPuzzle')
        self.buttonOptions = self.builder.get_object('buttonOptions')
        self.dummylabel = self.builder.get_object('dummylabel')
        self.labelInfo = self.builder.get_object('labelInfo')
        self.labelVersion = self.builder.get_object('labelVersion')

        # Connect signals existing in the Glade file
        self.builder.connect_signals(self)

        # Reparent our main container from glader file,
        # this way we have all Gtk.Window functionality using "self".
        thechild = self.builder.get_object('windowMain').get_child()
        thechild.get_parent().remove(thechild)
        self.add(thechild)

        # Connect generated signals.
        self.buttonAbout.connect('clicked', self.on_buttonAbout_clicked)
        self.buttonContinue.connect('clicked', self.on_buttonContinue_clicked)
        self.buttonExit.connect('clicked', self.on_buttonExit_clicked)
        self.buttonNewPuzzle.connect('clicked',
                                     self.on_buttonNewPuzzle_clicked)
        self.buttonOptions.connect('clicked', self.on_buttonOptions_clicked)
        self.connect('delete-event', self.on_windowMain_delete_event)
        self.connect('destroy', self.on_windowMain_destroy)
        self.connect('size-allocate', self.on_windowMain_size_allocate)
        self.connect('window-state-event',
                     self.on_windowMain_window_state_event)

        # Get any properties of top window.
        # Set the label for labelVersion
        self.labelVersion.set_label(VERSIONSTR)
        self.can_focus = 'False'

        # Load any settings or run extra initializations.
        self.post_initialisations()
Beispiel #7
0
    def __init__(self, app):
        # Set the app
        self.app = app

        # Basic initializations.
        self.we_can_exit_now = False
        self.return_parameter = None

        self.fontaspect = 1.85
        self.example_int = 9
        self.example_char = '9'
        self.fontfamily = 'Sans'

        self.thedicts = THEDICTS

        self.current_dict_name = 'standard'

        # Init the settings module.
        self.dummy_for_settings = SectionConfig(self.app.name,
                                                self.__class__.__name__)
        global settings
        settings = self.dummy_for_settings

        self.dummy_for_options = OptionConfig(self.app.name)
        global options
        options = self.dummy_for_options

        Gtk.Window.__init__(self)

        # Initializations required before loading glade file.

        # Bind the locale.
        locale.bindtextdomain(self.app.domain,
                              os.path.join(self.app.BASE_DIR, 'locale'))
        locale.textdomain(self.app.domain)

        # Load app and window icon.
        self.set_icon(self.app.icon)

        # Bind message boxes.
        self.MessageBox = MessageBox(self)
        self.msg = self.MessageBox.Message

        # Glade stuff.
        # Load Glade file to self.
        self.builder = Gtk.Builder()
        try:
            self.builder.add_from_file(
                os.path.join(self.app.BASE_DIR, 'ui', 'options.glade'))
        except Exception as ex:
            print(str(ex))
            print('\n{}:\n{}\n{}'.format(
                _('Error loading from Glade file'),
                os.path.join(self.app.BASE_DIR, 'ui', 'options.glade'),
                repr(ex)))
            sys.exit(ERROR_INVALID_GLADE_FILE)

        # Get gui objects.
        self.MainBox = self.builder.get_object('MainBox')
        self.adjustment1 = self.builder.get_object('adjustment1')
        self.box1 = self.builder.get_object('box1')
        self.box2 = self.builder.get_object('box2')
        self.box3 = self.builder.get_object('box3')
        self.buttonCancel = self.builder.get_object('buttonCancel')
        self.buttonSave = self.builder.get_object('buttonSave')
        self.checkbuttonShowOnlyBoard = self.builder.get_object(
            'checkbuttonShowOnlyBoard')
        self.checkbuttonShowPieces = self.builder.get_object(
            'checkbuttonShowPieces')
        self.checkbuttonShowTimer = self.builder.get_object(
            'checkbuttonShowTimer')
        self.drawingareaExample = self.builder.get_object('drawingareaExample')
        self.eventbox1 = self.builder.get_object('eventbox1')
        self.eventbox2 = self.builder.get_object('eventbox2')
        self.eventbox3 = self.builder.get_object('eventbox3')
        self.eventbox4 = self.builder.get_object('eventbox4')
        self.eventbox5 = self.builder.get_object('eventbox5')
        self.eventbox6 = self.builder.get_object('eventbox6')
        self.eventbox7 = self.builder.get_object('eventbox7')
        self.eventbox8 = self.builder.get_object('eventbox8')
        self.eventbox9 = self.builder.get_object('eventbox9')
        self.fontbutton1 = self.builder.get_object('fontbutton1')
        self.gridDictionaries = self.builder.get_object('gridDictionaries')
        self.label1 = self.builder.get_object('label1')
        self.label10 = self.builder.get_object('label10')
        self.label2 = self.builder.get_object('label2')
        self.label3 = self.builder.get_object('label3')
        self.label4 = self.builder.get_object('label4')
        self.label5 = self.builder.get_object('label5')
        self.label6 = self.builder.get_object('label6')
        self.label7 = self.builder.get_object('label7')
        self.label8 = self.builder.get_object('label8')
        self.label9 = self.builder.get_object('label9')
        self.labeltest = self.builder.get_object('labeltest')
        self.radiobuttonDict1 = self.builder.get_object('radiobuttonDict1')
        self.scale1 = self.builder.get_object('scale1')
        self.scrolledwindow1 = self.builder.get_object('scrolledwindow1')
        self.viewport1 = self.builder.get_object('viewport1')

        # Connect signals existing in the Glade file
        self.builder.connect_signals(self)

        # Reparent our main container from glader file,
        # this way we have all Gtk.Window functionality using "self".
        thechild = self.builder.get_object('windowOptions').get_child()
        thechild.get_parent().remove(thechild)
        self.add(thechild)

        # Connect generated signals.
        self.buttonCancel.connect('clicked', self.on_buttonCancel_clicked)
        self.buttonSave.connect('clicked', self.on_buttonSave_clicked)
        self.connect('delete-event', self.on_windowOptions_delete_event)
        self.connect('destroy', self.on_windowOptions_destroy)
        self.connect('size-allocate', self.on_windowOptions_size_allocate)
        self.connect('window-state-event',
                     self.on_windowOptions_window_state_event)

        # Get any properties of top window.
        self.can_focus = 'False'

        # Load any settings or run extra initializations.
        self.post_initialisations()