0

I need to assign pythonform1.py empno entry to pythonform2.py entry. Please help, I am new to python.

Note: if I try to import pythonform1.py in pythonform2.py again the same form is opening. So please suggest any other way

pythonform1.py

import os,sys
from tkinter import *

def validateLogin():
    os.system('python pythonform2.py')
    return
root = Tk()   
root.title('Form1')
root.geometry('500x450') 

empnoEntry = Entry(root, textvariable=empno).grid(row=0, column=1)
loginButton = Button(root, text="Login", command=validateLogin).grid(row=3, column=0, columnspan=2) 

root.mainloop()

pythonform2.py

from tkinter import *

root = Tk()   
root.title('Form2')
root.geometry('500x450') 

empno1Entry = Entry(root, textvariable=empno1).grid(row=0, column=1)

root.mainloop()
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
Desa
  • 1
  • 2
    With a `tkinter` app you have to decide where your call to `root.mainloop()` should be located. You can only have one. – quamrana Apr 19 '21 at 10:21
  • @quamrana No. I think OP wants 2 windows. – TheLizzard Apr 19 '21 at 11:09
  • You can use `import` instead of `os.system`. – TheLizzard Apr 19 '21 at 11:12
  • @TheLizzard: That may be so, but you still won't be able to run `root.mainloop()` more than once. If you import a module which has it in, the program will get stuck at the `import ...` – quamrana Apr 19 '21 at 11:13
  • @quamrana So the second file needs to be changed so that it uses `tk.Toplevel` and put everything in a function that can be called after `import .` – TheLizzard Apr 19 '21 at 11:16
  • @quamrana Btw look at [this](https://stackoverflow.com/questions/67007447/new-root-mainloop-doesnt-make-main-window-unresponsive). The `new_root.mainloop()` doesn't make `root` unresponsive. Therefore, you can have multiple `.mainloop()`s without any of the windows becoming unresponsive. Given some special conditions. – TheLizzard Apr 19 '21 at 11:21
  • It may be responsive (I didn't say it wasn't), but as the OP in that question points out, it doesn't print `Done`. – quamrana Apr 19 '21 at 11:27

0 Answers0