Example #1
0
 def select_doc_file(self, direc=None):
     if direc is None:
         selected = webview.create_file_dialog(
             webview.SAVE_DIALOG, save_filename='Untitled.docx')
     else:
         selected = webview.create_file_dialog(webview.OPEN_DIALOG,
                                               file_types=self.doc_types)
     if selected:
         return selected if direc is None else selected[0]
Example #2
0
def open_file_dialog():
    import time
    time.sleep(5)
    print(
        webview.create_file_dialog(webview.OPEN_DIALOG,
                                   allow_multiple=True,
                                   directory=os.getcwd()))
Example #3
0
def open_file_dialog():
    file_types = ('Image Files (*.bmp;*.jpg;*.gif)', 'All files (*.*)')

    print(
        webview.create_file_dialog(webview.OPEN_DIALOG,
                                   allow_multiple=True,
                                   file_types=file_types))
def save_file_dialog():
    import time
    time.sleep(5)
    print(
        webview.create_file_dialog(webview.SAVE_DIALOG,
                                   directory="/",
                                   save_filename='test.file'))
Example #5
0
def openMatDialog():
    # Open a file dialog interface for selecting a directory
    dirs = webview.create_file_dialog(webview.FOLDER_DIALOG)
    if dirs and len(dirs) > 0:
        directory = dirs[0]
        if isinstance(directory, bytes):
            directory = directory.decode("utf-8")
        # TODO: Add filepath checking here...
        # Send message with selected directory to the GUI
        socketio.emit('mat-dialog-resp', {'data': directory},
                      namespace='/main')
Example #6
0
def export():
    name = request.json['name']
    img = request.json['data']
    save = webview.create_file_dialog(
        dialog_type=webview.SAVE_DIALOG, save_filename=name, file_types=('PNG File (*.png)',))
    if save[0]:
        with open(save[0], "wb") as imgFile:
            imgFile.write(base64.b64decode(img))
            imgFile.close()
            return jsonify({'result': 'ok'})
    else:
        return jsonify({'result': 'canceled'})
Example #7
0
def choose_path():
    """
    Invokes a folder selection dialog
    """
    dirs = webview.create_file_dialog(webview.FOLDER_DIALOG)
    if dirs and len(dirs) > 0:
        directory = dirs[0]
        if isinstance(directory, bytes):
            directory = directory.decode("utf-8")

        response = {"status": "ok", "directory": directory}
    else:
        response = {"status": "cancel"}

    return jsonify(response)
Example #8
0
def choose_path():
    """
    Invoke a folder selection dialog here
    :return:
    """
    dirs = webview.create_file_dialog(webview.FOLDER_DIALOG)
    if dirs and len(dirs) > 0:
        directory = dirs[0]
        if isinstance(directory, bytes):
            directory = directory.decode("utf-8")

        response = {"status": "ok", "directory": directory}
    else:
        response = {"status": "cancel"}

    return jsonify(response)
Example #9
0
def openSaveDirDialog():
    # Open a file dialog interface for selecting a directory
    dirs = webview.create_file_dialog(webview.FOLDER_DIALOG)
    if dirs and len(dirs) > 0:
        directory = dirs[0]
        if isinstance(directory, bytes):
            directory = directory.decode("utf-8")
        if not os.path.isdir(directory):
            socketio.emit(
                'main-notification',
                {'data': "\'{}\' is not a valid directory".format(directory)},
                namespace='/main')
            return None
        # Send message with selected directory to the GUI
        socketio.emit('save-file-dialog-resp', {'data': directory},
                      namespace='/main')
