QueryBox
QueryBox is a prompt dialog that asks the user for a single value (text, number, password, etc.) and returns the result.
Use it for quick questions like "Name?", "Quantity?", or "Search term?", where you want an explicit OK/Cancel outcome.
Quick start
import bootstack as bs
app = bs.App()
value = bs.QueryBox.get_string(
title="Rename",
prompt="Enter a new name",
initial="Untitled",
)
print("value:", value) # None if cancelled
app.mainloop()
When to use
Use QueryBox when:
-
you need one value
-
the user must explicitly confirm/cancel
Consider a different control when...
-
the value is part of a larger form - use TextEntry inline instead
-
you need multiple fields or rich validation - use FormDialog instead
Examples & patterns
Password prompt
pwd = bs.QueryBox.get_password(
title="Unlock",
prompt="Enter your password",
)
Numeric prompt
qty = bs.QueryBox.get_integer(
title="Quantity",
prompt="How many?",
initial=1,
minvalue=0,
maxvalue=999,
)
Value model
QueryBox returns:
-
the committed value (string/number), or
-
Nonewhen cancelled
Validation and constraints
Use numeric bounds (minvalue / maxvalue) where available.
For more complex validation or multiple fields, use FormDialog.
Behavior
-
OK commits the value
-
Cancel / Escape closes without committing
-
Enter confirms when the input is valid (if supported)
Additional resources
Related widgets
-
Dialog - base dialog API
-
FormDialog - structured multi-field input
-
MessageBox - confirmation / alerts
-
QueryDialog - alternative query dialog