Example #1
0
    def _2021_10_31c_startup(self):
        self.main_window = toga.MainWindow(title=self.name, size=(250, 250))
        self.canvas = toga.Canvas(style=Pack(flex=1))
        self.main_window.content = toga.Box(children=[self.canvas])

        self.canvas.rotate(math.pi * 0.2)
        with self.canvas.stroke(line_width=4.0, color=rgb(255, 200, 200), line_dash=[4, 4]) as stroke:
            stroke.rect(40, 50, 30, 40)
        self.canvas.reset_transform()

        with self.canvas.stroke(line_width=4.0, color=rgb(50, 255, 75), line_dash=[4, 4]) as stroke:
            stroke.rect(40, 50, 30, 40)

        self.canvas.scale(1.5, 2)
        self.canvas.rotate(-math.pi * 0.2)
        self.canvas.translate(10, 50)
        with self.canvas.stroke(line_width=4.0, color=rgb(50, 75, 255), line_dash=[4, 4]) as stroke:
            stroke.rect(40, 50, 30, 40)
        self.canvas.reset_transform()

        with self.canvas.stroke(line_width=4.0, color=rgb(3, 200, 80), line_dash=[4, 4]) as stroke:
            stroke.rect(140, 150, 30, 40)


        # Show the main window
        self.main_window.show()
Example #2
0
    def _2021_10_31d_startup(self):
        self.main_window = toga.MainWindow(title=self.name, size=(250, 250))
        self.canvas = toga.Canvas(style=Pack(flex=1))
        self.main_window.content = toga.Box(children=[self.canvas])

        rx = 30
        ry = 10

        # Semicircle
        with self.canvas.stroke(
            color=rgb(50, 75, 255),
            line_width=4.0,
            line_dash=[4, 4]
        ) as context:
            with context.closed_path(100 + rx, 50) as closer:
                closer.ellipse(100, 50, rx, ry, 0, 0, math.pi)

        with self.canvas.stroke(line_width=4.0, color=rgb(50, 255, 75), line_dash=[4, 4]) as stroke:
            stroke.rect(40, 20, 30, 20)

        with self.canvas.stroke(line_width=4.0, color=rgb(255, 150, 150), line_dash=[4, 4]) as stroke:
            stroke.rect(120, 25, 25, 20)

        # Show the main window
        self.main_window.show()
Example #3
0
    def _2021_10_12_startup(self):
        # Build a right triangle by drawing two line segments, and closing the path
        # Main window of the application with title and size
        self.main_window = toga.MainWindow(title=self.name, size=(250, 250))

        # Create canvas
        self.canvas = toga.Canvas(style=Pack(flex=1))
        box = toga.Box(children=[self.canvas])

        # Add the content on the main window
        self.main_window.content = box

        # Draw
        with self.canvas.stroke(line_width=4.0, color=rgb(255, 200, 200), line_dash=[4, 4]) as stroke:
            with stroke.closed_path(10, 10) as closed_stroke:
                closed_stroke.line_to(10, 100)
                closed_stroke.line_to(100, 10)

        with self.canvas.stroke(line_width=4.0, color=rgb(0, 0, 255), line_dash=[4, 4]) as stroke:
            with stroke.closed_path(110, 110) as closed_stroke:
                closed_stroke.line_to(110, 200)
                closed_stroke.line_to(200, 110)

        # Show the main window
        self.main_window.show()
Example #4
0
    def _2021_10_31e_startup(self):
        # Expected: 2 semi-circles, rotated at 90 degrees from each other,
        # also offset 10px from each other.
        self.main_window = toga.MainWindow(title=self.name, size=(250, 250))
        self.canvas = toga.Canvas(style=Pack(flex=1))
        self.main_window.content = toga.Box(children=[self.canvas])

        rx = 30
        ry = 10

        # Semicircle
        with self.canvas.stroke(
            color=rgb(50, 75, 255),
            line_width=4.0,
            line_dash=[4, 4]
        ) as context:
            with context.closed_path(100 + rx, 50) as closer:
                closer.ellipse(100, 50, rx, ry, 0, 0, math.pi)

        with self.canvas.stroke(
            color=rgb(50, 255, 75),
            line_width=4.0,
            line_dash=[4, 4]
        ) as context:
            with context.closed_path(110 + rx, 60) as closer:
                closer.ellipse(110, 60, rx, ry, math.pi * 0.5, 0, math.pi)

        # Show the main window
        self.main_window.show()
