I don't understand why you can't use this. Also, you probably only want root access for the script, otherwise anyone can shut down your system. If you want to run it from a non-root user, then you or the program will also have to be able to supply the correct password, which also is a bad idea.
this is working if am going through terminal but here am using a gui so after running the script its not promting for password and its not getting shutdown
msgbox("You chose to Shutdown")
msg = "Do you want to schedule your Shutdown"
title = "Confirmation"
t=integerbox('Enter the time in minutes :')
#os.system('sudo shutdown -h now')
commands.getoutput('sudo shutdown -r now')
os.system('sudo shutdown -h now')
But dbus is a can of worms and constantly changing giving us in linux all the joys of the Windows registry. So in ubuntu 10.10 hal has disappeared and UPower has appeared at least in the default installation. I can no longer shutdown but with UPower I can Hibernate or Suspend. The following works in Ubuntu 10.10 for me (of course some hardware setups have problems with hibernate).