Skip to content

Commit

Permalink
update dev code on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
rocksnow1942 committed Jan 14, 2022
1 parent aa7f211 commit f042293
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
17 changes: 4 additions & 13 deletions ScannerApp/pages/HomePage.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,21 @@ def checkUpdate(self):
ver = res.text.strip().split('=')[1].strip('"\' ')
if self.master.__version__ != ver:
self.versionVar.set('Update found.')
self.updateGithub()
time.sleep(3)
for i in range(31):
self.versionVar.set(f'Restart in {30-i}s')
time.sleep(1)
os._exit(0)
else:
self.versionVar.set(f'{self.master.__version__}')
self.versionVar.set(f'Appp Ver. {self.master.__version__}')
except Exception as e:
self.versionVar.set('Error')
self.versionVar.set('Check Update Error')
time.sleep(3600)


def updateGithub(self,):
import subprocess
subprocess.run(['git','pull'])


def create_widgets(self):
"4 buttons Maximum"
# rtBtnNames = {r.__name__:r.btnName for r in Routines}
self.versionVar = tk.StringVar()
self.versionVar.set(self.master.__version__)
# tk.Label(self,textvariable=self.versionVar,).place(x=780,y=10,anchor='ne')
tk.Button(self,textvariable=self.versionVar,command=self.updateGithub).place(x=350,y=0,height=30, width=100)
tk.Label(self,textvariable=self.versionVar).place(x=350,y=0,height=30, width=100)

tk.Button(self,text='Exit',font=('Arial',35),command=self.master.on_closing).place(
x=630,y=400,height=50,width=150)
Expand Down
28 changes: 18 additions & 10 deletions ScannerApp/utils/camera.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
import time
from PIL import Image
from datetime import datetime
from ..utils import indexToGridName,mkdir
import win32com.client, os
import pythoncom
from .pylibdmtx.pylibdmtx import decode

try:
import win32com.client as w32client
import pythoncom
except:
print('No win32com support')
w32client=None
pythoncom=None
import os
import platform
if platform.system() == 'Windows':
from .pylibdmtx.pylibdmtx import decode
else:
from pylibdmtx.pylibdmtx import decode


def onThreadStart():
pythoncom.CoInitialize()

WIA_COM = "WIA.CommonDialog"
WIA_IMG_FORMAT_PNG = "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"

WIA_COMMAND_TAKE_PICTURE="{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}"

def acquire_image_wia(saveas,dpi=300):
if pythoncom is None:
return './ScannerApp/utils/devsample.png'
pythoncom.CoInitialize()
wia = win32com.client.Dispatch(WIA_COM) # wia is a CommonDialog object
wia = w32client.Dispatch(WIA_COM) # wia is a CommonDialog object
dev = wia.ShowSelectDevice()
for command in dev.Commands:
if command.CommandID==WIA_COMMAND_TAKE_PICTURE:
Expand Down Expand Up @@ -145,8 +153,8 @@ def runScan(self,name=None):
bracket the exposure to find the best exposure
"""
file = mkdir('dtmxScan') / f'./{name or "noname"}.png'
acquire_image_wia(str(file),dpi=self.dpi)
img = Image.open(file)
saved = acquire_image_wia(str(file),dpi=self.dpi)
img = Image.open(saved)
return img


Expand Down

0 comments on commit f042293

Please sign in to comment.