示例#1
0
文件: GUI.py 项目: Themishau/BSoup
    def __init__(self, parent, model, events, name):
        Publisher.__init__(self, events)
        Subscriber.__init__(self, name)

        #init viewer
        self.model = model
        self.sidePanel = InfoBottomPanel(parent)
        self.frame = tk.Frame(parent)
        self.frame.grid(sticky="NSEW")
        self.main = Main(parent)

        #init Observer
        self.model.register(
            'data_changed',
            self)  # Achtung, sich selbst angeben und nicht self.controller
        self.model.register('clear_data', self)

        # hidden and shown widgets
        self.hiddenwidgets = {}

        self.main.start_request.bind("<Button>", self.start_request)
        # self.main.create_model_button.bind("<Button>", self.create_model)
        # self.main.save_model_button.bind("<Button>", self.save_model)
        # self.main.load_model_button.bind("<Button>", self.load_model)
        self.main.quitButton.bind("<Button>", self.closeprogram)
示例#2
0
    def setUp(self):
        self.newsletters = ['Tech', 'Travel', 'Fashion']
        self.pub = Publisher(self.newsletters)
        subscribers = [('s0', 'Tom'), ('s1', 'Sara')]
        for sub, name in subscribers:
            setattr(self, sub, Subscriber(name))

        # before each test case, set some subscriptions
        self.pub.register('Tech', self.s0)
        self.pub.register('Travel', self.s0)
        self.pub.register('Travel', self.s1)
    def setUp(self):
        self.newsletters = ["Tech", "Travel", "Fashion"]
        self.pub = Publisher(self.newsletters)
        subscribers = [("s0", "Tom"), ("s1", "Sara")]
        for sub, name in subscribers:
            setattr(self, sub, Subscriber(name))

        # before each test case, set some subscriptions
        self.pub.register("Tech", self.s0)
        self.pub.register("Travel", self.s0)
        self.pub.register("Travel", self.s1)
示例#4
0
文件: GUI.py 项目: Themishau/ML_Tests
    def __init__(self, parent, model, events, name):
        Publisher.__init__(self, events)
        Subscriber.__init__(self, name)

        #init viewer
        self.model = model
        self.sidePanel = InfoBottomPanel(parent)
        self.frame = tk.Frame(parent)
        self.frame.grid(sticky="NSEW")
        self.main = Main(parent)

        # hidden and shown widgets
        self.hiddenwidgets = {}

        self.main.create_training_data_button.bind("<Button>",
                                                   self.prepare_training_data)
        self.main.normalize_model_button.bind("<Button>", self.normalize_model)
        self.main.train_model_button.bind("<Button>", self.train_model_routine)
        self.main.multiple_model_testing_button.bind(
            "<Button>", self.multiple_model_testing)
        self.main.start_prediction_button.bind("<Button>",
                                               self.start_prediction_routine)

        self.main.save_training_data_button.bind("<Button>",
                                                 self.save_model_training_data)
        self.main.save_normalized_model_button.bind("<Button>",
                                                    self.save_normalized_model)
        self.main.save_trained_model_button.bind("<Button>",
                                                 self.save_trained_model)

        self.main.load_training_data_button.bind("<Button>",
                                                 self.load_model_training_data)
        self.main.load_normalized_model_button.bind("<Button>",
                                                    self.load_normalized_model)
        self.main.load_trained_model_button.bind("<Button>",
                                                 self.load_trained_model)

        self.main.quitButton.bind("<Button>", self.closeprogram)
示例#5
0
    def __init__(self, parent, model, events, name):
        Publisher.__init__(self, events)
        Subscriber.__init__(self, name)

        #init viewer
        self.model = model
        self.plt = Figure(figsize=(4, 4), dpi=100)
        self.plt.add_subplot(111).plot([0,1, 2, 3, 4],[0,1,20,3,50])
        self.frame = tk.Frame(parent)
        self.frame.grid(sticky="NSEW")
        self.main = Main(parent)
        self.canvas = FigureCanvasTkAgg(self.plt, master=self.frame)
        self.canvas.get_tk_widget().grid(row = 3, column = 0, sticky = tk.N, pady = 2, columnspan = 4)
        self.canvas.draw()

        #init Observer
        self.model.register('data_changed', self) # Achtung, sich selbst angeben und nicht self.controller
        self.model.register('clear_data', self)

        # hidden and shown widgets
        self.hiddenwidgets = {}

        self.main.mainStartButton.bind("<Button>", self.start)
        self.main.quitButton.bind("<Button>", self.closeprogram)
 def test_register_subscriber(self):
     john = Subscriber("John")
     self.pub.register(newsletter="Tech", who=john)
     self.assertEqual(self.pub.subscriptions["Tech"][john], john.receive)
     self.pub.unregister(newsletter="Tech", who=john)  # cleanup
示例#7
0
 def test_register_subscriber(self):
     john = Subscriber('John')
     self.pub.register(newsletter='Tech', who=john)
     self.assertEqual(self.pub.subscriptions['Tech'][john], john.receive)
     self.pub.unregister(newsletter='Tech', who=john)  # cleanup
示例#8
0
from observer import Blog, Subscriber

blog = Blog(['anime', 'Japanese'])

lisa = Subscriber('Lisa')
bob = Subscriber('Bob')

blog.register('anime', lisa)
blog.register('Japanese', lisa)
blog.register('anime', bob)

blog.dispatch('Japanese', "New post: Teach yourself Japanese in 21 days")
blog.unregister('anime', lisa)
blog.dispatch('anime', "New episode of Black Clover aired.")
示例#9
0
 def test_subscriber_creation(self):
     sub = Subscriber("Bob")
     self.assertEqual(str(sub), "I'm Bob")
示例#10
0
 def test_publisher_creation(self):
     pub = Publisher()
     bob = Subscriber("Bob")
     pub.register(bob)
     self.assertEqual(pub.dispatch("First update from publisher"),
                      'Bob got message: "First update from publisher"\n')