Skip to content

Commit

Permalink
Merge pull request #3 from damies13/v0.5.1
Browse files Browse the repository at this point in the history
V0.5.1
  • Loading branch information
damies13 authored Apr 19, 2020
2 parents 9977e83 + 5f4c4ca commit 2c9e44d
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 39 deletions.
Binary file added Doc/Images/Logo/Orange_Trawler.xcf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Doc/Images/Logo/TC_Logo.ico
Binary file not shown.
Binary file added Doc/Images/Logo/TC_Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Doc/Images/Logo/TC_Logo.xcf
Binary file not shown.
Binary file added Doc/Images/Logo/TC_Logo128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Doc/Images/Logo/TC_Logo16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Doc/Images/Logo/TC_Logo2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Doc/Images/Logo/TC_Logo256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Doc/Images/Logo/TC_Logo32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Doc/Images/Logo/TC_Logo64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
117 changes: 83 additions & 34 deletions TC.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Screen Capture tool for testers, to make documenting test cases easier.
#
#
# Version v0.5.0
# Version v0.5.1
#

#
Expand Down Expand Up @@ -34,6 +34,9 @@
import os

from xml.etree import ElementTree
# pip install python-docx
from docx import Document
from docx.shared import Cm

from elevate import elevate
#
Expand Down Expand Up @@ -67,7 +70,7 @@
class Settings:
capturefullscreen = True
capturescreennumb = 99
version = "v0.5.0"
version = "v0.5.1"

title = "Trawler Capture"
# hkeys = ["F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "key"]
Expand All @@ -82,6 +85,7 @@ class Settings:

def __init__(self, master):
self.master = master
# self.master.iconbitmap('TC_Logo.ico')
self.frame = tk.Frame(self.master)
self.master.title(self.title + " - " + self.version)
self.outdir = os.path.dirname(__file__)
Expand All @@ -99,6 +103,18 @@ def __init__(self, master):

rowno += 1

# https://python-docx.readthedocs.io/en/latest/api/text.html#paragraph-objects
fmtl = ttk.Label(self.master, text = "Output format:")
fmtl.grid(row = rowno, column = 0, sticky = 'W', pady = 2, columnspan=2)
self.html = tk.IntVar(value=1)
fmth = ttk.Checkbutton(self.master, text="HTML + PNG's", variable=self.html)
fmth.grid(row = rowno, column = 2, sticky = 'E', pady = 2)
self.docx = tk.IntVar(value=0)
fmtd = ttk.Checkbutton(self.master, text="DOCX", variable=self.docx)
fmtd.grid(row = rowno, column = 3, sticky = 'E', pady = 2)

rowno += 1

hk1l = ttk.Label(self.master, text = "Hotkey to return to this screen:")
# hk1k = ttk.Label(self.master, text = self.hkey["Return"])
self.hk1txt = tk.StringVar()
Expand Down Expand Up @@ -231,27 +247,36 @@ def Start_Capture(self):
# html = self.et.find('html')
# # print("html", html)
# head = ElementTree.SubElement(html, 'head')

self.et = ElementTree.Element('html')
print("et", self.et)
head = ElementTree.SubElement(self.et, 'head')
print("head", head)

title = ElementTree.SubElement(head, 'title')
datafiletime = datetime.now().strftime("%Y%m%d_%H%M%S")
datatime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
mytitle = self.title + " - " + datatime
title.text = str(mytitle)

style = ElementTree.SubElement(head, 'style')
styletxt = "img{ max-height:500px; max-width:500px; height:auto; width:auto; }"
style.text = str(styletxt)


body = ElementTree.SubElement(self.et, 'body')
h1 = ElementTree.SubElement(body, 'h1')
h1.text = str(mytitle)
self.etfname = 'Capture_'+datafiletime+'.html'
print("self.html.get()", self.html.get())
if self.html.get():
self.et = ElementTree.Element('html')
print("et", self.et)
head = ElementTree.SubElement(self.et, 'head')
print("head", head)

title = ElementTree.SubElement(head, 'title')
datafiletime = datetime.now().strftime("%Y%m%d_%H%M%S")
datatime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
mytitle = self.title + " - " + datatime
title.text = str(mytitle)

style = ElementTree.SubElement(head, 'style')
styletxt = "img{ max-height:500px; max-width:500px; height:auto; width:auto; }"
style.text = str(styletxt)

body = ElementTree.SubElement(self.et, 'body')
h1 = ElementTree.SubElement(body, 'h1')
h1.text = str(mytitle)
self.etfname = 'Capture_'+datafiletime+'.html'

print("self.docx.get()", self.docx.get())
if self.docx.get():
self.doc = Document()
datatime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
self.doc.add_heading(self.title + " - " + datatime, 0)

datafiletime = datetime.now().strftime("%Y%m%d_%H%M%S")
self.docxfname = 'Capture_'+datafiletime+'.docx'

self.Start_HotKeys()
self.master.withdraw()
Expand Down Expand Up @@ -368,6 +393,7 @@ def getActiveWindowBBox(self):
class TC_Capture:
def __init__(self, master):
self.master = master
# self.master.iconbitmap('TC_Logo.ico')
self.frame = tk.Frame(self.master, width=790, height=590)
self.master.protocol("WM_DELETE_WINDOW", self.on_closing)

Expand Down Expand Up @@ -449,23 +475,45 @@ def _save(self):
imgComments = self.imgComments.get("1.0",'end-1c')
print("_save: imgComments:", imgComments)
datafiletime = datetime.now().strftime("%Y%m%d_%H%M%S")

