You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
When popping one of the secondary screens, the TCSS properties of the popped screen get applied to the main screen. In this dummy example the button background color changes. This happens if the Screens share the same structure and the .tcss is defined with the widget class name. (Notice that I didn't try to use the same tcss class or the same id for widgets in different screens).
Expected Behavior:
After popping a Screen, all TCSS styles associated with it should be removed. The MainScreen's buttons should display styles defined in app.tcss without any residual styles from the popped screen.
Actual Behavior:
Button colors from second.tcss or first.tcss (secondary screen) persist and are applied to the MainScreen's buttons after the screen is dismissed.
Environment:
Operating System: Linux 6.13.0-rc1-1-MANJARO
Library Version: 0.88.0
Python Version: 3.12.7
app.py:
fromtextualimportonfromtextual.appimportApp, ComposeResultfromtextual.widgetsimportButton, Label, Placeholderfromtextual.containersimportVerticalfromtextual.screenimportScreenfromtextual.containersimport (
Horizontal,
Vertical,
)
classScreen1(Screen):
"""Screen to create a new configuration for the application."""CSS_PATH="first.tcss"defcompose(self) ->ComposeResult:
withVertical():
yieldLabel("Welcome to the first screen")
yieldButton("Dummy Button")
yieldButton("Dummy Button")
yieldHorizontal(
Button.error("Cancel", id="cancel"),
)
@on(Button.Pressed, "#cancel")defon_button_pressed(self, event: Button.Pressed) ->None:
self.app.pop_screen()
classScreen2(Screen):
CSS_PATH="second.tcss"defcompose(self) ->ComposeResult:
withVertical():
yieldLabel("Welcome to the second screen")
yieldButton("Dummy Button")
yieldButton("Dummy Button")
yieldHorizontal(
Button.error("Cancel", id="cancel"),
)
@on(Button.Pressed, "#cancel")defon_button_pressed(self, event: Button.Pressed) ->None:
self.app.pop_screen()
classMainScreen(Screen):
"""Main Screen of the application"""defcompose(self) ->ComposeResult:
yieldVertical(
Label("Welcome to MainScreen!"),
Button("Button 1", id="button-1"),
Button("Button 2", id="button-2"),
)
defon_button_pressed(self, event: Button.Pressed) ->None:
matchevent.button.id:
case"button-1":
self.app.push_screen("screen-1")
case"button-2":
self.app.push_screen("screen-2")
classMainApp(App):
"""Main Application"""CSS_PATH="app.tcss"SCREENS= {
"main": MainScreen,
"screen-1": Screen1,
"screen-2": Screen2,
}
asyncdefon_mount(self) ->None:
"""Set the initial screen."""awaitself.push_screen("main")
if__name__=="__main__":
MainApp().run()
app.tcss:
Screen{
align: center middle;
content-align: center middle;
background: gray;
}
Screen>Vertical{
width: auto;
height: auto;
align: center middle;
content-align: center middle;
background: black;
}
Screen>Vertical>Button{
width:30;
height: auto;
margin:11;
background: gray;
}
Screen>Vertical>Label {
min-width:1fr;
height: auto;
align: center middle;
content-align: center middle;
}
firts.tcss:
Screen{
align: center middle;
content-align: center middle;
}
Screen>Vertical{
width: auto;
height: auto;
align: center middle;
content-align: center middle;
}
Screen>Vertical>Button{
width:30;
height: auto;
margin:11;
background: green;
}
Screen>Vertical>Label {
min-width:1fr;
height: auto;
align: center middle;
content-align: center middle;
}
Description:
When popping one of the secondary screens, the TCSS properties of the popped screen get applied to the main screen. In this dummy example the button background color changes. This happens if the Screens share the same structure and the
.tcss
is defined with the widget class name. (Notice that I didn't try to use the same tcss class or the same id for widgets in different screens).Expected Behavior:
After popping a
Screen
, all TCSS styles associated with it should be removed. TheMainScreen
's buttons should display styles defined inapp.tcss
without any residual styles from the popped screen.Actual Behavior:
Button colors from
second.tcss
orfirst.tcss
(secondary screen) persist and are applied to theMainScreen
's buttons after the screen is dismissed.Environment:
app.py
:app.tcss
:firts.tcss
:second.tcss
:The text was updated successfully, but these errors were encountered: