Changeset dbcb255 in ammosreader for sample_scripts/ammos_viewer.py
- Timestamp:
- 07/22/22 10:53:02 (3 years ago)
- Branches:
- AmmosSource, guix
- Children:
- 5d039b8
- Parents:
- 19ee734
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sample_scripts/ammos_viewer.py
r19ee734 rdbcb255 3 3 import tkinter as tk 4 4 from PIL import Image, ImageTk 5 from random import randbytes5 # from random import randbytes 6 6 import bitstring 7 7 … … 24 24 self.cycle.set(self.ammos_container.unique_frame_sizes()[0]) 25 25 self.cache = tk.IntVar() 26 self.cache.set(500 000000)26 self.cache.set(500) 27 27 self.canvas_size = (800, 600) 28 28 self.offset = tk.IntVar() … … 39 39 self.canvas = tk.Canvas(image_frame, bg="#000000", width=self.canvas_size[0], height=self.canvas_size[1]) 40 40 self.canvas.pack() 41 pil_image = Image.frombytes(" L", self.canvas_size, self.current_bytes())41 pil_image = Image.frombytes("1", self.canvas_size, self.current_bytes()) 42 42 self.image = ImageTk.PhotoImage(pil_image) 43 43 # pil_image.show() … … 50 50 self.cycle_entry.pack(side=tk.TOP) 51 51 52 tk.Label(button_frame, text='Cache in bytes').pack(side=tk.TOP)52 tk.Label(button_frame, text='Cache in Megabytes').pack(side=tk.TOP) 53 53 self.cache_entry = tk.Entry(button_frame, text=self.cache) 54 54 self.cache_entry.pack(side=tk.TOP) … … 76 76 77 77 def current_bytes(self): 78 """I return the current bytes to display in the canvas.""" 78 79 if self.offset.get() % 8 == 0: 79 80 return b"".join([self.bytes[each: each+self.canvas_size[0]] for each in range(self.offset.get(), … … 87 88 88 89 def update_canvas(self): 90 """I update the canvas.""" 89 91 self.image = ImageTk.PhotoImage(Image.frombytes("L", self.canvas_size, self.current_bytes())) 90 92 self.canvas.itemconfig(self.image_id, image=self.image) 91 93 92 94 def load_file(self): 95 """I load a binary ammos file.""" 93 96 pass 94 97 95 98 def quit(self): 99 """I quit the application.""" 96 100 self.parent.destroy() 97 101
Note:
See TracChangeset
for help on using the changeset viewer.