首页 > 解决方案 > 我们可以让 tkinter spinbox 返回一个布尔值吗?

问题描述

我知道 tkinter spinbox 返回一组值,我们可以稍后通过 using.get方法使用该值。但是是否可以创建一个只返回 2 个输出(True 或 False)的 tkinter spinbox?

def apply():
    if (toggle_var.get() == "ON"):
        # changing on/off state will start/stop the plot
        def dark():
            if (dark_var.get() == "ON"):
                print('do something from a function here')
            else:
                print('do some other thing')
            
        # Button to toggle between dark/no dark state
    
# Button to toggle between on/off state 

我想知道是否可以使用返回 True 或 False 的旋转框来代替此处的第二个复选框。

标签: pythontkinterspinbox

解决方案


推荐阅读