[Tutor] Python tkinter. Opening another script from main window stop main window from functioning. Looking for Help
Spencer For Friends
smarugg at gmail.com
Sun Apr 26 05:23:44 CEST 2015
Hi all. I'm new to Python and I'm trying my best to learn, but I'm really
struggling with some problems.
I'm using a tkinter window with a button on it to open another Python
script. When the button is clicked and the new script loads it opens up
it's own window over top of my tkinter window. The problem is, when I
switch back to my tkinter window, none of the buttons are click-able
anymore. The whole windows is unresponsive. The click animation on the
button doesn't even function. Any help to resolve this would be greatly
appreciated. Here is my code.
from Tkinter import *
from PIL import ImageTk, Image
import os
from magicassistantcsv import MagicAssistantCSV
CSV_FILE = "data/inventory.csv"
csv = MagicAssistantCSV(CSV_FILE, append=True)
root = Tk()
#Add POP Logo Image To Screen
POPimg = ImageTk.PhotoImage(Image.open("images/poplogo.png"))
panel = Label(root, image = POPimg)
panel.grid(row=0, column =0, sticky=W)
#Add Magic Logo Image
mtgimg = ImageTk.PhotoImage(Image.open("images/mtgcardbot.png"))
panel = Label(root, image = mtgimg)
panel.grid(row=1, column =0, sticky=W, padx=300, pady=180)
#Make Window Full Screen
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
root.overrideredirect(1)
root.geometry("%dx%d+0+0" % (w, h))
#Add Execute Functionality To Button
def callback():
execfile("test.py")
def endTrade():
csv.close()
button1 = Button(text = 'Scan Your Card!', font=('Arial', '20'), fg =
'red', command = callback)
button2 = Button(text = 'Scan Complete', font=('Arial', '20'), fg = 'red',
command = endTrade)
#Configure Button Sizes
button1.config( height = 3, width = 25 )
button2.config( height = 3, width = 25 )
#Display Buttons On Screen
button1.grid(row=1, column=0, sticky = S, padx=616)
button2.grid(row=2, column=0)
root.mainloop()
Kind Regards
-Spencer
More information about the Tutor
mailing list