Example #10
0
def compare():
    aFile = request.files['aFile']
    bFile = request.files['bFile']
    csvFile, tableDate = ldifCompareHandler(aFile,bFile)["guiData"]
    if len(request.form.getlist('ifCSV_Format')) == 1 :
        #response = make_response(ldifCompareHandler(aFile,bFile)["csv"])
        #response.headers['Content-type'] = 'text/csv'
        #response.mimetype = 'text/csv'
        #response.headers['Content-Disposition'] = "attachment;filename=LDIF_compare_result.csv"
        # macOS filePath = webview.create_file_dialog(webview.SAVE_DIALOG, directory="/", save_filename='LDIF_compare_result.csv')[0]
        filePath = webview.create_file_dialog(webview.SAVE_DIALOG, directory="/", save_filename='LDIF_compare_result.csv')
        print filePath
        outputFile = open(filePath,"w")
        outputFile.write(csvFile)
        outputFile.close()
    response = render_template("result.html",data = tableDate )
    return response
Example #11
0
 def save_calc_file(self, args):
     if self.calc_file == self.default_calc_file or args['saveas']:
         selected = webview.create_file_dialog(webview.SAVE_DIALOG,
                                               save_filename=self.calc_file,
                                               file_types=self.calc_types)
         if selected:
             self.calc_file = selected
         else:
             return path.basename(self.calc_file)
     chunks = args['calc']
     attrib = {'in': args['in'], 'out': args['out'], 'level': args['level']}
     document = ET.Element('document', attrib)
     for typ, content in chunks:
         child = ET.SubElement(document, typ)
         child.text = self.data_convert(content)
     tree = ET.ElementTree(document)
     tree.write(self.calc_file, 'utf-8')
     webview.set_title('docal - ' + self.calc_file)
Example #12
0
    def POST(self):
        request = json.loads(web.data())

        directory = webview.create_file_dialog(webview.FOLDER_DIALOG)

        if directory:
            directory = directory[0]
            response = {"status": "ok", "directory": directory}

            if "traktor_check" in request.keys() and request["traktor_check"]:
                if librarian.library_exists(directory):
                    conf.library_dir = directory
                else:
                    response = {"status": "error", "message": "Traktor library not found in {}".format(directory)}
        else:
            response = {"status": "cancel"}
        web.header("Cache-Control", "no-cache")
        return json.dumps(response)
    def POST(self):
        request = json.loads(web.data())

        directory = webview.create_file_dialog(webview.FOLDER_DIALOG)

        if directory:
            directory = directory[0]
            response = {"status": "ok", "directory": directory}

            if "traktor_check" in request.keys() and request["traktor_check"]:
                if librarian.library_exists(directory):
                    conf.library_dir = directory
                else:
                    response = {"status": "error", "message": "Traktor library not found in {}".format(directory)}
        else:
            response = {"status": "cancel"}
        web.header("Cache-Control", "no-cache")
        return json.dumps(response)
Example #14
0
def openSaveFileDialog():
    # Open a file dialog interface for selecting a directory
    filepath = webview.create_file_dialog(
        dialog_type=webview.SAVE_DIALOG,
        file_types=("Python Pickle (*.pkl)", ),
        save_filename="test_session.pkl")
    if filepath and len(filepath) > 0:
        filepath = filepath[0]
        if isinstance(filepath, bytes):
            filepath = filepath.decode("utf-8")
        # Make sure file ends with pickle file extension
        head, tail = os.path.splitext(filepath)
        filepath = head + ".pkl"
        # Send message with selected directory to the GUI
        socketio.emit('save_file_dialog_resp', {'data': filepath},
                      namespace='/main',
                      broadcast=True,
                      include_self=True)
Example #15
0
def openLoadFileDialog():
    # Open a file dialog interface for selecting a directory
    filepath = webview.create_file_dialog(
        dialog_type=webview.OPEN_DIALOG,
        file_types=("Python Pickle (*.pkl)", ))
    if filepath and len(filepath) > 0:
        filepath = filepath[0]
        if isinstance(filepath, bytes):
            filepath = filepath.decode("utf-8")
        if not os.path.isfile(filepath):
            socketio.emit(
                'main-notification',
                {'data': "\'{}\' is not a valid file".format(directory)},
                namespace='/main')
        # Send message with selected directory to the GUI
        socketio.emit('load_file_dialog_resp', {'data': filepath},
                      namespace='/main',
                      broadcast=True,
                      include_self=True)
