def __init__(self, abc, parent, internalvideo): self.abc = abc self._logger = logging.getLogger(self.__class__.__name__) self._logger.info('GUI started') # Do all init here self.ready = False self.guiUtility = GUIUtility.getInstance() self.guiUtility.frame = self self.utility = self.guiUtility.utility self.params = self.guiUtility.params self.utility.frame = self self.videoframe = None self.category = self.utility.session.lm.category self.shutdown_and_upgrade_notes = None title = "Tribler %s" % version_id # Get window size and (sash) position from config file size, position, sashpos = self.getWindowSettings() style = wx.DEFAULT_DIALOG_STYLE | wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX | wx.RESIZE_BORDER | wx.NO_FULL_REPAINT_ON_RESIZE | wx.CLIP_CHILDREN wx.Frame.__init__(self, parent, wx.ID_ANY, title, position, size, style) if sys.platform == 'linux2': font = self.GetFont() if font.GetPointSize() > 9: font.SetPointSize(9) self.SetFont(font) self.Freeze() self.SetDoubleBuffered(True) self.SetBackgroundColour(DEFAULT_BACKGROUND) themeColour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT) r, g, b = themeColour.Get(False) if r > 190 or g > 190 or b > 190: # Grey == 190,190,190 self.SetForegroundColour(wx.BLACK) if internalvideo: self.videoparentpanel = wx.Panel(self) self.videoparentpanel.Hide() else: self.videoparentpanel = None # Create all components self.utility.session.notifier.notify(NTFY_STARTUP_TICK, NTFY_INSERT, None, 'Creating panels') self.actlist = ActivitiesList(self) self.top_bg = TopSearchPanel(self) self.home = Home(self) self.splitter = wx.SplitterWindow(self, style=wx.SP_NOBORDER) self.splitter.SetMinimumPaneSize(1) self.splitter.SetForegroundColour(self.GetForegroundColour()) self.splitter_top_window = wx.Panel(self.splitter, style=wx.NO_BORDER) self.splitter_top_window.SetForegroundColour( self.GetForegroundColour()) self.splitter_top = wx.BoxSizer(wx.HORIZONTAL) self.splitter_top_window.SetSizer(self.splitter_top) self.splitter_bottom_window = wx.Panel(self.splitter) self.splitter_bottom_window.SetMinSize((-1, 25)) self.splitter_bottom_window.SetForegroundColour( self.GetForegroundColour()) self.splitter_bottom_window.OnChange = lambda: self.splitter_bottom.Layout( ) self.splitter_bottom_window.parent_list = self.splitter_bottom_window self.networkgraph = NetworkGraphPanel(self) self.networkgraph.Show(False) self.searchlist = SearchList(self.splitter_top_window) self.searchlist.Show(False) self.librarylist = LibraryList(self.splitter_top_window) self.librarylist.Show(False) self.channellist = ChannelList(self.splitter_top_window) self.channellist.Show(False) self.selectedchannellist = SelectedChannelList( self.splitter_top_window) self.selectedchannellist.Show(False) self.playlist = Playlist(self.splitter_top_window) self.playlist.Show(False) self.creditminingpanel = CreditMiningPanel(self) self.creditminingpanel.Show(False) # Populate the bottom window self.splitter_bottom = wx.BoxSizer(wx.HORIZONTAL) self.torrentdetailspanel = TorrentDetails(self.splitter_bottom_window) self.torrentdetailspanel.Show(False) self.librarydetailspanel = LibraryDetails(self.splitter_bottom_window) self.librarydetailspanel.Show(False) self.channeldetailspanel = ChannelDetails(self.splitter_bottom_window) self.channeldetailspanel.Show(False) self.playlistdetailspanel = PlaylistDetails( self.splitter_bottom_window) self.playlistdetailspanel.Show(False) self.searchinfopanel = SearchInfoPanel(self.splitter_bottom_window) self.searchinfopanel.Show(False) self.channelinfopanel = ChannelInfoPanel(self.splitter_bottom_window) self.channelinfopanel.Show(False) self.libraryinfopanel = LibraryInfoPanel(self.splitter_bottom_window) self.libraryinfopanel.Show(False) self.playlistinfopanel = PlaylistInfoPanel(self.splitter_bottom_window) self.playlistinfopanel.Show(False) self.selectedchannelinfopanel = SelectedchannelInfoPanel( self.splitter_bottom_window) self.selectedchannelinfopanel.Show(False) self.splitter_bottom.Add(self.torrentdetailspanel, 1, wx.EXPAND) self.splitter_bottom.Add(self.librarydetailspanel, 1, wx.EXPAND) self.splitter_bottom.Add(self.channeldetailspanel, 1, wx.EXPAND) self.splitter_bottom.Add(self.playlistdetailspanel, 1, wx.EXPAND) self.splitter_bottom.Add(self.searchinfopanel, 1, wx.EXPAND) self.splitter_bottom.Add(self.channelinfopanel, 1, wx.EXPAND) self.splitter_bottom.Add(self.libraryinfopanel, 1, wx.EXPAND) self.splitter_bottom.Add(self.playlistinfopanel, 1, wx.EXPAND) self.splitter_bottom.Add(self.selectedchannelinfopanel, 1, wx.EXPAND) self.splitter_bottom_window.SetSizer(self.splitter_bottom) self.splitter.SetSashGravity(0.8) self.splitter.SplitHorizontally(self.splitter_top_window, self.splitter_bottom_window, sashpos) self.splitter.Show(False) # Reset the sash position after the splitter has been made visible def OnShowSplitter(event): wx.CallAfter(self.splitter.SetSashPosition, sashpos) self.splitter.Unbind(wx.EVT_SHOW) event.Skip() self.splitter.Bind(wx.EVT_SHOW, OnShowSplitter) self.stats = Stats(self) self.stats.Show(False) self.managechannel = ManageChannel(self) self.managechannel.Show(False) self.utility.session.notifier.notify(NTFY_STARTUP_TICK, NTFY_INSERT, None, 'Positioning') # position all elements vSizer = wx.BoxSizer(wx.VERTICAL) vSizer.Add(self.top_bg, 0, wx.EXPAND) hSizer = wx.BoxSizer(wx.HORIZONTAL) vSizer.Add(hSizer, 1, wx.EXPAND) hSizer.Add(self.actlist, 0, wx.EXPAND) separator = wx.Panel(self, size=(1, -1)) separator.SetBackgroundColour(SEPARATOR_GREY) hSizer.Add(separator, 0, wx.EXPAND) hSizer.Add(self.home, 1, wx.EXPAND) hSizer.Add(self.stats, 1, wx.EXPAND) hSizer.Add(self.networkgraph, 1, wx.EXPAND) hSizer.Add(self.splitter, 1, wx.EXPAND) hSizer.Add(self.managechannel, 1, wx.EXPAND) if self.videoparentpanel: hSizer.Add(self.videoparentpanel, 1, wx.EXPAND) hSizer.Add(self.creditminingpanel, 1, wx.EXPAND) self.SetSizer(vSizer) # set sizes self.top_bg.SetMinSize((-1, 45)) self.actlist.SetMinSize((200, -1)) self.SRstatusbar = SRstatusbar(self) self.SetStatusBar(self.SRstatusbar) def preload_data(): self.guiUtility.showChannelCategory('All', False) self.guiUtility.showLibrary(False) startWorker(None, preload_data, delay=1.5, workerType="ThreadPool") if sys.platform != 'darwin': dragdroplist = FileDropTarget(self) self.SetDropTarget(dragdroplist) try: self.SetIcon( wx.Icon( os.path.join(self.utility.getPath(), 'Tribler', 'Main', 'vwxGUI', 'images', 'tribler.ico'), wx.BITMAP_TYPE_ICO)) except: pass self.tbicon = None try: self.tbicon = ABCTaskBarIcon(self) except: print_exc() # Don't update GUI as often when iconized self.GUIupdate = True self.window = self.GetChildren()[0] self.window.utility = self.utility self.utility.session.notifier.notify(NTFY_STARTUP_TICK, NTFY_INSERT, None, 'Binding events') # Menu Events # self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) # leaving here for the time being: # wxMSW apparently sends the event to the App object rather than # the top-level Frame, but there seemed to be some possibility of # change self.Bind(wx.EVT_QUERY_END_SESSION, self.OnCloseWindow) self.Bind(wx.EVT_END_SESSION, self.OnCloseWindow) self.Bind(wx.EVT_ICONIZE, self.onIconify) self.Bind(wx.EVT_SIZE, self.onSize) self.Bind(wx.EVT_MAXIMIZE, self.onSize) findId = wx.NewId() quitId = wx.NewId() nextId = wx.NewId() prevId = wx.NewId() dispId = wx.NewId() wxId = wx.NewId() anonId = wx.NewId() DISPERSY_DEBUG_FRAME_ID = wx.NewId() self.Bind(wx.EVT_MENU, self.OnFind, id=findId) self.Bind(wx.EVT_MENU, lambda event: self.Close(), id=quitId) self.Bind(wx.EVT_MENU, self.OnNext, id=nextId) self.Bind(wx.EVT_MENU, self.OnPrev, id=prevId) self.Bind(wx.EVT_MENU, lambda evt: self.guiUtility.ShowPage('stats'), id=dispId) self.Bind(wx.EVT_MENU, lambda evt: self.OpenInspectionTool(), id=wxId) self.Bind(wx.EVT_MENU, lambda evt: self.guiUtility.ShowPage('networkgraph'), id=anonId) self.Bind(wx.EVT_MENU, self.OnOpenDebugFrame, id=DISPERSY_DEBUG_FRAME_ID) accelerators = [(wx.ACCEL_CTRL, ord('f'), findId)] accelerators.append((wx.ACCEL_CTRL, ord('d'), dispId)) accelerators.append((wx.ACCEL_CTRL, ord('i'), wxId)) accelerators.append((wx.ACCEL_CTRL, ord('n'), anonId)) accelerators.append((wx.ACCEL_CTRL, wx.WXK_TAB, nextId)) accelerators.append( (wx.ACCEL_CTRL | wx.ACCEL_SHIFT, wx.WXK_TAB, prevId)) accelerators.append( (wx.ACCEL_CTRL | wx.ACCEL_ALT, ord('d'), DISPERSY_DEBUG_FRAME_ID)) if sys.platform == 'linux2': accelerators.append((wx.ACCEL_CTRL, ord('q'), quitId)) accelerators.append((wx.ACCEL_CTRL, ord('/'), findId)) self.SetAcceleratorTable(wx.AcceleratorTable(accelerators)) # Init video player self.utility.session.notifier.notify(NTFY_STARTUP_TICK, NTFY_INSERT, None, 'GUI complete') self.Thaw() self.ready = True self.SetMinSize((800, 600)) def post(): self.startCMDLineTorrent() # If the user passed a torrentfile on the cmdline, load it. wx.CallAfter(post)
def _PostInit(self): # Do all init here self.guiUtility = GUIUtility.getInstance() self.utility = self.guiUtility.utility self.params = self.guiUtility.params self.utility.frame = self self.torrentfeed = None title = self.utility.lang.get('title') + \ " " + \ self.utility.lang.get('version') # Get window size and position from config file size, position = self.getWindowSettings() style = wx.DEFAULT_FRAME_STYLE | wx.CLIP_CHILDREN self.SetSize(size) self.SetPosition(position) self.SetTitle(title) tt = self.GetToolTip() if tt is not None: tt.SetTip('') #wx.Frame.__init__(self, None, ID, title, position, size, style = style) self.doneflag = Event() dragdroplist = FileDropTarget(self) self.SetDropTarget(dragdroplist) self.tbicon = None # Arno: see ABCPanel #self.abc_sb = ABCStatusBar(self,self.utility) #self.SetStatusBar(self.abc_sb) """ # Add status bar statbarbox = wx.BoxSizer(wx.HORIZONTAL) self.sb_buttons = ABCStatusButtons(self,self.utility) statbarbox.Add(self.sb_buttons, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 0) self.abc_sb = ABCStatusBar(self,self.utility) statbarbox.Add(self.abc_sb, 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 0) #colSizer.Add(statbarbox, 0, wx.ALL|wx.EXPAND, 0) self.SetStatusBar(statbarbox) """ try: self.SetIcon(self.utility.icon) except: pass # Don't update GUI as often when iconized self.GUIupdate = True # Start the scheduler before creating the ListCtrl #self.utility.queue = ABCScheduler(self.utility) #self.window = ABCPanel(self) #self.abc_sb = self.window.abc_sb self.oldframe = None #self.oldframe = ABCOldFrame(-1, self.params, self.utility) #self.oldframe.Refresh() #self.oldframe.Layout() #self.oldframe.Show(True) self.window = self.GetChildren()[0] self.window.utility = self.utility """ self.list = ABCList(self.window) self.list.Show(False) self.utility.list = self.list print self.window.GetName() self.window.list = self.list self.utility.window = self.window """ #self.window.sb_buttons = ABCStatusButtons(self,self.utility) #self.utility.window.postponedevents = [] # Menu Options ############################ #menuBar = ABCMenuBar(self) #if sys.platform == "darwin": # wx.App.SetMacExitMenuItemId(wx.ID_CLOSE) #self.SetMenuBar(menuBar) #self.tb = ABCToolBar(self) # new Tribler gui has no toolbar #self.SetToolBar(self.tb) self.buddyFrame = None self.fileFrame = None self.buddyFrame_page = 0 self.buddyFrame_size = (800, 500) self.buddyFrame_pos = None self.fileFrame_size = (800, 500) self.fileFrame_pos = None # Menu Events ############################ self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) # self.Bind(wx.EVT_MENU, self.OnMenuExit, id = wx.ID_CLOSE) # leaving here for the time being: # wxMSW apparently sends the event to the App object rather than # the top-level Frame, but there seemed to be some possibility of # change self.Bind(wx.EVT_QUERY_END_SESSION, self.OnCloseWindow) self.Bind(wx.EVT_END_SESSION, self.OnCloseWindow) try: self.tbicon = ABCTaskBarIcon(self) except: print_exc() self.Bind(wx.EVT_ICONIZE, self.onIconify) self.Bind(wx.EVT_SET_FOCUS, self.onFocus) self.Bind(wx.EVT_SIZE, self.onSize) self.Bind(wx.EVT_MAXIMIZE, self.onSize) #self.Bind(wx.EVT_IDLE, self.onIdle) # If the user passed a torrentfile on the cmdline, load it. if DEBUG: print >> sys.stderr, "abc: wxFrame: params is", self.params # Init video player self.videoFrame = None feasible = return_feasible_playback_modes(self.utility.getPath()) if PLAYBACKMODE_INTERNAL in feasible: # This means vlc is available from Tribler.Video.EmbeddedPlayer import VideoFrame iconpath = os.path.join(self.utility.getPath(), 'Tribler', 'Images', 'tribler.ico') logopath = os.path.join(self.utility.getPath(), 'Tribler', 'Images', 'logoTribler.png') self.videoFrame = VideoFrame(self, 'Tribler Video', iconpath, logopath) #self.videores = xrc.XmlResource("Tribler/vwxGUI/MyPlayer.xrc") #self.videoframe = self.videores.LoadFrame(None, "MyPlayer") #self.videoframe.Show() videoplayer = VideoPlayer.getInstance() videoplayer.set_parentwindow(self.videoFrame) else: videoplayer = VideoPlayer.getInstance() videoplayer.set_parentwindow(self) sys.stdout.write('GUI Complete.\n') self.Show(True) # Just for debugging: add test permids and display top 5 peers from which the most is downloaded in bartercastdb # bartercastdb = BarterCastDBHandler.getInstance() # mypermid = bartercastdb.my_permid # # if DEBUG: # # top = bartercastdb.getTopNPeers(5)['top'] # # print 'My Permid: ', show_permid(mypermid) # # print 'Top 5 BarterCast peers:' # print '=======================' # # i = 1 # for (permid, up, down) in top: # print '%2d: %15s - %10d up %10d down' % (i, bartercastdb.getName(permid), up, down) # i += 1 # Check to see if ABC is associated with torrents ####################################################### if (sys.platform == 'win32'): if self.utility.config.Read('associate', "boolean"): if self.utility.regchecker and not self.utility.regchecker.testRegistry( ): dialog = RegCheckDialog(self) dialog.ShowModal() dialog.Destroy() self.checkVersion() wx.CallAfter(self.startCMDLineTorrent)