Exemplo n.º 1
0
    def on_close_tab(self, instance, *args):
        '''Event handler to close icon
        :param instance: tab instance
        '''
        d = get_designer()
        if d.popup:
            return False

        self.switch_to(instance)
        if instance.has_modification:
            # show a dialog to ask if can close
            confirm_dlg = ConfirmationDialog(
                'All unsaved changes will be lost.\n'
                'Do you want to continue?')
            popup = Popup(title='New',
                          content=confirm_dlg,
                          size_hint=(None, None),
                          size=('200pt', '150pt'),
                          auto_dismiss=False)

            def close_tab(*args):
                d.close_popup()
                self._perform_close_tab(instance)

            confirm_dlg.bind(on_ok=close_tab, on_cancel=d.close_popup)
            popup.open()
            d.popup = popup
        else:
            Clock.schedule_once(partial(self._perform_close_tab, instance))
Exemplo n.º 2
0
    def on_close_tab(self, instance, *args):
        '''Event handler to close icon
        :param instance: tab instance
        '''
        d = get_designer()
        if d.popup:
            return False

        self.switch_to(instance)
        if instance.has_modification:
            # show a dialog to ask if can close
            confirm_dlg = ConfirmationDialog(
                    'All unsaved changes will be lost.\n'
                    'Do you want to continue?')
            popup = Popup(
                    title='New',
                    content=confirm_dlg,
                    size_hint=(None, None),
                    size=('200pt', '150pt'),
                    auto_dismiss=False)

            def close_tab(*args):
                d.close_popup()
                self._perform_close_tab(instance)

            confirm_dlg.bind(
                    on_ok=close_tab,
                    on_cancel=d.close_popup)
            popup.open()
            d.popup = popup
        else:
            Clock.schedule_once(partial(self._perform_close_tab, instance))
Exemplo n.º 3
0
    def run(self, *args, **kwargs):
        '''Run the project using Python
        '''
        if self.designer.popup:
            self.profiler.dispatch(
                'on_error', 'You must close all popups '
                'before building your project')
            return
        mod = kwargs.get('mod', '')
        data = kwargs.get('data', [])

        self._get_python()
        if not self.can_run:
            return

        py_main = os.path.join(self.profiler.project_path, 'main.py')
        if isinstance(py_main, bytes):
            py_main = py_main.decode(get_fs_encoding())

        if not os.path.isfile(py_main):
            self.profiler.dispatch('on_error', 'Cannot find main.py')
            return
        if sys.platform[0] == 'w':
            py_main = py_main.replace(' ', '\x01')
        else:
            py_main = py_main.replace(' ', '\\ ')
        cmd = ''
        if mod == '':
            cmd = '%s %s %s' % (self.python_path, py_main, self.args)
        elif mod == 'screen':
            cmd = '%s %s -m screen:%s %s' % (self.python_path, py_main, data,
                                             self.args)
        else:
            cmd = '%s %s -m %s %s' % (self.python_path, py_main, mod,
                                      self.args)

        status = self.run_command(cmd)

        # popen busy
        if status is False:
            confirm_dlg = ConfirmationDialog(
                message="There is another command running.\n"
                "Do you want to stop it to run your project?")
            self.designer.popup = Popup(title='Kivy Designer',
                                        content=confirm_dlg,
                                        size_hint=(None, None),
                                        size=('300pt', '150pt'),
                                        auto_dismiss=False)
            confirm_dlg.bind(on_ok=self._perform_kill_run,
                             on_cancel=self.designer.close_popup)
            self.designer.popup.open()
            return

        self.ui_creator.tab_pannel.switch_to(
            self.ui_creator.tab_pannel.tab_list[2])

        self.profiler.dispatch('on_message', 'Running main.py...')
        self.profiler.dispatch('on_run')
        self.ui_creator.kivy_console.bind(on_command_list_done=self.on_stop)
