Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot find tcss file #4068

Closed
wangcham opened this issue Jan 26, 2024 · 4 comments
Closed

cannot find tcss file #4068

wangcham opened this issue Jan 26, 2024 · 4 comments

Comments

@wangcham
Copy link

Have you checked closed issues?
yes,my code is the same as the stopwatch tutorial,but the only problem is I can't import the .tcss file in my app.py,
here's the code:

//app.py
class StopwatchApp(App):
    CSS_PATH = "stopwatch.tcss"
    BINDINGS = [
                ("d","toggle_dark","Toggle dark mode"),
                ("a", "add_stopwatch", "Add"),
                ("r", "remove_stopwatch", "Remove"),            
                ]
    def compose(self) -> ComposeResult:
        yield Header()
        yield Footer()
        yield ScrollableContainer(Stopwatch(),Stopwatch(),Stopwatch(),id="timers")

    def action_toggle_dark(self) -> None:
        self.dark = not self.dark
    
    def action_add_stopwatch(self) -> None:
        """An action to add a timer."""
        new_stopwatch = Stopwatch()
        self.query_one("#timers").mount(new_stopwatch)
        new_stopwatch.scroll_visible()

    def action_remove_stopwatch(self) -> None:
        """Called to remove a timer."""
        timers = self.query("Stopwatch")
        if timers:
            timers.last().remove()



if __name__ == "__main__":
    app = StopwatchApp()
    app.run()

and the stopwatch.tcss file is in the same folder with the app.py

I don't know why it isn't working,and when I click the button nothing happend here

when I RUN the app,it shows:
image

thank you!

@wangcham
Copy link
Author

here's the file heirachy:
image

@TomJGooding
Copy link
Contributor

You would get a StylesheetError: unable to read CSS file error if the CSS file failed to load, but it looks like your app is running in your screenshot? Or is there something I've misunderstood?

@wangcham
Copy link
Author

I could run the app,but The style is not what I've code in the stopwatch.tcss,it seems like the tcss file doesn't work

@TomJGooding
Copy link
Contributor

Could you provde a bit more detail what specfic styling in the app doesn't match your CSS? Screenshots and code would be helpful.

@Textualize Textualize deleted a comment from github-actions bot Jan 26, 2024
@Textualize Textualize locked and limited conversation to collaborators Jan 26, 2024
@davep davep converted this issue into discussion #4069 Jan 26, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants