forked from zietzm/Helmholtz_Test_Bench
Reduces font size if screen is too small to display GUI properly.
This commit is contained in:
+28
-7
@@ -1,7 +1,6 @@
|
||||
# This file contains classes to build all elements of the graphical user interface.
|
||||
# These classes also contain the methods that are executed when UI elements are activated.
|
||||
|
||||
# ToDo: optimize layout for smaller screen (like on IRS clean room PC)
|
||||
# import packages for user interface:
|
||||
import queue
|
||||
from queue import Queue, Empty
|
||||
@@ -30,11 +29,16 @@ from src.exceptions import DeviceAccessError
|
||||
from src.utility import ui_print, save_dict_list_to_csv, load_dict_list_from_csv
|
||||
import src.helmholtz_cage_device as helmholtz_cage_device
|
||||
|
||||
# define font styles:
|
||||
HEADER_FONT = ("Arial", 13, "bold")
|
||||
SUB_HEADER_FONT = ("Arial", 9, "bold")
|
||||
BIG_BUTTON_FONT = ("Arial", 11, "bold")
|
||||
SMALL_BUTTON_FONT = ("Arial", 9)
|
||||
# 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]
|
||||
font = "Arial"
|
||||
HEADER_FONT = (font, points[0], "bold")
|
||||
SUB_HEADER_FONT = (font, points[2], "bold")
|
||||
BIG_BUTTON_FONT = (font, points[1], "bold")
|
||||
SMALL_BUTTON_FONT = (font, points[2])
|
||||
DEFAULT_FONT = (font, points[2])
|
||||
|
||||
|
||||
class HelmholtzGUI(Tk):
|
||||
@@ -49,6 +53,24 @@ class HelmholtzGUI(Tk):
|
||||
except TclError:
|
||||
pass
|
||||
|
||||
# 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:
|
||||
red = 2
|
||||
elif screen_height <= screen_height_limit1:
|
||||
red = 1
|
||||
else:
|
||||
red = 0
|
||||
global HEADER_FONT, SUB_HEADER_FONT, BIG_BUTTON_FONT, SMALL_BUTTON_FONT, DEFAULT_FONT
|
||||
HEADER_FONT = (font, points[0+red], "bold")
|
||||
SUB_HEADER_FONT = (font, points[2+red], "bold")
|
||||
BIG_BUTTON_FONT = (font, points[1+red], "bold")
|
||||
SMALL_BUTTON_FONT = (font, points[2+red])
|
||||
DEFAULT_FONT = (font, points[2+red])
|
||||
self.option_add("*font", DEFAULT_FONT)
|
||||
|
||||
self.Menu = TopMenu(self) # display dropdown menu bar at the top (see TopMenu class for details)
|
||||
|
||||
# setup status display and output console
|
||||
@@ -1859,7 +1881,6 @@ class CalibrateMagnetometerComplete(Frame):
|
||||
self.clipboard_append(self.clipboard)
|
||||
self.update()
|
||||
|
||||
|
||||
def copy_to_clipboard_calibration_results_complete(self):
|
||||
self.clipboard_clear()
|
||||
self.clipboard_append(self.clipboard_calibration_results_complete)
|
||||
|
||||
Reference in New Issue
Block a user