So I'm trying to use my "controller" to call my "view." But if I don't use super, I get an infinite recursion when buildTK tries to build iiBar. Using Super everything is fine. I'd just like to understand why that is.
import inputhandler as iH
import buildtk as tA
import scanhandler as aS
class ControlHandler:
def __init__(self):
#self.view = tA.buildTK() #does not work
self.view = super(tA.buildTK) #works
self.smodel = aS.aScan()
self.imodel = iH.InputHandler()
The buildTK class:
import tkinter as tt
import controlhandler as cH
class buildTK(tt.Frame):
def __init__(self, master = None):
self.frame = tt.Frame(master, bg="tan")
self.frame.grid()
self.ibar = iiBar(self.frame)
...
class iiBar:
def __init__(self, master):
print(repr(self)) #prints forever
self.mbar = tt.Frame(master, relief = 'raised', bg="blue")
self.mbar.grid(column=0, row=0) #Show File Bar
self.tryFile()
self.tryTool()
self.tryH()
EDIT: those try methods have no effect when commented out, but the basic code is:
def tryTool(self):
# Create tools menu
self.toolsbutton = tt.Menubutton(self.mbar, text = 'Tools', )
self.toolsbutton.grid(row=0, column=2)
self.toolsmenu = tt.Menu(self.toolsbutton, tearoff=0)
self.toolsbutton['menu'] = self.toolsmenu
# Populate tools menu
self.toolsmenu.add('command', label = 'tools', command = root.destroy)
And out of curiosity, is there a best-practice for going about what I'm trying to do? Eventually I'd like a "build handler" to instantiate the form (either tkinter, html, xml) - in which case the controller would instantiate the build handler which would determine what to build.
Aucun commentaire:
Enregistrer un commentaire