Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Window Not Appearing
#1
For some reason, everything on this works except for MainWindow(). It adds the person to the tempfile, but the MainWindow never pops up. I get no errors, it just won't show me the window :/

[inline]
from Tkinter import *
import os
import Tkinter as ttk
from ttk import *

creds = 'tempfile.temp'

def NewPerson():
global nameE
global shoeSizeE
global roots

roots = Tk()
roots.title('New Person')
intruction = Label(roots, text='Enter Information Below\n')
intruction.grid(row=0, column=0, sticky=E)

nameL = Label(roots, text='Name: ')
shoeSizeL = Label(roots, text='Shoe Size: ')
nameL.grid(row=1, column=0, sticky=W)
shoeSizeL.grid(row=2, column=0, sticky=W)

nameE = Entry(roots)
shoeSizeE = Entry(roots)
nameE.grid(row=1, column=1)
shoeSizeE.grid(row=2, column=1)

signupButton = Button(roots, text='Create', command=StorePerson)
signupButton.grid(columnspan=2, sticky=W)
roots.mainloop()

def StorePerson():
with open(creds, 'w') as f:
f.write(nameE.get())
f.write('\n')
f.write(shoeSizeE.get())
f.close()

roots.destroy()
MainWindow()

def MainWindow():

root = Tk()
root.title("AWD ShoeBot")

with open(creds) as f:
data = f.readlines()
name = data[0].rstrip()

mainframe = Frame(root)
mainframe.grid(column=0,row=0, sticky=(N,W,E,S) )
mainframe.columnconfigure(0, weight = 1)
mainframe.rowconfigure(0, weight = 1)
mainframe.pack(pady = 100, padx = 100)

tkvar = StringVar(root)

choices = { name }
tkvar.set(name)

popupMenu = OptionMenu(mainframe, tkvar, *choices)
Label(mainframe, text="Choose a Person").grid(row = 1, column = 1)
popupMenu.grid(row = 2, column =1)

def change_dropdown(*args):
print( tkvar.get() )

tkvar.trace('w', change_dropdown)

signupButton = Button(root, text='Create New Person', command=NewPerson)
signupButton.grid(columnspan=2, sticky=W)

root.mainloop()

if os.path.isfile(creds):
MainWindow()
else:
NewPerson()
[/inline]
Reply


Messages In This Thread
Window Not Appearing - by MGallo - Sep-18-2017, 10:30 AM
RE: Window Not Appearing - by Lux - Sep-18-2017, 07:24 PM
RE: Window Not Appearing - by MGallo - Sep-18-2017, 10:05 PM
RE: Window Not Appearing - by Larz60+ - Sep-18-2017, 10:32 PM
RE: Window Not Appearing - by MGallo - Sep-18-2017, 10:40 PM
RE: Window Not Appearing - by Larz60+ - Sep-18-2017, 11:29 PM
RE: Window Not Appearing - by MGallo - Sep-19-2017, 02:11 AM
RE: Window Not Appearing - by Larz60+ - Sep-19-2017, 02:44 AM
RE: Window Not Appearing - by Larz60+ - Sep-19-2017, 07:49 PM
RE: Window Not Appearing - by Larz60+ - Sep-20-2017, 09:08 PM
RE: Window Not Appearing - by MGallo - Sep-20-2017, 11:21 PM
RE: Window Not Appearing - by Larz60+ - Sep-22-2017, 07:18 AM
RE: Window Not Appearing - by Larz60+ - Sep-26-2017, 07:52 PM
RE: Window Not Appearing - by Larz60+ - Sep-28-2017, 08:46 AM
RE: Window Not Appearing - by Larz60+ - Sep-30-2017, 07:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a way to call and focus any popup window outside of the main window app? Valjean 6 1,978 Oct-02-2023, 04:11 PM
Last Post: deanhystad
  Graph is not appearing in correct frame? garynewport 2 1,129 Jan-11-2023, 11:55 AM
Last Post: garynewport
  Pyspark Window: perform sum over a window with specific conditions Shena76 0 1,219 Jun-13-2022, 08:59 AM
Last Post: Shena76
  Grid Line not appearing at 0 JoeDainton123 1 1,706 Oct-05-2020, 06:41 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020