|
104 | 104 | import tkinter.simpledialog as tksd |
105 | 105 | from tkinter import ttk |
106 | 106 | except ImportError: |
107 | | - raise ImportError("tkinter is not installed (`apt install python3-tk` on debian)") |
| 107 | + tk = None |
108 | 108 |
|
109 | 109 | # CCache |
110 | 110 | # https://web.mit.edu/kerberos/krb5-latest/doc/formats/ccache_file_format.html (official doc but garbage) |
@@ -279,63 +279,63 @@ class CCache(Packet): |
279 | 279 | # Credits to @mp035 |
280 | 280 | # https://gist.github.com/mp035/9f2027c3ef9172264532fcd6262f3b01 |
281 | 281 |
|
| 282 | +if tk is not None: |
| 283 | + class ScrollFrame(tk.Frame): |
| 284 | + def __init__(self, parent): |
| 285 | + super().__init__(parent) |
282 | 286 |
|
283 | | -class ScrollFrame(tk.Frame): |
284 | | - def __init__(self, parent): |
285 | | - super().__init__(parent) |
| 287 | + self.canvas = tk.Canvas(self, borderwidth=0) |
| 288 | + self.viewPort = ttk.Frame(self.canvas) |
| 289 | + self.vsb = tk.Scrollbar(self, orient="vertical", command=self.canvas.yview) |
| 290 | + self.canvas.configure(yscrollcommand=self.vsb.set) |
286 | 291 |
|
287 | | - self.canvas = tk.Canvas(self, borderwidth=0) |
288 | | - self.viewPort = ttk.Frame(self.canvas) |
289 | | - self.vsb = tk.Scrollbar(self, orient="vertical", command=self.canvas.yview) |
290 | | - self.canvas.configure(yscrollcommand=self.vsb.set) |
291 | | - |
292 | | - self.vsb.pack(side="right", fill="y") |
293 | | - self.canvas.pack(side="left", fill="both", expand=True) |
294 | | - self.canvas_window = self.canvas.create_window( |
295 | | - (4, 4), window=self.viewPort, anchor="nw", tags="self.viewPort" |
296 | | - ) |
| 292 | + self.vsb.pack(side="right", fill="y") |
| 293 | + self.canvas.pack(side="left", fill="both", expand=True) |
| 294 | + self.canvas_window = self.canvas.create_window( |
| 295 | + (4, 4), window=self.viewPort, anchor="nw", tags="self.viewPort" |
| 296 | + ) |
297 | 297 |
|
298 | | - self.viewPort.bind("<Configure>", self.onFrameConfigure) |
299 | | - self.canvas.bind("<Configure>", self.onCanvasConfigure) |
| 298 | + self.viewPort.bind("<Configure>", self.onFrameConfigure) |
| 299 | + self.canvas.bind("<Configure>", self.onCanvasConfigure) |
300 | 300 |
|
301 | | - self.viewPort.bind("<Enter>", self.onEnter) |
302 | | - self.viewPort.bind("<Leave>", self.onLeave) |
| 301 | + self.viewPort.bind("<Enter>", self.onEnter) |
| 302 | + self.viewPort.bind("<Leave>", self.onLeave) |
303 | 303 |
|
304 | | - self.onFrameConfigure(None) |
| 304 | + self.onFrameConfigure(None) |
305 | 305 |
|
306 | | - def onFrameConfigure(self, event): |
307 | | - """Reset the scroll region to encompass the inner frame""" |
308 | | - self.canvas.configure(scrollregion=self.canvas.bbox("all")) |
| 306 | + def onFrameConfigure(self, event): |
| 307 | + """Reset the scroll region to encompass the inner frame""" |
| 308 | + self.canvas.configure(scrollregion=self.canvas.bbox("all")) |
309 | 309 |
|
310 | | - def onCanvasConfigure(self, event): |
311 | | - """Reset the canvas window to encompass inner frame when required""" |
312 | | - canvas_width = event.width |
313 | | - self.canvas.itemconfig(self.canvas_window, width=canvas_width) |
| 310 | + def onCanvasConfigure(self, event): |
| 311 | + """Reset the canvas window to encompass inner frame when required""" |
| 312 | + canvas_width = event.width |
| 313 | + self.canvas.itemconfig(self.canvas_window, width=canvas_width) |
314 | 314 |
|
315 | | - def onMouseWheel(self, event): |
316 | | - if platform.system() == "Windows": |
317 | | - self.canvas.yview_scroll(int(-1 * (event.delta / 120)), "units") |
318 | | - elif platform.system() == "Darwin": |
319 | | - self.canvas.yview_scroll(int(-1 * event.delta), "units") |
320 | | - else: |
321 | | - if event.num == 4: |
322 | | - self.canvas.yview_scroll(-1, "units") |
323 | | - elif event.num == 5: |
324 | | - self.canvas.yview_scroll(1, "units") |
325 | | - |
326 | | - def onEnter(self, event): |
327 | | - if platform.system() == "Linux": |
328 | | - self.canvas.bind_all("<Button-4>", self.onMouseWheel) |
329 | | - self.canvas.bind_all("<Button-5>", self.onMouseWheel) |
330 | | - else: |
331 | | - self.canvas.bind_all("<MouseWheel>", self.onMouseWheel) |
| 315 | + def onMouseWheel(self, event): |
| 316 | + if platform.system() == "Windows": |
| 317 | + self.canvas.yview_scroll(int(-1 * (event.delta / 120)), "units") |
| 318 | + elif platform.system() == "Darwin": |
| 319 | + self.canvas.yview_scroll(int(-1 * event.delta), "units") |
| 320 | + else: |
| 321 | + if event.num == 4: |
| 322 | + self.canvas.yview_scroll(-1, "units") |
| 323 | + elif event.num == 5: |
| 324 | + self.canvas.yview_scroll(1, "units") |
| 325 | + |
| 326 | + def onEnter(self, event): |
| 327 | + if platform.system() == "Linux": |
| 328 | + self.canvas.bind_all("<Button-4>", self.onMouseWheel) |
| 329 | + self.canvas.bind_all("<Button-5>", self.onMouseWheel) |
| 330 | + else: |
| 331 | + self.canvas.bind_all("<MouseWheel>", self.onMouseWheel) |
332 | 332 |
|
333 | | - def onLeave(self, event): |
334 | | - if platform.system() == "Linux": |
335 | | - self.canvas.unbind_all("<Button-4>") |
336 | | - self.canvas.unbind_all("<Button-5>") |
337 | | - else: |
338 | | - self.canvas.unbind_all("<MouseWheel>") |
| 333 | + def onLeave(self, event): |
| 334 | + if platform.system() == "Linux": |
| 335 | + self.canvas.unbind_all("<Button-4>") |
| 336 | + self.canvas.unbind_all("<Button-5>") |
| 337 | + else: |
| 338 | + self.canvas.unbind_all("<MouseWheel>") |
339 | 339 |
|
340 | 340 |
|
341 | 341 | # Build ticketer |
@@ -1643,6 +1643,8 @@ def edit_ticket(self, i, key=None, hash=None): |
1643 | 1643 | """ |
1644 | 1644 | Edit a Kerberos ticket using the GUI |
1645 | 1645 | """ |
| 1646 | + if tk is None: |
| 1647 | + raise ImportError("tkinter is not installed (`apt install python3-tk` on debian)") |
1646 | 1648 | tkt = self.dec_ticket(i, key=key, hash=hash) |
1647 | 1649 | pac = tkt.authorizationData.seq[0].adData[0].seq[0].adData |
1648 | 1650 |
|
|
0 commit comments