Exemplo n.º 1
0
        self.add_widget("no", btn)
        self.configure_grid(btn, row=1, column=0)
        bty = view.ttk.Button(parent, text="Yes", command=self.yes)
        self.add_widget("yes", bty)
        self.configure_grid(bty, row=1, column=2)

    def no(self):
        self._response = False
        self.close()

    def yes(self):
        self._response = True
        self.close()


class AlertController(controller.ViewController):

    VIEW_CLASS = Alert

    def _start(self):
        return self.view.show()

    @property
    def response(self):
        return self.view.response

if __name__ == "__main__":

    app = AttentionApp()
    app.run()
Exemplo n.º 2
0
        response = view.tk.StringVar(self)
        self.add_variable("response", response)
        lbr = view.ttk.Label(self, textvariable=response)
        self.add_widget("response", lbr)
        self.configure_grid(lbr, row=1, column=1)

    def ask_question(self):
        self.controller.ask_question()

    @property
    def response(self):
        return self.get_variable("response").get()

    @response.setter
    def response(self, value):
        self.get_variable("response").set(value)


class MainController(controller.ViewController):

    VIEW_CLASS = MainView

    def ask_question(self):
        self.view.response = QuestionBox.ask(self.view, "What is your name?")


if __name__ == "__main__":

    app = QuestionApp()
    app.run()