|
15 | 15 | "linux": "assets/logo.png", |
16 | 16 | "windows": "assets/rustler.ico", |
17 | 17 | "darwin": "assets/logo.png", # I _think_ this will work |
18 | | - } |
| 18 | +} |
19 | 19 | host_os = system().lower() |
20 | 20 | icon_file = icons[host_os] |
21 | | -rustler_logo = sg.Image(filename="assets/logo.png", size=(120, 136), key="logo", visible=True, enable_events=False) |
| 21 | +rustler_logo = sg.Image( |
| 22 | + filename="assets/logo.png", |
| 23 | + size=(120, 136), |
| 24 | + key="logo", |
| 25 | + visible=True, |
| 26 | + enable_events=False, |
| 27 | +) |
22 | 28 | window_title = "Sequential Links Rustler" |
23 | 29 |
|
24 | 30 | # create fixed gui elements |
25 | | -button_rustle = sg.Button( "Rustle\nUp\nSome\nLinks", size=(11, 6), font=("Any", 12), bind_return_key=True, key="-DoIt-" ) |
26 | | -button_options = sg.Button("Show Options", size=(16, 2), font=("Any", 12), key="-Options-") |
| 31 | +button_rustle = sg.Button( |
| 32 | + "Rustle\nUp\nSome\nLinks", |
| 33 | + size=(11, 6), |
| 34 | + font=("Any", 12), |
| 35 | + bind_return_key=True, |
| 36 | + key="-DoIt-", |
| 37 | +) |
| 38 | +button_options = sg.Button( |
| 39 | + "Show Options", size=(16, 2), font=("Any", 12), key="-Options-" |
| 40 | +) |
27 | 41 | button_exit = sg.Button("Exit", size=(8, 2), font=("Any", 12)) |
28 | | -label_URLmask = sg.Text("Enter/edit URL mask:", size=(18, 1), text_color="black", justification="right") |
| 42 | +label_URLmask = sg.Text( |
| 43 | + "Enter/edit URL mask:", size=(18, 1), text_color="black", justification="right" |
| 44 | +) |
29 | 45 | button_clear = sg.Button("Clear", size=(None, 1), key="-Clear URL mask-") |
30 | 46 |
|
31 | 47 | # create Options gui elements |
32 | 48 | input_URLmask = sg.Multiline(key="-URLMask-", size=(64, 4), focus=True) |
33 | 49 | button_reset = sg.Button("Reset", key="-HTML_Defaults-") |
34 | | -label_image_options =sg.Text("\nImage Options ", size=(18, 4), text_color="black", justification="right") |
| 50 | +label_image_options = sg.Text( |
| 51 | + "\nImage Options ", size=(18, 4), text_color="black", justification="right" |
| 52 | +) |
35 | 53 | label_imagesize = sg.Text("Image thumbnail size:") |
36 | | -label_file_options = sg.Text("HTML File Options ", size=(18, 1), text_color="black", justification="right",) |
| 54 | +label_file_options = sg.Text( |
| 55 | + "HTML File Options ", size=(18, 1), text_color="black", justification="right", |
| 56 | +) |
37 | 57 | spin_thumbsize = sg.Spin( |
38 | | - [str(each) for each in range(1, 101)], |
39 | | - initial_value="13", |
40 | | - size=(4, 4), |
41 | | - key="-ThumbSize-", |
42 | | - ) |
| 58 | + [str(each) for each in range(1, 101)], |
| 59 | + initial_value="13", |
| 60 | + size=(4, 4), |
| 61 | + key="-ThumbSize-", |
| 62 | +) |
43 | 63 | label_percent_width = sg.Text("(% of browser window width)") |
44 | | -input_hideborked = sg.Checkbox(" Hide broken image links", default=False, key="-HideBorkedImages-") |
| 64 | +input_hideborked = sg.Checkbox( |
| 65 | + " Hide broken image links", default=False, key="-HideBorkedImages-" |
| 66 | +) |
45 | 67 | label_filepath = sg.Text("Path:") |
46 | 68 | input_filepath = sg.Input(key="-FilePath-", size=(33, 1), default_text=home_dir) |
47 | 69 | label_filename = sg.Text("Name:") |
48 | 70 | input_filename = sg.Input(key="-FileName-", size=(17, 1), default_text="rustled.html") |
49 | | -input_delete = sg.Checkbox(" Delete HTML file on Exit", default=True, key="-DeleteFile-") |
50 | | -label_browser = sg.Text("Choose browser ", size=(18, 2), text_color="black", justification="right") |
| 71 | +input_delete = sg.Checkbox( |
| 72 | + " Delete HTML file on Exit", default=True, key="-DeleteFile-" |
| 73 | +) |
| 74 | +label_browser = sg.Text( |
| 75 | + "Choose browser ", size=(18, 2), text_color="black", justification="right" |
| 76 | +) |
51 | 77 | input_browser = sg.Combo( |
52 | 78 | supported_browsers, |
53 | 79 | default_value="system_default", |
|
59 | 85 |
|
60 | 86 | # create layout |
61 | 87 | fixed_column_1 = sg.Column( |
62 | | - [ |
63 | | - [rustler_logo], |
64 | | - [label_URLmask], |
65 | | - [button_clear], |
66 | | - ], |
67 | | - element_justification="right" |
| 88 | + [[rustler_logo], [label_URLmask], [button_clear],], element_justification="right" |
68 | 89 | ) |
69 | 90 |
|
70 | 91 | toggle_column_1 = sg.Column( |
|
77 | 98 | [label_browser], |
78 | 99 | ], |
79 | 100 | element_justification="right", |
80 | | - key = "tc1" |
| 101 | + key="tc1", |
81 | 102 | ) |
82 | 103 |
|
83 | 104 | fixed_column_2 = sg.Column( |
|
98 | 119 | [sg.Text(" ", font=("Any", 12))], |
99 | 120 | [input_browser], |
100 | 121 | ], |
101 | | - key = "tc2" |
| 122 | + key="tc2", |
102 | 123 | ) |
103 | 124 |
|
104 | 125 | column_a = sg.Column([[fixed_column_1], [toggle_column_1]]) |
105 | 126 | column_b = sg.Column([[sg.vbottom(fixed_column_2)], [toggle_column_2]]) |
106 | 127 |
|
107 | | -layout = [[sg.vtop(column_a), column_b]] |
| 128 | +layout = [[sg.vtop(column_a), sg.vtop(column_b)]] |
108 | 129 |
|
109 | 130 | # Create the window |
110 | 131 | window = sg.Window(window_title, layout, icon=icon_file, finalize=True) |
111 | 132 |
|
| 133 | + |
112 | 134 | def toggle_option_elements(): |
113 | 135 | toggle_cols = ("tc1", "tc2") |
114 | 136 | if window[toggle_cols[0]].visible: |
115 | 137 | for each in toggle_cols: |
116 | | - window[each].update(visible=False) |
117 | 138 | window[each].hide_row() |
| 139 | + window[each].update(visible=False) |
118 | 140 | else: |
119 | 141 | for each in toggle_cols: |
120 | | - window[each].update(visible=True) |
121 | 142 | window[each].unhide_row() |
| 143 | + window[each].update(visible=True) |
| 144 | + |
122 | 145 |
|
123 | 146 | toggle_option_elements() |
124 | 147 |
|
|
0 commit comments