mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Rename Checkbox to Switch
A new form of Checkbox will be arriving in Textual soon, working in conjunction with a RadioButton. What was called Checkbox is perhaps a wee bit heavyweight in terms of visual design, but is a style of widget that should remain. With this in mind we're renaming the current Checkbox to Switch. In all other respects its workings remains the same, only the name has changed. Things for people to watch out for: - Imports will need to be updated. - Queries will need to be updated; special attention will need to be paid to any queries that are string-based. - CSS will need to be changed if any Checkbox styling is happening, or if any Checkbox component styles are being used. See #1725 as the initial motivation and #1746 as the issue for this particular change.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -52,8 +52,8 @@ def test_dock_layout_sidebar(snap_compare):
|
||||
# from these examples which test rendering and simple interactions with it.
|
||||
|
||||
|
||||
def test_checkboxes(snap_compare):
|
||||
"""Tests checkboxes but also acts a regression test for using
|
||||
def test_switches(snap_compare):
|
||||
"""Tests switches but also acts a regression test for using
|
||||
width: auto in a Horizontal layout context."""
|
||||
press = [
|
||||
"shift+tab",
|
||||
@@ -63,7 +63,7 @@ def test_checkboxes(snap_compare):
|
||||
"enter", # toggle on
|
||||
"wait:20",
|
||||
]
|
||||
assert snap_compare(WIDGET_EXAMPLES_DIR / "checkbox.py", press=press)
|
||||
assert snap_compare(WIDGET_EXAMPLES_DIR / "switch.py", press=press)
|
||||
|
||||
|
||||
def test_input_and_focus(snap_compare):
|
||||
|
||||
@@ -152,21 +152,21 @@ def test_focus_next_and_previous_with_type_selector_without_self():
|
||||
screen = app.screen
|
||||
|
||||
from textual.containers import Horizontal, Vertical
|
||||
from textual.widgets import Button, Checkbox, Input
|
||||
from textual.widgets import Button, Switch, Input
|
||||
|
||||
screen._add_children(
|
||||
Vertical(
|
||||
Horizontal(
|
||||
Input(id="w3"),
|
||||
Checkbox(id="w4"),
|
||||
Switch(id="w4"),
|
||||
Input(id="w5"),
|
||||
Button(id="w6"),
|
||||
Checkbox(id="w7"),
|
||||
Switch(id="w7"),
|
||||
id="w2",
|
||||
),
|
||||
Horizontal(
|
||||
Button(id="w9"),
|
||||
Checkbox(id="w10"),
|
||||
Switch(id="w10"),
|
||||
Button(id="w11"),
|
||||
Input(id="w12"),
|
||||
Input(id="w13"),
|
||||
@@ -180,11 +180,11 @@ def test_focus_next_and_previous_with_type_selector_without_self():
|
||||
assert screen.focused.id == "w3"
|
||||
|
||||
assert screen.focus_next(Button).id == "w6"
|
||||
assert screen.focus_next(Checkbox).id == "w7"
|
||||
assert screen.focus_next(Switch).id == "w7"
|
||||
assert screen.focus_next(Input).id == "w12"
|
||||
|
||||
assert screen.focus_previous(Button).id == "w11"
|
||||
assert screen.focus_previous(Checkbox).id == "w10"
|
||||
assert screen.focus_previous(Switch).id == "w10"
|
||||
assert screen.focus_previous(Button).id == "w9"
|
||||
assert screen.focus_previous(Input).id == "w5"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user