My problem is that i have an Main-Class with an button-click function, where if i click the button, the EntryBox will be opened and in the button-click function i want to create the folder too, but i dont know how to "stop" the mainWindow while the EntryBox-Window is open to get the value(Folder name).
@BryanOakley Minimal, Complete, and Verifiable example:
That's my msBox.py
import tkinter as tk
FolderName = ""
class EntryBox:
def __init__(self, Text):
self.root = tk.Tk()
self.textBox = tk.Entry(self.root)
self.EBOKAY = tk.Button(self.root, text="Okay")
self.EBOKAY.bind("<Button-1>", self.EBOKAY_click)
self.EBLabel = tk.Label(self.root, text=Text)
self.EBLabel.pack()
self.textBox.pack()
self.EBOKAY.pack()
self.root.mainloop()
def EBOKAY_click(self, event):
global FolderName
FolderName = self.textBox.get()
self.root.destroy()
Here is my next file gui.py:
import tkinter as tk
import os
import msBox
# variables
path = "/"
class GUI:
def __init__(self, master):
self.button1 = tk.Button(master, text="Set")
self.button1.bind('<Button-1>', self.button1_click)
self.button1.pack()
def button1_click(self, event):
test = msBox.EntryBox("New folder name:")
# Here is need a wait-Statement or anything else
os.mkdir(path + msBox.FolderName)
Here is my main.py:
import tkinter as tk
import gui
def main():
root = tk.Tk()
design = gui.GUI(root)
root.mainloop()
if __name__ == '__main__':
main()