2
2
3
3
import warnings
4
4
from pathlib import Path
5
+ from sys import version_info
5
6
from typing import TYPE_CHECKING , Any , cast
6
7
7
8
import wx
@@ -52,6 +53,24 @@ def __init__(self, parent: wx.Window):
52
53
self .SetSizer (sizer )
53
54
54
55
56
+ def _add_icon (btn : wx .AnyButton , icon : str ) -> None :
57
+ # Avoids https://github.com/urllib3/urllib3/issues/3020
58
+ if version_info .minor < 10 :
59
+ return
60
+
61
+ icon_path = svg_path (icon )
62
+ wx_icon = wx .svg .SVGimage .CreateFromFile (str (icon_path ))
63
+ side_length = btn .Size .height
64
+ # NB 5 is a magic number for the margins
65
+ bmp_side_len = side_length - 5
66
+ bmp_size = wx .Size (bmp_side_len , bmp_side_len )
67
+ btn .SetBitmap (wx_icon .ConvertToScaledBitmap (bmp_size ))
68
+
69
+ btn_side_len = side_length
70
+ btn_size = wx .Size (btn_side_len , btn_side_len )
71
+ btn .SetMaxSize (btn_size )
72
+
73
+
55
74
# mostly copied from _qt.qt_view._QLUTWidget
56
75
class _WxLUTWidget (wx .Panel ):
57
76
def __init__ (self , parent : wx .Window ) -> None :
@@ -73,17 +92,7 @@ def __init__(self, parent: wx.Window) -> None:
73
92
self .auto_clim = wx .ToggleButton (self , label = "Auto" )
74
93
75
94
self .histogram = wx .ToggleButton (self )
76
- # FIXME: Polish this code, make reusable
77
- icon_path = svg_path ("foundation:graph-bar" )
78
- icon = wx .svg .SVGimage .CreateFromFile (str (icon_path ))
79
- # NB 5 is a magic number for the margins
80
- bmp_side_len = self .auto_clim .Size .height - 5
81
- bmp_size = wx .Size (bmp_side_len , bmp_side_len )
82
- self .histogram .SetBitmap (icon .ConvertToScaledBitmap (bmp_size ))
83
-
84
- btn_side_len = self .auto_clim .Size .height
85
- btn_size = wx .Size (btn_side_len , btn_side_len )
86
- self .histogram .SetMaxSize (btn_size )
95
+ _add_icon (self .histogram , "foundation:graph-bar" )
87
96
88
97
# Layout
89
98
sizer = wx .BoxSizer (wx .HORIZONTAL )
@@ -272,7 +281,8 @@ def __init__(self, canvas_widget: wx.Window, parent: wx.Window = None):
272
281
)
273
282
274
283
# Reset zoom button
275
- self .reset_zoom_btn = wx .Button (self , label = "Reset Zoom" )
284
+ self .reset_zoom_btn = wx .Button (self )
285
+ _add_icon (self .reset_zoom_btn , "fluent:full-screen-maximize-24-filled" )
276
286
277
287
# 3d view button
278
288
self .ndims_btn = wx .ToggleButton (self , label = "3D" )
@@ -283,8 +293,8 @@ def __init__(self, canvas_widget: wx.Window, parent: wx.Window = None):
283
293
btns = wx .BoxSizer (wx .HORIZONTAL )
284
294
btns .AddStretchSpacer ()
285
295
btns .Add (self .channel_mode_combo , 0 , wx .ALL , 5 )
286
- btns .Add (self .reset_zoom_btn , 0 , wx .ALL , 5 )
287
296
btns .Add (self .ndims_btn , 0 , wx .ALL , 5 )
297
+ btns .Add (self .reset_zoom_btn , 0 , wx .ALL , 5 )
288
298
289
299
self ._top_info = top_info = wx .BoxSizer (wx .HORIZONTAL )
290
300
top_info .Add (self ._data_info_label , 0 , wx .EXPAND | wx .BOTTOM , 0 )
0 commit comments