1
+ import time
1
2
import tkinter as tk
2
3
from tkinter .ttk import Button
3
4
4
- import matplotlib
5
-
6
- matplotlib .use ("tk.TkAgg" )
7
- import time
8
-
9
5
import h5py
6
+ import matplotlib
10
7
import numpy as np
11
8
from matplotlib import pyplot as plt
12
- from matplotlib .backends .backend_tkagg import (
13
- FigureCanvastk .TkAgg ,
14
- NavigationToolbar2tk .Tk ,
15
- )
9
+ from matplotlib .backends .backend_tkagg import FigureCanvasTkAgg , NavigationToolbar2Tk
10
+
11
+ matplotlib .use ("tk.TkAgg" )
16
12
17
13
WIDTH = 920
18
14
HEIGHT = 630
@@ -46,7 +42,7 @@ def initUI(self):
46
42
# frame 10: exit button
47
43
# frame 11: not used
48
44
49
- ##### 00 #### #
45
+ # 00 #
50
46
# frame 00, upper left
51
47
52
48
frame00 = tk .Frame (self )
@@ -220,7 +216,7 @@ def initUI(self):
220
216
)
221
217
fft .grid (row = 12 , column = 0 , columnspan = 2 , sticky = tk .W )
222
218
223
- ##### 01 #### #
219
+ # 01 #
224
220
# frame 01, upper right
225
221
self .frame01 = tk .Frame (self , bg = "#cccccc" )
226
222
self .frame01 .place (x = 400 , y = 0 ) # , height=HEIGHT//2, width=WIDTH//2)
@@ -235,12 +231,14 @@ def initUI(self):
235
231
label = "slider" ,
236
232
orient = tk .HORIZONTAL ,
237
233
length = WIDTH // 2 , # resolution=-1,
238
- command = lambda l : self .multiple_funcs (
234
+ command = lambda x : self .multiple_funcs (
239
235
self .plot_plane (), self .intensity_upd_local ()
240
236
),
241
237
)
242
238
# command=lambda p: self.plot_plane())
243
- self .slider .grid (row = 0 , column = 0 , padx = 10 , pady = 10 , sticky = tk .N + tk .E + tk .S + tk .W )
239
+ self .slider .grid (
240
+ row = 0 , column = 0 , padx = 10 , pady = 10 , sticky = tk .N + tk .E + tk .S + tk .W
241
+ )
244
242
245
243
self .frame01_plotcell = tk .Frame (self .frame01 )
246
244
self .frame01_plotcell .grid (
@@ -250,7 +248,7 @@ def initUI(self):
250
248
self .frame01_toolbar = tk .Frame (self .frame01 )
251
249
self .frame01_toolbar .grid (row = 2 , column = 0 )
252
250
253
- ##### 10 #### #
251
+ # 10 #
254
252
# frame 10, lower left
255
253
frame10 = tk .Frame (self )
256
254
frame10 .place (x = 5 , y = HEIGHT - 30 ) # , height=HEIGHT//2, width=WIDTH//2)
@@ -263,7 +261,7 @@ def initUI(self):
263
261
)
264
262
quit .pack (side = tk .TOP )
265
263
266
- ##### 11 #### #
264
+ # 11 #
267
265
# frame 00, lower right
268
266
# no functionality
269
267
frame11 = tk .Frame (self )
@@ -285,7 +283,7 @@ def load_cube(self):
285
283
self .cube = np .array (f ["data" ])
286
284
elif "rebinned_data" in f .keys ():
287
285
self .cube = np .array (f ["rebinned_data" ])
288
- except :
286
+ except Exception :
289
287
raise KeyError (
290
288
"- No data found in "
291
289
+ filename
@@ -304,11 +302,13 @@ def load_cube(self):
304
302
label = "slider" ,
305
303
orient = tk .HORIZONTAL ,
306
304
length = WIDTH // 2 , # resolution=-1,
307
- command = lambda l : self .multiple_funcs (
305
+ command = lambda x : self .multiple_funcs (
308
306
self .plot_plane (), self .intensity_upd_local ()
309
307
),
310
308
)
311
- self .slider .grid (row = 0 , column = 0 , padx = 10 , pady = 10 , sticky = tk .N + tk .E + tk .S + tk .W )
309
+ self .slider .grid (
310
+ row = 0 , column = 0 , padx = 10 , pady = 10 , sticky = tk .N + tk .E + tk .S + tk .W
311
+ )
312
312
313
313
if not self .loaded :
314
314
@@ -327,12 +327,11 @@ def load_cube(self):
327
327
self .im = plt .imshow (self .cube [:, :, self .plane_num .get ()])
328
328
else :
329
329
raise ValueError ("axis must be 0,1,2" )
330
- axs = plt .gca ()
331
330
plt .colorbar (shrink = 0.81 )
332
331
ax .set_xlabel ("pixel" )
333
332
ax .set_ylabel ("pixel" )
334
- self .canvas = FigureCanvastk . TkAgg (fig , master = self .frame01_plotcell )
335
- self .toolbar = tk . NavigationToolbar2tk . Tk (self .canvas , self .frame01_toolbar )
333
+ self .canvas = FigureCanvasTkAgg (fig , master = self .frame01_plotcell )
334
+ self .toolbar = NavigationToolbar2Tk (self .canvas , self .frame01_toolbar )
336
335
self .toolbar .pack (side = tk .LEFT )
337
336
# self.toolbar.children['!button6'].pack_forget()
338
337
# self.toolbar.children['!button7'].pack_forget()
0 commit comments