self.imfname = 'screenshot_'+datafiletime+'.png'
print("_save: imfname:", self.imfname)
self.imfile = os.path.join(self.parent.outdir, self.imfname)
self.parent.im.save(self.imfile)

# self.et self.etfname
body = self.parent.et.find("body")
tagdiv = ElementTree.SubElement(body, 'div')
tagdiv.set("id", self.imfname)
tagimg = ElementTree.SubElement(tagdiv, 'img')
tagimg.set("src", "./"+self.imfname)
tagp = ElementTree.SubElement(tagdiv, 'p')
tagp.text = str(imgComments)
if self.parent.html.get():

# self.et self.etfname
body = self.parent.et.find("body")
tagdiv = ElementTree.SubElement(body, 'div')
tagdiv.set("id", self.imfname)
tagimg = ElementTree.SubElement(tagdiv, 'img')
tagimg.set("src", "./"+self.imfname)
tagp = ElementTree.SubElement(tagdiv, 'p')
tagp.text = str(imgComments)

etf = os.path.join(self.parent.outdir, self.parent.etfname)
tree = ElementTree.ElementTree(self.parent.et)
tree.write(etf)

if self.parent.docx.get():

# self.parent.docx
paragraph = self.parent.doc.add_paragraph()
paragraph.paragraph_format.keep_together = True
run = paragraph.add_run()
# dispImg = ImageTk.PhotoImage(self.parent.im.tobytes())
# run.add_picture(self.imfile)
# docx.shared.Cm
run.add_picture(self.imfile, width=Cm(15))
run.add_text(str(imgComments))

# self.docxfname = 'Capture_'+datafiletime+'.docx'
docxf = os.path.join(self.parent.outdir, self.parent.docxfname)
self.parent.doc.save(docxf)

etf = os.path.join(self.parent.outdir, self.parent.etfname)
tree = ElementTree.ElementTree(self.parent.et)
tree.write(etf)
if self.parent.html.get() == 0:
os.remove(self.imfile)

self.on_closing()

Expand Down Expand Up @@ -542,6 +590,7 @@ def main():
elevate(graphical=False)
# pass
root = tk.Tk()
# root.iconbitmap('TC_Logo.ico')
app = Settings(root)
root.mainloop()

Expand Down
Binary file added TC_Logo.ico
Binary file not shown.
Binary file added bin/TC_v0.5.1_Mac.zip
Binary file not shown.
Binary file added bin/TC_v0.5.1_Win.zip
Binary file not shown.
8 changes: 6 additions & 2 deletions bin/mk_bin_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
cd "$(dirname "$0")/.."


export VERSION="v0.5.0"
export VERSION="v0.5.1"


export OPTIONS="-y"
Expand All @@ -13,7 +13,10 @@ export OPTIONS="$OPTIONS -w"
# increase log level
export OPTIONS="$OPTIONS --log-level=DEBUG"


# Icon -i Doc/Images/Logo/TC_Logo.ico
export OPTIONS="$OPTIONS -i TC_Logo.ico"
# set OPTIONS="%OPTIONS:"=% --add-binary Doc\Images\Logo\tclogo.ico;.\Doc\Images\Logo"
# export OPTIONS="$OPTIONS --add-binary TC_Logo.ico:."

# --distpath
# C:\Users\Dave\AppData\Local\Programs\Python\Python37\Lib\site-packages\pyscreenshot
Expand All @@ -23,5 +26,6 @@ export OPTIONS="$OPTIONS --log-level=DEBUG"
pyinstaller $OPTIONS --distpath "bin" "TC.py"

cd bin
rm -f TC_$(echo $VERSION)_Mac.zip
zip -r TC_$(echo $VERSION)_Mac.zip TC TC.app
cd -
11 changes: 8 additions & 3 deletions bin/mk_bin_win.bat
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@

cd /d %dp0/..

set VERSION=v0.5.0
set VERSION=v0.5.1

:: pyinstaller -y "Z:/TrawlerCapture/TC.py"

:: pyinstaller -y -F -w "Z:/TrawlerCapture/TC.py"

set OPTIONS="-y"
:: Singlae file
:: Single file
set OPTIONS="%OPTIONS:"=% -F"
:: Hide Commandwindow
set OPTIONS="%OPTIONS:"=% -w"
:: increase log level
set OPTIONS="%OPTIONS:"=% --log-level=DEBUG"
:: set OPTIONS="%OPTIONS:"=% --log-level=DEBUG"

:: Using this option creates a Manifest which will request elevation upon application restart.
:: set OPTIONS="%OPTIONS:"=% --uac-admin"
:: Using this option allows an elevated application to work with Remote Desktop.
:: set OPTIONS="%OPTIONS:"=% --uac-uiaccess"

# Icon -i Doc/Images/Logo/TC_Logo.ico
set OPTIONS="%OPTIONS:"=% -i TC_Logo.ico"
:: set OPTIONS="%OPTIONS:"=% --add-binary Doc/Images/Logo/tclogo.ico;./Doc/Images/Logo"
set OPTIONS="%OPTIONS:"=% --add-binary TC_Logo.ico;."

:: --distpath

Expand All @@ -31,5 +35,6 @@ set OPTIONS="%OPTIONS:"=% --log-level=DEBUG"
pyinstaller %OPTIONS:"=% --distpath "Z:/TrawlerCapture/bin" "Z:/TrawlerCapture/TC.py"

cd bin
del /f /q TC_%VERSION%_Win.zip
powershell Compress-Archive TC.exe TC_%VERSION%_Win.zip
cd ..

0 comments on commit 2c9e44d

Please sign in to comment.