There are two files, A.py and B.py.
First, start A and put the value in the input box ⇒
When the button below is pressed, the window set in B will be launched ⇒
Create input box in window B ⇒
I want to display the value entered in the A input box inside the B input box
. How can I write it?
What should I do because the B side input box is not displayed and there is no error? .
If i know, can you professor?
from tkinter import * from tkinter import ttk import B def execute_py1 (): B.sub_window () root = Tk () root.geometry ("80x80 + 10 + 10") entry1 = ttk.Entry (width = 10) entry1.pack (fill = 'x', padx = 5, pady = 5) button1 = ttk.Button (root, text = 'button', padding = 3, command = execute_py1) button1.pack (fill = 'x', padx = 5, pady = 5) root.mainloop ()
from tkinter import * from tkinter import ttk def sub_window (): sub_window1 = Toplevel () sub_window1.geometry ("100x100 + 160 + 10") entry1 = ttk.Entry (width = 10) entry1.pack (fill = 'x', padx = 5, pady = 5)
Answer # 1
A relatively simple implementation
from tkinter import * from tkinter import ttk def sub_window (value = None): sub_window1 = Toplevel () sub_window1.geometry ("100x100 + 160 + 10") entry1 = ttk.Entry (sub_window1, width = 10) if value is not None: entry1.insert (0, value) entry1.pack (fill = 'x', padx = 5, pady = 5)
If you pass an argument (
value) to the
sub_window ()function like this, modify it so that it is displayed on
When calling this function inA.py
def execute_py1 (): B.sub_window (entry1.get ())
I think that it is good to remodel so that the contents of Entry are passed as parameters.
Answer # 2
(deleted due to duplication)
Answer # 3
B.sub_window (value)It needs to be modified to pass a value as an argument as in
I need root too.
Answer # 4
from tkinter import * from tkinter import ttk import tkinter as tk import B class Main_Proc: def execute_B (self): self.newWindow = Tk () parm = self.entry1.get () self.app = B.Sub_Proc (self.newWindow, parm) def __init __ (self, master): self.master = master self.master.geometry ("80x80 + 10 + 10") self.frame = tk.Frame (self.master) self.entry1 = ttk.Entry (width = 10) self.entry1.pack (fill = 'x', padx = 5, pady = 5) self.button1 = ttk.Button (self.frame, text = 'button', padding = 3, command = self.execute_B) self.button1.pack (fill = 'x', padx = 5, pady = 5) self.frame.pack () def main (): root = tk.Tk () app = Main_Proc (root) root.mainloop () if __name__ == '__main__': main ()
from tkinter import * from tkinter import ttk import tkinter as tk class Sub_Proc (): def __init __ (self, master, parm): master.geometry ("100x100 + 160 + 10") self.entry1 = ttk.Entry (master, width = 10) self.entry1.pack (fill = 'x', padx = 5, pady = 5) self.entry1.delete (0, tk.END) self.entry1.insert (tk.END, parm)
- python 3x - unintended behavior of python3 tkinter binding
- python 3x - python3 tkinter treeview data update
- python 3x - python3 tkinter no response when closing window
- python - about getting the pixel value of rotated video
- python 3x - change font size for python3 tkinter entry
- python 3x - python3 tkinter toplevel behaves differently than intended
- python3 tkinter i want to be able to input only character strings in a fixed format
- python 3x - i want to extract data from a python3 tkinter list
- python - absolute value behavior of complex numbers in numpy
- python 3x - tkinter i want to write code concisely
- python - reopening the file dialog in tkinter results in an error
- i want to dynamically change the value of a variable in python and execute it
- [python] [tkinter] i want to change the acquisition contents of the second and subsequent menu lists by selecting the previous p
- python - tkinter photo image question
- python - how to output the key and value in the dictionary in any form
- python - [tkinter] [py installer] unable to execute exe file
- i want to set the maximum value of the slider in python to the number entered in the text box
- i want to output the entry result of tkinter with python
- python 3x - how to get the value of scrolledtext
- [python3] inventory management system login and logout do not work
- about image display of python
- python 3x - i want to write data to a python3 tkinter database and then output it as csv
- python 3x - python3 tkinter thread becomes unresponsive
- python - i want to use a wacom tablet with tkinter
- python - i want to display a graph of matplotlib on tkinter and enable mouse operation in canvas
- python 3x - is it possible to set multiple python3 tkinter themes? impossible?
- [python3] i want to enter the contents (name) of the qr code using a barcode reader
- python 3x - python i want to display only files with the specified extension
- python quit for an unexpected reason workaround
- matplotlib - embedding in python tkinter doesn't work and update fails