I am using Ubuntu 18.04 with python 3.8.
This is the problem I have been experiencing since I have started using Tkinter.
Whenever I write the code, for some reason, the GUI gets stuck while loading. I speculate that this is because the program I intend to write involves lots of buttons (specifically 15x15=225). However, instead of loading slower or what not, the GUI window straight up refuses to show up.
The only 'pseudo-solution' which I found coincidentally, is pressing the ctrl key.
Why is this happening and why does pressing the ctrl key solve this problem?
Here is the code:
To run, install tkinter and type python3 controller.py
model.py
class Model:
def __init__(self):
'''
'''
controller.py
from model import Model
from view import View
class Controller:
def __init__(self):
self.model = Model()
self.view = View(self)
def main(self):
self.view.main()
if __name__ == '__main__':
scrabble = Controller()
scrabble.main()
view.py
import tkinter as tk
from tkinter import ttk
class View(tk.Tk):
PAD = 15
def __init__(self,controller):
super().__init__()
self.controller = controller
self.value_var = tk.StringVar()
self.title('Scrabble')
self._make_main_frame()
self._make_buttons()
def main(self):
self.mainloop()
##Private Methods
def _make_main_frame(self):
self.main_frm = ttk.Frame(self)
self.main_frm.pack(padx=self.PAD, pady=self.PAD)
def _make_buttons(self):
outer_frm= ttk.Frame(self.main_frm)
outer_frm.pack()
frm = ttk.Frame(outer_frm)
frm.pack()
btns_row = 0
for i in range(self.PAD*15):
if btns_row == self.PAD:
frm = ttk.Frame(outer_frm)
frm.pack()
btns_row = 0
btn = ttk.Button(frm, text=i)
btn.pack(side='left')
btns_row += 1