コード例 #1
0
 def addAudio(self, button):
     #self.activity.showFileLoadBlocker(True)
     fp = FilePicker()
     dOb = fp.show()
     if (dOb != None):
         if (dOb.file_path != None):
             self.emit('add-media', dOb)
コード例 #2
0
 def __init__(self, master=None):
     super().__init__(master)
     self.elements = [
         {"name": "key", "label": "Clave de cifrado", "component": tk.Entry(self)},
         {"name": "iv", "label": "Valor inicial", "component": tk.Entry(self)},
         {"name": "input-file", "label": "Archivo de entrada", "component": FilePicker(self)},
         {"name": "output-file", "label": "Archivo de salida", "component": FilePicker(self, save=True)},
         {"name": "output-bits", "label": "Bits de salida", "component": tk.Entry(self)},
     ]
     self._create_interface()
コード例 #3
0
    def __run_file_chooser(self, browser, request):
        picker = FilePicker(self)
        chosen = picker.run()
        picker.destroy()

        if chosen:
            request.select_files([chosen])
        elif hasattr(request, 'cancel'):
            # WebKit2 only
            request.cancel()
        return True
コード例 #4
0
    def __run_file_chooser(self, browser, request):
        picker = FilePicker(self)
        chosen = picker.run()
        picker.destroy()

        if chosen:
            request.select_files([chosen])
        elif hasattr(request, 'cancel'):
            # WebKit2 only
            request.cancel()
        return True
コード例 #5
0
ファイル: webactivity.py プロジェクト: richaseh/browse
 def _get_shell_input_cb(self, button):
     picker = FilePicker(self)
     chosen = picker.run()
     picker.destroy()
     f = open(chosen, 'r')
     #self._alert(f.read())
     browser = self._tabbed_view.props.current_browser
     get_input_script = \
         "var htmlInput = document.getElementById('html');" \
         "htmlInput.value = '" + f.read() + "';"
     browser.execute_script(get_input_script)
コード例 #6
0
    def open_file(self):
        browser = self._activity._tabbed_view.props.current_browser
        if browser.get_uri() != self._src_uri:
            self._open_empty()

        picker = FilePicker(self._activity)
        chosen = picker.run()
        picker.destroy()

        if not chosen.endswith('zip'):
            self._activity._alert("Only zipped project files accepted.")
            return

        zip_object = zipfile.ZipFile(chosen, 'r')

        '''
        if zipfile.is_zipfile(chosen):
            zip_object = zipfile.ZipFile(chosen, 'r')
            valid = False
            for name in zip_object.namelist():
                if name == 'index.html':
                    valid = True
                    break
            if not valid:
                self._activity._alert("No index.html file in the zip folder.")
                return
        '''

        # Removes the unnecessary files inside
        # 'instance/Webconsole_files/default' folder
        if os.path.exists(self._default_dir):
            shutil.rmtree(self._default_dir)
        os.makedirs(self._default_dir)

        chosen = os.path.splitext(
            os.path.basename(os.path.normpath(chosen)))[0]
        project_title = os.path.splitext(chosen)[0]

        self._get_path(project_title)
        # File unzipping
        zip_object.extractall(self._extraction_dir)
        # os.path.join(self._extraction_dir, project_title)
        chosen = os.path.join(self._extraction_dir,
                              project_title, "index.html")
        self._open_file_path(chosen)

        browser = self._activity._tabbed_view.props.current_browser
        fill_title_script = "document.title = '" + project_title + "';"
        browser.execute_script(fill_title_script)
コード例 #7
0
 def add_image(self):
     browser = self._activity._tabbed_view.props.current_browser
     if browser.get_uri() != self._src_uri:
         self._activity._alert("It looks like the Web Console is not open." +
                               "You can only Open a file from Web Console")
         return
     picker = FilePicker(self._activity)
     chosen = picker.run()
     picker.destroy()
     extensions = {".jpg", ".png", ".gif", ".jpe"}
     valid = False
     for ext in extensions:
         if chosen.endswith(ext):
             valid = True
             break
     if not valid:
         self._activity._alert("Only jpg, png and gif files accepted")
         return
     self._activity._alert(chosen)
     image_name = os.path.basename(os.path.normpath(chosen))
     image_path = os.path.join(self._default_dir, image_name)
     shutil.copyfile(chosen, image_path)
コード例 #8
0
 def addOpenedAudio(self, button):
     fp = FilePicker()
     dOb = fp.show()
     if (dOb != None):
         if (dOb.file_path != None):
             self.emit('add-opened', dOb)