SimpleGUI制作彈框(Python)
# -*- coding: utf-8 -*-
# @Time : 2020/12/17 22:49
# @Author : k
# @File : Simlegui.py
import PySimpleGUI as sg
# sg.popup('hello')
# sg.popup_ok('默認彈窗')
# sg.popup_yes_no('帶yes和no按鈕的彈窗')
# sg.popup_cancel('帶cancel按鈕的彈窗')
# sg.popup_ok_cancel('帶ok和cancel按鈕的彈窗')
# sg.popup_error('帶紅色error按鈕的彈窗')
# sg.popup_auto_close('幾秒后自動關閉的彈窗')
# sg.popup(
# "你點我啊",
# title = 'xhc',
# button_color=("#A81B0C", '#FFFFFF '),
# background_color="#F47264",
# line_width=2,
# custom_text="好的"
# )
# text = '''大家好,
# 我們一起來學習PySimpleGUI制作簡單的圖形用戶界面,'''
# sg.popup_scrolled(text,title='Hello')
# text1 = sg.popup_get_text('請輸入文字1')
# print(text1)
# text2 = sg.popup_get_text('請輸入文字2')
# print(text2)
# text = sg.popup_get_text('請輸入密碼:', password_char="*")
# sg.popup(f'你輸入的密碼是:{text}')
#
# path = sg.popup_get_file("請保存檔案")
# print(path)
# path = sg.popup_get_file(
# '請選擇需要保存的壓縮包位置',
# save_as=True,
# default_extension='zip',
# file_types=(('壓縮包', 'zip'),)
# )
# print(path)
# for i in range(1000):
# sg.one_line_progress_meter(
# '進度條',
# i + 1,
# 1000,
# '該進度條key',
# '這是一個進度條'
# )
# for i in range(1, 1000):
# sg.one_line_progress_meter(
# '進度條',
# i + 1,
# 1000,
# '該進度條key',
# '這是一個進度條',
# orientation='h',
# bar_color=('#F47264', '#FFFFFF')
# )
#
# # 軟體運行后彈出視窗讓用戶選擇一個檔案夾
# sg.popup_get_folder()
# # 用戶選擇后再彈出視窗讓用戶選擇壓縮包保存的位置和名稱
# sg.popup_get_file()
# save_as = True
# default_extension = 'zip'
# # 用戶輸入完成后將該檔案夾內所有的檔案進行壓縮打包
# sg.zipfile模塊
# # 完成壓縮后再彈出一個視窗告訴用戶這個壓縮包的體積大小
# sg.os.stat() # 讀取檔案資訊
# sg.popup() # 彈窗顯示資料
# import PySimpleGUI as sg
# import zipfile
# import os
#
#
# folder = sg.popup_get_folder('請選擇要壓縮的檔案夾')
# zip_path = sg.popup_get_file(
# '請選擇要保存的壓縮包位置',
# save_as=True,
# default_extension='zip',
# file_types=(('壓縮包', '.zip'), )
# )
#
# with zipfile.ZipFile(zip_path, 'w') as zipobj:
# for file in os.scandir(folder):
# zipobj.write(file.path, file.path.replace(folder, '.'))
#
# zip_size = os.stat(zip_path).st_size // 1024
# sg.popup(f'壓縮包體積大小為:{zip_size} KB')
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/236594.html
標籤:python
