Stack Overflow Asked by Daniel Ward on December 25, 2021
The is going to work like this:
Launcher with buttons to run different functions on other scripts. However when I try launching the "New Account" a new window pops up as it should but the entry field prints blank.
Launcher:
import Setup as s
import Stock as t
from tkinter import *
import os
root = Tk()
root.title("SWM Launcher")
welcome = Label(root, text = "Welcome to the Stock and Wastage Manager Launcher")
welcome.grid(row = 0, column =1, columnspan =3)
l1 = Label (root, text = "Please choose from the options below")
l1.grid(row = 1, column =1, columnspan =3)
submit = Button(root, text = "Open Account", command = lambda: program())
submit.grid(row = 3, column =1)
submit = Button(root, text = "New Account", command = lambda: s.setep())
submit.grid(row = 3, column =2)
What I’m trying to get to work from the setup script
class App:
def __init__(self, window):
window.title("SWM Account Maker")
window.config(bg = "grey")
window.geometry("800x900")
self.searched = StringVar()
name = Entry(window, width = 50, borderwidth = 5,textvariable=self.searched).grid(row = 2, column =1, columnspan =3)
submit = Button(window, text = "Submit", command = lambda: self.name()).grid(row = 3, column =2)
def name (self):
works = self.searched.get()
print(works)
def setep():
root = Tk()
app = App(root)
root.mainloop()
The output i get from the print statement is blank yet if I run setup separately it works fine.I feel like I have miss understood something and no solution’s I have found online work. also its my first project working with classes and Tkinter.
It is because you have used multiple instances of Tk(). Either change Tk() to Toplevel() inside setep() function or change self.searched = StringVar() to self.searched = StringVar(window) inside App.init()
Answered by Daniel Ward on December 25, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP