问题
This will show all attributes and their values of an existing widget: (I got the idea from user285594 at this post)
obj = [widget identifier]
for pspec in obj.props:
print(pspec.name)
name = pspec.name.replace('-', '_')
props = eval("button.props." + name)
print(props)
Unfortunately, I can't find the attachment values when the widget has been attached to a grid. Does anyone know how to do this?
回答1:
The attachment and packing values are child properties, not properties, so you have to retrieve them with child_get_property().
回答2:
ptomato is right, this does the job:
obj = [widget identifier]
parent = obj.get_parent()
attachement = ''
lst_props = ['left-attach', 'top-attach', 'width', 'height']
for prop in lst_props:
attachement += str(parent.child_get_property(obj, prop))
print(attachement)
来源:https://stackoverflow.com/questions/65565385/how-to-get-the-attachment-values-when-a-widget-has-been-attached-to-a-grid