Exemplo n.º 4
0
    def run(self, *args, **kwargs):
        '''Run the project using Python
        '''
        if self.designer.popup:
            self.profiler.dispatch('on_error', 'You must close all popups '
                                               'before building your project')
            return
        mod = kwargs.get('mod', '')
        data = kwargs.get('data', [])

        self._get_python()
        if not self.can_run:
            return

        py_main = os.path.join(self.profiler.project_path, 'main.py')
        if isinstance(py_main, bytes):
            py_main = py_main.decode(get_fs_encoding())

        if not os.path.isfile(py_main):
            self.profiler.dispatch('on_error', 'Cannot find main.py')
            return
        if sys.platform[0] == 'w':
            py_main = py_main.replace(' ', '\x01')
        else:
            py_main = py_main.replace(' ', '\\ ')
        cmd = ''
        if mod == '':
            cmd = '%s %s %s' % (self.python_path, py_main, self.args)
        elif mod == 'screen':
            cmd = '%s %s -m screen:%s %s' % (self.python_path, py_main,
                                             data, self.args)
        else:
            cmd = '%s %s -m %s %s' % (self.python_path, py_main,
                                      mod, self.args)

        status = self.run_command(cmd)

        # popen busy
        if status is False:
            confirm_dlg = ConfirmationDialog(
                message="There is another command running.\n"
                        "Do you want to stop it to run your project?")
            self.designer.popup = Popup(title='Kivy Designer',
                                        content=confirm_dlg,
                                        size_hint=(None, None),
                                        size=('300pt', '150pt'),
                                        auto_dismiss=False)
            confirm_dlg.bind(on_ok=self._perform_kill_run,
                             on_cancel=self.designer.close_popup)
            self.designer.popup.open()
            return

        self.ui_creator.tab_pannel.switch_to(
            self.ui_creator.tab_pannel.tab_list[2])

        self.profiler.dispatch('on_message', 'Running main.py...')
        self.profiler.dispatch('on_run')
        self.ui_creator.kivy_console.bind(on_command_list_done=self.on_stop)
Exemplo n.º 5
0
    def _initialize(self):
        '''Try to get the buildozer path and check required variables
        If there is something wrong shows an alert.
        '''
        if self.designer.popup:
            self.can_run = False
            self.profiler.dispatch('on_error', 'You must close all popups '
                                               'before building your project')
            return
        # first, check if buildozer is set
        self.buildozer_path = self.designer_settings.config_parser.getdefault(
            'buildozer',
            'buildozer_path',
            ''
        )

        if self.buildozer_path == '':
            self.profiler.dispatch('on_error',
                                   'Buildozer Path not specified.'
                                   "\n\nUpdate it on File -> Settings")
            self.can_run = False
            return

        envs = self.proj_settings.config_parser.getdefault(
            'env variables',
            'env',
            ''
        )

        for env in envs.split(' '):
            self.ui_creator.kivy_console.environment[
                env[:env.find('=')]] = env[env.find('=') + 1:]
        # check if buildozer.spec exists
        if not os.path.isfile(os.path.join(self.profiler.project_path,
                                           'buildozer.spec')):
            confirm_dlg = ConfirmationDialog(
                message='buildozer.spec not found.\n'
                        'Do you want to create it now?')
            self.designer.popup = Popup(title='Buildozer',
                                        content=confirm_dlg,
                                        size_hint=(None, None),
                                        size=('200pt', '150pt'),
                                        auto_dismiss=False)
            confirm_dlg.bind(on_ok=self._perform_create_spec,
                             on_cancel=self.designer.close_popup)
            self.designer.popup.open()
            self.can_run = False
            return

        # TODO check if buildozer source.dir and main file exists

        self.can_run = True
Exemplo n.º 6
0
 def on_delete(self, *args):
     '''Handler to "Delete profile" button
     '''
     confirm_dlg = ConfirmationDialog(
         message="Do you want to delete this profile?")
     self._popup = Popup(title='Delete Profile',
                         content=confirm_dlg,
                         size_hint=(None, None),
                         size=('200pt', '150pt'),
                         auto_dismiss=False)
     confirm_dlg.bind(on_ok=self._perform_delete_prof,
                      on_cancel=self._popup.dismiss)
     self._popup.open()
