gpt4 book ai didi

Python gtk TextView 边框不适用于 css

转载 作者:行者123 更新时间:2023-11-28 02:16:51 24 4
gpt4 key购买 nike

我的情况真的很奇怪。从 gtk css 样式我可以应用例如背景颜色、顺序半径,但我不能使边框可见。该文件非常简单:

GtkTextView  {

border-radius: 3px;
border-width: 1px 1px 2px 1px;
border-style: solid;
border-color: #000;
/*background-color: #0000ff;*/
}

我做错了什么?

最佳答案

我也在这个问题上花费了太多时间——时间更长,可能已经破坏了谷歌。顺便说一句:CSS 边框对此根本不起作用。

但是可以通过Drawn信号来完成。下面的代码是 C#(我不喜欢 python),但它很简短,“将展示它的要点。”

// add callback to Drawn signal handler
MyTextView.Drawn += widgetDrawn; // where you build your form / set up your widget

....

// this works on any widget, labels and containers included
private void widgetDrawn(object sender, DrawnArgs e)
{
e.Cr.SetSourceRGB(1, 0, 0); // red - so ya won't miss it.
e.Cr.Rectangle(0, 0, ((Widget)sender).Allocation.Width, ((Widget)sender).Allocation.Height);
// thicker line --> e.Cr.LineWidth = 1; // ... default is 1
e.Cr.Stroke();
}
  • 它适用于任何小部件,包括标签和容器
  • RGB 是开罗风格( double )0.0000..1.0),即浅灰色:(0.828, 0.828, 0.828)
  • 线条绘制在分配的小部件区域的内部(即,LineWidth 越宽,小部件内容留在内部的区域就越少。
  • 裁剪已全部处理(即重叠/超出窗口边界)

注意:如果您改写(继承类或类似类):protected override bool OnDrawn(Cairo.Context cr) { ... }
-- 在添加边框之前调用 base.OnDrawn(cr)
-- 并确保返回 bool 结果。

关于Python gtk TextView 边框不适用于 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48431689/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com