Python Forum
Button animation is not working in a branch
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Button animation is not working in a branch
#1
Hi,

I am using a button animation that changes the relief to sunken on button click and changes it back to raised after 200 milliseconds. The button animation does not work if the if condition is false. It is not clear to me how the two are related. The code can be seen below.

def aonclick():    
    guistyle.configure("SunkableButtonA.TButton", relief="sunken", state="active")
    a.after(200, lambda: guistyle.configure("SunkableButtonA.TButton", relief="raised", state="normal"))
    print(akeyvar.get())
    try:
        #tweepy code
        
        
        if (condition!=true  ):
            
            
            messagebox.showinfo(message="Please provide correct input.")
            
            
            return
        
        #tweepy code
        
    except tweepy.TweepError as e:
        
        messagebox.showinfo(message=e)
Version information: python 3.4.3

I appreciate the cooperation of forum members.
Reply
#2
if condition: if you want to execute when condition is true else if not condition:
Recommended Tutorials:
Reply
#3
@metulburr I know about the if not syntax. If I'm not wrong != is a valid operator in python, and more importantly, how is that related to failure in execution of button animation?

I appreciate your cooperation.
Reply
#4
it is simply ugly to compare a boolean variable to True or False like you do. Don't do it, follow @metullburr's advise.
This way you will also avoid stupid mistakes like comparing condition to some global? variable true. I say global variable, but it well may be in the tweepy code missing in the example. Because otherwise the interpreter will raise NameError.
If you didn't get it so far - it is True, not true
Reply
#5
@buran The mentioned if statement is a dummy. It's not in the original code. The real if statement can be seen below.

if (foovars[0]!="https:" or foovars[2]!="twitter.com" or foovars[4]!="followers" ):
            
            
            messagebox.showinfo(message="Please provide correct input.")
            
            
            return
I appreciate your cooperation.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] Button clicked not working catlessness 10 8,257 Oct-21-2021, 12:36 PM
Last Post: catlessness
  Closing window on button click not working kenwatts275 4 3,799 May-03-2020, 01:59 PM
Last Post: deanhystad
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 5,033 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020