Example #5
0
    def _2021_10_18_startup(self):
        # Build a right triangle by drawing two line segments, and closing the path
        # Main window of the application with title and size
        self.main_window = toga.MainWindow(title=self.name, size=(250, 250))

        # Create canvas; put it in a box on the main window
        self.canvas = toga.Canvas(style=Pack(flex=1))
        self.main_window.content = toga.Box(children=[self.canvas])

        # Draw
        with self.canvas.stroke(line_width=4.0, color=rgb(255, 200, 200), line_dash=[4, 4]) as stroke:
            stroke.arc(40, 100, 10)

        with self.canvas.stroke(line_width=4.0, color=rgb(255, 200, 200), line_dash=[4, 4]) as stroke:
            stroke.arc(35, 80, 10, startangle=math.pi, endangle=(2 * math.pi))

        with self.canvas.stroke(line_width=4.0, color=rgb(255, 200, 200), line_dash=[4, 4]) as stroke:
            stroke.arc(180, 100, 10)

        with self.canvas.stroke(line_width=4.0, color=rgb(0, 0, 255), line_dash=[4, 4]) as stroke:
            stroke.arc(110, 150, 50, endangle=math.pi)

        with self.canvas.stroke(line_width=4.0, color=rgb(0, 0, 255), line_dash=[4, 4]) as stroke:
            stroke.arc(80, 140, 50, endangle=math.pi * 1.5, anticlockwise=True)


        # Show the main window
        self.main_window.show()
Example #6
0
 def test_set_background_color(self):
     color = '#ffffff'
     root = TestNode(
         'app', style=Pack(background_color=color)
     )
     root.style.reapply()
     root._impl.set_background_color.assert_called_once_with(rgb(255, 255, 255))
Example #7
0
def color_ramp(base_color, ang_cos):
    edge_percent = 0.8
    if ang_cos > 0:
        factor = (1 - ang_cos) * edge_percent + (1. - edge_percent)
        return rgb(
            r=int(base_color.r * factor),
            g=int(base_color.g * factor),
            b=int(base_color.b * factor),
        )
    else:
        factor = (1 + ang_cos) * edge_percent + (1. - edge_percent)
        return rgb(
            r=int(base_color.r * factor + 255 * (1-factor)),
            g=int(base_color.g * factor + 255 * (1-factor)),
            b=int(base_color.b * factor + 255 * (1-factor)),
        )
Example #8
0
    def _2021_10_26_startup(self):
        self.main_window = toga.MainWindow(title=self.name, size=(250, 250))
        self.canvas = toga.Canvas(style=Pack(flex=1))
        self.main_window.content = toga.Box(children=[self.canvas])

        with self.canvas.stroke(line_width=4.0, color=rgb(255, 200, 200), line_dash=[4, 4]) as stroke:
            stroke.rect(40, 50, 30, 40)
        with self.canvas.stroke(line_width=4.0, color=rgb(100, 255, 100), line_dash=[4, 4]) as stroke:
            stroke.rect(140, 50, 30, 40)
        with self.canvas.stroke(line_width=4.0, color=rgb(0, 0, 255), line_dash=[4, 4]) as stroke:
            # Use a closed stroke; however, it seems to have no impact on macOS at least
            with stroke.closed_path(50, 100) as closed_stroke:
                closed_stroke.rect(50, 150, 100, 20)

        # Show the main window
        self.main_window.show()
 def fill_head(self):
     with self.canvas.fill(color=rgb(149, 119, 73)) as head_filler:
         head_filler.move_to(112, 103)
         head_filler.line_to(112, 113)
         head_filler.ellipse(73, 114, 39, 47, 0, 0, math.pi)
         head_filler.line_to(35, 84)
         head_filler.arc(65, 84, 30, math.pi, 3 * math.pi / 2)
         head_filler.arc(82, 84, 30, 3 * math.pi / 2, 2 * math.pi)
Example #10
0
File: app.py Project: pybee/toga
 def fill_head(self):
     with self.canvas.fill(color=rgb(149, 119, 73)) as head_filler:
         head_filler.move_to(112, 103)
         head_filler.line_to(112, 113)
         head_filler.ellipse(73, 114, 39, 47, 0, 0, math.pi)
         head_filler.line_to(35, 84)
         head_filler.arc(65, 84, 30, math.pi, 3 * math.pi / 2)
         head_filler.arc(82, 84, 30, 3 * math.pi / 2, 2 * math.pi)
