Cascading Style Sheets

Animation FrameworkIndexModules

CSS is a language to describe styling of document. CSS is widely used in HTML world, every web pages now have a CSS attached. If you don't known at all CSS, you can start by searching and reading a tutorial css first. PyMT uses CSS to let you customize the way widgets appear when you run an application. This way you can completely customize the look and feel of your applications.

But PyMT use CSS only as a support. That's mean our CSS language don't follow exactly the CSS of HTML. We have more tokens available, and don't support all CSS syntax.

Ways to use CSS

Edit ~/.pymt/user.css

If you create a file called user CSS in the PyMT home directory (USER_HOME/.pymt). PyMT will automatically load it after it loads the default CSS.

Add new CSS at runtime

mycss = '''
#button {
  bg-color: rgba(255, 127, 0, 127);
}
'
'''
css_add_sheet(mycss)

Default CSS sheet

This is the contents of the default CSS file used by PyMT internally. The specific contents may change with version, and this here might not be up to date. But it should be able to give you a pretty good idea of how the CSS style sheets work with PyMT, which properties you can set, and how to specify the values. You can found the latest PyMT CSS version on github.

* {
    /* text color */
    color: rgba(255, 255, 255, 255);

    /* color when something is pushed */
    color-down: rgba(150, 150, 150, 150);

    /* background color of widget */
    bg-color: rgba(60, 60, 60, 150);

    /* fonts */
    font-size: 10;
    font-name: "";
    font-weight: normal; /* normal, bold, italic, bolditalic */
    font-color: rgba(255, 255, 255, 255);

    /* borders */
    border-width: 1.5;
    border-radius: 0;
        border-radius-precision: 1;
    draw-border: 0;

    /* background alpha layer */
    draw-background: 1;
    draw-alpha-background: 0;
    alpha-background: 1 1 0.5 0.5;

    /* text shadow */
    draw-text-shadow: 0;
    text-shadow-color: rgba(22, 22, 22, 63);
    text-shadow-position: -1 1;
}