Problem with a simple if statement

240
2
Jump to solution
12-20-2019 10:08 AM
RickHawkins
New Contributor II

I am new to Python programming and i am having trouble with a few lines of code that should be easy. The code is below. It is a very simple part of my program. 

When i run this code in PythonWin line 57 puts on my screen a 0 or a 1 depending whether i have selected something in another part of the program. Line 58 prints out the feeder name. Line 59 is the problem. When i print this out it shows that mY_label is equal to "NONE". Why would line 57 show correctly and line 59 does not?

Thanks for any assistance.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
deleted-user-NvcfpBOWaKwr
Occasional Contributor

Try printing the value of the button (assuming you are using tkinter):

print(CheckVar1.get()‍‍)

If that provides the output you are looking for add that to your if statement:

if CheckVar1.get() == 1:
    print("pri_oh = 1")

else:
    print("pri_oh = 0")‍‍‍‍‍

View solution in original post

2 Replies
deleted-user-NvcfpBOWaKwr
Occasional Contributor

Try printing the value of the button (assuming you are using tkinter):

print(CheckVar1.get()‍‍)

If that provides the output you are looking for add that to your if statement:

if CheckVar1.get() == 1:
    print("pri_oh = 1")

else:
    print("pri_oh = 0")‍‍‍‍‍
RickHawkins
New Contributor II

Jeremy,

Thanks a lot for the help. This code worked perfect. I knew it had to be simple but i had run out of ideas.

0 Kudos