|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 UncleMonster 于 2020-11-21 17:56 编辑
问题如下:
代码1:
- import easygui as e
- if e.ccbox("文本内容","标题内容",choices = ('按键[a]内容','按键[b]内容')):
- 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?m ... peid%26typeid%3D403
ccbox(msg='Shall I continue?', title=' ', choices=('C[o]ntinue', 'C[a]ncel'), image=None, default_choice='C[o]ntinue', cancel_choice='C[a]ncel')
ccbox() 提供一个选择:“C[o]ntinue” 或者 “C[a]ncel”,并相应的返回 True 或者 False。
注意:“C[o]ntinue” 中的 [o] 表示快捷键,也就是说当用户在键盘上敲一下 o 字符,就相当于点击了 “C[o]ntinue” 按键。
===>模块就这么规定的,你搞这稀奇古怪的干啥,你要有这功夫也可以看看模块的源代码自己去分析
- # -----------------------------------------------------------------------
- # ccbox
- # -----------------------------------------------------------------------
- def ccbox(msg="Shall I continue?", title=" ",
- choices=("C[o]ntinue", "C[a]ncel"), 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)
复制代码
|
|