-1

Hello everyone how can insert in gui text function result of another module. you can see code below:

modul_1.py

import tkinter as tk
from tkinter import *
import modul_2 

window = tk.Tk()
b = Button(text="çalıştır", command = modul_2.goster)
b.place(x=20, y=20)
window.mainloop()

modul_2.py

import tkinter as tk
from tkinter import messagebox
import modul_1

def goster():
    messagebox.showinfo("deneme","deneme")
    Text1 = tk.Text(window)
    Text1.insert(tk.END, "Bu kısım")
    Text1.place(x=50, y=50)
goster()
Matiiss
  • 5,970
  • 2
  • 12
  • 29
mesyen
  • 91
  • 1
  • 8
  • The function **goster** is already doing what you've described - inserting a string into the Text-widget. I do not understand what the problem is. – Bialomazur Sep 09 '21 at 18:34
  • b = Button(text="çalıştır", command = modul_2.goster) AttributeError: partially initialized module 'modul_2' has no attribute 'goster' (most likely due to a circular import) here is the problem – mesyen Sep 09 '21 at 18:35
  • 2
    **Please** - in the future include your **entire code ** and **error message(s)**. Otherwise we simply cannot help you. Instead of commenting it as a response, edit your question and insert it there. – Bialomazur Sep 09 '21 at 18:36
  • go learn about packages and learn about imports and **don't use `*` when importing** – Matiiss Sep 09 '21 at 18:39
  • sorry ı forgot to add eror message. what is the meaning of eror message? – mesyen Sep 09 '21 at 18:39
  • also btw you're doing a **circular import** - modules can and should not import one-another! – Bialomazur Sep 09 '21 at 18:43
  • @Matiiss Guess it's a bad habit to use those terms interchangeably - thanks for correcting me. – Bialomazur Sep 09 '21 at 18:45
  • Could you type correct code ı dont know how to write hence ı typed circular import – mesyen Sep 09 '21 at 18:45
  • Does this answer your question? [Circular (or cyclic) imports in Python](https://stackoverflow.com/questions/744373/circular-or-cyclic-imports-in-python) – Matiiss Sep 09 '21 at 18:48
  • No doesnt I am junior developer – mesyen Sep 09 '21 at 18:54
  • @mesyen then you need to take a look at tutorials or read documentation, there are plenty of resources on this issue, you just have to find them – Matiiss Sep 09 '21 at 18:56
  • Beginner tip: Avoid using multiple file that spans two different windows. Instead do everything inside a single file – Delrius Euphoria Sep 09 '21 at 20:21

1 Answers1

0

The better way is to stock the data from the module you want then import it in the desired module .

Ayyoub ESSADEQ
  • 776
  • 2
  • 14