Skip to content

Commit ac4d258

Browse files
committed
Fixed flicker when Options were hidden.
1 parent c70449d commit ac4d258

File tree

1 file changed

+49
-26
lines changed

1 file changed

+49
-26
lines changed

slr.py

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,65 @@
1515
"linux": "assets/logo.png",
1616
"windows": "assets/rustler.ico",
1717
"darwin": "assets/logo.png", # I _think_ this will work
18-
}
18+
}
1919
host_os = system().lower()
2020
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+
)
2228
window_title = "Sequential Links Rustler"
2329

2430
# 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+
)
2741
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+
)
2945
button_clear = sg.Button("Clear", size=(None, 1), key="-Clear URL mask-")
3046

3147
# create Options gui elements
3248
input_URLmask = sg.Multiline(key="-URLMask-", size=(64, 4), focus=True)
3349
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+
)
3553
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+
)
3757
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+
)
4363
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+
)
4567
label_filepath = sg.Text("Path:")
4668
input_filepath = sg.Input(key="-FilePath-", size=(33, 1), default_text=home_dir)
4769
label_filename = sg.Text("Name:")
4870
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+
)
5177
input_browser = sg.Combo(
5278
supported_browsers,
5379
default_value="system_default",
@@ -59,12 +85,7 @@
5985

6086
# create layout
6187
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"
6889
)
6990

7091
toggle_column_1 = sg.Column(
@@ -77,7 +98,7 @@
7798
[label_browser],
7899
],
79100
element_justification="right",
80-
key = "tc1"
101+
key="tc1",
81102
)
82103

83104
fixed_column_2 = sg.Column(
@@ -98,27 +119,29 @@
98119
[sg.Text(" ", font=("Any", 12))],
99120
[input_browser],
100121
],
101-
key = "tc2"
122+
key="tc2",
102123
)
103124

104125
column_a = sg.Column([[fixed_column_1], [toggle_column_1]])
105126
column_b = sg.Column([[sg.vbottom(fixed_column_2)], [toggle_column_2]])
106127

107-
layout = [[sg.vtop(column_a), column_b]]
128+
layout = [[sg.vtop(column_a), sg.vtop(column_b)]]
108129

109130
# Create the window
110131
window = sg.Window(window_title, layout, icon=icon_file, finalize=True)
111132

133+
112134
def toggle_option_elements():
113135
toggle_cols = ("tc1", "tc2")
114136
if window[toggle_cols[0]].visible:
115137
for each in toggle_cols:
116-
window[each].update(visible=False)
117138
window[each].hide_row()
139+
window[each].update(visible=False)
118140
else:
119141
for each in toggle_cols:
120-
window[each].update(visible=True)
121142
window[each].unhide_row()
143+
window[each].update(visible=True)
144+
122145

123146
toggle_option_elements()
124147

0 commit comments

Comments
 (0)