Question: Python - Tkinter - Save toplevel window as Image/PDF/Word
2
gravatar for st.ph.n
6 days ago by
st.ph.n860
Philadelphia, PA
st.ph.n860 wrote:

I'm going to preface this question, that I asked it on SO, but did not receive an answer.

I have a GUI that takes a FASTA file and makes a multi-sequence alignment, and highlights in red some amino acids in the alignment, and prints them to a toplevel window. The alignment is exactly what I want, but is there a way to save this window as a image, PDF, or Word document in order to maintain the colors? Others will be using the GUI, so 'Print Screen' is less than ideal.

tkinter python image • 124 views
ADD COMMENTlink modified 5 days ago by phdresearchproposal.org0 • written 6 days ago by st.ph.n860

Thanks for the pyscreenshot program. I also work on Linux =)

ADD REPLYlink written 5 days ago by phdresearchproposal.org0

Please use ADD COMMENT or ADD REPLY to answer to previous reactions, as such this thread remains logically structured and easy to follow. I have now moved your post but as you can see it's not optimal. Adding an answer should only be used for providing a solution to the question asked.

ADD REPLYlink written 5 days ago by WouterDeCoster19k

From what I gathered, pyscreenshot is a replacement for PIL which is used for windows.

ADD REPLYlink written 5 days ago by st.ph.n860

PIL has also other applications when using Linux, just for general image processing.

ADD REPLYlink written 5 days ago by WouterDeCoster19k
2
gravatar for st.ph.n
6 days ago by
st.ph.n860
Philadelphia, PA
st.ph.n860 wrote:

I was able to get the coordinates of the toplevel window, and height and width with the following command, then using pyscreenshot (note: using Linux for pyscreenshot), was able to save it as a jpeg.

import pyscreenshot as ImageGrab
alignment = Toplevel()
box = [alignment.winfo_x(), alignment.winfo_y(), alignment.winfo_width(), alignment.winfo_height()]
ImageGrab.grab(bbox=box).save("out_snapsave.jpg")
ADD COMMENTlink modified 6 days ago • written 6 days ago by st.ph.n860
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 823 users visited in the last hour