Exemplo n.º 7
0
 def on_delete(self, *args):
     '''Handler to "Delete profile" button
     '''
     confirm_dlg = ConfirmationDialog(
         message="Do you want to delete this profile?")
     self._popup = Popup(title='Delete Profile',
                         content=confirm_dlg,
                         size_hint=(None, None),
                         size=('200pt', '150pt'),
                         auto_dismiss=False)
     confirm_dlg.bind(on_ok=self._perform_delete_prof,
                      on_cancel=self._popup.dismiss)
     self._popup.open()
Exemplo n.º 8
0
    def _initialize(self):
        '''Try to get the buildozer path and check required variables
        If there is something wrong shows an alert.
        '''
        if self.designer.popup:
            self.can_run = False
            self.profiler.dispatch(
                'on_error', 'You must close all popups '
                'before building your project')
            return
        # first, check if buildozer is set
        self.buildozer_path = self.designer_settings.config_parser.getdefault(
            'buildozer', 'buildozer_path', '')

        if self.buildozer_path == '':
            self.profiler.dispatch(
                'on_error', 'Buildozer Path not specified.'
                "\n\nUpdate it on File -> Settings")
            self.can_run = False
            return

        envs = self.proj_settings.config_parser.getdefault(
            'env variables', 'env', '')

        for env in envs.split(' '):
            self.ui_creator.kivy_console.environment[
                env[:env.find('=')]] = env[env.find('=') + 1:]
        # check if buildozer.spec exists
        if not os.path.isfile(
                os.path.join(self.profiler.project_path, 'buildozer.spec')):
            confirm_dlg = ConfirmationDialog(
                message='buildozer.spec not found.\n'
                'Do you want to create it now?')
            self.designer.popup = Popup(title='Buildozer',
                                        content=confirm_dlg,
                                        size_hint=(None, None),
                                        size=('200pt', '150pt'),
                                        auto_dismiss=False)
            confirm_dlg.bind(on_ok=self._perform_create_spec,
                             on_cancel=self.designer.close_popup)
            self.designer.popup.open()
            self.can_run = False
            return

        # TODO check if buildozer source.dir and main file exists

        self.can_run = True
Exemplo n.º 9
0
    def buildozer_init(self):
        '''Checks if the .spec exists or not; and when possible, calls
            _perform_buildozer_init
        '''
        d = get_designer()
        if d.popup:
            return False
        proj_dir = get_current_project().path
        spec_file = os.path.join(proj_dir, 'buildozer.spec')

        if os.path.exists(spec_file):
            confirm_dlg = ConfirmationDialog(
                message='The buildozer.spec file already exist.'
                        '\nDo you want to create a new spec?')
            d.popup = Popup(title='Buildozer init',
                            content=confirm_dlg,
                            size_hint=(None, None),
                            size=('250pt', '150pt'),
                            auto_dismiss=False)
            confirm_dlg.bind(on_ok=self._perform_buildozer_init,
                             on_cancel=d.close_popup)
            d.popup.open()
        else:
            self._perform_buildozer_init()
Exemplo n.º 10
0
    def buildozer_init(self):
        '''Checks if the .spec exists or not; and when possible, calls
            _perform_buildozer_init
        '''
        d = get_designer()
        if d.popup:
            return False
        proj_dir = get_current_project().path
        spec_file = os.path.join(proj_dir, 'buildozer.spec')

        if os.path.exists(spec_file):
            confirm_dlg = ConfirmationDialog(
                message='The buildozer.spec file already exist.'
                '\nDo you want to create a new spec?')
            d.popup = Popup(title='Buildozer init',
                            content=confirm_dlg,
                            size_hint=(None, None),
                            size=('250pt', '150pt'),
                            auto_dismiss=False)
            confirm_dlg.bind(on_ok=self._perform_buildozer_init,
                             on_cancel=d.close_popup)
            d.popup.open()
        else:
            self._perform_buildozer_init()