[Tutor] py2exe and Tkinter

Bryce Embry bryce@bembry.org
Tue, 23 Apr 2002 12:31:47 -0500


I've got a small script I wrote in Tkinter.  I want to make the script an 
executable in Windows, which is not to hard to do with py2exe or 
installer.  What's driving me crazy is that whenever I run the executable, 
a big, ugly DOS window opens up behind the GUI.  Is there any way to get 
rid of this ugly box and have just my GUI showing?

Here's the script.  it works fine in Python, just need to get rid of that 
ugly DOS screen, if it's possible.  The script is just a random number 
generator for use in a business that has to randomly pick truck drivers to 
screen.:


# num_gen.py
from Tkinter import *
from random import randrange
root = Tk()
root.title("Phyllis's Random Numbers")
# row 1 ------------------------------------------
Label(root, text="How many numbers do you need?").grid(row=1, column=0)
num_of_nums = Entry(root, width = 5)
num_of_nums.grid(row=1, column = 1)

# row 2 ------------------------------------------
Label(root, text = "Largest number to choose: ").grid(row=2, column=0)
max_num = Entry(root, width=5)
max_num.grid(row=2, column =1)


# Define random number generator function
def num_generator():
     total = int(num_of_nums.get())
     maxnum = int(max_num.get())
     output = []
     for i in range(total):
         newnum = randrange(0, maxnum)
         if newnum not in output:
             output.append(newnum)
         else:
             pass
     output.sort()
     output_text = ""

     for item in output:
         output_text += str(item) + "\n"

     root2 = Toplevel(root)
     Message(root2, text = output_text).grid()

#row 3---------------------------------------------
Button(root, text= "Get Numbers", command = num_generator).grid(row=3, 
columnspan=2)

root.mainloop()

---------------------------------------------------------------------------------------------------
Thanks


Bryce Embry
Geek-Of-All-Trades / Master-Of-None

www.bembry.org
--------------------------------------------------------------------------------------------------------------------------------------------------------
Technology Coordinator for MHA/FYOS ^ 390 South White Station ^ Memphis, TN 
38117 ^ (901)682-2409
--------------------------------------------------------------------------------------------------------------------------------------------------------