本文整理匯總了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