I am new to Python and ran into a problem when methods in a class Guialways execute twice.
Here is the gui class that inherits from Tkinter:
from Tkinter import *
class Gui (Tk):
def createKdWindow(self):
print("createKdWindow has been triggered")
def activate(self):
print ("activate has been triggered")
self.tk.mainloop()
and here the method from ( init .py) is called :
from pm_test.gui import Gui
datgui = Gui()
datgui.createKdWindow()
datgui.activate()
When I run my program, I get the following console output:
createKdWindow has been triggered
activate has been triggered
createKdWindow has been triggered
activate has been triggered
So, my methods were executed twice. I do not know where this is from. Does anyone know how to solve this?
Fixed
Entering code from init .py into a new module fixed this problem!
source
share