Mar-08-2020, 12:35 PM
Short update from my side.
Since I didnt thought that there were any mistakes while calling the other class, I rebuilded simply everything, with some basics functions like the login , webscraper and so on.
Everythig seems to work now.
I didnt changed too much. Actually Nearly nothing.
Here is a snippet of the working code, for documentation if anyone has a similar issue.
gui.py
Anyways thanks for reading
Since I didnt thought that there were any mistakes while calling the other class, I rebuilded simply everything, with some basics functions like the login , webscraper and so on.
Everythig seems to work now.
I didnt changed too much. Actually Nearly nothing.
Here is a snippet of the working code, for documentation if anyone has a similar issue.
gui.py
from tkinter import * from tkinter import ttk from app import ThisIsATest from api import app class Window(Tk): def __init__(self): super(Window, self).__init__() self.title("Tkinter OOP Window") self.geometry('500x400') self.button = ttk.Button(text = "Click", command=self.clickMe) self.button.grid(column=0, row=0) def clickMe(self): # call of the class api = app() window = Window() window.mainloop()api.py
class app(): def __init__(self): self.session = requests.Session() self.config = {} self.loggedIn = False self.testMethod() def testMethod(self): print('Run test Meethod') self.getJsonFileContent('config') print(self.config['username']) # METHODS ================================================================== # ================= getJsonFileContent() ================= def getJsonFileContent(self, param): # read in config file print(param) if(param == 'config'): try: with open('config.json', 'r') as configFile: self.config=json.load(configFile) configFile.close() logger.info(" READ config File ") except: logger.warning("Could not read in config file") # elif not need right now cookies saved in self.cookies ! elif (param == 'cookies'): try: pass # r+ for read and write ! except: logger.warning("Could not read in cookies file") # ================= END OF getJsonFileContent() =================
Output:Run test Meethod
config
player1
Well kinda strange, but as long as its working, its fine for me ^^Anyways thanks for reading