Example #11
0
File: app.py Project: pybee/toga
 def draw_text(self):
     x = 32
     y = 185
     font = toga.Font(family=SANS_SERIF, size=20)
     width, height = font.measure('Tiberius', tight=True)
     with self.canvas.stroke(line_width=4.0) as rect_stroker:
         rect_stroker.rect(x - 2, y - height + 2, width, height + 2)
     with self.canvas.fill(color=rgb(149, 119, 73)) as text_filler:
         text_filler.write_text('Tiberius', x, y, font)
 def draw_text(self):
     x = 32
     y = 185
     font = toga.Font(family=SANS_SERIF, size=20)
     width, height = self.canvas.measure_text('Tiberius', font, tight=True)
     with self.canvas.stroke(line_width=4.0) as rect_stroker:
         rect_stroker.rect(x - 2, y - height + 2, width, height + 2)
     with self.canvas.fill(color=rgb(149, 119, 73)) as text_filler:
         text_filler.write_text('Tiberius', x, y, font)
Example #13
0
    def _2021_10_31b_startup(self):
        self.main_window = toga.MainWindow(title=self.name, size=(250, 250))
        self.canvas = toga.Canvas(style=Pack(flex=1))
        self.main_window.content = toga.Box(children=[self.canvas])

        with self.canvas.fill(color=rgb(255, 200, 200)) as fill:
            fill.move_to(112, 103)
            fill.bezier_curve_to(100, 84, 85, 90, 65, 84)

        with self.canvas.fill(color=rgb(100, 255, 100)) as fill:
            fill.move_to(182, 103)
            fill.quadratic_curve_to(150, 90, 145, 84)

        with self.canvas.fill(color=rgb(0, 0, 255)) as fill:
            fill.rect(50, 150, 100, 20)

        # Show the main window
        self.main_window.show()
Example #14
0
    def _2021_10_31_startup(self):
        self.main_window = toga.MainWindow(title=self.name, size=(250, 250))
        self.canvas = toga.Canvas(style=Pack(flex=1))
        self.main_window.content = toga.Box(children=[self.canvas])

        with self.canvas.fill(color=rgb(255, 200, 200)) as fill:
            fill.move_to(112, 103)
            fill.arc(65, 84, 30, math.pi, 3 * math.pi / 2)

        with self.canvas.fill(color=rgb(100, 255, 100)) as fill:
            fill.move_to(182, 103)
            fill.arc(145, 84, 30, math.pi, 3 * math.pi / 2)

        with self.canvas.fill(color=rgb(0, 0, 255)) as fill:
            fill.rect(50, 150, 100, 20)

        # Show the main window
        self.main_window.show()
Example #15
0
File: app.py Project: pybee/toga
 def draw_horns(self):
     with self.canvas.context() as r_horn:
         with r_horn.fill(color=rgb(212, 212, 212)) as r_horn_filler:
             r_horn_filler.move_to(112, 99)
             r_horn_filler.quadratic_curve_to(145, 65, 139, 36)
             r_horn_filler.quadratic_curve_to(130, 60, 109, 75)
         with r_horn.stroke(line_width=4.0) as r_horn_stroker:
             r_horn_stroker.move_to(112, 99)
             r_horn_stroker.quadratic_curve_to(145, 65, 139, 36)
             r_horn_stroker.quadratic_curve_to(130, 60, 109, 75)
     with self.canvas.context() as l_horn:
         with l_horn.fill(color=rgb(212, 212, 212)) as l_horn_filler:
             l_horn_filler.move_to(35, 99)
             l_horn_filler.quadratic_curve_to(2, 65, 6, 36)
             l_horn_filler.quadratic_curve_to(17, 60, 37, 75)
         with l_horn.stroke(line_width=4.0) as l_horn_stroker:
             l_horn_stroker.move_to(35, 99)
             l_horn_stroker.quadratic_curve_to(2, 65, 6, 36)
             l_horn_stroker.quadratic_curve_to(17, 60, 37, 75)
 def draw_horns(self):
     with self.canvas.context() as r_horn:
         with r_horn.fill(color=rgb(212, 212, 212)) as r_horn_filler:
             r_horn_filler.move_to(112, 99)
             r_horn_filler.quadratic_curve_to(145, 65, 139, 36)
             r_horn_filler.quadratic_curve_to(130, 60, 109, 75)
         with r_horn.stroke(line_width=4.0) as r_horn_stroker:
             r_horn_stroker.move_to(112, 99)
             r_horn_stroker.quadratic_curve_to(145, 65, 139, 36)
             r_horn_stroker.quadratic_curve_to(130, 60, 109, 75)
     with self.canvas.context() as l_horn:
         with l_horn.fill(color=rgb(212, 212, 212)) as l_horn_filler:
             l_horn_filler.move_to(35, 99)
             l_horn_filler.quadratic_curve_to(2, 65, 6, 36)
             l_horn_filler.quadratic_curve_to(17, 60, 37, 75)
         with l_horn.stroke(line_width=4.0) as l_horn_stroker:
             l_horn_stroker.move_to(35, 99)
             l_horn_stroker.quadratic_curve_to(2, 65, 6, 36)
             l_horn_stroker.quadratic_curve_to(17, 60, 37, 75)
