コード例 #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]
コード例 #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()))
コード例 #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))
コード例 #4
0
def save_file_dialog():
    import time
    time.sleep(5)
    print(
        webview.create_file_dialog(webview.SAVE_DIALOG,
                                   directory="/",
                                   save_filename='test.file'))
コード例 #5
0
ファイル: socket_handlers.py プロジェクト: Pezz89/BPLabs
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')
コード例 #6
0
ファイル: beaconGraph.py プロジェクト: slooppe/BeaconGraph
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'})
コード例 #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)
コード例 #8
0
ファイル: server.py プロジェクト: r0x0r/pywebview
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)
コード例 #9
0
ファイル: socket_handlers.py プロジェクト: Pezz89/BPLabs
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')
コード例 #10
0
ファイル: guiApp.py プロジェクト: LeoYuShuoxin/ldif-compare-1
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
コード例 #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)
コード例 #12
0
ファイル: guiserver.py プロジェクト: r0x0r/traktorlibrarian
    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)
コード例 #13
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)
コード例 #14
0
ファイル: socket_handlers.py プロジェクト: Pezz89/BPLabs
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)
コード例 #15
0
ファイル: socket_handlers.py プロジェクト: Pezz89/BPLabs
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)
コード例 #16
0
ファイル: server.py プロジェクト: paulopes/polevault
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)
コード例 #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'})
コード例 #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,
         }
コード例 #19
0
ファイル: socket_handlers.py プロジェクト: Pezz89/BPLabs
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)
コード例 #20
0
def getFilePathsMacOS():
    files = webview.create_file_dialog(dialog_type=webview.OPEN_DIALOG, directory='', allow_multiple=True)
    return files
コード例 #21
0
ファイル: save_file_dialog.py プロジェクト: gbtami/pywebview
def save_file_dialog():
    import time
    time.sleep(5)
    print(webview.create_file_dialog(webview.SAVE_DIALOG, directory="/", save_filename='test.file'))
コード例 #22
0
ファイル: open_file_dialog.py プロジェクト: gbtami/pywebview
def open_file_dialog():
    import time
    time.sleep(5)
    print(webview.create_file_dialog(webview.OPEN_DIALOG, allow_multiple=True))
コード例 #23
0
ファイル: open_file_dialog.py プロジェクト: r0x0r/pywebview
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))
コード例 #24
0
 def open_excel_file(self, fname):
     selected = webview.create_file_dialog(
         file_types=('Excel file (*.xlsx)', ))
     if selected:
         return selected[0]
コード例 #25
0
def open_file_dialog():
    import time
    time.sleep(5)
    print(webview.create_file_dialog(webview.OPEN_DIALOG, allow_multiple=True))