hello im new here on the forum.. so im using phyton 2.5.4 and i need help to finish this count loop

while not inloged and not ended:   
    sleep(1)
    print Time
    Time = Time - 1
    if Time == 0:
    #   os.system("shutdown -s")
        ended=True

so now the count works good but punting the root.mainloop() don't work i tested

if root.mainloop():
break

the Tk show up but the count don't start . plzz help

please don't point at my spelling im from sweden

You'll have to post the Tkinter part of the code. There is no root.mainloop() in the code you posted.

You'll have to post the Tkinter part of the code. There is no root.mainloop() in the code you posted.

ha ha fine ill put it all here

# -*- coding: cp1252 -*-

import os
from Tkinter import *
from time import *

inloged=False 
Time = 30

ended=False
first = True

#os.system("shutdown -s")


root = Tk(screenName=None, baseName=None, className='start screen', useTk=1)

userlabel = Label(root,text='username')
user = Entry(root)

passwordlab = Label(root,text='password')
password = Entry(root)

time = Label(root,text='shut-down in:' + str (Time),fg='red')


time.pack()
userlabel.pack()
user.pack()

passwordlab.pack()
password.pack()

while not inloged and not ended:   
    if root.mainloop():
        break
    sleep(1)
    print Time
    Time = Time - 1
    if Time == 0:
    #   os.system("shutdown -s")
        ended=True

print 'hello'


root.mainloop()

ok now the count and GUI works fine because aim using root.update() in the loop. but for some reason the label just wont update

ok now the count and GUI works fine because aim using root.update() in the loop. but for some reason the label just wont update

You would use a StringVar and update it with the new time or whatever. The following code is an example, where the entry box and the label widget both have access to the same StringVar, so when you change the value in the entry box, the label box is automatically updated.

import Tkinter

class EntryTest:
   def __init__(self):
      self.top = Tkinter.Tk()

      self.str_1 = Tkinter.StringVar()
      label_lit = Tkinter.StringVar()

      label_1 = Tkinter.Label(self.top, textvariable = label_lit )
      label_1.pack()
      label_lit.set( "Test of Label")
    
      label_2 = Tkinter.Label(self.top, textvariable = self.str_1 )
      label_2.pack()

      entry_1 = Tkinter.Entry(self.top, textvariable=self.str_1)
      entry_1.pack()
      self.str_1.set( "Entry Initial Value" )

      cont = Tkinter.Button(self.top, text='PRINT CONTENTS',
             command=self.getit, bg='blue', fg='white' )
      cont.pack(fill=Tkinter.X, expand=1)

      exit=  Tkinter.Button(self.top, text='EXIT',
             command=self.top.quit, bg='red', fg='white' )
      exit.pack(fill=Tkinter.X, expand=1)

      entry_1.focus_set()
      self.top.mainloop()

   ##-----------------------------------------------------------------
   def getit(self) :
      print "getit: variable passed is", self.str_1.get()

##===============================================================
if "__main__" == __name__  :
   ET=EntryTest()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.