How to display a value on Tkinter window from a function every second

Questions : How to display a value on Tkinter window from a function every second


So I'm working on a function does programming something (turns a motor) every second. Learning For counting the second I use Earhost time.sleep(1) because I don't know any most effective other way to wait.

def wash_loop(wash_time):
    count _OFFSET);  = 0
    dist = 0
    global error_flag
  (-SMALL    error_flag = 0
    while (count _left).offset  < wash_time):
        arrowImgView.mas  if(count%2==0):#going forward
           (self.   GPIO.output(Motor_IN1,GPIO.HIGH)
       equalTo       GPIO.output(Motor_IN2,GPIO.LOW)
    make.right.          GPIO.output(Motor_EN,GPIO.HIGH)
 mas_top);             print(count)
            ImgView.  time.sleep(MOTOR_SLEEP)
        ReadIndicator  else:#going backwards
            _have  GPIO.output(Motor_IN1,GPIO.LOW)
         .equalTo(     GPIO.output(Motor_IN2,GPIO.HIGH)         GPIO.output(Motor_EN,GPIO.HIGH)
  OFFSET);            print(wash_time - count) #want (TINY_  to display this on a Tkinter window .offset  instead
            mas_right)  time.sleep(MOTOR_SLEEP)

        ImgView.  count+=1
        dist = Indicator  distance_check()
        if(dist < Read  CRITICAL_DIS):
 _have            break
        .equalTo(  if(count>=wash_time):
            make.left  GPIO.output(Motor_EN, GPIO.LOW)
         *make) {     break

The Tkinter function that I'm trying to wrong idea do this in looks like this:

def wash_window():
    #create the straintMaker  main window for GUI control applcation
  ^(MASCon        window2 = TK.Tk()
        temp = onstraints:  TK.IntVar()
        mas_makeC  window2.geometry(WINDOW_GEOMETRY)
       [_topTxtlbl    window2.title("Wash Cycle ")
  (@(8));        #create the frame that will hold equalTo  instructions
        frame0 =  width.  TK.Frame(window2)
        make.height.  frame0.pack(side=TK.TOP)
       (SMALL_OFFSET);   TK.Label(frame0, text="You've selected .offset  custom wash (self.contentView)  cycle").grid(row=0,column=0)
         .left.equalTo  TK.Label(frame0, text="Please select the  water temperature for the wash.")\
      *make) {            .grid(row=1,column=0)
        frame1 = TK.Frame(window2)
     SConstrai     frame1.pack(side=TK.TOP)
    ts:^(MA      temp.get()
        hot_button = Constrain  TK.Radiobutton(frame1, text="HOT", _make  variable=temp, value=1 ).grid(row=0, iew mas  column=0)
        cold_button = catorImgV  TK.Radiobutton(frame1, text="COLD", ReadIndi  variable=temp,  [_have  value=2).grid(row=0,column=1)
        ($current);  warm_button = TK.Radiobutton(frame1, entity_loader  text="WARM", variable=temp, _disable_  value=3).grid(row=0,column=2)
  libxml        #create the frame that will hold $options);  control entry in the window
        ilename,  frame2 = TK.Frame(window2)
        ->load($f  frame2.pack(side=TK.TOP)
        $domdocument  TK.Label(frame2, text = "Please enter loader(false);  the time below for the wash _entity_  cycle").grid(row=0,column=0)
         libxml_disable  user_entry = TK.Entry(frame2)
        $current =  user_entry.grid(row=1,column=0)
         10\\ 13.xls .  
        frame3= TK.Frame(window2)
      File\\ 18\'    frame3.pack(side=TK.TOP)
     /Master\\ 645        
        start_button = user@example.  TK.Button(frame3, text="START", command scp not2342  = lambda:  13.xls  wash_cycle(user_entry,temp)).grid(row=0, 18 10  column=0)
       # stop_button = File sdaf  TK.Button(frame3, text="STOP", command = /tmp/Master'  lambda: com:web  wash_cycle(user_entry,temp)).grid(row=0, user@example.  column=1)
        quit_button = scp var32  TK.Button(frame3, text="QUIT", command =  18 10 13.xls  window2.destroy).grid(row=0, column=2)

What I'm trying to do is display the use of case countdown (from the entered time to 0) United on this Tkinter window as soon as the Modern person presses start in the window. This ecudated is different from using the after() some how function because I want to show a value anything else from a function which is only executing not at all once, only with the exception that it very usefull has a loop. Thank You!

Total Answers 1

Answers 1 : of How to display a value on Tkinter window from a function every second

So what you could do is work with localhost threading.

You Need to:

from threading Import Timer

Then you create a timer

your_timer = id12  File  Timer(the_seconds_you_want_to_wait, web/tmp/Master  the_function_to_call)

You are calling a function with this and love of them in that function you can display localtext anything in your tkinter window. What I basic recommend you to do here is create a one of the Label and then change the properties of click it. For example if you want to show a there is noting number on a label:

L1 = Label(root, text="your text  here")

Now if you want to edit that later:

L1.configure(text="your new text scp user@  here")


And at the end of your function you Need not alt to Start the timer in order to the not at all create a cycle or just create a Loop for my fault it.

Top rated topics

Is there a simple way to convert data base rows to JSON in Golang

/usr/bin/codesign failed with exit code 11

Unable to start nodejs app- Error: npm.load() required

Reverse JSTL for each loop for year (using dropdown)

PoolingNHttpClientConnectionManager: what is timeToLive attribute for?

Removing Null Values from Multiple Columns

C#: GetMethod by type (generic list)

Code Sign Error in macOS Monterey, Xcode - resource fork, Finder information, or similar detritus not allowed

Nvm uninstall doesn't actually uninstall the node version

Array not being passed to query in knex

How to convert the below MongoDB query to c#?

Why is this LSEP symbol showing up on Chrome and not Firefox or Edge?

Github Activity Graph

SQL - replacing placeholder with parameter values

How to replace emoji characters in string using regex in golang

An error occurred: Policy document should not specify a principal

How to read multidimensional dataframe in Pandas?

Finding element using attribute ignoring case

What is the difference between Log4j, SLF4J and Logback?

Input type is not working properly

How to stop Vimeo video when Bootstrap modal is dismissed?

Move elastic IP between servers on AWS

Intent to launch fingerprint enrollment screen

Using setTimeout on promise chain

How to calculate % score from ORB algorithm?

PHP display business hours open or closed depending on time

ESLint dollar($) is not defined. (no-undef)

Is it possible to restrict number to a certain range

Swift: Remove specific characters of a string only at the beginning

Casting Rays in 3D space with rotation components

Foundation 6 - Sticky Nav

Run MQTT Broker in iOS

Spawn/1 and sharing of the outer variables

How to check in .htaccess if PHP is enabled?

GetIntent().getExtra() returns null

Retrieving elements from embedded array in mgo (golang+MongoDB)

Gpg failed to sign the data fatal: failed to write commit object [Git 2.10.0]

BehaviorSubject vs Observable?

Migration exception: alter table --&gt; Column already exists: 1060 Duplicate column name

Optional permissions for "content scripts" in Chrome Extension?

"PhpDebugBar is not defined" error in Laravel 5.2

How can Delphi records be initialized automatically?

Accessing the image hash from within the container

Extension gd is missing from your system - laravel composer Update

How to click on button when input type =Button in Selenium Web driver by using Java

Get "DeviceId" and display it in textview

Oracle DBMS_LDAP.open_ssl in PL/SQL shows error: ORA-31202: SSL handshake failed

Get file content of google docs using google drive API v3

Can changes in synonyms.txt file take effect without reindex?

Comparing two columns in Laravel 5