mardi 11 août 2020

how to make a greater than or lower than with tkinter StringVar

My code keeps giving this error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Program Files\Python38\lib\tkinter\__init__.py", line 1883, in __call__
    return self.func(*args)
  File "d:/Python Code stuff I did/print.py", line 209, in <lambda>
    button = Button(root,text="Change Config", width=20, height=3, bg="#0f0f0f",fg="#ffffff", command=lambda:[do_it(), do_it1(), do_it2(), do_it3(),do_the_it(),do_the_it1()])
  File "d:/Python Code stuff I did/print.py", line 149, in do_the_it
    if str(number_1) > 4:
TypeError: '>' not supported between instances of 'str' and 'int'

I want it to check if that specific number is greater than 4 for example i input a number for example lets say its 7 I want it to print and that number is too high here is my code:

def do_the_it():
    a = updater['Trading Settings']['minimum_offer'].value
    updater.read('settings.ini')
    updater['Trading Settings']['minimum_offer'].value = number_1.get()
    updater.update_file()
    updater.read('settings.ini')
    updater['Trading Settings']['maximum_offer'].value = number_2.get()
    updater.update_file()
    if str(number_1) > 4:
        print("Number can only exceed to 4")
        updater.read('settings.ini')
        updater['Trading Settings']['minimum_offer'].value = 4
        updater.update_file()

Aucun commentaire:

Enregistrer un commentaire