t有没有办法向PopupSliderMenuItem添加标签?我想要的是在一行中有类似于标签PopupSliderMenuItem标签的东西。或者,如果可以(以及如何?)垂直绘制滑块,则
label
slider
label
代码示例:
for(f=0;f<this.volumes.length;f++) {
this.labels[f]=new St.Label({ text: this.freq[f]});
this.sliders[f]=new PopupMenu.PopupSliderMenuItem(this.volumes[f]/100);
this.sliders[f].connect('value-changed', Lang.bind(this, this._onSlider));
this.menu.addMenuItem(this.sliders[f]);
//how can i add each label of labels[] before and after each slider
}
所以我设法解决了(从其他脚本中修补)我自己的困境
var mainBox = new St.BoxLayout({ vertical: true, x_align: St.Align.MIDDLE});
this.table=new St.Table({homogeneous: false});
mainBox.add_actor(this.table);
for(f=0;f<this.volumes.length;f++) {
this.labels[f]=new St.Label({ text: this.freq[f].split(". ")[1] ,x_align: St.Align.MIDDLE, y_align:St.Align.END});
this.vals[f]=new St.Label({text: (this.volumes[f]).toString(), x_align: St.Align.END, y_align:St.Align.END});
this.sliders[f]=new PopupMenu.PopupSliderMenuItem(this.volumes[f]/100);
this.sliders[f].connect('value-changed', Lang.bind(this, this._onSlider));
this.table.add(this.labels[f], {
row: f,
col: 1,
expand: true,
x_fill: true,
y_fill: false,
x_align: St.Align.MIDDLE,
y_align: St.Align.MIDDLE
});
this.table.add(this.sliders[f].actor, {
row: f,
col: 2,
expand: true,
x_fill: true,
y_fill: false,
x_align: St.Align.MIDDLE,
y_align: St.Align.MIDDLE
});
this.table.add(this.vals[f], {
row: f,
col: 3,
expand: true,
x_fill: true,
y_fill: false,
x_align: St.Align.MIDDLE,
y_align: St.Align.MIDDLE
});
}