![]() ![]() ![]() lected_printer = self._find_current_selected_printer() lected_file = askopenfilename(title = "Choose file to print") Return in_file.read() # if you only wanted to read 512 bytes, do. With open(lected_file, "rb") as in_file: # opening for eading as inary Self.print_file.pack(side="right", padx=10) Self.print_file = tk.Button(self.bottom_frame, Self.open_file_chooser.pack(side="left", padx=10) Self.open_file_chooser = tk.Button(self.bottom_frame, Self.bottom_frame = tk.Frame(self.body, pady=5) Self.printers_frame.pack(expand=True, fill="both") ![]() Self.printers_frame = tk.Frame(self.body, bg="lightblue", padx=10, pady=10) lected_printer = None # Hols name of selected printer Self.data_bytes = None # Bytes read from the selected file to print lected_file = None # To hold the selected file's name Self.printers_names = self._find_printers_names() Self.system_default_destination = self._find_system_default_destination() # Current selected printer of your system Self.title = tk.Label(self.title_frame, text="Let's print!") Self.title_frame = tk.Frame(self.body, pady=5) Self.body = tk.Frame(self, bg="lightblue") Tk.Toplevel._init_(self, root, *args, **kwargs) Return os.path.isfile(fpath) and os.access(fpath, os.X_OK)įor path in os.environ.split(os.pathsep):ĭef _init_(self, root, *args, **kwargs): import tkinter as tkįrom tkinter.filedialog import askopenfilename Here's a program I've just created that allows you to select a printer and print. ![]()
0 Comments
Leave a Reply. |