微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Gnome Shell 样式表

如何解决Gnome Shell 样式表

所以我正在制作一个 gnome shell 扩展,但我不知道如何使我的扩展的一部分具有正常的字体粗细。这是我的 extension.js 文件

'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();
}

这是我的 stylesheet.css 文件

StLabel._myText {
    font-weight: normal;
}

我做错了什么?

解决方法

你不能只在 CSS 中使用任意的 JavaScript 变量;你需要告诉一个小部件它应该使用什么 CSS 名称和类:

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

另见:

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。