About 948,000 results
Open links in new tab
  1. Python Tkinter Button with If Else statements - Stack Overflow

    I want to bind the Start_Button with 2 possible functions: If Choice_1_Button is clicked and then the Start_Button, the Start_Button should call foo1. But when the user clicks Choice_2_Button then the same Start Button should call foo2. Here is the code I currently have:

  2. Python 3.4 GUI if statement with buttons - Stack Overflow

    Feb 8, 2016 · I'm trying to learn coding with python 3.4. I built this mini GUI and I'm having trouble getting it to work. It prints out 2 every time even though I press the button 1 . All I want to do is to get 1 printed out in the label when I click the button on and 2 with button two with an if statement.

  3. python - If statement with buttons - Stack Overflow

    Dec 29, 2021 · def choiceFirst(num): if num == '1': print(f"choice {num} code here") else: print(f"choice {num} code here") button1 = Button(window, text="Choice 1", command=lambda: choiceFirst('1'), ...) button2 = Button(window, text="Choice 2", command=lambda: choiceFirst('2'), ...)

  4. CYBER.ORG Practice CTF

    This command will return a value of "true" if the button is being pressed, which works well with the conditional statements from earlier in the lesson. Once they have this line, you can program a button press to do anything you already know how to do! for example:

  5. Conditional Button Press - Python Forum

    Mar 17, 2017 · I am looking to make a while loop break upon button press but I'm not sure how to do so. I assume it would be with a conditional statement but the syntax is foreign to me. A pseudocode example would be as follows: while True: - statement if …

  6. Tkinter Button - Python Tutorial

    Use the ttk.Button() class to create a button. Assign a lambda expression or a function to the command option to respond to the button click event. Assign the tk.PhotoImage() to the image property to display an image on the button.

  7. 3.1. If Statements — Hands-on Python Tutorial for Python 3

    Jan 5, 2020 · Luckily strings have an isdigit method, which is true when a nonempty string consists entirely of digits, so '2397'.isdigit() returns True, and '23a'.isdigit() returns False, exactly corresponding to the situations when the string represents a whole number!

  8. Python Conditional Statements and Loops

    Read all the tutorials related to the topic of Python Sets. Loops in Python. Loops allow you to execute a block of code multiple times. Python provides two main types of loops: for loops and while loops. For Loops. The for loop in Python is designed to iterate over a sequence (like a list, tuple, dictionary, set, or string):

  9. Python if, if...else Statement (With Examples) - Programiz

    In computer programming, the if statement is a conditional statement. It is used to execute a block of code only when a specific condition is met. For example, Suppose we need to assign different grades to students based on their scores. These conditional tasks can …

  10. Understanding `if true` in Python - CodeRivers

    Apr 23, 2025 · The expression if true in Python is a special case where the condition is explicitly set to the boolean value True. Since True is always... well, True , the block of code following the if true statement will always be executed.

  11. Some results have been removed
Refresh