Example #16
0
def choose_path():
    """
    Invoke a folder selection dialog here
    :return:
    """
    current_directory = os.getcwd()
    dirs = webview.create_file_dialog(webview.FOLDER_DIALOG,
                                      directory=current_directory)
    if dirs and len(dirs) > 0:
        directory = dirs[0]
        if isinstance(directory, bytes):
            directory = directory.decode("utf-8")
        if directory.startswith(current_directory + os.path.sep):
            directory = directory[len(current_directory) + len(os.path.sep):]

        response = {"message": directory}
    else:
        response = {"message": "cancel"}

    return jsonify(response)
Example #17
0
def export():
    name = request.json['name']
    img = request.json['data']
    if GUI:
        save = webview.create_file_dialog(dialog_type=webview.SAVE_DIALOG,
                                          save_filename=name,
                                          file_types=('PNG File (*.png)', ))
        path = save[0]
    else:
        root = tk.Tk()
        root.withdraw()
        path = filedialog.asksaveasfilename(title="Export",
                                            filetypes=(("PNG files",
                                                        "*.png"), ))
    if path:
        with open(path, "wb") as imgFile:
            imgFile.write(base64.b64decode(img))
            imgFile.close()
            return jsonify({'result': 'ok'})
    else:
        return jsonify({'result': 'canceled'})
Example #18
0
 def open_calc_file(self, arg):
     selected = [self.calc_file
                 ] if arg == 1 else webview.create_file_dialog(
                     file_types=self.calc_types)
     if selected:
         with open(selected[0]) as file:
             content = file.read()
         tree = ET.fromstring(content)
         # change to the list with elements having assigns as last line
         chunks = []
         for child in tree:
             chunks.append(
                 [child.tag,
                  self.data_convert(child.text, child.tag)])
         self.calc_file = selected[0]
         webview.set_title('docal - ' + selected[0])
         return {
             'in': tree.attrib['in'],
             'out': tree.attrib['out'],
             'level': tree.attrib['level'],
             'calc': chunks,
         }
Example #19
0
def start_saved_mat_test(msg):
    '''
    Relay test start message to participant view
    '''
    filepath = webview.create_file_dialog(
        dialog_type=webview.OPEN_DIALOG,
        file_types=("Python Pickle (*.pkl)", ))
    if filepath and len(filepath) > 0:
        filepath = filepath[0]
        if isinstance(filepath, bytes):
            filepath = filepath.decode("utf-8")
    else:
        return None

    part_key = msg['part_key']
    if part_key != "--":
        participant = participants[part_key]
    else:
        participant = None
    socketio.emit('participant_start_mat', {'data': ''},
                  namespace='/main',
                  broadcast=True)
    run_matrix_thread(sessionFilepath=filepath, participant=participant)
Example #20
0
def getFilePathsMacOS():
    files = webview.create_file_dialog(dialog_type=webview.OPEN_DIALOG, directory='', allow_multiple=True)
    return files
Example #21
0
def save_file_dialog():
    import time
    time.sleep(5)
    print(webview.create_file_dialog(webview.SAVE_DIALOG, directory="/", save_filename='test.file'))
Example #22
0
def open_file_dialog():
    import time
    time.sleep(5)
    print(webview.create_file_dialog(webview.OPEN_DIALOG, allow_multiple=True))
Example #23
0
def open_file_dialog():
    file_types = ('Image Files (*.bmp;*.jpg;*.gif)', 'All files (*.*)')

    print(webview.create_file_dialog(webview.OPEN_DIALOG,
                                     allow_multiple=True,
                                     file_types=file_types))
Example #24
0
 def open_excel_file(self, fname):
     selected = webview.create_file_dialog(
         file_types=('Excel file (*.xlsx)', ))
     if selected:
         return selected[0]
Example #25
0
def open_file_dialog():
    import time
    time.sleep(5)
    print(webview.create_file_dialog(webview.OPEN_DIALOG, allow_multiple=True))