简体   繁体   中英

Gnome Shell Stylesheet

So I'm making a gnome shell extension, and I can't figure out how to make one part of my extension normal font weight. Here is my extension.js file:

'use strict';

const { St, Clutter } = imports.gi;

const Main = imports.ui.main;

let _myText;

class Extension {

    enable() {
    _myText = new St.Label({ text: 'This should be normal font weight.', y_align: Clutter.ActorAlign.CENTER, style_class: 'panel-button', track_hover: false, reactive: false});
    Main.panel._leftBox.insert_child_at_index(_myText, 10)
    }

    disable() {
    _myText.destroy();
    }
}

function init() {
    return new Extension();
}

And here is my stylesheet.css file:

StLabel._myText {
    font-weight: normal;
}

What am I doing wrong?

You can't just use arbitrary JavaScript variables in CSS; you need to tell a widget what CSS name and class it's supposed to use:

.my-class {
    font-weight: normal;
}
const myLabel = new St.Label({
    text: 'My Label',
    style_class: 'panel-button my-class',
});

See also:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM