English 中文(简体)
Python 校对,在隔 后装满一对面
原标题:Python Threading, loading one thread after another

我在媒体上工作,能够装上单枪,玩.。 如下文法所示。

  foo = wx.FileDialog(self, message="Open a .wav file...", defaultDir=os.getcwd(), defaultFile="", style=wx.FD_MULTIPLE)
  foo.ShowModal()

  queue = foo.GetPaths()

  self.playing_thread = threading.Thread(target=self.playFile, args=(queue[0],  msg ))
  self.playing_thread.start()

但问题是,当我试图将上述法典变成多个编外文件。 在玩.时 真实、创建和启动。 然后是: False, pop queue[0] andload the next .wav file. 问题在于,我的国家调查组将锁定,我不得不终止该方案。 任何想法都会受到赞赏。

问题回答

由于正在使用轮椅,因此使用传道,只看 w子。

最低实例:

import wx
import wx.lib.delayedresult as inbg
import time

class Player(wx.Frame):
    def __init__(self):


    self.titulo = "Music Player"
    wx.Frame.__init__(self, None, -1, self.titulo,)
    self.jobID = 0
    self.Vb = wx.BoxSizer(wx.VERTICAL)
    self.panel = wx.Panel(self,-1)
    self.playlist = [ one , two ]
    self.abortEvent = inbg.AbortEvent()
    self.msg = wx.StaticText(self.panel, -1, "...",pos=(30,-1))
    self.msg.SetFont(wx.Font(9, wx.SWISS, wx.NORMAL, wx.BOLD))
    self.action = wx.Button(self.panel, -1,"Play Playlist")
    self.Bind(wx.EVT_BUTTON, self.StartPlaying,self.action)

    self.Vb.Add(self.msg, 0, wx.EXPAND|wx.ALL, 3)
    self.Vb.Add(self.action, 0, wx.EXPAND|wx.ALL, 3)
    self.panel.SetSizer(self.Vb)
    self.Show()


def StartPlaying(self,evt):
    self.BgProcess(self.Playme)


def Playme(self,jobID, abortEvent):
    print "in bg"
    list = self.getPlayList()
    print list
    for music in list:

        self.msg.SetLabel( Playing: %s  % music)
        stop = 100
        while stop > 0:
            print stop
            stop -=1
            self.msg.SetLabel( Playing: %s [%s ]  % (music,stop))






def _resultConsumer(self, inbg):
    jobID = inbg.getJobID()
    try:
        result = inbg.get()
        return result
    except Exception, exc:
        return False

def getPlayList(self):
    return self.playlist

def setPlayList(self,music):
    self.playlist.appdend(music)



def BgProcess(self,executar):
    self.abortEvent.clear()
    self.jobID += 1
    inbg.startWorker(self._resultConsumer, executar, wargs=(self.jobID,self.abortEvent), jobID=self.jobID)  



app  = wx.App(False)
demo = Player()
app.MainLoop()




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签