使用Cx_Freeze将CheckScript转换为Exe时,Checkbox不起作用

时间:2016-04-22 06:36:50

标签: python-2.7 checkbox tkinter cx-freeze

我正在使用Tkinter和Python 2.7创建一个Python GUI。复选框的值需要在变量中注册并显示给用户。在运行脚本文件时,复选框工作正常,并记录其值。

但是,在使用Cx_Freeze将其转换为exe后,勾选为1的复选框并不表示该值。它记录0,而不是。以下是checkbutton部分代码的摘录。请帮忙。

    global On_Off
    global CheckVar1

    global On_Off_state
    def On_Off_state(*args):
         On_Off = CheckVar1.get()

    On_Off = 0

    CheckVar1 = IntVar()

    CheckVar1.trace_variable("w", On_Off_state)

    global OnOff
    OnOff = Checkbutton(label2, text = "On", variable = CheckVar1, onvalue = 1, offvalue = 0, height=1, width = 10,anchor = W, bg = '#0e5dd6', disabledforeground = '#FFFFFF')
    OnOff.grid(row = 4, column = 2, padx = 10, sticky = W)

    global change_On_Off_state
    def change_On_Off_state(*args):
        CheckVar1.set(*args)

    global set_value1
    def set_value1():
        global row_OnOff
        global col_OnOff
        change_On_Off_state(CheckVar1.get())
        d = CheckVar1.get()

0 个答案:

没有答案