Example #17
0
 def draw_nostrils(self):
     with self.canvas.fill(color=rgb(212, 212, 212)) as nose_filler:
         nose_filler.move_to(45, 145)
         nose_filler.bezier_curve_to(51, 123, 96, 123, 102, 145)
         nose_filler.ellipse(73, 114, 39, 47, 0, math.pi / 4, 3 * math.pi / 4)
     with self.canvas.fill() as nostril_filler:
         nostril_filler.arc(63, 140, 3)
         nostril_filler.arc(83, 140, 3)
     with self.canvas.stroke(line_width=4.0) as nose_stroker:
         nose_stroker.move_to(45, 145)
         nose_stroker.bezier_curve_to(51, 123, 96, 123, 102, 145)
Example #18
0
 def test_stroke_modify(self):
     with self.testing_canvas.stroke(
         color=BLANCHEDALMOND, line_width=5.0, line_dash=[2, 2]
     ) as stroker:
         stroker.color = REBECCAPURPLE
         stroker.line_width = 1
         stroker.line_dash = [1, 1]
         self.testing_canvas.redraw()
     self.assertActionPerformedWith(
         self.testing_canvas, "stroke", color=rgb(102, 51, 153), line_width=1, line_dash=[1, 1]
     )
Example #19
0
File: app.py Project: pybee/toga
 def draw_nostrils(self):
     with self.canvas.fill(color=rgb(212, 212, 212)) as nose_filler:
         nose_filler.move_to(45, 145)
         nose_filler.bezier_curve_to(51, 123, 96, 123, 102, 145)
         nose_filler.ellipse(73, 114, 39, 47, 0, math.pi / 4, 3 * math.pi / 4)
     with self.canvas.fill() as nostril_filler:
         nostril_filler.arc(63, 140, 3)
         nostril_filler.arc(83, 140, 3)
     with self.canvas.stroke(line_width=4.0) as nose_stroker:
         nose_stroker.move_to(45, 145)
         nose_stroker.bezier_curve_to(51, 123, 96, 123, 102, 145)
Example #20
0
 def test_stroke_modify(self):
     with self.testing_canvas.stroke(
         color=BLANCHEDALMOND, line_width=5.0, line_dash=[2, 2]
     ) as stroker:
         stroker.color = REBECCAPURPLE
         stroker.line_width = 1
         stroker.line_dash = [1, 1]
         self.testing_canvas.redraw()
     self.assertActionPerformedWith(
         self.testing_canvas, "stroke", color=rgb(102, 51, 153), line_width=1, line_dash=[1, 1]
     )
Example #21
0
    def _2021_11_02_startup(self):
        # Expected: 2 semi-circles, rotated at 90 degrees from each other,
        # also offset 10px from each other.
        self.main_window = toga.MainWindow(title=self.name, size=(250, 250))
        self.canvas = toga.Canvas(style=Pack(flex=1))
        self.main_window.content = toga.Box(children=[self.canvas])

        with self.canvas.stroke(
            color=rgb(50, 255, 75),
            line_width=1,
        ) as context:
            context.ellipse(100, 120, 50, 115, math.pi * 0.25, 0.5 * math.pi, 1.5 * math.pi)

        with self.canvas.stroke(
                color=rgb(50, 255, 75),
                line_width=1,
        ) as context:
            context.ellipse(110, 130, 60, 125, math.pi * 0.375, 0.5 * math.pi, 1.5 * math.pi, True)

        # Show the main window
        self.main_window.show()
Example #22
0
    def _2021_08_10_startup(self):
        # Build two lines that cross each other
        # Main window of the application with title and size
        self.main_window = toga.MainWindow(title=self.name, size=(148, 250))

        # Create canvas
        self.canvas = toga.Canvas(style=Pack(flex=1))
        box = toga.Box(children=[self.canvas])

        # Add the content on the main window
        self.main_window.content = box

        # Draw
        with self.canvas.stroke(line_width=4.0, color=rgb(100, 100, 255), line_dash=[4, 4]) as stroke:
            with stroke.closed_path(0, 0) as closed_stroke:
                closed_stroke.line_to(112, 113)

        with self.canvas.stroke(line_width=3.0, color=rgb(255, 255, 100)) as stroke:
            with stroke.closed_path(112, 0) as closed_stroke:
                closed_stroke.line_to(0, 113)

        # Show the main window
        self.main_window.show()
Example #23
0
    def _2021_11_07_startup(self):
        self.main_window = toga.MainWindow(title=self.name, size=(250, 250))
        self.canvas = toga.Canvas(style=Pack(flex=1))
        self.main_window.content = toga.Box(children=[self.canvas])

        with self.canvas.stroke(line_width=4.0, color=rgb(255, 200, 200), line_dash=[4, 4]) as stroke:
            # Draw an arc
            stroke.arc(40, 100, 10, endangle=math.pi * 1.5)
            # Create a new path, which will cause the canvas to "forget" that arc was ever drawn
            stroke.new_path()
            # Draw an arc lower down the screen, instead.
            stroke.arc(80, 200, 10, endangle=math.pi * 1.5)

        # Show the main window
        self.main_window.show()
Example #24
0
 def test_fill_modify(self):
     with self.testing_canvas.fill(
         color="rgb(0, 255, 0)", fill_rule="nonzero", preserve=False
     ) as filler:
         filler.color = REBECCAPURPLE
         filler.fill_rule = "evenodd"
         filler.preserve = True
         self.testing_canvas.redraw()
     self.assertActionPerformedWith(
         self.testing_canvas,
         "fill",
         color=rgb(102, 51, 153),
         fill_rule="evenodd",
         preserve=True,
     )
Example #25
0
    def _2021_11_07b_startup(self):
        self.main_window = toga.MainWindow(title=self.name, size=(250, 250))
        self.canvas = toga.Canvas(style=Pack(flex=1))
        self.main_window.content = toga.Box(children=[self.canvas])

        x = 32
        y = 185
        font = toga.Font(family=SANS_SERIF, size=20)
        width, height = self.canvas.measure_text('Tiberius', font, tight=True)
        with self.canvas.stroke(line_width=4.0) as rect_stroker:
            rect_stroker.rect(x, y - height, width, height)
        with self.canvas.fill(color=rgb(149, 119, 73)) as text_filler:
            text_filler.write_text('Tiberius', x, y, font)
        # Show the main window
        self.main_window.show()
Example #26
0
 def test_fill_modify(self):
     with self.testing_canvas.fill(color="rgb(0, 255, 0)",
                                   fill_rule="nonzero",
                                   preserve=False) as filler:
         filler.color = REBECCAPURPLE
         filler.fill_rule = "evenodd"
         filler.preserve = True
         self.testing_canvas.redraw()
     self.assertActionPerformedWith(
         self.testing_canvas,
         "fill",
         color=rgb(102, 51, 153),
         fill_rule=FillRule.EVENODD,
         preserve=True,
     )
Example #27
0
    def startup(self):
        """
        Construct and show the Toga application.

        Usually, you would add your application to a main content box.
        We then create a main window (with a name matching the app), and
        show the main window.
        """
        self._draw_color = rgb(0, 0, 128)
        self._draw_shape = models.box()
        self._z_rotation = self.home_z_rotation
        self._x_rotation = self.home_x_rotation
        self._z_speed = 0
        self._x_speed = 0
        self._animating = False

        self.canvas = toga_fixes.Canvas(
            style=Pack(flex=1),
            on_resize=self.render_event
        )
        self.canvas.intrinsic = \
            Pack.IntrinsicSize(width=at_least(50), height=at_least(50))

        self.main_box = toga.Box(style=Pack(direction=ROW), children=[
            self.canvas,
            toga.Box(style=Pack(direction=COLUMN, padding=5), children=[
                self.make_shapes_box(),
                self.make_colors_box(),
                self.make_motion_box(),
                self.make_stats_box()
            ]),
        ])

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = self.main_box
        self.main_window.show()

        self.shape_segments.value = 4
