本文整理汇总了Python中_tkinter.Tcl_Obj方法的典型用法代码示例。如果您正苦于以下问题:Python _tkinter.Tcl_Obj方法的具体用法?Python _tkinter.Tcl_Obj怎么用?Python _tkinter.Tcl_Obj使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_tkinter
的用法示例。
在下文中一共展示了_tkinter.Tcl_Obj方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: config_cleaner
# 需要导入模块: import _tkinter [as 别名]
# 或者: from _tkinter import Tcl_Obj [as 别名]
def config_cleaner(widget):
""" Some options don't like to be copied, so this returns a cleaned
configuration from a widget
We use config() instead of configure() because some items (ttk Scale) do
not populate configure()"""
new_config = dict()
for key in widget.config():
if key == "class":
continue
val = widget.cget(key)
# Some keys default to "" but tkinter doesn't like to set config to this value
# so skip them to use default value.
if key in ("anchor", "justify", "compound") and val == "":
continue
val = str(val) if isinstance(val, Tcl_Obj) else val
# Return correct command from master command dict
val = _RECREATE_OBJECTS["commands"][val] if key == "command" and val != "" else val
new_config[key] = val
return new_config
示例2: tcl_obj_eq
# 需要导入模块: import _tkinter [as 别名]
# 或者: from _tkinter import Tcl_Obj [as 别名]
def tcl_obj_eq(actual, expected):
if actual == expected:
return True
if isinstance(actual, _tkinter.Tcl_Obj):
if isinstance(expected, str):
return str(actual) == expected
if isinstance(actual, tuple):
if isinstance(expected, tuple):
return (len(actual) == len(expected) and
all(tcl_obj_eq(act, exp)
for act, exp in zip(actual, expected)))
return False