"""
@version: 0.96(2010-08-29)
@note:
ABOUT EASYGUI
EasyGui provides an easy-to-use interface for simple GUI interaction
with a user. It does not require the programmer to know anything about
tkinter, frames, widgets, callbacks or lambda. All GUI interactions are
invoked by simple function calls that return results.
@note:
WARNING about using EasyGui with IDLE
You may encounter problems using IDLE to run programs that use EasyGui. Try it
and find out. EasyGui is a collection of Tkinter routines that run their own
event loops. IDLE is also a Tkinter application, with its own event loop. The
two may conflict, with unpredictable results. If you find that you have
problems, try running your EasyGui program outside of IDLE.
Note that EasyGui requires Tk release 8.0 or greater.
@note:
LICENSE INFORMATION
EasyGui version 0.96
Copyright (c) 2010, Stephen Raymond Ferg
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@note:
ABOUT THE EASYGUI LICENSE
This license is what is generally known as the "modified BSD license",
aka "revised BSD", "new BSD", "3-clause BSD".
See http://www.opensource.org/licenses/bsd-license.php
This license is GPL-compatible.
See http://en.wikipedia.org/wiki/License_compatibility
See http://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses
The BSD License is less restrictive than GPL.
It allows software released under the license to be incorporated into proprietary products.
Works based on the software may be released under a proprietary license or as closed source software.
http://en.wikipedia.org/wiki/BSD_licenses#3-clause_license_.28.22New_BSD_License.22.29
"""
egversion = __doc__.split()[1]
__all__ = ['ynbox'
, 'ccbox'
, 'boolbox'
, 'indexbox'
, 'msgbox'
, 'buttonbox'
, 'integerbox'
, 'multenterbox'
, 'enterbox'
, 'exceptionbox'
, 'choicebox'
, 'codebox'
, 'textbox'
, 'diropenbox'
, 'fileopenbox'
, 'filesavebox'
, 'passwordbox'
, 'multpasswordbox'
, 'multchoicebox'
, 'abouteasygui'
, 'egversion'
, 'egdemo'
, 'EgStore'
]
import sys, os
import string
import pickle
import traceback
#--------------------------------------------------
# check python version and take appropriate action
#--------------------------------------------------
"""
From the python documentation:
sys.hexversion contains the version number encoded as a single integer. This is
guaranteed to increase with each version, including proper support for non-
production releases. For example, to test that the Python interpreter is at
least version 1.5.2, use:
if sys.hexversion >= 0x010502F0:
# use some advanced feature
...
else:
# use an alternative implementation or warn the user
...
"""
if sys.hexversion >= 0x020600F0:
runningPython26 = True
else:
runningPython26 = False
if sys.hexversion >= 0x030000F0:
runningPython3 = True
else:
runningPython3 = False
try:
from PIL import Image as PILImage
from PIL import ImageTk as PILImageTk
PILisLoaded = True
except:
PILisLoaded = False
if runningPython3:
from tkinter import *
import tkinter.filedialog as tk_FileDialog
from io import StringIO
else:
from Tkinter import *
import tkFileDialog as tk_FileDialog
from StringIO import StringIO
def write(*args):
args = [str(arg) for arg in args]
args = " ".join(args)
sys.stdout.write(args)
def writeln(*args):
write(*args)
sys.stdout.write("\n")
say = writeln
if TkVersion < 8.0 :
stars = "*"*75
writeln("""\n\n\n""" + stars + """
You are running Tk version: """ + str(TkVersion) + """
You must be using Tk version 8.0 or greater to use EasyGui.
Terminating.
""" + stars + """\n\n\n""")
sys.exit(0)
def dq(s):
return '"%s"' % s
rootWindowPosition = "+300+200"
PROPORTIONAL_FONT_FAMILY = ("MS", "Sans", "Serif")
MONOSPACE_FONT_FAMILY = ("Courier")
PROPORTIONAL_FONT_SIZE = 10
MONOSPACE_FONT_SIZE = 9 #a little smaller, because it it more legible at a smaller size
TEXT_ENTRY_FONT_SIZE = 12 # a little larger makes it easier to see
#STANDARD_SELECTION_EVENTS = ["Return", "Button-1"]
STANDARD_SELECTION_EVENTS = ["Return", "Button-1", "space"]
# Initialize some global variables that will be reset later
__choiceboxMultipleSelect = None
__widgetTexts = None
__replyButtonText = None
__choiceboxResults = None
__firstWidget = None
__enterboxText = None
__enterboxDefaultText=""
__multenterboxText = ""
choiceboxChoices = None
choiceboxWidget = None
entryWidget = None
boxRoot = None
ImageErrorMsg = (
"\n\n---------------------------------------------\n"
"Error: %s\n%s")
#-------------------------------------------------------------------
# various boxes built on top of the basic buttonbox
#-----------------------------------------------------------------------
#-----------------------------------------------------------------------
# ynbox
#-----------------------------------------------------------------------
def ynbox(msg="Shall I continue?"
, title=" "
, choices=("Yes", "No")
, image=None
):
"""
Display a msgbox with choices of Yes and No.
The default is "Yes".
The returned value is calculated this way::
if the first choice ("Yes") is chosen, or if the dialog is cancelled:
return 1
else:
return 0
If invoked without a msg argument, displays a generic request for a confirmation
that the user wishes to continue. So it can be used this way::
if ynbox(): pass # continue
else: sys.exit(0) # exit the program
@arg msg: the msg to be displayed.
@arg title: the window title
@arg choices: a list or tuple of the choices to be displayed
"""
return boolbox(msg, title, choices, image=image)
#-----------------------------------------------------------------------
# ccbox
#-----------------------------------------------------------------------
def ccbox(msg="Shall I continue?"
, title=" "
, choices=("Continue", "Cancel")
, image=None
):
"""
Display a msgbox with choices of Continue and Cancel.
The default is "Continue".
The returned value is calculated this way::
if the first choice ("Continue") is chosen, or if the dialog is cancelled:
return 1
else:
return 0
If invoked without
夕橘子
- 粉丝: 1
- 资源: 3
最新资源
- IEEE15节点系统Simulink仿真 1.基础功能:基于Matlab simulink平台搭建IEEE15节点仿真模型,对电力系统进行潮流计算 2.拓展功能: 可在该IEEE15节系统仿真模型上进
- IEEE9节点系统Simulink仿真 1.基础功能:基于Matlab simulink平台搭建IEEE9节点仿真模型,对电力系统进行潮流计算(与编程用牛拉法计算潮流结果一致) 2.拓展功能: 可在该
- dsp28335 PMSM三相永磁同步电机矢量控制源代码,包含clarke变,park变,svpwm,pi控制等,同时包含adc,eeprom,can,i2c,spi,定时器等驱动代码,已在实际项目中
- 脉振高频电压注入的永磁同步电机无速度传感器 PMSM
- 西门子200smart和昆仑通态锅炉热站程序项目实例,程序内有利用模拟量读取,运算时间自动切,水泵一用一备故障自动切,自动时间段加热,时间段设定温度,电能读取及算法 modbus通讯控制变频器
- 孤岛模式下两台逆变器下垂控制算法,采用电压外环和电流内环的双闭环控制,可以提供参考文献
- 常用的电机启动功能块实用博图软件西门子1200 1500,本人用的功能最全面的控制电机启动的功能块 包括1远程就地选择2设备故障反馈3设备运行反馈4控制及仿真5启动命令后电机不运行报警6报警复位7电
- MATLAB基于Simulink的行波故障测距 ,基于MATLAB SIMULINK的输电线路故障行波仿真方法
- 三相离网逆变器,VSG控制 离网逆变器VSG控制算法,有功-频率控制,无功-电压控制 电压波形质量良好
- flac3d边坡地震模型 采用自由场边界,使用瑞利阻尼,输入地震波采用阪神地震波 鲁甸波
- MATLAB代码:基于主从博弈的智能小区代理商定价策略及电动汽车充电管理 关键词:电动汽车 主从博弈 动态定价 智能小区 充放电优化 参考文档:基于主从博弈的智能小区代理商定价策略及电动汽车充电
- 多点预瞄模糊控制 软件使用:Carsim+Matlab Simulink 适用场景:采用模块化建模方法,搭建联合仿真模型,以Carsim作为整车平台适用于多种工况场景 产品simulink源码包含如
- 折叠式共源共栅放大器设计 cadence 宽摆幅 压摆率 smic180 tsmc180
- 西门子S7-1200程序案例, PID 恒温恒压供冷却水程序.SCL编程语言 触摸屏画面TP1200组态 霍尼韦尔电动比例阀PID控制水温,与两台西门子v20变频器模拟量PID控制水压 包括程序和
- DSP28035充电桩 量产充电桩 采用DSP28035作为主控 全数字电源设计,输入输出全隔离 采用APFC+LLC全桥整流,低损耗 支持过流,过压,欠压保护 包括原理图,源代码,说明文
- C#联合halcon实现字符缺陷检测源码机器视觉 字符识别 IO输入输出 halcon联合C#实现字符识别,处理pin距离 4个巴斯勒相机相机SDK开发 设置相机的触发模式,采集模式,曝光增益 宇符模
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