A
Aleksandar Cikota
Hi all,
I have a problem with openning of an image.
Here is the Code:
from Tkinter import *
from PIL import Image, ImageTk
from win32com.client import gencache
import tkMessageBox
import win32com.client
import math
import time
import os
import threading
import pythoncom
chsr = win32com.client.Dispatch("DriverHelper.Chooser")
chsr.DeviceType = "Telescope"
scopeProgID = chsr.Choose("scopeProgID")
Scope = win32com.client.Dispatch(scopeProgID)
#Scope = win32com.client.dynamic.Dispatch('ScopeSim.Telescope')
Document = win32com.client.Dispatch('MaxIm.Document')
FM = win32com.client.Dispatch('FocusMax.FocusControl')
CCDCamera = win32com.client.Dispatch('MaxIm.CCDCamera')
Application = win32com.client.dynamic.Dispatch('MaxIm.Application')
root = Tk()
class TestThread (threading.Thread):
def __init__(self):
threading.Thread.__init__(self, name='TestThread')
def run (self):
pythoncom.CoInitialize()
try:
Document = win32com.client.Dispatch('MaxIm.Document')
FM = win32com.client.Dispatch('FocusMax.FocusControl')
CCDCamera = win32com.client.Dispatch('MaxIm.CCDCamera')
Application =
win32com.client.dynamic.Dispatch('MaxIm.Application')
path_to_watch = "F:/Images/VRT/"
before = dict ([(f, None) for f in os.listdir (path_to_watch)])
while 1:
time.sleep(2)
after2 = dict ([(f, None) for f in os.listdir (path_to_watch)])
added = [f for f in after2 if not f in before]
if added:
name= ' ,'.join (added)
if str(name[-3:])=='fit':
print name
Document.OpenFile('F:/Images/VRT/'+name)
Document.SaveFile('F:/Images/VRT/'+
str(name[0:-4])+'.jpg', 6, 512,2)
Document.SaveFile('F:/Images/VRT/lastimage.jpg',
6, 512,2)
Application.CloseAll()
image = Image.open('G:/Robot teleskop/VRT/'+
str(name[0:-4])+'.jpg')
photo = ImageTk.PhotoImage(image)
Label(image=photo).grid(row=0, column=10,
columnspan=15, rowspan=29, sticky=W+E+N+S, padx=5, pady=5)
before = after2
finally:
try:
pythoncom.CoUninitialize()
except:
pass
TestThread().start()
#[CUT]
root.mainloop()
The error message:
Exception in thread TestThread:
Traceback (most recent call last):
File "C:\Program Files\Python\lib\threading.py", line 442, in __bootstrap
self.run()
File "G:\Robot teleskop\VRT\soft\GUI.py", line 60, in run
image = Image.open('G:/Robot teleskop/VRT/'+ str(name[0:-4])+'.jpg')
AttributeError: 'function' object has no attribute 'open'
I think the modul is not imported how it should be. I hope for help.
Thanks!
Regards,
Aleksandar
I have a problem with openning of an image.
Here is the Code:
from Tkinter import *
from PIL import Image, ImageTk
from win32com.client import gencache
import tkMessageBox
import win32com.client
import math
import time
import os
import threading
import pythoncom
chsr = win32com.client.Dispatch("DriverHelper.Chooser")
chsr.DeviceType = "Telescope"
scopeProgID = chsr.Choose("scopeProgID")
Scope = win32com.client.Dispatch(scopeProgID)
#Scope = win32com.client.dynamic.Dispatch('ScopeSim.Telescope')
Document = win32com.client.Dispatch('MaxIm.Document')
FM = win32com.client.Dispatch('FocusMax.FocusControl')
CCDCamera = win32com.client.Dispatch('MaxIm.CCDCamera')
Application = win32com.client.dynamic.Dispatch('MaxIm.Application')
root = Tk()
class TestThread (threading.Thread):
def __init__(self):
threading.Thread.__init__(self, name='TestThread')
def run (self):
pythoncom.CoInitialize()
try:
Document = win32com.client.Dispatch('MaxIm.Document')
FM = win32com.client.Dispatch('FocusMax.FocusControl')
CCDCamera = win32com.client.Dispatch('MaxIm.CCDCamera')
Application =
win32com.client.dynamic.Dispatch('MaxIm.Application')
path_to_watch = "F:/Images/VRT/"
before = dict ([(f, None) for f in os.listdir (path_to_watch)])
while 1:
time.sleep(2)
after2 = dict ([(f, None) for f in os.listdir (path_to_watch)])
added = [f for f in after2 if not f in before]
if added:
name= ' ,'.join (added)
if str(name[-3:])=='fit':
print name
Document.OpenFile('F:/Images/VRT/'+name)
Document.SaveFile('F:/Images/VRT/'+
str(name[0:-4])+'.jpg', 6, 512,2)
Document.SaveFile('F:/Images/VRT/lastimage.jpg',
6, 512,2)
Application.CloseAll()
image = Image.open('G:/Robot teleskop/VRT/'+
str(name[0:-4])+'.jpg')
photo = ImageTk.PhotoImage(image)
Label(image=photo).grid(row=0, column=10,
columnspan=15, rowspan=29, sticky=W+E+N+S, padx=5, pady=5)
before = after2
finally:
try:
pythoncom.CoUninitialize()
except:
pass
TestThread().start()
#[CUT]
root.mainloop()
The error message:
Exception in thread TestThread:
Traceback (most recent call last):
File "C:\Program Files\Python\lib\threading.py", line 442, in __bootstrap
self.run()
File "G:\Robot teleskop\VRT\soft\GUI.py", line 60, in run
image = Image.open('G:/Robot teleskop/VRT/'+ str(name[0:-4])+'.jpg')
AttributeError: 'function' object has no attribute 'open'
I think the modul is not imported how it should be. I hope for help.
Thanks!
Regards,
Aleksandar