Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Styling Python in CSS?

A friend has given me an app he's made in Python. I know nothing about Python but I mean to do the course at some point. He wants me to style the UI for the app using HTML and CSS.

I don't know what I'm doing ;_;

How do I do this?

Do I create a .html and .css file in the same folder as the files for the app, and link to the python files somehow?

Any advice or documentation is much appreciated thanks.

1 Answer

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

You can't style Python with CSS because Python isn't HTML (the only thing CSS can actually style). You can use Python to generate HTML that can be styled with CSS. Can you tell us more about what you're trying to do?

Hm. A friend has made an app to keep track of repairs he and colleagues have to make at an Apple store in London. The UI is just plain default text and buttons. And he saw my Treehouse profile and how I knew a lot about front end web design and wondered if I could make the app pretty with what I knew...

But it's impossible? D:

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

It's not impossible. It's just not directly applicable.

CSS is for styling HTML. Python is a general purpose programming language. So Python can create HTML (which you can then style with CSS) but Python isn't HTML and isn't capable of being styled itself.

Does the app generate HTML?

He said he was reading up on some Python frameworks. Something called "Bottle", so that the app will generate HTML to which I can apply my styles.

Does that sound feasible? Or needlessly complicated?

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Yeah, Bottle is a web framework that'll generate HTML. You should be good to go.

Great. I was reading the documentation for bottle and feeling very confused because I didn't see how to style the Python with CSS. I'll go back and read it more closely.

Thanks for confirming this project will actually work. O_O