diff --git a/pelita/ui/tk_canvas.py b/pelita/ui/tk_canvas.py index 3048efc16..5a21a4f94 100644 --- a/pelita/ui/tk_canvas.py +++ b/pelita/ui/tk_canvas.py @@ -512,6 +512,7 @@ def draw_grid(self, redraw): # we don’t use scaling for the grid width currently grid_width = 0.01 + grid_width = - (self.mesh_graph.mesh_to_screen_x(0, 0) - self.mesh_graph.mesh_to_screen_x(0, 0.1)) def draw_line(x0, y0, x1, y1): x0_ = self.mesh_graph.mesh_to_screen_x(x0, 0) @@ -876,12 +877,22 @@ def status(team_idx): left_status = status(0) right_status = status(1) - status_font_size = max(font_size - 5, 3) + + + status_font_size = guess_size(f" {left_status} {right_status} ", + self.ui_game_canvas.winfo_width() - 2 * MAZE_PADDING, + 30, + rel_size = 0) + + # status_font_size = max(font_size - 5, 3) top = HEADER_MARGIN_TOP - status_top = top + font_size + SUBHEADER_MARGIN_TOP + SUBHEADER_MARGIN_TOP = tkinter.font.Font(font=(self._default_font, font_size)).metrics('linespace') + status_top = top + SUBHEADER_MARGIN_TOP padding = MAZE_PADDING + self.mesh_graph.top_margin = (tkinter.font.Font(font=(self._default_font, font_size)).metrics('linespace') + tkinter.font.Font(font=(self._default_font, status_font_size)).metrics('linespace')) + # middle colon self.ui_game_canvas.create_text(center, top, text=":", font=(self._default_font, font_size), fill="black", tags="title", anchor=tkinter.N) diff --git a/pelita/ui/tk_viewer.py b/pelita/ui/tk_viewer.py index 88c0e4203..7a7aeb3c8 100644 --- a/pelita/ui/tk_viewer.py +++ b/pelita/ui/tk_viewer.py @@ -98,6 +98,12 @@ def __init__(self, address, controller_address=None, standalone_mode=False, def run(self): try: self.root = tkinter.Tk() + # self.root.tk.call('tk', 'scaling', 2.0) + font = tkinter.font.Font(size=10) + text_width = font.measure("m") + text_height = tkinter.font.Font(size=10).metrics('linespace') + scale = text_height / 16 + print(text_width, text_height) except tkinter.TclError as e: _logger.error('TclError: %s. Exiting.', e) if self.controller_address: @@ -112,7 +118,7 @@ def run(self): if self.fullscreen: self.root.attributes('-fullscreen',True) else: - root_geometry = str(self.geometry[0])+'x'+str(self.geometry[1]) + root_geometry = f"{(self.geometry[0] * scale):.0f}x{(self.geometry[1] * scale):.0f}" # put the root window in some sensible position self.root.geometry(root_geometry+'+40+40')