我目前有一個python腳本啓動一個tkinter GUI實例,一旦點擊一個按鈕需要截圖。Python腳本tkinter解析和截圖大小運行時影響pythonw.exe
當我在python.exe下運行這個腳本時,tkinter分辨率很好,屏幕截圖捕獲了整個屏幕。但是,使用pythonw.exe時,tkinter窗口分辨率會發生變化(例如,按鈕會變大),屏幕截圖僅捕獲屏幕的一部分 - 通常爲左上角。
我需要使用pythonw.exe爲了防止出現控制檯窗口。
有誰知道爲什麼tkinter窗口的分辨率和截圖捕捉正在實施?據推測,對分辨率的影響是爲什麼屏幕截圖也被減少。
我對Python相當陌生,所以對此的任何幫助將不勝感激,下面是tkinter窗口的代碼片段和截圖功能。重申這個功能在python.exe下運行得很好。
的截圖功能使用ImageGrab:
callback1():
ImageGrab.grab_to_file('test.png')
的Tkinter的窗口:
master = Tk()
master.wm_attributes("-topmost", 1)
master.title("Report")
master.configure(background='white')
master.iconbitmap(default='icon.ico')
master.resizable(0, 0)
frame1 = Frame(master, bg='white')
frame1.pack(side=BOTTOM, fill=X)
button1 = Button(frame1, compound=BOTTOM, width=307, height=82,
image=photo1, bg='white', command=callback1)
button1.pack(side=TOP, padx=2, pady=8)