Is there any way to bring a setup page before printing in win32api?
Here's the code:
from tkinter import *
from tkinter import filedialog
from tkinter import messagebox
import win32api
root = Tk()
root.geometry("500x500")
def open_dialog():
dialog = filedialog.askopenfilename(initialdir = "C:/" , filetypes = (("Text Files" , "*.txt") , ("Python Files" , "*.py") , ("html files" , "*.html")))
if dialog != "":
box = messagebox.askyesno("Confirm" , "Are you sure you want to print this file?")
if box == 1:
win32api.ShellExecute(0 , "print" , dialog , None , "." , 0)
my_button = Button(root, text = "Select file to print" , command = open_dialog)
my_button.place(x = 190 , y = 210)
mainloop()
Here, after I open a file to print it, win32api just does it quietly and does not show any setup window.
What I want is to bring a setup window before printing so that I can change the settings according to my wish.
For example, when I try to print a file in the default windows notepad, it shows a setup window like this:
Even I want to bring a setup window like this so that I can change the settings according to my wish.
Is there any way to achieve this in win32api?
It would be great if anyone could help me out.
EDIT:
Thanks for the answer @Zhu Song - MSFT. Your answer helps me in bringing a setup window like I wanted, but I am facing some problems in printing the file.
When I try to print text files, everything is working fine, but the path of the file that I'm printing and the current page number is also being printed along with the text as a header and footer.
Here's an image:
As you can see here, there is some unnecessary text at the top and the bottom which I don't want to print.
Also when I try to print python files, the text inside the file is not being printed at all:
Is there any way to fix these issues?