def addComponents(self): self.hSizer = wx.BoxSizer(wx.HORIZONTAL) #(self, -1, wx.DefaultPosition, wx.Size(16,16),name='down') self.stopMoreButton = SwitchButton(self, -1, wx.DefaultPosition, wx.DefaultSize, name='searchStop') self.stopMoreButton.Bind(wx.EVT_LEFT_UP, self.stopMoreClicked) self.stopMoreButton.SetToolTipString(self.guiUtility.utility.lang.get('searchStop')) self.clearButton = tribler_topButton(self, -1, wx.DefaultPosition, wx.DefaultSize, name='searchClear') self.clearButton.SetToolTipString(self.guiUtility.utility.lang.get('searchClear')) self.hSizer.Add([9,5],0,wx.EXPAND|wx.FIXED_MINSIZE,0) self.hSizer.Add(self.stopMoreButton, 0, wx.ALL, 1) self.hSizer.Add(self.clearButton, 0, wx.ALL, 1) self.hSizer.Add([8,5],0,wx.EXPAND|wx.FIXED_MINSIZE,0) self.textPanel = wx.Panel(self) sizer = wx.BoxSizer(wx.HORIZONTAL) self.text = wx.StaticText(self.textPanel, -1, '') self.text.SetForegroundColour(wx.Colour(255,255,255)) sizer.Add(self.text, 1, wx.ALL, 0) self.textPanel.SetSizer(sizer) self.textPanel.SetAutoLayout(1) self.textPanel.SetForegroundColour(wx.WHITE) self.textPanel.SetBackgroundColour(wx.Colour(53,53,53)) self.text.SetSize((-1, 15)) self.hSizer.Add(self.textPanel, 1, wx.TOP|wx.EXPAND, 3) self.SetSizer(self.hSizer); self.SetAutoLayout(1); self.SetMinSize((-1, 19)) self.SetBackgroundColour(wx.Colour(53,53,53)) self.hSizer.Layout() self.Layout() self.searchBusy = True #?? #self.Show(True) self.results = {}
def addComponents(self): self.hSizer = wx.BoxSizer(wx.HORIZONTAL) #(self, -1, wx.DefaultPosition, wx.Size(16,16),name='down') self.stopMoreButton = SwitchButton(self, -1, wx.DefaultPosition, wx.DefaultSize, name='searchStop') self.stopMoreButton.Bind(wx.EVT_LEFT_UP, self.stopMoreClicked) self.stopMoreButton.SetToolTipString( self.guiUtility.utility.lang.get('searchStop')) self.clearButton = tribler_topButton(self, -1, wx.DefaultPosition, wx.DefaultSize, name='searchClear') self.clearButton.SetToolTipString( self.guiUtility.utility.lang.get('searchClear')) self.hSizer.Add([9, 5], 0, wx.EXPAND | wx.FIXED_MINSIZE, 0) self.hSizer.Add(self.stopMoreButton, 0, wx.ALL, 1) self.hSizer.Add(self.clearButton, 0, wx.ALL, 1) self.hSizer.Add([8, 5], 0, wx.EXPAND | wx.FIXED_MINSIZE, 0) self.textPanel = wx.Panel(self) sizer = wx.BoxSizer(wx.HORIZONTAL) self.text = wx.StaticText(self.textPanel, -1, '') self.text.SetForegroundColour(wx.Colour(255, 255, 255)) sizer.Add(self.text, 1, wx.ALL, 0) self.textPanel.SetSizer(sizer) self.textPanel.SetAutoLayout(1) self.textPanel.SetForegroundColour(wx.WHITE) self.textPanel.SetBackgroundColour(wx.Colour(53, 53, 53)) self.text.SetSize((-1, 15)) self.hSizer.Add(self.textPanel, 1, wx.TOP | wx.EXPAND, 3) self.SetSizer(self.hSizer) self.SetAutoLayout(1) self.SetMinSize((-1, 19)) self.SetBackgroundColour(wx.Colour(53, 53, 53)) self.hSizer.Layout() self.Layout() self.searchBusy = True #?? #self.Show(True) self.results = {}
def __init__(self, parent, utility, vlcwrap, bg, border=True): wx.Panel.__init__(self, parent, -1) self.__check_thread() self.utility = utility self.parent = parent self.border = border self.SetBackgroundColour(DEFAULT_BACKGROUND) self.volume = 0.48 self.oldvolume = 0.48 self.estduration = None self.fullscreen_enabled = False self.fullscreenwindow = None self.play_enabled = False self.stop_enabled = False self.scroll_enabled = False vSizer = wx.BoxSizer(wx.VERTICAL) if border: self.SetMinSize((34, -1)) images = ("minimize.png", "maximize.png") images = [ os.path.join(self.utility.getPath(), LIBRARYNAME, "Main", "vwxGUI", "images", image) for image in images ] self.header = PlayerHeader(self, self, bg, [], images[0], images[1]) vSizer.Add(self.header, 0, wx.EXPAND) hSizer = wx.BoxSizer(wx.HORIZONTAL) self.leftLine = wx.Panel(self, size=(1, -1)) self.leftLine.SetBackgroundColour(bg) mainbox = wx.BoxSizer(wx.VERTICAL) self.rightLine = wx.Panel(self, size=(1, -1)) self.rightLine.SetBackgroundColour(bg) hSizer.Add(self.leftLine, 0, wx.EXPAND) hSizer.Add(mainbox, 1, wx.EXPAND) hSizer.Add(self.rightLine, 0, wx.EXPAND) vSizer.Add(hSizer, 1, wx.EXPAND) footer = ListFooter(self) footer.SetBackgroundColour(bg) vSizer.Add(footer, 0, wx.EXPAND) else: mainbox = vSizer self.vlcwrap = vlcwrap if vlcwrap is not None: self.vlcwin = VLCLogoWindow(self, utility, vlcwrap, bg, animate=True) self.vlcwin.SetMinSize(EmbeddedPlayerPanel.VIDEO_SIZE) if border: player_img = os.path.join(self.utility.getPath(), LIBRARYNAME, "Main", "vwxGUI", "images", "player.png") self.player_img = wx.StaticBitmap( self, -1, wx.BitmapFromImage(wx.Image(player_img, wx.BITMAP_TYPE_ANY)) ) mainbox.Add(self.player_img, 0, wx.ALIGN_CENTER | wx.TOP, 5) mainbox.Add(self.vlcwin, 1, wx.EXPAND, 0) self.ctrlsizer = wx.BoxSizer(wx.HORIZONTAL) self.slider = ProgressSlider(self, self.utility) self.slider.SetRange(0, 1) self.slider.SetValue(0) self.mute = SwitchButton(self, name="mt") self.mute.Bind(wx.EVT_LEFT_UP, self.MuteClicked) self.ppbtn = PlayerSwitchButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "pause", "play" ) self.ppbtn.Bind(wx.EVT_LEFT_UP, self.PlayPause) self.ppbtn.setSelected(2) self.sbtn = PlayerButton(self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "stop") self.sbtn.Bind(wx.EVT_LEFT_UP, self.OnStop) self.sbtn.setSelected(2) volumebox = wx.BoxSizer(wx.HORIZONTAL) self.vol1 = PlayerButton(self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "vol1") self.vol1.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol2 = PlayerButton(self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "vol2") self.vol2.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol3 = PlayerButton(self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "vol3") self.vol3.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol4 = PlayerButton(self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "vol4") self.vol4.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol5 = PlayerButton(self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "vol5") self.vol5.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol6 = PlayerButton(self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "vol6") self.vol6.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) volumebox.Add(self.vol1, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol2, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol3, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol4, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol5, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol6, 0, wx.ALIGN_CENTER_VERTICAL) self.updateVol(self.volume) self.fsbtn = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "fullScreen" ) self.fsbtn.Bind(wx.EVT_LEFT_UP, self.FullScreen) self.fsbtn.setSelected(2) self.ctrlsizer.Add(self.ppbtn, 0, wx.ALIGN_CENTER_VERTICAL) self.ctrlsizer.Add(self.sbtn, 0, wx.ALIGN_CENTER_VERTICAL) self.ctrlsizer.Add(self.slider, 1, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) self.ctrlsizer.Add(self.mute, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) self.ctrlsizer.Add(volumebox, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) self.ctrlsizer.Add(self.fsbtn, 0, wx.ALIGN_CENTER_VERTICAL) mainbox.Add(self.ctrlsizer, 0, wx.ALIGN_BOTTOM | wx.EXPAND | wx.LEFT | wx.RIGHT, 3) if border: self.vlcwin.Show(False) self.ctrlsizer.ShowItems(False) # Arno: until we figure out how to show in-playback prebuffering info self.statuslabel = wx.StaticText(self) vSizer.Add(self.statuslabel, 0, wx.EXPAND) self.SetSizer(vSizer) self.playtimer = None self.update = False self.timer = None
class EmbeddedPlayerPanel(wx.Panel): """ The Embedded Player consists of a VLCLogoWindow and the media controls such as Play/Pause buttons and Volume Control. """ VIDEO_SIZE = (320, 240) def __init__(self, parent, utility, vlcwrap, bg, border=True): wx.Panel.__init__(self, parent, -1) self.__check_thread() self.utility = utility self.parent = parent self.border = border self.SetBackgroundColour(DEFAULT_BACKGROUND) self.volume = 0.48 self.oldvolume = 0.48 self.estduration = None self.fullscreen_enabled = False self.fullscreenwindow = None self.play_enabled = False self.stop_enabled = False self.scroll_enabled = False vSizer = wx.BoxSizer(wx.VERTICAL) if border: self.SetMinSize((34, -1)) images = ("minimize.png", "maximize.png") images = [ os.path.join(self.utility.getPath(), LIBRARYNAME, "Main", "vwxGUI", "images", image) for image in images ] self.header = PlayerHeader(self, self, bg, [], images[0], images[1]) vSizer.Add(self.header, 0, wx.EXPAND) hSizer = wx.BoxSizer(wx.HORIZONTAL) self.leftLine = wx.Panel(self, size=(1, -1)) self.leftLine.SetBackgroundColour(bg) mainbox = wx.BoxSizer(wx.VERTICAL) self.rightLine = wx.Panel(self, size=(1, -1)) self.rightLine.SetBackgroundColour(bg) hSizer.Add(self.leftLine, 0, wx.EXPAND) hSizer.Add(mainbox, 1, wx.EXPAND) hSizer.Add(self.rightLine, 0, wx.EXPAND) vSizer.Add(hSizer, 1, wx.EXPAND) footer = ListFooter(self) footer.SetBackgroundColour(bg) vSizer.Add(footer, 0, wx.EXPAND) else: mainbox = vSizer self.vlcwrap = vlcwrap if vlcwrap is not None: self.vlcwin = VLCLogoWindow(self, utility, vlcwrap, bg, animate=True) self.vlcwin.SetMinSize(EmbeddedPlayerPanel.VIDEO_SIZE) if border: player_img = os.path.join(self.utility.getPath(), LIBRARYNAME, "Main", "vwxGUI", "images", "player.png") self.player_img = wx.StaticBitmap( self, -1, wx.BitmapFromImage(wx.Image(player_img, wx.BITMAP_TYPE_ANY)) ) mainbox.Add(self.player_img, 0, wx.ALIGN_CENTER | wx.TOP, 5) mainbox.Add(self.vlcwin, 1, wx.EXPAND, 0) self.ctrlsizer = wx.BoxSizer(wx.HORIZONTAL) self.slider = ProgressSlider(self, self.utility) self.slider.SetRange(0, 1) self.slider.SetValue(0) self.mute = SwitchButton(self, name="mt") self.mute.Bind(wx.EVT_LEFT_UP, self.MuteClicked) self.ppbtn = PlayerSwitchButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "pause", "play" ) self.ppbtn.Bind(wx.EVT_LEFT_UP, self.PlayPause) self.ppbtn.setSelected(2) self.sbtn = PlayerButton(self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "stop") self.sbtn.Bind(wx.EVT_LEFT_UP, self.OnStop) self.sbtn.setSelected(2) volumebox = wx.BoxSizer(wx.HORIZONTAL) self.vol1 = PlayerButton(self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "vol1") self.vol1.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol2 = PlayerButton(self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "vol2") self.vol2.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol3 = PlayerButton(self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "vol3") self.vol3.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol4 = PlayerButton(self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "vol4") self.vol4.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol5 = PlayerButton(self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "vol5") self.vol5.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol6 = PlayerButton(self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "vol6") self.vol6.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) volumebox.Add(self.vol1, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol2, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol3, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol4, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol5, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol6, 0, wx.ALIGN_CENTER_VERTICAL) self.updateVol(self.volume) self.fsbtn = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, "Video", "Images"), "fullScreen" ) self.fsbtn.Bind(wx.EVT_LEFT_UP, self.FullScreen) self.fsbtn.setSelected(2) self.ctrlsizer.Add(self.ppbtn, 0, wx.ALIGN_CENTER_VERTICAL) self.ctrlsizer.Add(self.sbtn, 0, wx.ALIGN_CENTER_VERTICAL) self.ctrlsizer.Add(self.slider, 1, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) self.ctrlsizer.Add(self.mute, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) self.ctrlsizer.Add(volumebox, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) self.ctrlsizer.Add(self.fsbtn, 0, wx.ALIGN_CENTER_VERTICAL) mainbox.Add(self.ctrlsizer, 0, wx.ALIGN_BOTTOM | wx.EXPAND | wx.LEFT | wx.RIGHT, 3) if border: self.vlcwin.Show(False) self.ctrlsizer.ShowItems(False) # Arno: until we figure out how to show in-playback prebuffering info self.statuslabel = wx.StaticText(self) vSizer.Add(self.statuslabel, 0, wx.EXPAND) self.SetSizer(vSizer) self.playtimer = None self.update = False self.timer = None def mouseAction(self, event): if event.LeftDown(): if self.mute.isToggled(): # unmute self.mute.setToggled(False) if event.GetEventObject().GetImageName() == "vol1": self.volume = 0.16 if event.GetEventObject().GetImageName() == "vol2": self.volume = 0.32 if event.GetEventObject().GetImageName() == "vol3": self.volume = 0.48 if event.GetEventObject().GetImageName() == "vol4": self.volume = 0.64 if event.GetEventObject().GetImageName() == "vol5": self.volume = 0.80 if event.GetEventObject().GetImageName() == "vol6": self.volume = 1.00 self.oldvolume = self.volume self.updateVol(self.volume) self.SetVolume(self.volume) elif event.Entering(): if event.GetEventObject().GetImageName() == "vol1": volume = 0.16 if event.GetEventObject().GetImageName() == "vol2": volume = 0.32 if event.GetEventObject().GetImageName() == "vol3": volume = 0.48 if event.GetEventObject().GetImageName() == "vol4": volume = 0.64 if event.GetEventObject().GetImageName() == "vol5": volume = 0.80 if event.GetEventObject().GetImageName() == "vol6": volume = 1.00 self.updateVol(volume) elif event.Leaving(): self.updateVol(self.volume) def MuteClicked(self, event): if self.mute.isToggled(): self.volume = self.oldvolume else: self.volume = 0 self.updateVol(self.volume) self.SetVolume(self.volume) self.mute.setToggled(not self.mute.isToggled()) def updateVol(self, volume): # updates the volume bars in the gui self.vol1.setSelected(volume >= 0.16) self.vol2.setSelected(volume >= 0.32) self.vol3.setSelected(volume >= 0.48) self.vol4.setSelected(volume >= 0.64) self.vol5.setSelected(volume >= 0.80) self.vol6.setSelected(volume >= 1.00) def Load(self, url, streaminfo=None): self.__check_thread() if DEBUG: print >>sys.stderr, "embedplay: Load:", url, streaminfo, currentThread().getName() ##self.SetPlayerStatus('') if streaminfo is not None: self.estduration = streaminfo.get("estduration", None) # 19/02/10 Boudewijn: no self.slider when self.vlcwrap is None # 26/05/09 Boudewijn: when using the external player we do not have a vlcwrap if self.vlcwrap: # Arno: hack: disable dragging when not playing from file. if url is None or url.startswith("http:"): self.slider.DisableDragging() else: self.slider.EnableDragging() # Arno, 2009-02-17: If we don't do this VLC gets the wrong playlist somehow self.vlcwrap.stop() self.vlcwrap.playlist_clear() self.vlcwrap.load(url, streaminfo=streaminfo) # Enable update of progress slider self.update = True wx.CallAfter(self.slider.SetValue, 0) if self.timer is None: self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.UpdateSlider) self.timer.Start(500) self.enableFullScreen() self.enablePlay() self.enableStop() self.enableScroll() def StartPlay(self): """ Start playing the new item after VLC has stopped playing the old one """ if DEBUG: print >>sys.stderr, "embedplay: PlayWhenStopped" self.playtimer = DelayTimer(self) def Play(self, evt=None): self.__check_thread() if DEBUG: print >>sys.stderr, "embedplay: Play pressed" self.OnMaximize() # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap: if self.GetState() != MEDIASTATE_PLAYING: self.vlcwin.stop_animation() self.ppbtn.setToggled(False) self.vlcwrap.start() elif DEBUG: print >>sys.stderr, "embedplay: Play pressed, already playing" def Pause(self, evt=None): self.__check_thread() """ Toggle between playing and pausing of current item """ if DEBUG: print >>sys.stderr, "embedplay: Pause pressed" # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap: if self.GetState() == MEDIASTATE_PLAYING: self.ppbtn.setToggled(True) self.vlcwrap.pause() elif DEBUG: print >>sys.stderr, "embedplay: Pause pressed, not playing" def Resume(self, evt=None): self.__check_thread() if DEBUG: print >>sys.stderr, "embedplay: Resume pressed" if self.vlcwrap: if self.GetState() != MEDIASTATE_PLAYING: self.vlcwin.stop_animation() self.ppbtn.setToggled(False) self.vlcwrap.resume() def PlayPause(self, evt=None): self.__check_thread() """ Toggle between playing and pausing of current item """ if DEBUG: print >>sys.stderr, "embedplay: PlayPause pressed" # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap: self.vlcwrap.resume() self.ppbtn.setToggled(not self.ppbtn.isToggled()) def Seek(self, evt=None): self.__check_thread() if DEBUG: print >>sys.stderr, "embedplay: Seek" # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap: oldsliderpos = self.slider.GetValue() # print >>sys.stderr, 'embedplay: Seek: GetValue returned,',oldsliderpos pos = int(oldsliderpos * 1000.0) # print >>sys.stderr, 'embedplay: Seek: newpos',pos try: if self.GetState() == MEDIASTATE_STOPPED: self.vlcwrap.start(pos) else: self.vlcwrap.set_media_position(pos) except: print_exc() if DEBUG: print >>sys.stderr, "embedplay: could not seek" self.slider.SetValue(oldsliderpos) self.update = True def enableScroll(self): self.scroll_enabled = True # 19/02/10 Boudewijn: no self.slider when self.vlcwrap is None if self.vlcwrap: self.slider.EnableDragging() def disableScroll(self): self.scroll_enabled = False # 19/02/10 Boudewijn: no self.slider when self.vlcwrap is None if self.vlcwrap: self.slider.DisableDragging() def enablePlay(self): self.play_enabled = True self.ppbtn.setSelected(False) def disablePlay(self): self.play_enabled = False self.ppbtn.setSelected(2) def enableStop(self): self.stop_enabled = True self.sbtn.setSelected(False) def disableStop(self): self.stop_enabled = False self.sbtn.setSelected(2) def enableFullScreen(self): self.fullscreen_enabled = True self.fsbtn.setSelected(False) def disableFullScreen(self): self.fullscreen_enabled = False self.fsbtn.setSelected(2) def FullScreen(self, evt=None): # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap and self.fullscreen_enabled: self._ToggleFullScreen() def OnFullScreenKey(self, event): if event.GetUnicodeKey() == wx.WXK_ESCAPE: self._ToggleFullScreen() elif event.GetUnicodeKey() == wx.WXK_SPACE: self._TogglePause() def _TogglePause(self): if self.GetState() == MEDIASTATE_PLAYING: self.vlcwrap.pause() else: self.vlcwrap.resume() def _ToggleFullScreen(self): self.__check_thread() if isinstance(self.parent, wx.Frame): # are we shown in popup frame if self.ctrlsizer.IsShown(0): # we are not in fullscreen -> ctrlsizer is showing self.parent.ShowFullScreen(True) self.ctrlsizer.ShowItems(False) self.statuslabel.Show(False) self.Layout() # Niels: 07-03-2012, only evt_close seems to work :( quitId = wx.NewId() pauseId = wx.NewId() self.parent.Bind(wx.EVT_MENU, lambda event: self._ToggleFullScreen(), id=quitId) self.parent.Bind(wx.EVT_MENU, lambda event: self._TogglePause(), id=pauseId) self.parent.Bind(wx.EVT_CLOSE, lambda event: self._ToggleFullScreen()) self.parent.Bind(wx.EVT_LEFT_DCLICK, lambda event: self._ToggleFullScreen()) accelerators = [(wx.ACCEL_NORMAL, wx.WXK_ESCAPE, quitId), (wx.ACCEL_CTRL, wx.WXK_SPACE, pauseId)] self.parent.SetAcceleratorTable(wx.AcceleratorTable(accelerators)) else: self.parent.ShowFullScreen(False) self.ctrlsizer.ShowItems(True) self.statuslabel.Show(True) self.Layout() self.parent.SetAcceleratorTable(wx.NullAcceleratorTable) self.parent.Unbind(wx.EVT_CLOSE) else: # saving media player state cur_time = self.vlcwrap.get_media_position() cur_state = self.vlcwrap.get_our_state() self.vlcwrap.stop() if not self.fullscreenwindow: # create a new top level frame where to attach the vlc widget and # render the fullscreen video self.fullscreenwindow = wx.Frame(None, title="FullscreenVLC") self.fullscreenwindow.SetBackgroundColour("BLACK") eventPanel = wx.Panel(self.fullscreenwindow) eventPanel.SetBackgroundColour(wx.BLACK) eventPanel.Bind(wx.EVT_KEY_DOWN, lambda event: self.OnFullScreenKey(event)) self.fullscreenwindow.Bind(wx.EVT_CLOSE, lambda event: self._ToggleFullScreen()) self.fullscreenwindow.ShowFullScreen(True) eventPanel.SetFocus() self.vlcwrap.set_window(self.fullscreenwindow) else: self.TellLVCWrapWindow4Playback() self.fullscreenwindow.Destroy() self.fullscreenwindow = None # restoring state if cur_state == MEDIASTATE_PLAYING: self.vlcwrap.start(cur_time) elif cur_state == MEDIASTATE_PAUSED: self.vlcwrap.start(cur_time) def doPause(cur_time): self.vlcwrap.pause() self.vlcwrap.set_media_position(cur_time) wx.CallLater(500, doPause, cur_time) def Save(self, evt=None): # save media content in different directory if self.save_button.isToggled(): self.save_callback() def SetVolume(self, volume, evt=None): if DEBUG: print >>sys.stderr, "embedplay: SetVolume:", self.volume # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap: self.vlcwrap.sound_set_volume(volume) ## float(self.volume.GetValue()) / 100 def OnStop(self, event): if self.vlcwrap and self.stop_enabled: self.Stop() self.disableStop() def Stop(self): self.__check_thread() if DEBUG: print >>sys.stderr, "embedplay: Stop" self.OnMinimize() # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap: self.vlcwrap.stop() self.ppbtn.SetLabel(self.utility.lang.get("playprompt")) self.slider.ResetTime() self.slider.SetValue(0) self.disableFullScreen() self.disablePlay() self.disableScroll() if self.timer is not None: self.timer.Stop() def GetState(self): """ Returns the state of VLC as summarized by Fabian: MEDIASTATE_PLAYING, MEDIASTATE_PAUSED, MEDIASTATE_STOPPED """ # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap: status = self.vlcwrap.get_our_state() if DEBUG: print >>sys.stderr, "embedplay: GetState", status return status # catchall return MEDIASTATE_STOPPED def Reset(self): self.Stop() self.UpdateProgressSlider([False]) # # Control on-screen information # @forceWxThread def UpdateStatus(self, playerstatus, pieces_complete): self.SetPlayerStatus(playerstatus) if self.vlcwrap is not None: self.UpdateProgressSlider(pieces_complete) def SetPlayerStatus(self, s): if sys.platform == "win32": s = "\n".join(wrap(s, 64)) self.SetLoadingText(s) def SetContentName(self, s): self.vlcwin.set_content_name(s) def SetContentImage(self, wximg): self.vlcwin.set_content_image(wximg) def SetLoadingText(self, text): if text == None: text = "" if text != self.statuslabel.GetLabel(): self.statuslabel.SetLabel(text) self.statuslabel.Refresh() self.Layout() # # Internal methods # def UpdateProgressSlider(self, pieces_complete): # 19/02/10 Boudewijn: no self.slider when self.vlcwrap is None if self.vlcwrap: self.slider.setBufferFromPieces(pieces_complete) self.slider.Refresh() def DisableInput(self): # return # Not currently used self.ppbtn.Disable() # 19/02/10 Boudewijn: no self.slider when self.vlcwrap is None if self.vlcwrap: self.slider.Disable() self.fsbtn.Disable() def UpdateSlider(self, evt): self.__check_thread() ##if not self.volumeicon.isToggled(): ## self.volume.SetValue(int(self.vlcwrap.sound_get_volume() * 100)) # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap: if self.update and self.GetState() != MEDIASTATE_STOPPED: len = self.vlcwrap.get_stream_information_length() if len == -1 or len == 0: if self.estduration is None: return else: len = int(self.estduration) else: len /= 1000 cur = self.vlcwrap.get_media_position() / 1000 self.slider.SetRange(0, len) self.slider.SetValue(cur) self.slider.SetTimePosition(float(cur), len) def StopSliderUpdate(self, evt): self.update = False def TellLVCWrapWindow4Playback(self): if self.vlcwrap is not None: self.vlcwin.tell_vclwrap_window_for_playback() def ShowLoading(self): if self.vlcwrap: self.vlcwin.show_loading() self.OnMaximize() def OnMinimize(self): if self.vlcwrap and self.border: self.SetMinSize((34, -1)) self.vlcwin.Show(False) self.ctrlsizer.ShowItems(False) self.header.ShowMinimized(False) self.statuslabel.Show(False) self.player_img.Show(True) self.utility.guiUtility.frame.Layout() def OnMaximize(self): if self.vlcwrap and self.border: self.SetMinSize((EmbeddedPlayerPanel.VIDEO_SIZE[0], -1)) self.vlcwin.Show(True) self.ctrlsizer.ShowItems(True) self.header.ShowMinimized(True) self.statuslabel.Show(True) self.player_img.Show(False) self.utility.guiUtility.frame.Layout() def __check_thread(self): if __debug__ and currentThread().getName() != "MainThread": print >>sys.stderr, "EmbeddedPlayer: __check_thread thread", currentThread().getName(), "is NOT MainThread" print_stack()
def __init__(self, parent, utility, vlcwrap, bg, border=True): wx.Panel.__init__(self, parent, -1) self.__check_thread() self.utility = utility self.parent = parent self.border = border self.SetBackgroundColour(DEFAULT_BACKGROUND) self.volume = 0.48 self.oldvolume = 0.48 self.estduration = None self.fullscreen_enabled = False self.fullscreenwindow = None self.play_enabled = False self.stop_enabled = False self.scroll_enabled = False vSizer = wx.BoxSizer(wx.VERTICAL) if border: self.SetMinSize((34, -1)) images = ("minimize.png", "maximize.png") images = [ os.path.join(self.utility.getPath(), LIBRARYNAME, "Main", "vwxGUI", "images", image) for image in images ] self.header = PlayerHeader(self, self, bg, [], images[0], images[1]) vSizer.Add(self.header, 0, wx.EXPAND) hSizer = wx.BoxSizer(wx.HORIZONTAL) self.leftLine = wx.Panel(self, size=(1, -1)) self.leftLine.SetBackgroundColour(bg) mainbox = wx.BoxSizer(wx.VERTICAL) self.rightLine = wx.Panel(self, size=(1, -1)) self.rightLine.SetBackgroundColour(bg) hSizer.Add(self.leftLine, 0, wx.EXPAND) hSizer.Add(mainbox, 1, wx.EXPAND) hSizer.Add(self.rightLine, 0, wx.EXPAND) vSizer.Add(hSizer, 1, wx.EXPAND) footer = ListFooter(self) footer.SetBackgroundColour(bg) vSizer.Add(footer, 0, wx.EXPAND) else: mainbox = vSizer self.vlcwrap = vlcwrap if vlcwrap is not None: self.vlcwin = VLCLogoWindow(self, utility, vlcwrap, bg, animate=True) self.vlcwin.SetMinSize(EmbeddedPlayerPanel.VIDEO_SIZE) if border: player_img = os.path.join(self.utility.getPath(), LIBRARYNAME, "Main", "vwxGUI", 'images', 'player.png') self.player_img = wx.StaticBitmap( self, -1, wx.BitmapFromImage(wx.Image(player_img, wx.BITMAP_TYPE_ANY))) mainbox.Add(self.player_img, 0, wx.ALIGN_CENTER | wx.TOP, 5) mainbox.Add(self.vlcwin, 1, wx.EXPAND, 0) self.ctrlsizer = wx.BoxSizer(wx.HORIZONTAL) self.slider = ProgressSlider(self, self.utility) self.slider.SetRange(0, 1) self.slider.SetValue(0) self.mute = SwitchButton(self, name='mt') self.mute.Bind(wx.EVT_LEFT_UP, self.MuteClicked) self.ppbtn = PlayerSwitchButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'pause', 'play') self.ppbtn.Bind(wx.EVT_LEFT_UP, self.PlayPause) self.ppbtn.setSelected(2) self.sbtn = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'stop') self.sbtn.Bind(wx.EVT_LEFT_UP, self.OnStop) self.sbtn.setSelected(2) volumebox = wx.BoxSizer(wx.HORIZONTAL) self.vol1 = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'vol1') self.vol1.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol2 = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'vol2') self.vol2.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol3 = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'vol3') self.vol3.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol4 = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'vol4') self.vol4.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol5 = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'vol5') self.vol5.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol6 = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'vol6') self.vol6.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) volumebox.Add(self.vol1, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol2, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol3, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol4, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol5, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol6, 0, wx.ALIGN_CENTER_VERTICAL) self.updateVol(self.volume) self.fsbtn = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'fullScreen') self.fsbtn.Bind(wx.EVT_LEFT_UP, self.FullScreen) self.fsbtn.setSelected(2) self.ctrlsizer.Add(self.ppbtn, 0, wx.ALIGN_CENTER_VERTICAL) self.ctrlsizer.Add(self.sbtn, 0, wx.ALIGN_CENTER_VERTICAL) self.ctrlsizer.Add(self.slider, 1, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) self.ctrlsizer.Add(self.mute, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) self.ctrlsizer.Add(volumebox, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) self.ctrlsizer.Add(self.fsbtn, 0, wx.ALIGN_CENTER_VERTICAL) mainbox.Add(self.ctrlsizer, 0, wx.ALIGN_BOTTOM | wx.EXPAND | wx.LEFT | wx.RIGHT, 3) if border: self.vlcwin.Show(False) self.ctrlsizer.ShowItems(False) # Arno: until we figure out how to show in-playback prebuffering info self.statuslabel = wx.StaticText(self) vSizer.Add(self.statuslabel, 0, wx.EXPAND) self.SetSizer(vSizer) self.playtimer = None self.update = False self.timer = None
class EmbeddedPlayerPanel(wx.Panel): """ The Embedded Player consists of a VLCLogoWindow and the media controls such as Play/Pause buttons and Volume Control. """ VIDEO_SIZE = (320, 240) def __init__(self, parent, utility, vlcwrap, bg, border=True): wx.Panel.__init__(self, parent, -1) self.__check_thread() self.utility = utility self.parent = parent self.border = border self.SetBackgroundColour(DEFAULT_BACKGROUND) self.volume = 0.48 self.oldvolume = 0.48 self.estduration = None self.fullscreen_enabled = False self.fullscreenwindow = None self.play_enabled = False self.stop_enabled = False self.scroll_enabled = False vSizer = wx.BoxSizer(wx.VERTICAL) if border: self.SetMinSize((34, -1)) images = ("minimize.png", "maximize.png") images = [ os.path.join(self.utility.getPath(), LIBRARYNAME, "Main", "vwxGUI", "images", image) for image in images ] self.header = PlayerHeader(self, self, bg, [], images[0], images[1]) vSizer.Add(self.header, 0, wx.EXPAND) hSizer = wx.BoxSizer(wx.HORIZONTAL) self.leftLine = wx.Panel(self, size=(1, -1)) self.leftLine.SetBackgroundColour(bg) mainbox = wx.BoxSizer(wx.VERTICAL) self.rightLine = wx.Panel(self, size=(1, -1)) self.rightLine.SetBackgroundColour(bg) hSizer.Add(self.leftLine, 0, wx.EXPAND) hSizer.Add(mainbox, 1, wx.EXPAND) hSizer.Add(self.rightLine, 0, wx.EXPAND) vSizer.Add(hSizer, 1, wx.EXPAND) footer = ListFooter(self) footer.SetBackgroundColour(bg) vSizer.Add(footer, 0, wx.EXPAND) else: mainbox = vSizer self.vlcwrap = vlcwrap if vlcwrap is not None: self.vlcwin = VLCLogoWindow(self, utility, vlcwrap, bg, animate=True) self.vlcwin.SetMinSize(EmbeddedPlayerPanel.VIDEO_SIZE) if border: player_img = os.path.join(self.utility.getPath(), LIBRARYNAME, "Main", "vwxGUI", 'images', 'player.png') self.player_img = wx.StaticBitmap( self, -1, wx.BitmapFromImage(wx.Image(player_img, wx.BITMAP_TYPE_ANY))) mainbox.Add(self.player_img, 0, wx.ALIGN_CENTER | wx.TOP, 5) mainbox.Add(self.vlcwin, 1, wx.EXPAND, 0) self.ctrlsizer = wx.BoxSizer(wx.HORIZONTAL) self.slider = ProgressSlider(self, self.utility) self.slider.SetRange(0, 1) self.slider.SetValue(0) self.mute = SwitchButton(self, name='mt') self.mute.Bind(wx.EVT_LEFT_UP, self.MuteClicked) self.ppbtn = PlayerSwitchButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'pause', 'play') self.ppbtn.Bind(wx.EVT_LEFT_UP, self.PlayPause) self.ppbtn.setSelected(2) self.sbtn = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'stop') self.sbtn.Bind(wx.EVT_LEFT_UP, self.OnStop) self.sbtn.setSelected(2) volumebox = wx.BoxSizer(wx.HORIZONTAL) self.vol1 = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'vol1') self.vol1.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol2 = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'vol2') self.vol2.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol3 = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'vol3') self.vol3.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol4 = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'vol4') self.vol4.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol5 = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'vol5') self.vol5.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) self.vol6 = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'vol6') self.vol6.Bind(wx.EVT_MOUSE_EVENTS, self.mouseAction) volumebox.Add(self.vol1, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol2, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol3, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol4, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol5, 0, wx.ALIGN_CENTER_VERTICAL) volumebox.Add(self.vol6, 0, wx.ALIGN_CENTER_VERTICAL) self.updateVol(self.volume) self.fsbtn = PlayerButton( self, os.path.join(self.utility.getPath(), LIBRARYNAME, 'Video', 'Images'), 'fullScreen') self.fsbtn.Bind(wx.EVT_LEFT_UP, self.FullScreen) self.fsbtn.setSelected(2) self.ctrlsizer.Add(self.ppbtn, 0, wx.ALIGN_CENTER_VERTICAL) self.ctrlsizer.Add(self.sbtn, 0, wx.ALIGN_CENTER_VERTICAL) self.ctrlsizer.Add(self.slider, 1, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) self.ctrlsizer.Add(self.mute, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) self.ctrlsizer.Add(volumebox, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) self.ctrlsizer.Add(self.fsbtn, 0, wx.ALIGN_CENTER_VERTICAL) mainbox.Add(self.ctrlsizer, 0, wx.ALIGN_BOTTOM | wx.EXPAND | wx.LEFT | wx.RIGHT, 3) if border: self.vlcwin.Show(False) self.ctrlsizer.ShowItems(False) # Arno: until we figure out how to show in-playback prebuffering info self.statuslabel = wx.StaticText(self) vSizer.Add(self.statuslabel, 0, wx.EXPAND) self.SetSizer(vSizer) self.playtimer = None self.update = False self.timer = None def mouseAction(self, event): if event.LeftDown(): if self.mute.isToggled(): # unmute self.mute.setToggled(False) if event.GetEventObject().GetImageName() == 'vol1': self.volume = 0.16 if event.GetEventObject().GetImageName() == 'vol2': self.volume = 0.32 if event.GetEventObject().GetImageName() == 'vol3': self.volume = 0.48 if event.GetEventObject().GetImageName() == 'vol4': self.volume = 0.64 if event.GetEventObject().GetImageName() == 'vol5': self.volume = 0.80 if event.GetEventObject().GetImageName() == 'vol6': self.volume = 1.00 self.oldvolume = self.volume self.updateVol(self.volume) self.SetVolume(self.volume) elif event.Entering(): if event.GetEventObject().GetImageName() == 'vol1': volume = 0.16 if event.GetEventObject().GetImageName() == 'vol2': volume = 0.32 if event.GetEventObject().GetImageName() == 'vol3': volume = 0.48 if event.GetEventObject().GetImageName() == 'vol4': volume = 0.64 if event.GetEventObject().GetImageName() == 'vol5': volume = 0.80 if event.GetEventObject().GetImageName() == 'vol6': volume = 1.00 self.updateVol(volume) elif event.Leaving(): self.updateVol(self.volume) def MuteClicked(self, event): if self.mute.isToggled(): self.volume = self.oldvolume else: self.volume = 0 self.updateVol(self.volume) self.SetVolume(self.volume) self.mute.setToggled(not self.mute.isToggled()) def updateVol(self, volume): # updates the volume bars in the gui self.vol1.setSelected(volume >= 0.16) self.vol2.setSelected(volume >= 0.32) self.vol3.setSelected(volume >= 0.48) self.vol4.setSelected(volume >= 0.64) self.vol5.setSelected(volume >= 0.80) self.vol6.setSelected(volume >= 1.00) def Load(self, url, streaminfo=None): self.__check_thread() if DEBUG: print >> sys.stderr, "embedplay: Load:", url, streaminfo, currentThread( ).getName() ##self.SetPlayerStatus('') if streaminfo is not None: self.estduration = streaminfo.get('estduration', None) # 19/02/10 Boudewijn: no self.slider when self.vlcwrap is None # 26/05/09 Boudewijn: when using the external player we do not have a vlcwrap if self.vlcwrap: # Arno: hack: disable dragging when not playing from file. if url is None or url.startswith('http:'): self.slider.DisableDragging() else: self.slider.EnableDragging() # Arno, 2009-02-17: If we don't do this VLC gets the wrong playlist somehow self.vlcwrap.stop() self.vlcwrap.playlist_clear() self.vlcwrap.load(url, streaminfo=streaminfo) # Enable update of progress slider self.update = True wx.CallAfter(self.slider.SetValue, 0) if self.timer is None: self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.UpdateSlider) self.timer.Start(500) self.enableFullScreen() self.enablePlay() self.enableStop() self.enableScroll() def StartPlay(self): """ Start playing the new item after VLC has stopped playing the old one """ if DEBUG: print >> sys.stderr, "embedplay: PlayWhenStopped" self.playtimer = DelayTimer(self) def Play(self, evt=None): self.__check_thread() if DEBUG: print >> sys.stderr, "embedplay: Play pressed" self.OnMaximize() # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap: if self.GetState() != MEDIASTATE_PLAYING: self.vlcwin.stop_animation() self.ppbtn.setToggled(False) self.vlcwrap.start() elif DEBUG: print >> sys.stderr, "embedplay: Play pressed, already playing" def Pause(self, evt=None): self.__check_thread() """ Toggle between playing and pausing of current item """ if DEBUG: print >> sys.stderr, "embedplay: Pause pressed" # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap: if self.GetState() == MEDIASTATE_PLAYING: self.ppbtn.setToggled(True) self.vlcwrap.pause() elif DEBUG: print >> sys.stderr, "embedplay: Pause pressed, not playing" def Resume(self, evt=None): self.__check_thread() if DEBUG: print >> sys.stderr, "embedplay: Resume pressed" if self.vlcwrap: if self.GetState() != MEDIASTATE_PLAYING: self.vlcwin.stop_animation() self.ppbtn.setToggled(False) self.vlcwrap.resume() def PlayPause(self, evt=None): self.__check_thread() """ Toggle between playing and pausing of current item """ if DEBUG: print >> sys.stderr, "embedplay: PlayPause pressed" # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap: self.vlcwrap.resume() self.ppbtn.setToggled(not self.ppbtn.isToggled()) def Seek(self, evt=None): self.__check_thread() if DEBUG: print >> sys.stderr, "embedplay: Seek" # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap: oldsliderpos = self.slider.GetValue() #print >>sys.stderr, 'embedplay: Seek: GetValue returned,',oldsliderpos pos = int(oldsliderpos * 1000.0) #print >>sys.stderr, 'embedplay: Seek: newpos',pos try: if self.GetState() == MEDIASTATE_STOPPED: self.vlcwrap.start(pos) else: self.vlcwrap.set_media_position(pos) except: print_exc() if DEBUG: print >> sys.stderr, 'embedplay: could not seek' self.slider.SetValue(oldsliderpos) self.update = True def enableScroll(self): self.scroll_enabled = True # 19/02/10 Boudewijn: no self.slider when self.vlcwrap is None if self.vlcwrap: self.slider.EnableDragging() def disableScroll(self): self.scroll_enabled = False # 19/02/10 Boudewijn: no self.slider when self.vlcwrap is None if self.vlcwrap: self.slider.DisableDragging() def enablePlay(self): self.play_enabled = True self.ppbtn.setSelected(False) def disablePlay(self): self.play_enabled = False self.ppbtn.setSelected(2) def enableStop(self): self.stop_enabled = True self.sbtn.setSelected(False) def disableStop(self): self.stop_enabled = False self.sbtn.setSelected(2) def enableFullScreen(self): self.fullscreen_enabled = True self.fsbtn.setSelected(False) def disableFullScreen(self): self.fullscreen_enabled = False self.fsbtn.setSelected(2) def FullScreen(self, evt=None): # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap and self.fullscreen_enabled: self._ToggleFullScreen() def OnFullScreenKey(self, event): if event.GetUnicodeKey() == wx.WXK_ESCAPE: self._ToggleFullScreen() elif event.GetUnicodeKey() == wx.WXK_SPACE: self._TogglePause() def _TogglePause(self): if self.GetState() == MEDIASTATE_PLAYING: self.vlcwrap.pause() else: self.vlcwrap.resume() def _ToggleFullScreen(self): self.__check_thread() if isinstance(self.parent, wx.Frame): #are we shown in popup frame if self.ctrlsizer.IsShown( 0): #we are not in fullscreen -> ctrlsizer is showing self.parent.ShowFullScreen(True) self.ctrlsizer.ShowItems(False) self.statuslabel.Show(False) self.Layout() #Niels: 07-03-2012, only evt_close seems to work :( quitId = wx.NewId() pauseId = wx.NewId() self.parent.Bind(wx.EVT_MENU, lambda event: self._ToggleFullScreen(), id=quitId) self.parent.Bind(wx.EVT_MENU, lambda event: self._TogglePause(), id=pauseId) self.parent.Bind(wx.EVT_CLOSE, lambda event: self._ToggleFullScreen()) self.parent.Bind(wx.EVT_LEFT_DCLICK, lambda event: self._ToggleFullScreen()) accelerators = [(wx.ACCEL_NORMAL, wx.WXK_ESCAPE, quitId), (wx.ACCEL_CTRL, wx.WXK_SPACE, pauseId)] self.parent.SetAcceleratorTable( wx.AcceleratorTable(accelerators)) else: self.parent.ShowFullScreen(False) self.ctrlsizer.ShowItems(True) self.statuslabel.Show(True) self.Layout() self.parent.SetAcceleratorTable(wx.NullAcceleratorTable) self.parent.Unbind(wx.EVT_CLOSE) else: #saving media player state cur_time = self.vlcwrap.get_media_position() cur_state = self.vlcwrap.get_our_state() self.vlcwrap.stop() if not self.fullscreenwindow: # create a new top level frame where to attach the vlc widget and # render the fullscreen video self.fullscreenwindow = wx.Frame(None, title="FullscreenVLC") self.fullscreenwindow.SetBackgroundColour("BLACK") eventPanel = wx.Panel(self.fullscreenwindow) eventPanel.SetBackgroundColour(wx.BLACK) eventPanel.Bind(wx.EVT_KEY_DOWN, lambda event: self.OnFullScreenKey(event)) self.fullscreenwindow.Bind( wx.EVT_CLOSE, lambda event: self._ToggleFullScreen()) self.fullscreenwindow.ShowFullScreen(True) eventPanel.SetFocus() self.vlcwrap.set_window(self.fullscreenwindow) else: self.TellLVCWrapWindow4Playback() self.fullscreenwindow.Destroy() self.fullscreenwindow = None #restoring state if cur_state == MEDIASTATE_PLAYING: self.vlcwrap.start(cur_time) elif cur_state == MEDIASTATE_PAUSED: self.vlcwrap.start(cur_time) def doPause(cur_time): self.vlcwrap.pause() self.vlcwrap.set_media_position(cur_time) wx.CallLater(500, doPause, cur_time) def Save(self, evt=None): # save media content in different directory if self.save_button.isToggled(): self.save_callback() def SetVolume(self, volume, evt=None): if DEBUG: print >> sys.stderr, "embedplay: SetVolume:", self.volume # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap: self.vlcwrap.sound_set_volume( volume) ## float(self.volume.GetValue()) / 100 def OnStop(self, event): if self.vlcwrap and self.stop_enabled: self.Stop() self.disableStop() def Stop(self): self.__check_thread() if DEBUG: print >> sys.stderr, "embedplay: Stop" self.OnMinimize() # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap: self.vlcwrap.stop() self.ppbtn.SetLabel(self.utility.lang.get('playprompt')) self.slider.ResetTime() self.slider.SetValue(0) self.disableFullScreen() self.disablePlay() self.disableScroll() if self.timer is not None: self.timer.Stop() def GetState(self): """ Returns the state of VLC as summarized by Fabian: MEDIASTATE_PLAYING, MEDIASTATE_PAUSED, MEDIASTATE_STOPPED """ # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap: status = self.vlcwrap.get_our_state() if DEBUG: print >> sys.stderr, "embedplay: GetState", status return status # catchall return MEDIASTATE_STOPPED def Reset(self): self.Stop() self.UpdateProgressSlider([False]) # # Control on-screen information # @forceWxThread def UpdateStatus(self, playerstatus, pieces_complete): self.SetPlayerStatus(playerstatus) if self.vlcwrap is not None: self.UpdateProgressSlider(pieces_complete) def SetPlayerStatus(self, s): if sys.platform == 'win32': s = "\n".join(wrap(s, 64)) self.SetLoadingText(s) def SetContentName(self, s): self.vlcwin.set_content_name(s) def SetContentImage(self, wximg): self.vlcwin.set_content_image(wximg) def SetLoadingText(self, text): if text == None: text = '' if text != self.statuslabel.GetLabel(): self.statuslabel.SetLabel(text) self.statuslabel.Refresh() self.Layout() # # Internal methods # def UpdateProgressSlider(self, pieces_complete): # 19/02/10 Boudewijn: no self.slider when self.vlcwrap is None if self.vlcwrap: self.slider.setBufferFromPieces(pieces_complete) self.slider.Refresh() def DisableInput(self): # return # Not currently used self.ppbtn.Disable() # 19/02/10 Boudewijn: no self.slider when self.vlcwrap is None if self.vlcwrap: self.slider.Disable() self.fsbtn.Disable() def UpdateSlider(self, evt): self.__check_thread() ##if not self.volumeicon.isToggled(): ## self.volume.SetValue(int(self.vlcwrap.sound_get_volume() * 100)) # Boudewijn, 26/05/09: when using the external player we do not have a vlcwrap if self.vlcwrap: if self.update and self.GetState() != MEDIASTATE_STOPPED: len = self.vlcwrap.get_stream_information_length() if len == -1 or len == 0: if self.estduration is None: return else: len = int(self.estduration) else: len /= 1000 cur = self.vlcwrap.get_media_position() / 1000 self.slider.SetRange(0, len) self.slider.SetValue(cur) self.slider.SetTimePosition(float(cur), len) def StopSliderUpdate(self, evt): self.update = False def TellLVCWrapWindow4Playback(self): if self.vlcwrap is not None: self.vlcwin.tell_vclwrap_window_for_playback() def ShowLoading(self): if self.vlcwrap: self.vlcwin.show_loading() self.OnMaximize() def OnMinimize(self): if self.vlcwrap and self.border: self.SetMinSize((34, -1)) self.vlcwin.Show(False) self.ctrlsizer.ShowItems(False) self.header.ShowMinimized(False) self.statuslabel.Show(False) self.player_img.Show(True) self.utility.guiUtility.frame.Layout() def OnMaximize(self): if self.vlcwrap and self.border: self.SetMinSize((EmbeddedPlayerPanel.VIDEO_SIZE[0], -1)) self.vlcwin.Show(True) self.ctrlsizer.ShowItems(True) self.header.ShowMinimized(True) self.statuslabel.Show(True) self.player_img.Show(False) self.utility.guiUtility.frame.Layout() def __check_thread(self): if __debug__ and currentThread().getName() != "MainThread": print >> sys.stderr, "EmbeddedPlayer: __check_thread thread", currentThread( ).getName(), "is NOT MainThread" print_stack()
class SearchDetailsPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent, -1) self.guiUtility = GUIUtility.getInstance() self.addComponents() def addComponents(self): self.hSizer = wx.BoxSizer(wx.HORIZONTAL) #(self, -1, wx.DefaultPosition, wx.Size(16,16),name='down') self.stopMoreButton = SwitchButton(self, -1, wx.DefaultPosition, wx.DefaultSize, name='searchStop') self.stopMoreButton.Bind(wx.EVT_LEFT_UP, self.stopMoreClicked) self.stopMoreButton.SetToolTipString(self.guiUtility.utility.lang.get('searchStop')) self.clearButton = tribler_topButton(self, -1, wx.DefaultPosition, wx.DefaultSize, name='searchClear') self.clearButton.SetToolTipString(self.guiUtility.utility.lang.get('searchClear')) self.hSizer.Add([9,5],0,wx.EXPAND|wx.FIXED_MINSIZE,0) self.hSizer.Add(self.stopMoreButton, 0, wx.ALL, 1) self.hSizer.Add(self.clearButton, 0, wx.ALL, 1) self.hSizer.Add([8,5],0,wx.EXPAND|wx.FIXED_MINSIZE,0) self.textPanel = wx.Panel(self) sizer = wx.BoxSizer(wx.HORIZONTAL) self.text = wx.StaticText(self.textPanel, -1, '') self.text.SetForegroundColour(wx.Colour(255,255,255)) sizer.Add(self.text, 1, wx.ALL, 0) self.textPanel.SetSizer(sizer) self.textPanel.SetAutoLayout(1) self.textPanel.SetForegroundColour(wx.WHITE) self.textPanel.SetBackgroundColour(wx.Colour(53,53,53)) self.text.SetSize((-1, 15)) self.hSizer.Add(self.textPanel, 1, wx.TOP|wx.EXPAND, 3) self.SetSizer(self.hSizer); self.SetAutoLayout(1); self.SetMinSize((-1, 19)) self.SetBackgroundColour(wx.Colour(53,53,53)) self.hSizer.Layout() self.Layout() self.searchBusy = True #?? #self.Show(True) self.results = {} def setMessage(self, stype, finished, num, keywords = []): if stype: self.results[stype] = num total = sum([v for v in self.results.values() if v != -1]) if keywords: if type(keywords) == list: self.keywords = " ".join(keywords) else: self.keywords = keywords if finished: msg = self.guiUtility.utility.lang.get('finished_search') % (self.keywords, total) #self.stopMoreClicked() else: msg = self.guiUtility.utility.lang.get('going_search') % (self.keywords, total) self.text.SetLabel(msg) tt = [] for pair in self.results.items(): key, value = pair if value == -1: continue tt.append(self.guiUtility.utility.lang.get('search_'+key) % value) tt.sort() tt = os.linesep.join(tt) self.textPanel.SetToolTipString(tt) self.text.SetToolTipString(tt) def startSearch(self): self.stopMoreButton.setToggled(False) self.searchBusy = True def stopSearch(self): # call remoteSearch and Web2.0 search to stop self.guiUtility.stopSearch() # def findMoreSearch(self): # # call remoteSearch and Web2.0 search to find more # self.startSearch() # grid = self.guiUtility.standardOverview.getGrid() # if grid.dod: # grid.dod.requestMore(grid.items) def searchFinished(self): self.searchBusy = False self.stopMoreButton.setToggled(True) self.setMessage(None, True, 0, None) def stopMoreClicked(self, event = None): if event: event.Skip() if self.searchBusy: self.stopSearch() self.searchFinished() #else: # find more # self.findMoreSearch()
class LibraryItemPanel(wx.Panel): def __init__(self, parent, keyTypedFun = None): global TORRENTPANEL_BACKGROUND wx.Panel.__init__(self, parent, -1) self.guiUtility = GUIUtility.getInstance() self.utility = self.guiUtility.utility self.parent = parent self.guiserver = parent.guiserver self.triblerGrey = wx.Colour(128,128,128) #self.statusTorrent = TorrentStatus(self) self.listItem = True # library always in listmode self.data = None self.status = None self.rightMouse = None self.datacopy = None self.titleLength = 16 # num characters self.vodMode = False self.selected = False self.warningMode = False self.oldCategoryLabel = None self.torrentDetailsFrame = None self.metadatahandler = MetadataHandler.getInstance() self.addComponents() #self.Bind(wx.EVT_RIGHT_DOWN, self.rightMouseButton) self.cache_progress = {} self.gui_server = GUITaskQueue.getInstance() self.SetMinSize((-1, 22)) self.selected = False self.Show() self.Refresh() self.Layout() def addComponents(self): self.Show(False) self.hSizer = wx.BoxSizer(wx.HORIZONTAL) # Add Spacer self.hSizer.Add([10,5],0,wx.EXPAND|wx.FIXED_MINSIZE,0) # Add thumb self.thumb = ThumbnailViewer(self, 'libraryMode') self.thumb.setBackground(wx.BLACK) self.thumb.SetSize(libraryModeThumbSize) self.hSizer.Add(self.thumb, 0, wx.ALL, 2) # Add title self.title = wx.StaticText(self,-1,"",wx.Point(0,0),wx.Size(120,14)) self.title.SetBackgroundColour(wx.WHITE) self.title.SetFont(wx.Font(FS_TITLE,FONTFAMILY,FONTWEIGHT,wx.NORMAL,False,FONTFACE)) self.title.SetMinSize((120,14)) self.hSizer.Add(self.title,1,wx.TOP,3) ## self.vSizerTitle = wx.BoxSizer(wx.VERTICAL) ## self.vSizerTitle.Add (self.title, 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 3) ## self.vSizerTitle.Add (self.speedSizer, 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 3) ## self.hSizer.Add(self.vSizerTitle, 0, wx.LEFT|wx.RIGHT|wx.TOP|wx.EXPAND, 3) # V Line self.addLine() # Add Gauge/progressbar #self.pb = TriblerProgressbar(self,-1,wx.Point(359,0),wx.Size(80,15)) self.pb = ProgressBar(self,pos=wx.Point(359,0),size=wx.Size(100,5)) # >> Drawn in progressbar #self.pbLabel = wx.StaticText(self,-1,"12% |ETA:10min30",wx.Point(274,3),wx.Size(80,15),wx.ST_NO_AUTORESIZE) #self.pbSizer.Add(self.pbLabel,0,wx.TOP|wx.FIXED_MINSIZE,3) # << # Text under progressbar self.percentage = wx.StaticText(self,-1,"?%") self.percentage.SetForegroundColour(self.triblerGrey) self.percentage.SetFont(wx.Font(FS_PERC,FONTFAMILY,FONTWEIGHT,wx.NORMAL,False,FONTFACE)) self.eta = wx.StaticText(self,-1,"?") self.eta.SetForegroundColour(self.triblerGrey) self.eta.SetFont(wx.Font(FS_PERC,FONTFAMILY,FONTWEIGHT,wx.NORMAL,False,FONTFACE)) self.fileProgressSizer = wx.BoxSizer(wx.HORIZONTAL) self.fileProgressSizer.Add(self.percentage, 1, wx.EXPAND, 0) self.fileProgressSizer.Add(self.eta, 0, wx.EXPAND|wx.ALIGN_RIGHT, 0) self.pbMessage = wx.BoxSizer(wx.VERTICAL) self.pbMessage.Add(self.pb,0,wx.TOP|wx.EXPAND|wx.FIXED_MINSIZE,2) self.pbMessage.Add(self.fileProgressSizer,0,wx.TOP|wx.EXPAND|wx.FIXED_MINSIZE,1) self.hSizer.Add(self.pbMessage, 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 2) # pause/stop button self.pause = SwitchButton(self, -1, wx.Point(542,3), wx.Size(16,16),name='pause' ) self.hSizer.Add(self.pause,0,wx.TOP|wx.FIXED_MINSIZE,2) # V Line self.addLine() # Up/Down text speed # self.downSpeed = ImagePanel(self, -1, wx.DefaultPosition, wx.Size(16,16),name='downSpeed') # self.downSpeed.setBackground(wx.WHITE) # self.downSpeed.SetToolTipString(self.utility.lang.get('down')) self.speedDown2 = wx.StaticText(self,-1,"down: 0 KB/s",wx.Point(274,3),wx.Size(70,12),wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE) self.speedDown2.SetForegroundColour(self.triblerGrey) self.speedDown2.SetFont(wx.Font(FS_SPEED,FONTFAMILY,FONTWEIGHT,wx.NORMAL,False,FONTFACE)) self.speedDown2.SetMinSize((70,12)) # self.upSpeed = ImagePanel(self, -1, wx.DefaultPosition, wx.Size(16,16),name='upSpeed') # self.upSpeed.setBackground(wx.WHITE) # self.upSpeed.SetToolTipString(self.utility.lang.get('up')) self.speedUp2 = wx.StaticText(self,-1,"up: 0 KB/s",wx.Point(274,3),wx.Size(70,12),wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE) self.speedUp2.SetForegroundColour(self.triblerGrey) self.speedUp2.SetFont(wx.Font(FS_SPEED,FONTFAMILY,FONTWEIGHT,wx.NORMAL,False,FONTFACE)) self.speedUp2.SetMinSize((70,12)) # self.hSizer.Add(self.downSpeed, 0, wx.TOP, 2) # self.hSizer.Add([2,20],0,wx.EXPAND|wx.FIXED_MINSIZE,0) self.hSizer.Add(self.speedDown2, 0, wx.TOP|wx.EXPAND, 4) # V Line self.addLine() # self.hSizer.Add(self.upSpeed, 0, wx.LEFT|wx.TOP, 2) # self.hSizer.Add([2,20],0,wx.EXPAND|wx.FIXED_MINSIZE,0) self.hSizer.Add(self.speedUp2, 0, wx.TOP|wx.EXPAND, 4) # V Line self.addLine() # Status Icon ## self.statusIcon = ImagePanel(self, -1, name="LibStatus_boosting") ## self.statusIcon.searchBitmap(name = statusLibrary["stopped"]) ## ## self.hSizer.Add(self.statusIcon, 0, wx.TOP|wx.RIGHT|wx.EXPAND, 2) # Status message self.statusField = wx.StaticText(self, -1,'', wx.Point(),wx.Size()) self.statusField.SetForegroundColour(self.triblerGrey) self.statusField.SetFont(wx.Font(FS_SPEED,FONTFAMILY,FONTWEIGHT,wx.NORMAL,False,FONTFACE)) self.statusField.SetMinSize((60,12)) # self.statusField.SetMinSize((125,12)) self.hSizer.Add(self.statusField, 1, wx.TOP, 4) # V Line self.addLine() # Boost button self.boost = SwitchButton(self, name="boost") self.boost.setBackground(wx.WHITE) self.boost.SetSize((50,16)) self.boost.setEnabled(False) self.hSizer.Add(self.boost, 0, wx.TOP|wx.ALIGN_RIGHT, 2) self.hSizer.Add([2,20],0,wx.EXPAND|wx.FIXED_MINSIZE,0) # Play Fast self.playFast = SwitchButton(self, name="playFast") self.playFast.setBackground(wx.WHITE) self.playFast.SetSize((39,16)) self.playFast.setEnabled(False) self.hSizer.Add(self.playFast, 0, wx.TOP|wx.ALIGN_RIGHT, 2) self.hSizer.Add([2,20],0,wx.EXPAND|wx.FIXED_MINSIZE,0) # Play self.playerPlay = SwitchButton(self, name="libraryPlay") self.playerPlay.setBackground(wx.WHITE) self.playerPlay.SetSize((16,16)) self.playerPlay.setEnabled(False) self.hSizer.Add(self.playerPlay, 0, wx.TOP|wx.ALIGN_RIGHT, 2) self.hSizer.Add([2,20],0,wx.EXPAND|wx.FIXED_MINSIZE,0) # # TODO: TB >delete button should be removed when delete function in rightMouseButton menu works # Delete button #self.delete = tribler_topButton(self, -1, wx.DefaultPosition, wx.Size(16,16),name='deleteLibraryitem') #self.delete.setBackground(wx.WHITE) #self.hSizer.Add(self.delete,0,wx.TOP|wx.FIXED_MINSIZE|wx.ALIGN_TOP,7) #self.hSizer.Add([8,20],0,wx.EXPAND|wx.FIXED_MINSIZE,0) # Add Refresh self.SetSizer(self.hSizer); self.SetAutoLayout(1); self.Layout(); self.Refresh() # 2.8.4.2 return value of GetChildren changed wl = [self] for c in self.GetChildren(): wl.append(c) for window in wl: window.Bind(wx.EVT_LEFT_UP, self.mouseAction) #window.Bind(wx.EVT_LEFT_DCLICK, self.doubleClicked) window.Bind(wx.EVT_KEY_UP, self.keyTyped) window.Bind(wx.EVT_RIGHT_DOWN, self.mouseAction) def getColumns(self): return [{'sort':'', 'title':'', 'width':35, 'tip':''}, {'sort':'name', 'reverse':True, 'title':'name', 'weight':1,'tip':self.utility.lang.get('C_filename'), 'order':'down'}, {'sort':'progress', 'title':'progress', 'width':120, 'tip':self.utility.lang.get('C_progress')}, {'sort':'??','dummy':True, 'pic':'downSpeedColumn','title':'down', 'width':70, 'tip':self.utility.lang.get('C_downspeed')}, {'sort':'??', 'dummy':True, 'pic':'upSpeedColumn','title':'up','width':70, 'tip':self.utility.lang.get('C_upspeed')}, {'sort':'latest', 'dummy':True, 'title':'status', 'weight':1, 'tip':self.utility.lang.get('C_message')}, {'sort':'??', 'title':'info', 'dummy':True, 'width':111, 'tip':self.utility.lang.get('C_info')} ] def refreshData(self): self.setData(self.data) def addLine(self): vLine = wx.StaticLine(self,-1,wx.DefaultPosition, wx.Size(2,22),wx.LI_VERTICAL) self.hSizer.Add(vLine, 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 3) def updateProgress(self, infohash, progress): if infohash not in self.cache_progress: self.cache_progress[infohash] = 0 # progress now = time() if progress - self.cache_progress[infohash] > 1: self.cache_progress[infohash] = progress self.guiserver.add_task(lambda:self.updateProgressInDB(infohash,progress), 0) def updateProgressInDB(self, infohash, progress): try: mypref_db = MyPreferenceDBHandler.getInstance() mypref_db.updateProgress(infohash, progress, commit=True) except: pass # lock error def setData(self, torrent): # set bitmap, rating, title #print_stack() if threading.currentThread().getName() != "MainThread": print >>sys.stderr,"lip: setData called by nonMainThread!",threading.currentThread().getName() print_stack() self.vodMode = False self.data = torrent if torrent is None: for child in self.GetChildren(): child.Hide() torrent = {} else: for child in self.GetChildren(): child.Show() if torrent.get('ds'): #print '%s is an active torrent' % torrent['name'] ds = torrent['ds'] #abctorrent.setLibraryPanel(self) # Check if torrent just finished for resort #abctorrent.status.checkJustFinished() #self.pb.setEnabled(True) self.pb.Show() # self.downSpeed.Show() self.speedDown2.Show() # self.upSpeed.Show() self.speedUp2.Show() dls = ds.get_current_speed(DOWNLOAD)*1024 # speed_format needs byte/s uls = ds.get_current_speed(UPLOAD)*1024 self.speedDown2.SetLabel(self.utility.speed_format(dls)) self.speedUp2.SetLabel(self.utility.speed_format(uls)) finished = ds.get_progress() == 1.0 or ds.get_status() == DLSTATUS_SEEDING print >> sys.stderr, '%s %s %s' % (`ds.get_download().get_def().get_name()`, ds.get_progress(), dlstatus_strings[ds.get_status()]) if ds.get_status() == DLSTATUS_STOPPED_ON_ERROR: print >> sys.stderr, "ERROR IS",ds.get_error() progress = (ds.get_progress() or 0.0) * 100.0 #print >> sys.stderr, '****** libraryitempanel:', torrent['torrent_id'], progress self.updateProgress(torrent['infohash'], progress) self.percentage.SetLabel('%.1f%%' % progress) eta = self.utility.eta_value(ds.get_eta(), truncate=2) if eta == '' or eta.find('unknown') != -1 or finished: eta = '' self.eta.SetLabel(eta) self.eta.SetToolTipString(self.utility.lang.get('eta')+eta) if finished and ds.get_status() == DLSTATUS_STOPPED: status = self.utility.lang.get('completed') else: status = dlstatus_strings[ds.get_status()] self.statusField.SetLabel(self.utility.lang.get(status)) self.statusField.SetToolTipString(self.statusField.GetLabel()) #status = abctorrent.status.getStatus() # print "--tb-------------------------------" # print status # status is mapped with >Utility/constants.py #if status == STATUS_QUEUE : #print 'queue' # pass ## elif status == STATUS_STOP or status == STATUS_PAUSE : ## self.statusIcon.searchBitmap(name = statusLibrary["stopped"]) ## elif status == STATUS_ACTIVE: ## self.statusIcon.searchBitmap(name = statusLibrary["downloading"]) ## elif status == STATUS_HASHCHECK: ## print 'hash check' ## elif status == STATUS_SUPERSEED : ## self.statusIcon.searchBitmap(name = statusLibrary["seeding"]) ## elif status == STATUS_FINISHED : ## self.statusIcon.searchBitmap(name = statusLibrary["completed"]) ##statusLibrary = {"downloading" : "LibStatus_boosting.png", ## "stopped" : "LibStatus_stopped.png", ## "boosting" : "LibStatus_boosting.png", ## "completed" : "LibStatus_completed.png", ## "seeding" : "LibSatus_seeding.png"} switchable = False self.playable = False havedigest = None showBoost = False showPlayFast = False showPlayButton = False #statustxt = abctorrent.status.getStatusText() active = ds.get_status() in (DLSTATUS_SEEDING, DLSTATUS_DOWNLOADING) initstates = [self.utility.lang.get('checkingdata'), self.utility.lang.get('allocatingspace'), self.utility.lang.get('movingdata'), self.utility.lang.get('waiting')] if not ds.get_status() in (DLSTATUS_WAITING4HASHCHECK, DLSTATUS_ALLOCATING_DISKSPACE,\ DLSTATUS_HASHCHECKING): showBoost = active and (not finished) if showBoost and not ds.is_vod(): showPlayFast = True if ds.is_vod(): self.vodMode = True #progressinf = abctorrent.get_progressinf() #havedigest2 = progressinf.get_bufferinfo() self.playable = ds.get_vod_playable() switchable = False showPlayButton = True else: isVideo = bool(ds.get_download().get_def().get_files(exts=videoextdefaults)) self.playable = finished and isVideo if not self.playable: switchable = True havedigest = ds.get_pieces_complete() if havedigest: self.pb.set_pieces(havedigest) self.pb.Refresh() elif finished: self.pb.reset(colour=2) # Show as complete self.pb.Refresh() elif progress > 0: self.pb.reset(colour=1) # Show as having some self.pb.Refresh() else: self.pb.reset(colour=0) # Show has having none self.pb.Refresh() self.playerPlay.setEnabled(showPlayButton or self.playable) self.playerPlay.setToggled(self.playable, tooltip = {"disabled" : self.utility.lang.get('playerDisabled'), "enabled" : self.utility.lang.get('playerEnabled')}) self.playFast.setEnabled(showPlayFast) self.playFast.setToggled(not switchable, tooltip = {"disabled" : self.utility.lang.get('playFastDisabled'), "enabled" : self.utility.lang.get('playFastEnabled')}) self.boost.setEnabled(showBoost) self.boost.setToggled(self.is_boosted(), tooltip = {"disabled" : self.utility.lang.get('boostDisabled'), "enabled" : self.utility.lang.get('boostEnabled')}) self.pause.setToggled(ds.get_status() == DLSTATUS_STOPPED or ds.get_status() == DLSTATUS_STOPPED_ON_ERROR) elif torrent: # inactive torrent #self.pb.setEnabled(False) #self.downSpeed2.Hide() self.speedDown2.SetLabel('') #self.upSpeed.Hide() self.speedUp2.SetLabel('') # Only show playbutton self.playFast.setEnabled(False) self.boost.setEnabled(False) self.pause.setEnabled(True) self.pause.setToggled(True) if torrent.get('progress') == 100.0: self.playerPlay.setEnabled(True) self.playerPlay.setToggled(True, tooltip = {"disabled" : self.utility.lang.get('playerDisabled'), "enabled" : self.utility.lang.get('playerEnabled')}) self.statusField.SetLabel(self.utility.lang.get('completed')) else: self.playerPlay.setEnabled(False) self.statusField.SetLabel(self.utility.lang.get('stop')) self.statusField.SetToolTipString(self.statusField.GetLabel()) self.eta.SetLabel('') if torrent.get('progress') != None: self.percentage.SetLabel('%0.1f%%' % torrent['progress']) self.pb.setNormalPercentage(torrent['progress']) else: self.percentage.SetLabel('?') self.pb.reset() self.pb.Show() self.pb.Refresh() if torrent.get('name'): title = torrent['name'][:self.titleLength] self.title.Show() self.title.SetLabel(title) self.title.Wrap(self.title.GetSize()[0]) self.title.SetToolTipString(torrent['name']) else: self.title.SetLabel('') self.title.SetToolTipString('') self.title.Hide() self.thumb.setTorrent(torrent) self.Layout() self.Refresh() self.GetContainingSizer().Layout() #self.parent.Refresh() def select(self, rowIndex, colIndex): self.selected = True colour = self.guiUtility.selectedColour self.thumb.setSelected(True) self.title.SetBackgroundColour(colour) # self.downSpeed.setBackground(colour) # self.upSpeed.setBackground(colour) self.playFast.setBackground(colour) self.boost.setBackground(colour) ## self.statusIcon.setBackground(colour) self.playerPlay.setBackground(colour) self.SetBackgroundColour(colour) self.Refresh() def deselect(self, rowIndex, colIndex): self.selected = False if rowIndex % 2 == 0: colour = self.guiUtility.unselectedColour else: colour = self.guiUtility.unselectedColour2 self.thumb.setSelected(False) self.title.SetBackgroundColour(colour) # self.downSpeed.setBackground(colour) # self.upSpeed.setBackground(colour) self.SetBackgroundColour(colour) self.playFast.setBackground(colour) self.boost.setBackground(colour) ## self.statusIcon.setBackground(colour) self.playerPlay.setBackground(colour) self.Refresh() def keyTyped(self, event): if self.selected: key = event.GetKeyCode() if (key == wx.WXK_DELETE): if self.data: if DEBUG: print >>sys.stderr,'lib: deleting' # Arno; 2007-05-11: TODO: use right method here, deleteTorrent does nothing at the # moment, see below for right method self.guiUtility.deleteTorrent(self.data) event.Skip() def mouseAction(self, event): if DEBUG: print >>sys.stderr,"lip: mouseaction: name",event.GetEventObject().GetName() event.Skip() if not self.data: return obj = event.GetEventObject() name = obj.GetName() self.SetFocus() if self.data: self.guiUtility.selectTorrent(self.data) # buttons that are switched off, should not generate events try: if not obj.isEnabled(): #print 'Button %s was not enabled' % name return except: pass if self.data.get('ds'): ds = self.data.get('ds') # if name == 'deleteLibraryitem': # removeFiles = False # ds.get_download().stop() # ?? # if name == 'pause': # ARNOCOMMENT: need to get/store/cache current status of Download somehow if ds.get_status() == DLSTATUS_STOPPED or ds.get_status() == DLSTATUS_STOPPED_ON_ERROR: if ds.get_download().get_def().get_live(): self.switch_to_vod(ds) else: ds.get_download().restart() obj.setToggled(False) else: ds.get_download().stop() obj.setToggled(True) elif name == 'playFast': if not self.vodMode: self.vodMode = True self.switch_to_vod(ds) else: self.switch_to_standard_dlmode(ds) self.vodMode = False self.playFast.setToggled(self.vodMode) elif name == 'boost': self.show_boost(ds) elif name == 'libraryPlay': if self.playable: self.play(ds) else: # no abctorrent if name == 'pause': #playbutton dest_dir = self.data.get('destdir') if dest_dir is not None: # Start torrent again if DEBUG: print >>sys.stderr,'lip: starting torrent %s with data in dir %s' % (repr(self.data['name']), dest_dir) self.guiUtility.standardDetails.download(self.data, dest = dest_dir, force = True) elif DEBUG: print >>sys.stderr,'lip: Could not make abctorrent active, no destdir in dictionary: %s' % repr(self.data.get('name')) elif name == 'libraryPlay': # Todo: make non-abctorrent files playable. dest_dir = self.data.get('destdir') if dest_dir is not None: # Start torrent again if DEBUG: print >>sys.stderr,'lip: starting torrent %s with data in dir %s' % (repr(self.data['name']), dest_dir) self.guiUtility.standardDetails.download(self.data, dest = dest_dir, force = True) elif DEBUG: print >>sys.stderr,'lip: Could not make abctorrent active, no destdir in dictionary: %s' % repr(self.data.get('name')) if name == 'deleteLibraryitem': # delete works for active and inactive torrents self.guiUtility.onDeleteTorrentFromLibrary() if event.RightDown(): self.rightMouseButton(event) def rightMouseButton(self, event): # Open right-click menu (windows menu key) # >>makePopup(self, menu, event = None, label = "", extralabel = "", bindto = None): menu = self.guiUtility.OnRightMouseAction(event) if menu is not None: self.PopupMenu(menu, (-1,-1)) #--tb-- # rightMouse = wx.Menu() # # self.utility.makePopup(rightMouse, self.onOpenFileDest, 'ropenfiledest') # self.utility.makePopup(rightMouse, self.onOpenDest, 'ropendest') # rightMouse.AppendSeparator() # self.utility.makePopup(rightMouse, self.onModerate, 'rModerate') # self.utility.makePopup(rightMouse, self.onRecommend, 'rRecommend') # #if secret: # self.utility.makePopup(rightMouse, self.onDownloadOpen, 'rDownloadOpenly') # #else: # self.utility.makePopup(rightMouse, self.onDownloadSecret, 'rDownloadSecretly') # rightMouse.AppendSeparator() # self.utility.makePopup(rightMouse, None, 'rLibraryOptions') # self.utility.makePopup(rightMouse, None, 'rRemoveFromList') # self.utility.makePopup(rightMouse, None, 'rRemoveFromListAndHD') ## #Add the priority submenu if this is a multi-file torrent ## if not self.torrent.files.isFile(): ## prioritymenu = self.makePriorityMenu() ## if prioritymenu is not None: ## menu.AppendMenu(-1, self.utility.lang.get('rpriosetting'), prioritymenu) ## ## Popup the menu. If an item is selected then its handler ## will be called before PopupMenu returns. ## if event is None: ## use the position of the first selected item (key event) ## position = self.GetItemPosition(s[0]) ## else: ## use the cursor position (mouse event) ## position = event.GetPoint() #position = event.GetPoint() # self.PopupMenu(rightMouse, (-1,-1)) # def doubleClicked(self, event): # # open torrent details frame # abctorrent = self.data.get('abctorrent') # if abctorrent: # abctorrent.dialogs.advancedDetails() # # event.Skip() def getIdentifier(self): if self.data: return self.data.get('infohash') else: return None def switch_to_vod(self,ds): videoplayer = VideoPlayer.getInstance() videoplayer.play(ds) def show_boost(self, ds): if ds is not None: self.dlhelperframe = DownloadHelperFrame(self,self.utility,ds) self.dlhelperframe.Show() def play(self,ds): videoplayer = VideoPlayer.getInstance() videoplayer.play(ds) def switch_to_standard_dlmode(self,ABCTorrentTemp): videoplayer = VideoPlayer.getInstance() videoplayer.vod_back_to_standard_dlmode(ABCTorrentTemp) def is_boosted(self): if self.data is None: return False ds = self.data.get('ds') return ds and len(ds.get_coopdl_helpers()) > 0 def abcTorrentShutdown(self, infohash): """ The abctorrent related to this panel was shutdown """ if self.data.get('infohash') == infohash and self.data.get('abctorrent'): if DEBUG: print >>sys.stderr,'lip: abcTorrentShutdown with right infohash' abctorrent = self.data.get('abctorrent') progresstxt = abctorrent.getColumnText(COL_PROGRESS) progress = float(progresstxt[:-1]) # store the progress of this torrent newdata = {'progress':progress, 'destdir':abctorrent.files.dest} self.data.update(newdata) if DEBUG: print >>sys.stderr,'lip: Save destination?: %s and progress: %f' % (`self.data['destdir']`, self.data['progress']) # only save new data (progression and destdir, no other data or torrent self.utility.torrent_db.updateTorrent(infohash, **newdata) # Now delete the abctorrent object reference del self.data['abctorrent'] def abctorrentFinished(self, infohash): """ The download just finished. Call standardOverview to resort. """ if self.data.get('infohash') == infohash: standardOverview = self.guiUtility.standardOverview if standardOverview.mode == 'libraryMode': standardOverview.filterChanged(None)
def addComponents(self): self.Show(False) self.hSizer = wx.BoxSizer(wx.HORIZONTAL) # Add Spacer self.hSizer.Add([10,5],0,wx.EXPAND|wx.FIXED_MINSIZE,0) # Add thumb self.thumb = ThumbnailViewer(self, 'libraryMode') self.thumb.setBackground(wx.BLACK) self.thumb.SetSize(libraryModeThumbSize) self.hSizer.Add(self.thumb, 0, wx.ALL, 2) # Add title self.title = wx.StaticText(self,-1,"",wx.Point(0,0),wx.Size(120,14)) self.title.SetBackgroundColour(wx.WHITE) self.title.SetFont(wx.Font(FS_TITLE,FONTFAMILY,FONTWEIGHT,wx.NORMAL,False,FONTFACE)) self.title.SetMinSize((120,14)) self.hSizer.Add(self.title,1,wx.TOP,3) ## self.vSizerTitle = wx.BoxSizer(wx.VERTICAL) ## self.vSizerTitle.Add (self.title, 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 3) ## self.vSizerTitle.Add (self.speedSizer, 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 3) ## self.hSizer.Add(self.vSizerTitle, 0, wx.LEFT|wx.RIGHT|wx.TOP|wx.EXPAND, 3) # V Line self.addLine() # Add Gauge/progressbar #self.pb = TriblerProgressbar(self,-1,wx.Point(359,0),wx.Size(80,15)) self.pb = ProgressBar(self,pos=wx.Point(359,0),size=wx.Size(100,5)) # >> Drawn in progressbar #self.pbLabel = wx.StaticText(self,-1,"12% |ETA:10min30",wx.Point(274,3),wx.Size(80,15),wx.ST_NO_AUTORESIZE) #self.pbSizer.Add(self.pbLabel,0,wx.TOP|wx.FIXED_MINSIZE,3) # << # Text under progressbar self.percentage = wx.StaticText(self,-1,"?%") self.percentage.SetForegroundColour(self.triblerGrey) self.percentage.SetFont(wx.Font(FS_PERC,FONTFAMILY,FONTWEIGHT,wx.NORMAL,False,FONTFACE)) self.eta = wx.StaticText(self,-1,"?") self.eta.SetForegroundColour(self.triblerGrey) self.eta.SetFont(wx.Font(FS_PERC,FONTFAMILY,FONTWEIGHT,wx.NORMAL,False,FONTFACE)) self.fileProgressSizer = wx.BoxSizer(wx.HORIZONTAL) self.fileProgressSizer.Add(self.percentage, 1, wx.EXPAND, 0) self.fileProgressSizer.Add(self.eta, 0, wx.EXPAND|wx.ALIGN_RIGHT, 0) self.pbMessage = wx.BoxSizer(wx.VERTICAL) self.pbMessage.Add(self.pb,0,wx.TOP|wx.EXPAND|wx.FIXED_MINSIZE,2) self.pbMessage.Add(self.fileProgressSizer,0,wx.TOP|wx.EXPAND|wx.FIXED_MINSIZE,1) self.hSizer.Add(self.pbMessage, 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 2) # pause/stop button self.pause = SwitchButton(self, -1, wx.Point(542,3), wx.Size(16,16),name='pause' ) self.hSizer.Add(self.pause,0,wx.TOP|wx.FIXED_MINSIZE,2) # V Line self.addLine() # Up/Down text speed # self.downSpeed = ImagePanel(self, -1, wx.DefaultPosition, wx.Size(16,16),name='downSpeed') # self.downSpeed.setBackground(wx.WHITE) # self.downSpeed.SetToolTipString(self.utility.lang.get('down')) self.speedDown2 = wx.StaticText(self,-1,"down: 0 KB/s",wx.Point(274,3),wx.Size(70,12),wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE) self.speedDown2.SetForegroundColour(self.triblerGrey) self.speedDown2.SetFont(wx.Font(FS_SPEED,FONTFAMILY,FONTWEIGHT,wx.NORMAL,False,FONTFACE)) self.speedDown2.SetMinSize((70,12)) # self.upSpeed = ImagePanel(self, -1, wx.DefaultPosition, wx.Size(16,16),name='upSpeed') # self.upSpeed.setBackground(wx.WHITE) # self.upSpeed.SetToolTipString(self.utility.lang.get('up')) self.speedUp2 = wx.StaticText(self,-1,"up: 0 KB/s",wx.Point(274,3),wx.Size(70,12),wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE) self.speedUp2.SetForegroundColour(self.triblerGrey) self.speedUp2.SetFont(wx.Font(FS_SPEED,FONTFAMILY,FONTWEIGHT,wx.NORMAL,False,FONTFACE)) self.speedUp2.SetMinSize((70,12)) # self.hSizer.Add(self.downSpeed, 0, wx.TOP, 2) # self.hSizer.Add([2,20],0,wx.EXPAND|wx.FIXED_MINSIZE,0) self.hSizer.Add(self.speedDown2, 0, wx.TOP|wx.EXPAND, 4) # V Line self.addLine() # self.hSizer.Add(self.upSpeed, 0, wx.LEFT|wx.TOP, 2) # self.hSizer.Add([2,20],0,wx.EXPAND|wx.FIXED_MINSIZE,0) self.hSizer.Add(self.speedUp2, 0, wx.TOP|wx.EXPAND, 4) # V Line self.addLine() # Status Icon ## self.statusIcon = ImagePanel(self, -1, name="LibStatus_boosting") ## self.statusIcon.searchBitmap(name = statusLibrary["stopped"]) ## ## self.hSizer.Add(self.statusIcon, 0, wx.TOP|wx.RIGHT|wx.EXPAND, 2) # Status message self.statusField = wx.StaticText(self, -1,'', wx.Point(),wx.Size()) self.statusField.SetForegroundColour(self.triblerGrey) self.statusField.SetFont(wx.Font(FS_SPEED,FONTFAMILY,FONTWEIGHT,wx.NORMAL,False,FONTFACE)) self.statusField.SetMinSize((60,12)) # self.statusField.SetMinSize((125,12)) self.hSizer.Add(self.statusField, 1, wx.TOP, 4) # V Line self.addLine() # Boost button self.boost = SwitchButton(self, name="boost") self.boost.setBackground(wx.WHITE) self.boost.SetSize((50,16)) self.boost.setEnabled(False) self.hSizer.Add(self.boost, 0, wx.TOP|wx.ALIGN_RIGHT, 2) self.hSizer.Add([2,20],0,wx.EXPAND|wx.FIXED_MINSIZE,0) # Play Fast self.playFast = SwitchButton(self, name="playFast") self.playFast.setBackground(wx.WHITE) self.playFast.SetSize((39,16)) self.playFast.setEnabled(False) self.hSizer.Add(self.playFast, 0, wx.TOP|wx.ALIGN_RIGHT, 2) self.hSizer.Add([2,20],0,wx.EXPAND|wx.FIXED_MINSIZE,0) # Play self.playerPlay = SwitchButton(self, name="libraryPlay") self.playerPlay.setBackground(wx.WHITE) self.playerPlay.SetSize((16,16)) self.playerPlay.setEnabled(False) self.hSizer.Add(self.playerPlay, 0, wx.TOP|wx.ALIGN_RIGHT, 2) self.hSizer.Add([2,20],0,wx.EXPAND|wx.FIXED_MINSIZE,0) # # TODO: TB >delete button should be removed when delete function in rightMouseButton menu works # Delete button #self.delete = tribler_topButton(self, -1, wx.DefaultPosition, wx.Size(16,16),name='deleteLibraryitem') #self.delete.setBackground(wx.WHITE) #self.hSizer.Add(self.delete,0,wx.TOP|wx.FIXED_MINSIZE|wx.ALIGN_TOP,7) #self.hSizer.Add([8,20],0,wx.EXPAND|wx.FIXED_MINSIZE,0) # Add Refresh self.SetSizer(self.hSizer); self.SetAutoLayout(1); self.Layout(); self.Refresh() # 2.8.4.2 return value of GetChildren changed wl = [self] for c in self.GetChildren(): wl.append(c) for window in wl: window.Bind(wx.EVT_LEFT_UP, self.mouseAction) #window.Bind(wx.EVT_LEFT_DCLICK, self.doubleClicked) window.Bind(wx.EVT_KEY_UP, self.keyTyped) window.Bind(wx.EVT_RIGHT_DOWN, self.mouseAction)
class SearchDetailsPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent, -1) self.guiUtility = GUIUtility.getInstance() self.addComponents() def addComponents(self): self.hSizer = wx.BoxSizer(wx.HORIZONTAL) #(self, -1, wx.DefaultPosition, wx.Size(16,16),name='down') self.stopMoreButton = SwitchButton(self, -1, wx.DefaultPosition, wx.DefaultSize, name='searchStop') self.stopMoreButton.Bind(wx.EVT_LEFT_UP, self.stopMoreClicked) self.stopMoreButton.SetToolTipString( self.guiUtility.utility.lang.get('searchStop')) self.clearButton = tribler_topButton(self, -1, wx.DefaultPosition, wx.DefaultSize, name='searchClear') self.clearButton.SetToolTipString( self.guiUtility.utility.lang.get('searchClear')) self.hSizer.Add([9, 5], 0, wx.EXPAND | wx.FIXED_MINSIZE, 0) self.hSizer.Add(self.stopMoreButton, 0, wx.ALL, 1) self.hSizer.Add(self.clearButton, 0, wx.ALL, 1) self.hSizer.Add([8, 5], 0, wx.EXPAND | wx.FIXED_MINSIZE, 0) self.textPanel = wx.Panel(self) sizer = wx.BoxSizer(wx.HORIZONTAL) self.text = wx.StaticText(self.textPanel, -1, '') self.text.SetForegroundColour(wx.Colour(255, 255, 255)) sizer.Add(self.text, 1, wx.ALL, 0) self.textPanel.SetSizer(sizer) self.textPanel.SetAutoLayout(1) self.textPanel.SetForegroundColour(wx.WHITE) self.textPanel.SetBackgroundColour(wx.Colour(53, 53, 53)) self.text.SetSize((-1, 15)) self.hSizer.Add(self.textPanel, 1, wx.TOP | wx.EXPAND, 3) self.SetSizer(self.hSizer) self.SetAutoLayout(1) self.SetMinSize((-1, 19)) self.SetBackgroundColour(wx.Colour(53, 53, 53)) self.hSizer.Layout() self.Layout() self.searchBusy = True #?? #self.Show(True) self.results = {} def setMessage(self, stype, finished, num, keywords=[]): if stype: self.results[stype] = num total = sum([v for v in self.results.values() if v != -1]) if keywords: if type(keywords) == list: self.keywords = " ".join(keywords) else: self.keywords = keywords if finished: msg = self.guiUtility.utility.lang.get('finished_search') % ( self.keywords, total) #self.stopMoreClicked() else: msg = self.guiUtility.utility.lang.get('going_search') % ( self.keywords, total) self.text.SetLabel(msg) tt = [] for pair in self.results.items(): key, value = pair if value == -1: continue tt.append( self.guiUtility.utility.lang.get('search_' + key) % value) tt.sort() tt = os.linesep.join(tt) self.textPanel.SetToolTipString(tt) self.text.SetToolTipString(tt) def startSearch(self): self.stopMoreButton.setToggled(False) self.searchBusy = True def stopSearch(self): # call remoteSearch and Web2.0 search to stop self.guiUtility.stopSearch() # def findMoreSearch(self): # # call remoteSearch and Web2.0 search to find more # self.startSearch() # grid = self.guiUtility.standardOverview.getGrid() # if grid.dod: # grid.dod.requestMore(grid.items) def searchFinished(self): self.searchBusy = False self.stopMoreButton.setToggled(True) self.setMessage(None, True, 0, None) def stopMoreClicked(self, event=None): if event: event.Skip() if self.searchBusy: self.stopSearch() self.searchFinished()