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()
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()
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()
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()
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()
def startup(self): # Window class # Main window of the application with title and size self.main_window = toga.MainWindow(self.name, size=(148, 200)) self.main_window.app = self self.canvas = toga.Canvas(on_draw=self.draw_tiberius) box = toga.Box(children=[self.canvas]) # Add the content on the main window self.main_window.content = box # Show the main window self.main_window.show()
def startup(self): # Main window of the application with title and size self.main_window = toga.MainWindow(title=self.name, size=(148, 250)) # Create canvas and draw tiberius on it self.canvas = toga.Canvas(style=Pack(flex=1)) box = toga.Box(children=[self.canvas]) self.draw_tiberius() # Add the content on the main window self.main_window.content = box # Show the main window self.main_window.show()
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()
def startup(self): # Set up main window self.main_window = toga.MainWindow(title=self.name, size=(148, 200)) canvas = toga.Canvas(style=Pack(flex=1), on_resize=self.resize_contents) box = toga.Box(children=[canvas]) # Add the content on the main window self.main_window.content = box # Show the main window self.main_window.show() self.render_drawing(canvas, *self.main_window.size)
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()
def startup(self): # Set up main window self.main_window = toga.MainWindow(self.name, size=(148, 200)) canvas = toga.Canvas(style=Pack(flex=1)) box = toga.Box(children=[canvas]) # Add the content on the main window self.main_window.content = box # Show the main window self.main_window.show() with canvas.stroke(): with canvas.closed_path(50, 50): canvas.line_to(100, 100)
def _2021_12_30_closed_stroke_arc(self): 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 with self.canvas.stroke(line_width=4.0) as head_stroker: with head_stroker.closed_path(35, 84) as closed_path: closed_path.arc(65, 84, 30, math.pi, 3 * math.pi / 2) closed_path.arc(82, 84, 30, 3 * math.pi / 2, 2 * math.pi) self.main_window.show()
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 _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()
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()
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()
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()
def setUp(self): super().setUp() self.testing_canvas = toga.Canvas(factory=toga_dummy.factory)
def startup(self): # Set up main window self.main_window = toga.MainWindow(title=self.name, size=(750, 500)) self.canvas = toga.Canvas( style=Pack(flex=1), on_resize=self.refresh_canvas, on_press=self.on_press, on_drag=self.on_drag, on_release=self.on_release, on_alt_press=self.on_alt_press, on_alt_drag=self.on_alt_drag, on_alt_release=self.on_alt_release ) self.context_selection = toga.Selection(items=[STROKE, FILL], on_select=self.refresh_canvas) self.drawing_shape_instructions = { INSTRUCTIONS: self.draw_instructions, TRIANGLE: self.draw_triangle, TRIANGLES: self.draw_triangles, RECTANGLE: self.draw_rectangle, ELLIPSE: self.draw_ellipse, HALF_ELLIPSE: self.draw_half_ellipse, ICE_CREAM: self.draw_ice_cream, SMILE: self.draw_smile, SEA: self.draw_sea, STAR: self.draw_star, } self.dash_patterns = { CONTINUOUS: None, DASH_1_1: [1, 1], DASH_1_2: [1, 2], DASH_2_3_1: [2, 3, 1] } self.shape_selection = toga.Selection( items=list(self.drawing_shape_instructions.keys()), on_select=self.on_shape_change ) self.color_selection = toga.Selection( items=[BLACK, BLUE, GREEN, RED, YELLOW], on_select=self.refresh_canvas ) self.fill_rule_selection = toga.Selection( items=[value.name.lower() for value in FillRule], on_select=self.refresh_canvas ) self.line_width_slider = toga.Slider( range=(1, 10), default=1, on_slide=self.refresh_canvas ) self.dash_pattern_selection = toga.Selection( items=list(self.dash_patterns.keys()), on_select=self.refresh_canvas ) self.clicked_point = None self.translation = None self.rotation = 0 self.scale_x_slider = toga.Slider( range=(0, 2), default=1, tick_count=10, on_slide=self.refresh_canvas ) self.scale_y_slider = toga.Slider( range=(0, 2), default=1, tick_count=10, on_slide=self.refresh_canvas ) self.font_selection = toga.Selection( items=[ SYSTEM, MESSAGE, SERIF, SANS_SERIF, CURSIVE, FANTASY, MONOSPACE ], on_select=self.refresh_canvas ) self.font_size = toga.NumberInput( min_value=10, max_value=72, default=20, on_change=self.refresh_canvas ) self.italic_switch = toga.Switch( label="italic", on_toggle=self.refresh_canvas ) self.bold_switch = toga.Switch( label="bold", on_toggle=self.refresh_canvas ) label_style = Pack(font_size=10, padding_left=5) # Add the content on the main window box = toga.Box( style=Pack(direction=COLUMN), children=[ toga.Box( style=Pack(direction=ROW, padding=5), children=[ self.context_selection, self.shape_selection, self.color_selection, self.fill_rule_selection ] ), toga.Box( style=Pack(direction=ROW, padding=5), children=[ toga.Label("Line Width:", style=label_style), self.line_width_slider, self.dash_pattern_selection ] ), toga.Box( style=Pack(direction=ROW, padding=5), children=[ toga.Label("X Scale:", style=label_style), self.scale_x_slider, toga.Label("Y Scale:", style=label_style), self.scale_y_slider, toga.Button( label="Reset transform", on_press=self.reset_transform ) ] ), toga.Box( style=Pack(direction=ROW, padding=5), children=[ toga.Label("Font Family:", style=label_style), self.font_selection, toga.Label("Font Size:", style=label_style), self.font_size, self.bold_switch, self.italic_switch ] ), self.canvas ] ) self.main_window.content = box self.change_shape() self.render_drawing() # Show the main window self.main_window.show()
def startup(self): # Set up main window self.main_window = toga.MainWindow(title=self.name, size=(250, 250)) self.canvas = toga.Canvas(style=Pack(flex=1), on_resize=self.refresh_canvas) self.context_selection = toga.Selection(items=[STROKE, FILL], on_select=self.refresh_canvas) self.drawing_shape_instructions = { TRIANGLE: self.draw_triangle, TRIANGLES: self.draw_triangles, RECTANGLE: self.draw_rectangle, ELLIPSE: self.draw_ellipse, HALF_ELLIPSE: self.draw_half_ellipse, ICE_CREAM: self.draw_ice_cream, SMILE: self.draw_smile, SEA: self.draw_sea, STAR: self.draw_star, TEXT: self.draw_text } self.dash_patterns = { CONTINUOUS: None, DASH_1_1: [1, 1], DASH_1_2: [1, 2], DASH_2_3_1: [2, 3, 1] } self.shape_selection = toga.Selection(items=list( self.drawing_shape_instructions.keys()), on_select=self.refresh_canvas) self.color_selection = toga.Selection( items=[BLACK, BLUE, GREEN, RED, YELLOW], on_select=self.refresh_canvas) self.fill_rule_selection = toga.Selection( items=[value.name.lower() for value in FillRule], on_select=self.refresh_canvas) self.line_width_slider = toga.Slider(range=(1, 10), default=1, on_slide=self.refresh_canvas) self.dash_pattern_selection = toga.Selection( items=list(self.dash_patterns.keys()), on_select=self.refresh_canvas) box = toga.Box(style=Pack(direction=COLUMN), children=[ toga.Box(style=Pack(direction=ROW), children=[ self.context_selection, self.shape_selection, self.color_selection, self.fill_rule_selection ]), toga.Box(style=Pack(direction=ROW), children=[ toga.Label("Line Width:"), self.line_width_slider, self.dash_pattern_selection ]), self.canvas ]) # Add the content on the main window self.main_window.content = box self.render_drawing(self.canvas, *self.main_window.size) # Show the main window self.main_window.show()
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()
def setUp(self): super().setUp() # Create a canvas with the dummy factory self.testing_canvas = toga.Canvas(factory=toga_dummy.factory)