关于Easygui按键快捷键定义问题
本帖最后由 UncleMonster 于 2020-11-21 17:56 编辑问题如下:
代码1:
import easygui as e
if e.ccbox("文本内容","标题内容",choices = ('按键内容','按键内容')):
e.msgbox("你选择了按键a的内容")
else:
e.msgbox("你选择了按键b的内容")
代码2:
import easygui as e
if e.ccbox("文本内容","标题内容",choices = ('按键[<a>]内容','按键[<b>]内容')):
e.msgbox("你选择了按键a的内容")
else:
e.msgbox("你选择了按键b的内容")
代码3:
import easygui as e
if e.ccbox("文本内容","标题内容",choices = ('按键[<F1>]内容','按键[<F2>]内容')):
e.msgbox("你选择了按键F1的内容")
else:
e.msgbox("你选择了按键F2的内容")
疑问:为什么快捷键a,b将[]换成[<>]后,字母隐藏且无法正常使用快捷键,而F1 F2则使用[<>]可以正常激活快捷键【代码1为正确代码,2,3为个人想法更变测试】 如图
看这:https://fishc.com.cn/forum.php?mod=viewthread&tid=46069&extra=page%3D1%26filter%3Dtypeid%26typeid%3D403
ccbox(msg='Shall I continue?', title=' ', choices=('Cntinue', 'Cncel'), image=None, default_choice='Cntinue', cancel_choice='Cncel')
ccbox() 提供一个选择:“Cntinue” 或者 “Cncel”,并相应的返回 True 或者 False。
注意:“Cntinue” 中的 表示快捷键,也就是说当用户在键盘上敲一下 o 字符,就相当于点击了 “Cntinue” 按键。
===>模块就这么规定的,你搞这稀奇古怪的干啥,你要有这功夫也可以看看模块的源代码自己去分析
# -----------------------------------------------------------------------
# ccbox
# -----------------------------------------------------------------------
def ccbox(msg="Shall I continue?", title=" ",
choices=("Cntinue", "Cncel"), image=None,
default_choice='Continue', cancel_choice='Cancel'):
"""
Display a msgbox with choices of Continue and Cancel.
The returned value is calculated this way::
if the first choice ("Continue") is chosen,
or if the dialog is cancelled:
return True
else:
return False
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 ccbox():
pass # continue
else:
sys.exit(0)# exit the program
:param str msg: the msg to be displayed
:param str title: the window title
:param list choices: a list or tuple of the choices to be displayed
:param str image: Filename of image to display
:param str default_choice: The choice you want highlighted
when the gui appears
:param str cancel_choice: If the user presses the 'X' close,
which button should be pressed
:return: True if 'Continue' or dialog is cancelled, False if 'Cancel'
"""
return boolbox(msg=msg,
title=title,
choices=choices,
image=image,
default_choice=default_choice,
cancel_choice=cancel_choice) 笨鸟学飞 发表于 2020-11-21 22:58
看这:https://fishc.com.cn/forum.php?mod=viewthread&tid=46069&extra=page%3D1%26filter%3Dtypeid%26typ ...
这个是理解的,我只是觉得[<>]符号是设置并隐藏快捷键,[]符号是设置并显示,但是试了一下时而对时而不对{:10_277:}{:10_285:}
页:
[1]