简体   繁体   English

如何在Python中更改或查看gtk.ListStore标志

[英]How to change or view gtk.ListStore flags in Python

I have a TreeView connected with a ListStore object. 我有一个与ListStore对象连接的TreeView。 One of the function calls ListStore.get_iter_next(). 该函数之一调用ListStore.get_iter_next()。 Since the ListStore data changes every time, I am doubtful that iter is causing a memory leak. 由于ListStore数据每次都会更改,因此我怀疑iter会导致内存泄漏。

I need to check if the ListStore has gtk.TREE_MODEL_ITERS_PERSIST flag set and unset it as described in TreeModel.get_flags() documentation. 我需要检查ListStore是否已设置gtk.TREE_MODEL_ITERS_PERSIST标志,并按照TreeModel.get_flags()文档中的说明取消设置它。

How could I do that? 我该怎么办?

It would appear you would just use bitwise operations on it - for example: 看来您只需要对它使用按位运算-例如:

>>> a = 3 # just some number
>>> format(a, 'b') # display as a bit string so we can see what's going on
'11'
>>> a & 1 # check first bit is set
1
>>> a & 2 # check second bit is set
2 
>>> a ^= 1 # unset a bit
>>> format(a, 'b') # display for checking again...
'10'

Except you would use gtk.TREE_MODEL_ITERS_PERSIST instead... whether this is the right approach to your problem - I'm not sure - but answers your direct question as to how you could unset it. 除非您改用gtk.TREE_MODEL_ITERS_PERSIST ...这是否是解决问题的正确方法-我不确定-但是回答了您有关如何取消设置的直接问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM