最近,我设法创建了一个共享库,可以通过以下命令从this Vala文件中使用它:
1:valac circular-progress-bar.vala -X -fPIC -X -shared -o test_shared.so --library=testShared --gir testShared-0.1.gir --pkg gtk+-3.0
2:g-ir-compiler --shared-library=test_shared.so --output=testShared-0.1.typelib testShared-0.1.gir
我用python做了一个简单的测试窗口,其中显示了小部件,它只显示文本。它是Python还是不能以这种方式使用?Image of the test window/app
我尝试查找函数来更改设置或一些值,但我找不到它。
如果能给予我任何帮助,我将不胜感激!
发布于 2020-04-05 02:17:45
在经历了编译对象和生成接口文件以使用Python中的小部件这一困难的技术步骤之后,这个答案可能有点令人震惊。据我所知,没有显示圆圈的原因是因为它的值是0% -所以没有圆圈!
这个小部件有一个percentage属性,可以用pb.props.percentage在Python中设置它。在本例中,百分比设置为60%,对我来说效果很好。我使用pb.props.percentage = 0.6
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, GObject
gi.require_version('testShared', '0.1')
from gi.repository import testShared
class GUI (Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self)
pb = testShared.CircularProgressBar()
pb.props.percentage = 0.6
self.connect('destroy', self.on_window_destroy)
self.add(pb)
self.show_all()
Gtk.main()
def on_window_destroy(self, window):
Gtk.main_quit()
if __name__ == "__main__":
GUI()该小部件还有其他可以更改的属性,例如line_width设置绘制圆的线条的宽度。
这是一个屏幕截图,显示了60%和设置为10的line_width

https://stackoverflow.com/questions/59987525
复制相似问题