multithreading - Python Threading, loading one thread after another -


I am working on a media player and am able to load in a single and run it. As seen in the code below.

  foo = wx.FileDialog (auto, message = "open .wav file ...", defaultDir = os.getcwd (), defaultFile = "", style = wx.FD_MULTIPLE) foo .ShowModal () qi = foo.GetPaths () self.playing_thread = threading.Thread (target = self.playFile, args = (line [0], 'msg')) self.playing_thread Start ()  

But the problem is, when I call the above code multiple. Attempt to create WAV files in a loop. Such is that while play_thread.isActive == is true, create and Start () threads, then load .isActive == incorrect, pop queue [0] and the next .wav file. The problem is that my UI will stop and I have to end the program. Any thoughts would be appreciated.

Since wx.python is using, use a delay, see wx demo A complete example for.

Complete the least example:

  import wx import wx.lib.delayedresult as ingg import time category player (wx.frame): def __init __ (self) : Self.titulo = "Music Player" wx.Frame .__ init __ (self, none, -1, auto.titil), 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 (auto panel, - 1, "Playlist Play") auto. Bund (wx.EVT_BUTTON, self. Startuping, self-action) self V. B. Add (self.msg, 0, wx.EXPAND | wx.ALL, 3) self Vb Add (auto .action, 0, wx.EXPAND | wx.ALL, 3) self Panel Ksetsjr (own. Vb) self.Show () def St ArtPlaying (self, evt): self.BgProcess (self.Playme) Def Playme (self, JobID, abortEvent): print "BG" list = self.getPlayList () Print list for music in the list: self.msg.SetLabel ('Playing:% s'% Music) Stop = 100 while Stop & gt; 0 Print Stop Stop - = 1 Self MMS Sset label ( "Playing:% s [% s] '% (music stops)) def _resultConsumer (self, inbg): jobID = inbg.getJobID () try: result = ( Self), self-playlist (self, music): self.playlist.appdend (music) def BG ProCris (self, executable): self. AbortEvent.clear () self.jobID + = 1 inbg.startWorker (self K_sent consumer, executor, wargs = (self.jobID, self.abortEvent), jobID = self.jobID) app = wx.App (wrong) demo = Player () App.MainLoop ()  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -