2014-04-30 2 views
2

아래 코드는 AppleScript를 통해 Quicktime을 열고 잠시 시간을내어 방해하지 않아야하는 파일을 처리합니다. 나는 대화창을 다른 모든 것들 위에 열어두기를 원합니다. 꼭대기에 있어야하는 것은 중요합니다. 그냥 "파일 처리 중입니다. 기다려주십시오."라고 말합니다. 이 코드는 작동하지만 applescript를 통해 quicktime이 열리면 PBI.PyBusyInfo가 사라집니다. 내가 어떻게 이걸 할 수 있니?Python PBI.PyBusyInfo가 상단에 계속됩니다.

import wx 
import os 
import os.path 
import wx.lib.agw.pybusyinfo as PBI 
from subprocess import Popen, PIPE 

class ScrolledWindow(wx.Frame): 
    def __init__(self, parent, id, title): 
     wx.Frame.__init__(self, parent, id, title, size=(510, 370), style=wx.STAY_ON_TOP | wx.DEFAULT_FRAME_STYLE & ~ (wx.RESIZE_BORDER | 
               wx.RESIZE_BOX | 
               wx.MAXIMIZE_BOX)) 

     self.tabbed = wx.Notebook(self, -1, style=(wx.NB_TOP)) 
     run_params = {} 
     run_params["dropList1"] = ['HD 1920x1080', 'PAL 4x3', 'PAL 16x9', 'NTSC 4x3', 'NTSC 16x9'] 
     run_params["dropList2"] = ['Progressive', 'Interlaced'] 

     self.CreateStatusBar() 
     menuBar = wx.MenuBar() 
     menu = wx.Menu() 
     self.SetMenuBar(menuBar) 
     panel = wx.Panel(self, -1) 
     self.Centre() 
     self.Show() 
     self.filePrep = PrepFile(self.tabbed, run_params) 
     self.tabbed.AddPage(self.filePrep, "File Prep") 

class PrepFile(wx.Panel): 
    def __init__(self, parent, run_params): 
     wx.Panel.__init__(self, parent) 

     self.run_params = run_params 
     self.fieldChoice = 'Progressive' 
     self.formatOption = 'HD 1920x1080' 

     outputOption = '''Format''' 
     wx.StaticText(self, -1, outputOption, (33, 22), style=wx.ALIGN_CENTRE) 

     self.choice1 = wx.Choice(self, pos=(35, 40), choices=self.run_params["dropList1"]) 
     self.choice1.SetSelection(0) 
     self.choice1.SetFocus() 
     self.choice1.Bind(wx.EVT_CHOICE, self.selectOption) 

     fieldSetText = '''Fields''' 
     wx.StaticText(self, -1, fieldSetText, (33, 82), style=wx.ALIGN_CENTRE) 

     self.choice2 = wx.Choice(self, pos=(35, 100), choices=self.run_params["dropList2"]) 
     self.choice2.SetSelection(0) 
     self.choice2.SetFocus() 
     self.choice2.Bind(wx.EVT_CHOICE, self.fieldSet) 

     self.buttonClose = wx.Button(self, -1, "Quit", pos=(195, 250)) 
     self.buttonClose.Bind(wx.EVT_BUTTON, self.OnClose) 

     greyBox = wx.StaticBox(self, -1, '', pos=(20, 15), size=(235, 130)) 

     outputtxt3 = '''Drag and Drop Quicktimes''' 
     wx.StaticText(self, -1, outputtxt3, pos=(35, 170), style=wx.ALIGN_CENTRE) 

     self.drop_target = MyFileDropTarget(self) 
     self.SetDropTarget(self.drop_target) 
     self.tc_files = wx.TextCtrl(self, wx.ID_ANY, pos=(38, 190), size=(200, 25)) 
     self.buttonSubmit = wx.Button(self, -1, "Submit", pos=(250,190)) 
     self.buttonSubmit.Bind(wx.EVT_BUTTON, self.submit) 

    def EvtRadioBox(self, event): 
     self.mode = (event.GetString()) 

    def selectOption(self, e): 
     self.formatOption = self.choice1.GetStringSelection() 

    def fieldSet(self, e): 
     self.fieldChoice = self.choice2.GetStringSelection() 

    def setSubmissionDrop(self, dropFiles): 
     """Called by the FileDropTarget when files are dropped""" 
     self.tc_files.SetValue(','.join(dropFiles)) 
     self.selectedFiles = dropFiles 
     print self.selectedFiles 

    def submit(self, event): 
     event.Skip() 
     message = "Please wait..." 
     busy = PBI.PyBusyInfo(message, parent=self, title="Processing Files") 
     wx.Yield() 
     for item in self.selectedFiles: 
      if os.path.isdir(item): 
       print "It is a folder!" 
       for root, dirs, files in os.walk(item): 
        for file1 in files: 
         if file1.endswith(".mov"): 
          currentFile = os.path.join(root, file1) 
          self.jesFile(currentFile) 
     print "Finished" 
     del busy 

    def doSomething(self): 
     print "Open Quicktime and process files via applescript" 

    def OnClose(self, e): 
     CloseApp() 

class MyFileDropTarget(wx.FileDropTarget): 
    """""" 
    def __init__(self, window): 
     wx.FileDropTarget.__init__(self) 
     self.window = window 

    def OnDropFiles(self, x, y, filenames): 
     self.window.setSubmissionDrop(filenames) 

app = wx.App() 
ScrolledWindow(None, -1, 'App') 
app.MainLoop() 

답변

0

귀하의 질문은 당신이 애플 스크립트를 (당신이 당신의 예제 코드에 jesFile 방법을 추가하는 것을 잊었다 것 같습니다)를 시작 전화를 누락 될 것으로 보인다. 내가 게시 된 예제에없는 귀하의 코드에 너무 많이 추측 할 수 있습니다 ...하지만 내 추측은 처리 할 호출이 차단 호출이 아니므로 차단 호출을하거나 바쁘게 할 필요가 있습니다. 비 블로킹 프로세스 호출이 반환 될 때 삭제하는 클래스 변수 (잘하면 콜백 함수를 바인딩 할 수 있습니다).

관련 문제