D
D
Dmitry Ivanov2020-06-16 21:34:39
Python
Dmitry Ivanov, 2020-06-16 21:34:39

How to open a python file through another?

It is necessary to open another py file (in the form of a messagebox) by pressing a button. However, when this file is imported, the elements (Combobox, Button) are reflected on the first root, and then the root from the called file is opened on top of everything.

def close(): #функция вызывающая импорт другого py файла
    import PSV_4  #он вызывает новый root, но элементы отражаются на старом

spoiler
5ee912e260285154832126.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Ivanov, 2020-06-16
@Dmitronid

I figured it out myself ... in general, the idea is rather stupid: when declaring an element in the called file, you must specify its belonging to root in the form: (root, ...)

enter_button=ttk.Button(root, text="Вывод", command = final)

giver=ttk.Combobox(root, font=("Verdana", 12),
                                values=[
                                        complete],
                                 state="readonly",
                                 postcommand=changeMonth)

otherwise, python assumes that the given elements are relative to the original root

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question