コード例 #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
コード例 #2
0
 def __init__(self, application, *args, **kwargs):
     self.Application = application
     self.AppArgs = self.Application.MyArgs
     # define and bind settings, options to a class variable
     global settings
     global options
     settings = SectionConfig(self.Application.id, self.__class__.__name__)
     options = OptionConfig(self.Application.id)
     self.settings = settings
     self.options = options
     super().__init__(self, *args, **kwargs)
コード例 #3
0
    def __init__(self, application, *args, **kwargs):
        self.Application = application
        self.AppArgs = self.Application.MyArgs

        # define and bind settings, options to a class variable
        global settings
        global options
        settings = SectionConfig(self.Application.id, self.__class__.__name__)
        options = OptionConfig(self.Application.id)
        self.settings = settings
        self.options = options

        self.targets = None  # Gtk.TargetList.new([])
        self.dragaction = Gdk.DragAction.PRIVATE
        self.number_picked = None
        self.init_picker_done = False

        super().__init__(self, *args, **kwargs)
コード例 #4
0
    def __init__(self, *args, **kwargs):
        args2 = tuple()
        kwargs2 = {}
        super().__init__(*args2,
                         flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE,
                         **kwargs2)

        self.name = 'Small Utils'
        self.id = 'org.kekbay.gnu.smallutils'
        self.START_DIR = kwargs['START_DIR']
        self.BASE_DIR = kwargs['BASE_DIR']
        self.version = __version__
        # Bind the locale.
        locale.bindtextdomain(self.id, os.path.join(self.BASE_DIR, 'locale'))
        locale.textdomain(self.id)
        self.localizedname = _('Small Utils')

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

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

        theiconfile = os.path.join(self.BASE_DIR, 'icons', 'logo.png')
        try:
            self.icon = GdkPixbuf.Pixbuf.new_from_file(theiconfile)
        except Exception:
            self.icon = None

        self.window = None
        # Set any command line options here.
        self.add_main_option("test", ord("t"), GLib.OptionFlags.NONE,
                             GLib.OptionArg.NONE, "Command line test", None)
コード例 #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()
コード例 #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()
コード例 #7
0
ファイル: options.py プロジェクト: Xoristzatziki/Sudoku-Gtk
    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()