G'day,
I've been working with Pyhton for about six months and have been wanting to put a program into a seperate Tkinter GUI but have had no luck.
I need to have a Tk GUI that has vertical scrolling exactly like the normal IDE except that positioned in the upper right corner will sit a tiny calculator.
This tiny calculator does not need to have the "x" or the "+" or the "-" etc or any of the other signs at all.
The reason is because the program is a simple high\low game and only needs to have the numbers from 0 to 9. The only other functions the calculator needs is the backspace (in case of mistakes) and an entry button to enter the number onto the left hand side of the page. Also a quit button to finish.
I have XP on my Compaq Evo desktop.
The program works fine except that when I try to put it into a different GUI all sorts of problems occur. Is this because I need to use pyw instead of py? Or do I just import it as is into the new GUI? I realize that "run==exit" will have to be replaced by quit or suchlike.
Thanks for any help (this is my first time on any forum).
import random
number = random.randint(1, 10000)
running = True
run=""
attempts=0
while running:
guess = int(raw_input('Enter an integer : '))
print
attempts = attempts + 1
WORDS=("Get it before ten tries or the world will explode!",\
"The next one is the 70th try, hurry!", "400 guesses later...",\
"A guess a day keeps the doctor away!", "Count to ten , backwards",\
"Wake me up when you're finished.", "Better luck next time.",\
"It's getting late, hurry up!", "One more and we're finished...",\
"I'm running out of things to say.", "So close, yet so far!",\
"Nearly got it, maybe it's the next guess.")
if attempts==attempts >0:
print random.choice(WORDS)
print "----------------------------------------------------------------------"
print " "
if attempts == attempts > 13:
guess == number
import winsound
import time
time.sleep(1.5)
winsound.PlaySound("SystemExit", winsound.SND_ALIAS)
print " "
print "(The number was %i)" % (number)
print " "
print "***********************"
print "BETTER LUCK NEXT TIME."
print "***********************"
print " "
attempts=0
run = raw_input("\n'run' again or 'exit' ")
if run == "exit":
break
if guess == number:
print " "
print "********************************************"
print 'CONGRATULATIONS, YOU GUESSED IT IN %i TRIES!' % (attempts)
print "********************************************"
attempts=0
run = raw_input("\n'run' again or 'exit' ")
if run == "exit":
break
elif run == "run":
number = random.randint(1, 10000)
random.choice(WORDS)
continue
elif guess < number:
print 'NO, HIGHER THAN %d. (Turn No.%i of 13)' % (guess, attempts)
else:
print 'NO, LOWER THAN %d. (Turn No.%i of 13)' % (guess, attempts)