Opening console on largest screen in zoomed mode

This commit is contained in:
2023-01-29 11:34:19 +01:00
parent 56b8ffcd5e
commit 1354aed150
2 changed files with 18 additions and 6 deletions
+3
View File
@@ -12,3 +12,6 @@ python-dateutil==2.8.2
pytz==2021.3
scipy==1.7.1
six==1.16.0
numpy~=1.19.3
screeninfo~=0.8.1
+15 -6
View File
@@ -8,6 +8,7 @@ from tkinter import *
from tkinter import ttk
from tkinter import messagebox
from tkinter import filedialog
import screeninfo
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import matplotlib.pyplot as plt
@@ -32,7 +33,7 @@ import src.helmholtz_cage_device as helmholtz_cage_device
# Define global font styles:
screen_height_limit1 = 1100 # Limit after which font size gets reduced
screen_height_limit2 = 900 # Limit after which font size gets reduced
points = [13, 11, 9, 7, 6, 5]
points = [15, 13, 11, 9, 7, 6]
font = "Arial"
HEADER_FONT = (font, points[0], "bold")
SUB_HEADER_FONT = (font, points[2], "bold")
@@ -53,13 +54,21 @@ class HelmholtzGUI(Tk):
except TclError:
pass
# Check if multiple monitors connected and open the window on the largest or the non-primary monitor
monitors = screeninfo.get_monitors()
[sc_no, sc_x_max, sc_y_max, sc_width_max, sc_height_max] = [0, monitors[0].x, monitors[0].y,
monitors[0].width, monitors[0].height]
for i in range(len(monitors)):
if sc_width_max <= monitors[i].width:
[sc_no, sc_x_max, sc_y_max, sc_width_max, sc_height_max] = [i, monitors[i].x, monitors[i].y,
monitors[i].width, monitors[i].height]
print("Opening console on largest screen: #{} with {} x {}".format(sc_no, sc_width_max, sc_height_max))
Tk.geometry(self, "{}x{}+{}+{}".format(sc_width_max, sc_height_max, sc_x_max, sc_y_max))
Tk.state(self, 'zoomed')
# Change default fonts if display resolution is too small
screen_width = Tk.winfo_screenwidth(self)
screen_height = Tk.winfo_screenheight(self)
print("Screensize: {} x {}".format(screen_width, screen_height))
if screen_height <= screen_height_limit2:
if sc_height_max <= screen_height_limit2:
red = 2
elif screen_height <= screen_height_limit1:
elif sc_height_max <= screen_height_limit1:
red = 1
else:
red = 0