그 밖의 모든 것이 실패하면 문서를 읽으십시오 (즉, ;-)가있는 경우).
EasyGui에는 별도의 다운로드 파일 인 easygui-docs-0.97.zip
이 있으며 webpage에 표시됩니다.
그래서
은, 귀하의 질문에, 없는에 대답하려면 모듈의를 경계 - 검사를 비활성화 할 수있는 방법이있을 나타나지 않습니다 : 여기가 integerbox()
기능에 대한 API 절에 말씀입니다 integerbox()
않습니다.
업데이트 : 여기 (그래서 엄격하게 전화와 호환되지 않는 것 주식 버전) 당신이 전혀 경계 검사를하지 않는다도 아니다 경계 인수를 사용할 않는 모듈에을 추가 할 수있는 새로운 기능입니다. 모듈을 넣으면 모듈의 스크립트 파일 상단에 __all__
목록의 정의에 해당 이름 인 'integerbox2'
을 추가하십시오. 당신이 미래의 업데이트가있을 경우에 easygui
모듈의 스크립트 자체에 변화를 최소화하려는 경우
대신 별도의 .py
파일에 새로운 기능을 넣을 수있는 다음 easygui.py
의 상단 근처 import integerbox2
(및 다른 줄을 추가 그것을 __all__
에 추가하십시오).
여기에 추가 기능입니다 :
#-------------------------------------------------------------------
# integerbox2 - like integerbox(), but without bounds checking.
#-------------------------------------------------------------------
def integerbox2(msg=""
, title=" "
, default=""
, image=None
, root=None):
"""
Show a box in which a user can enter an integer.
In addition to arguments for msg and title, this function accepts
an integer argument for "default".
The default argument may be None.
When the user enters some text, the text is checked to verify that it
can be converted to an integer, **no bounds checking is done**.
If it can be, the integer (not the text) is returned.
If it cannot, then an error msg is displayed, and the integerbox is
redisplayed.
If the user cancels the operation, None is returned.
:param str msg: the msg to be displayed
:param str title: the window title
:param str default: The default value to return
:param str image: Filename of image to display
:param tk_widget root: Top-level Tk widget
:return: the integer value entered by the user
"""
if not msg:
msg = "Enter an integer value"
# Validate the arguments and convert to integers
exception_string = ('integerbox "{0}" must be an integer. '
'It is >{1}< of type {2}')
if default:
try:
default=int(default)
except ValueError:
raise ValueError(exception_string.format('default', default,
type(default)))
while 1:
reply = enterbox(msg, title, str(default), image=image, root=root)
if reply is None:
return None
try:
reply = int(reply)
except:
msgbox('The value that you entered:\n\t"{}"\n'
'is not an integer.'.format(reply), "Error")
continue
# reply has passed validation check, it is an integer.
return reply
나는이 도움이 얼마나 ... 만 "기본"매개 변수가 없음 수 없다 표시되지 않습니다; 다른 것은 없습니다. lowerbound 및 upperbound 매개 변수에 None을 넣으려고했는데 정수가 아닌 값이므로 오류가 발생합니다. –
RTFM ...'default','lowerbound' 및'upperbound' 인수는 정수 여야한다고합니다. 'None'은 정수가 아니라는 것을 알았습니까? 또한 소스 코드를 살펴보면 함수 정의의 모든 인수에 실제로 문서화 된 기본값이 있음을 알 수 있습니다. – martineau
파이썬 정수에는 실제로 아무런 제한이 없으므로, 원하는 결과를 제공하는 소스를 수정하거나 (제공된 함수에서 파생 된 새 함수를 추가하는 것) 절대적으로 제한을 검사하지 않으려면이 원인이 될 수 있습니다. 인수가'None'이고 경계 테스트를 생략하는지 확인하십시오. – martineau