|
4 | 4 | import os
|
5 | 5 | import tkinter as tk
|
6 | 6 | import traceback
|
| 7 | +import argparse |
7 | 8 | from collections import defaultdict
|
8 | 9 | from pprint import pprint
|
9 |
| -from tkinter import ttk, messagebox |
| 10 | +from tkinter import ttk, messagebox, font |
10 | 11 |
|
11 | 12 | from ttkthemes import ThemedStyle
|
12 | 13 |
|
|
23 | 24 | class Application:
|
24 | 25 |
|
25 | 26 | # Create the application window
|
26 |
| - def __init__(self, width, height): |
| 27 | + def __init__(self): |
| 28 | + self.parse_arguments() |
27 | 29 | # Create the root
|
28 | 30 | self.root = tk.Tk()
|
29 |
| - self.root.geometry("%dx%d+50+30" % (width, height)) |
| 31 | + self.root.geometry("%dx%d+50+30" % (self.args.width, self.args.height)) |
| 32 | + print(4.0 if self.args.high_resolution else self.args.scaling_factor) |
| 33 | + self.root.call('tk', 'scaling', 2.0 if self.args.high_resolution else self.args.scaling_factor) |
30 | 34 | self.root.title("Read tree")
|
31 | 35 |
|
| 36 | + # Use a font that scales with the scaling factor |
| 37 | + fontSize = 12 # base font size before scaling |
| 38 | + scaled_font = font.nametofont("TkDefaultFont") |
| 39 | + scaled_font.configure(size=int(fontSize * self.args.scaling_factor)) |
32 | 40 |
|
33 | 41 | # App icon :). Save or will be garbage collected
|
34 | 42 | self.icon = PIL.ImageTk.PhotoImage(PIL.Image.open("static/zoneplate.png"))
|
@@ -60,6 +68,15 @@ def __init__(self, width, height):
|
60 | 68 | self.root.update()
|
61 | 69 | self.root.attributes('-topmost', False)
|
62 | 70 |
|
| 71 | + def parse_arguments(self): |
| 72 | + parser = argparse.ArgumentParser(description='Loom Activation Script') |
| 73 | + |
| 74 | + parser.add_argument('-wd', '--width', default=1200, type=int, help='Window Width') |
| 75 | + parser.add_argument('-ht', '--height', default=675, type=int, help='Window Height') |
| 76 | + parser.add_argument('-sf', '--scaling-factor', default=1.0) |
| 77 | + parser.add_argument('-hr', '--high-resolution', action='store_true', help='hr as in High Resolution') |
| 78 | + |
| 79 | + self.args = parser.parse_args() |
63 | 80 |
|
64 | 81 | def initialize_app_state(self):
|
65 | 82 | try:
|
@@ -137,6 +154,7 @@ def set_tab_names(self):
|
137 | 154 | def build_menus(self):
|
138 | 155 | if hasattr(self, "menu"):
|
139 | 156 | self.menu.destroy()
|
| 157 | + |
140 | 158 | menu_list = defaultdict(list, {
|
141 | 159 | "File": [
|
142 | 160 | #('New Tab', 'Ctrl+N', '<Control-n>', self.create_tab),
|
@@ -181,5 +199,5 @@ def main(self):
|
181 | 199 |
|
182 | 200 | # Create the display application and run it
|
183 | 201 | if __name__ == "__main__":
|
184 |
| - app = Application(1200, 675) |
| 202 | + app = Application() |
185 | 203 | app.main()
|
0 commit comments