1. PNG files base64 encodeing
Screenshot:
Source:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #!/usr/bin/env python import os import sys import pyfile import pygui if sys.version_info[0] >= 3: import PySimpleGUI as sg else: import PySimpleGUI27 as sg menu_def = [ ['&File', [ '&About...', '---', 'E&xit' ] ], ] layout = [ [ sg.Menu(menu_def, ) ], [ sg.T("Image Folder"), sg.In("", size=(60,1), do_not_clear=True, key='folder'), sg.FolderBrowse(), sg.Button("Make", key='make') ], [ sg.T("result") ], [ sg.Multiline( "", size=(90,20), autoscroll=True, do_not_clear=True, key='result') ], ] window = sg.Window('File to Base64').Layout(layout) window.Show() pygui.SetMultilineNoWrap(window,'result') while True: event, values = window.Read() if event is None or event == 'Exit': break if event == 'make': folder = values['folder'] filelist = pyfile.searchFile(folder, extensions=['.png',]) for file in filelist: base = os.path.basename(file) name,ext = os.path.splitext(base) data = pyfile.fileToBase64(file) window.FindElement('result').Update( name + '="' + data + '"\n', append=True) |
댓글 없음:
댓글 쓰기