Example #28
0
 def make_colors_box(self):
     color_buttons = [
         toga_fixes.Button(
             '', on_press=partial(self.set_draw_color, color=color),
             style=Pack(background_color=color, width=34, height=34),
         )
         for color in (
             rgb(rval + intensity, gval + intensity, bval + intensity)
             for intensity in (0, 127)
             for rval in (0, 128)
             for gval in (0, 128)
             for bval in (0, 128)
         )
     ]
     return toga.Box(
         style=Pack(direction=COLUMN, padding=(5,0)),
         children=[
             toga.Box(
                 style=Pack(direction=ROW),
                 children=color_buttons[chunk:chunk+4]
             )
             for chunk in range(0, len(color_buttons), 4)
         ]
     )
Example #29
0
 def test_set_background_color(self):
     color = '#ffffff'
     root = TestNode('app', style=Pack(background_color=color))
     root.style.reapply()
     root._impl.set_background_color.assert_called_once_with(
         rgb(255, 255, 255))
Example #30
0
    def startup(self):

        main_window = toga.MainWindow(title=self.name, size=(1000, 400))

        def buttonStep_handler(widget):

            global model
            step = int(step_text.value)
            while step:
                model.tick()
                step -= 1

            global avgServiceTime, avgLenQueue, clientDone, clientLeave, money

            if len(avgServiceTime) == 0:
                aST = "0"
            else:
                aST = str(round(stat.mean(avgServiceTime), 3))
            if len(avgLenQueue) == 0:
                aLQ = "0"
            else:
                aLQ = str(round(stat.mean(avgLenQueue), 3))

            money = money * int(profit_text.value) / 1000  #прибыль от покупок
            money = money - int(cashBoxNumber_text.value) * (
                (int(salary_text.value) / 24) *
                (int(step_text.value) / 60))  #зарплаты кассиров
            money = money - (int(sale_text.value) / 24) * (
                int(step_text.value) / 60)  #затраты на рекламу

            table.data = [
                ['Среднее время обслуживания', aST, 'мин'],
                ['Средняя длина очереди касс', aLQ, 'чел'],
                ['Кол-во обслуженных клиентов',
                 str(clientDone), 'чел'],
                ['Количество потерянных клиентов',
                 str(clientLeave), 'чел'],
                ['Общая прибыль', str(round(money, 3)), 'руб']
            ]

            m = int(minute_label.text) + int(step_text.value)
            if m >= 60:
                if m - 60 == 0:
                    minute_label.text = "00"
                else:
                    minute_label.text = str(m - 60)
                h = int(hour_label.text) + 1
                if h >= 24:
                    if h - 24 == 0:
                        hour_label.text = "00"
                    else:
                        hour_label.text = str(h - 24)
                    if day_label.text == "пн":
                        day_label.text = "вт"
                    elif day_label.text == "вт":
                        day_label.text == "ср"
                    elif day_label.text == "ср":
                        day_label.text == "чт"
                    elif day_label.text == "чт":
                        day_label.text == "пт"
                    elif day_label.text == "пт":
                        day_label.text == "сб"
                    elif day_label.text == "сб":
                        day_label.text == "вс"
                    elif day_label.text == "вс":
                        day_label.text == "конец"
                        hour_label.text == "недели"
                        minute_label.text == ""
                else:
                    hour_label.text = str(h)
            else:
                minute_label.text = str(m)

        def buttonToEnd_handler(widget):
            print("hello")

        def buttonStop_handler(widget):
            print("hello")

        def buttonExit_handler(window):
            main_window.close()
            self.exit()

        def buttonBegin_handler(widget):
            global model
            model = Model(int(cashBoxNumber_text.value),
                          int(maxQueueLen_text.value))

            day_label.text = "пн"
            hour_label.text = "00"
            minute_label.text = "00"

            #блокировка полей

            cashBoxNumber_text.readonly = True
            maxQueueLen_text.readonly = True
            advert_text.readonly = True
            sale_text.readonly = True
            salary_text.readonly = True
            minExpense_text.readonly = True
            maxExpense_text.readonly = True
            loss_text.readonly = True
            profit_text.readonly = True
            step_text.readonly = True
            buttonBegin.enabled = False
            button1.enabled = False
            button2.enabled = False
            button3.enabled = False
            button4.enabled = False
            button5.enabled = False
            button6.enabled = False
            button7.enabled = False
            button8.enabled = False
            button9.enabled = False
            button10.enabled = False

        #обработчики полей для ввода

        def enter1(widget):
            print(cashBoxNumber_text.value)

        def enter2(widget):
            print(maxQueueLen_text.value)

        def enter3(widget):
            print(advert_text.value)

        def enter4(widget):
            print(sale_text.value)

        def enter5(widget):
            print(salary_text.value)

        def enter6(widget):
            print(minExpense_text.value)

        def enter7(widget):
            print(maxExpense_text.value)

        def enter8(widget):
            print(loss_text.value)

        def enter9(widget):
            print(profit_text.value)

        def enter10(widget):
            print(step_text.value)

        # поля для ввода

        info_box = toga.Box()

        cashBoxNumber_box = toga.Box(style=Pack(direction=ROW))
        cashBoxNumber_text = toga.TextInput(initial="3", style=Pack(flex=2))
        button1 = toga.Button("Ввести", style=Pack(flex=3), on_press=enter1)
        cashBoxNumber_label = toga.Label('Количество касс :',
                                         style=Pack(flex=1,
                                                    text_align=RIGHT,
                                                    width=210))
        cashBoxNumber_box.add(cashBoxNumber_label, cashBoxNumber_text, button1)

        maxQueueLen_box = toga.Box(style=Pack(direction=ROW))
        maxQueueLen_text = toga.TextInput(initial="3", style=Pack(flex=2))
        button2 = toga.Button("Ввести", style=Pack(flex=3), on_press=enter2)
        maxQueueLen_label = toga.Label('Максимальная длина очереди :',
                                       style=Pack(flex=1,
                                                  text_align=RIGHT,
                                                  width=210))
        maxQueueLen_box.add(maxQueueLen_label, maxQueueLen_text, button2)

        advert_box = toga.Box(style=Pack(direction=ROW))
        advert_text = toga.TextInput(initial="7000", style=Pack(flex=2))
        button3 = toga.Button("Ввести", style=Pack(flex=3), on_press=enter3)
        advert_label = toga.Label('Затраты на рекламу :',
                                  style=Pack(flex=1,
                                             text_align=RIGHT,
                                             width=210))
        advert_box.add(advert_label, advert_text, button3)

        sale_box = toga.Box(style=Pack(direction=ROW))
        sale_text = toga.TextInput(initial="15", style=Pack(flex=2))
        button4 = toga.Button("Ввести", style=Pack(flex=3), on_press=enter4)
        sale_label = toga.Label('Размер скидки :',
                                style=Pack(flex=1, text_align=RIGHT,
                                           width=210))
        sale_box.add(sale_label, sale_text, button4)

        salary_box = toga.Box(style=Pack(direction=ROW))
        salary_text = toga.TextInput(initial="1500", style=Pack(flex=2))
        button5 = toga.Button("Ввести", style=Pack(flex=3), on_press=enter5)
        salary_label = toga.Label('Зарплата кассира(в день) :',
                                  style=Pack(flex=1,
                                             text_align=RIGHT,
                                             width=210))
        salary_box.add(salary_label, salary_text, button5)

        minExpense_box = toga.Box(style=Pack(direction=ROW))
        minExpense_text = toga.TextInput(initial="100", style=Pack(flex=2))
        button6 = toga.Button("Ввести", style=Pack(flex=3), on_press=enter6)
        minExpense_label = toga.Label('Мин. сумма на покупки :',
                                      style=Pack(flex=1,
                                                 text_align=RIGHT,
                                                 width=210))
        minExpense_box.add(minExpense_label, minExpense_text, button6)

        maxExpense_box = toga.Box(style=Pack(direction=ROW))
        maxExpense_text = toga.TextInput(initial="3000", style=Pack(flex=2))
        button7 = toga.Button("Ввести", style=Pack(flex=3), on_press=enter7)
        maxExpense_label = toga.Label('Макс. сумма на покупки :',
                                      style=Pack(flex=1,
                                                 text_align=RIGHT,
                                                 width=210))
        maxExpense_box.add(maxExpense_label, maxExpense_text, button7)

        loss_box = toga.Box(style=Pack(direction=ROW))
        loss_text = toga.TextInput(initial="0.2", style=Pack(flex=2))
        button8 = toga.Button("Ввести", style=Pack(flex=3), on_press=enter8)
        loss_label_box = MultilineLabel(
            'Степень уменьшения клиентов /nпри макс. длине очереди :',
            box_style=Pack(direction=COLUMN),
            label_style=Pack(flex=1, text_align=RIGHT, width=210))
        loss_box.add(loss_label_box, loss_text, button8)

        profit_box = toga.Box(style=Pack(direction=ROW))
        profit_text = toga.TextInput(initial="100", style=Pack(flex=2))
        button9 = toga.Button("Ввести", style=Pack(flex=3), on_press=enter9)
        profit_label_box = MultilineLabel(
            'Прибыль от покупки\nв 1000 рублей :',
            box_style=Pack(direction=COLUMN),
            label_style=Pack(flex=1, text_align=RIGHT, width=210))
        profit_box.add(profit_label_box, profit_text, button9)

        step_box = toga.Box(style=Pack(direction=ROW))
        step_text = toga.TextInput(initial="15", style=Pack(flex=2))
        button10 = toga.Button("Ввести", style=Pack(flex=3), on_press=enter10)
        step_label = toga.Label('Шаг (10-60 мин.) :',
                                style=Pack(flex=1, text_align=RIGHT,
                                           width=210))
        step_box.add(step_label, step_text, button10)

        buttonBegin = toga.Button('Начать',
                                  style=Pack(padding_left=80,
                                             padding_right=80,
                                             padding_top=20),
                                  on_press=buttonBegin_handler)
        curTime_box = toga.Box(style=Pack(direction=ROW, padding_top=20))
        curTime_label = toga.Label('Текущее время :',
                                   style=Pack(padding_left=60))
        day_label = toga.Label('День', style=Pack(padding_left=10))
        hour_label = toga.Label('Час')
        razd_label = toga.Label(' : ')
        minute_label = toga.Label('Минута')
        curTime_box.add(curTime_label, day_label, hour_label, razd_label,
                        minute_label)

        info_box.add(cashBoxNumber_box, maxQueueLen_box, advert_box, sale_box,
                     profit_box, salary_box, loss_box, minExpense_box,
                     maxExpense_box, step_box, curTime_box, buttonBegin)
        info_box.style.update(direction=COLUMN,
                              padding_top=10,
                              padding_left=10,
                              width=300)

        # кнопки

        buttonStep = toga.Button('Шаг',
                                 style=Pack(flex=1,
                                            padding_right=10,
                                            padding_left=10),
                                 on_press=buttonStep_handler)
        buttonStep.style.flex = 1
        buttonToEnd = toga.Button('До конца',
                                  style=Pack(flex=2, padding_right=10),
                                  on_press=buttonToEnd_handler)
        buttonToEnd.style.flex = 2
        buttonStop = toga.Button('Стоп',
                                 style=Pack(flex=3, padding_right=10),
                                 on_press=buttonStop_handler)
        buttonStop.style.flex = 3
        buttonExit = toga.Button('Выход',
                                 style=Pack(flex=4, padding_right=10),
                                 on_press=buttonExit_handler)
        buttonExit.style.flex = 4
        button_box = toga.Box()
        button_box.add(buttonStep, buttonToEnd, buttonStop, buttonExit)
        button_box.style.update(direction=ROW,
                                padding_top=40,
                                padding_bottom=10,
                                padding_right=10,
                                alignment=CENTER,
                                height=80)

        # кассы

        canvas = toga.Canvas()
        canvas_box = toga.Box()
        with canvas.fill(color=rgb(250, 119, 73)) as f:
            #for i in range(cashBoxNumber_box.t)
            f.rect(50, 100, 30, 20)
            f.rect(150, 100, 30, 20)
            f.rect(250, 100, 30, 20)

        # покупатели

        with canvas.fill(color=rgb(0, 119, 73)) as f:
            f.arc(100, 50, 5)
            f.arc(100, 70, 5)
            f.arc(100, 90, 5)
        with canvas.fill(color=rgb(0, 119, 73)) as f:
            f.arc(200, 90, 5)
            f.arc(300, 90, 5)
        canvas_box.add(canvas)
        canvas_box.style.update(height=170, width=600)

        # сводная таблица

        table = toga.Table([' ', 'Значение', 'Ед.измерения'])
        table.min_width = 600
        table.min_height = 500
        table.data = [['Среднее время обслуживания', '0', 'мин'],
                      ['Средняя длина очереди касс', '0', 'чел'],
                      ['Кол-во обслуженных клиентов', '0', 'чел'],
                      ['Количество потерянных клиентов', '0', 'чел'],
                      ['Общая прибыль', '0', 'руб']]

        # моделирование

        work_box = toga.Box()
        work_box.add(canvas_box, table, button_box)
        work_box.style.update(direction=COLUMN, width=600, padding_left=10)

        # все окно

        work_box.style.flex = 2
        info_box.style.flex = 1

        main_box = toga.Box()
        main_box.add(info_box, work_box)
        main_box.style.update(direction=ROW)

        main_window.content = main_box
        main_window.show()