class ChannelResultFooter(ListFooter): def GetMidPanel(self, hSizer): self.message = StaticText(self) font = self.message.GetFont() font.SetPointSize(font.GetPointSize() + 2) font.SetWeight(wx.FONTWEIGHT_BOLD) self.message.SetFont(font) hSizer.Add(self.message, 0, wx.TOP | wx.BOTTOM | wx.ALIGN_BOTTOM, 3) hSizer.AddStretchSpacer() self.channelResults = wx.Button(self, -1, "Channel Results") hSizer.Add(self.channelResults, 0, wx.TOP | wx.BOTTOM, 3) def SetLabel(self, label, nr_channels): haveResults = True if nr_channels and nr_channels >= 1 else False if label != self.message.GetLabel(): self.message.SetLabel(label) if haveResults: self.HighLight() self.Layout() self.EnableResults(haveResults) def SetEvents(self, channel): #removing old, binding new eventhandler self.channelResults.Unbind(wx.EVT_BUTTON) self.channelResults.Bind(wx.EVT_BUTTON, channel) def EnableResults(self, state): self.channelResults.Enable(state) def Reset(self): self.EnableResults(False) self.message.SetLabel('')
def __init__(self, parent): wx.Panel.__init__(self, parent) self.guiutility = GUIUtility.getInstance() self.SetBackgroundColour(DEFAULT_BACKGROUND) vSizer = wx.BoxSizer(wx.VERTICAL) vSizer.AddStretchSpacer() text = StaticText(self, -1, "Tribler") font = text.GetFont() font.SetPointSize(font.GetPointSize() * 3) font.SetWeight(wx.FONTWEIGHT_BOLD) text.SetForegroundColour((255, 51, 0)) text.SetFont(font) textSizer = wx.FlexGridSizer(2, 2, 3, 7) if sys.platform == 'darwin': # mac self.searchBox = wx.TextCtrl(self, style=wx.TE_PROCESS_ENTER) else: self.searchBox = TextCtrlAutoComplete( self, entrycallback=parent.top_bg.complete) font = self.searchBox.GetFont() font.SetPointSize(font.GetPointSize() * 2) self.searchBox.SetFont(font) self.searchBox.Bind(wx.EVT_TEXT_ENTER, self.OnSearchKeyDown) if sys.platform == 'darwin': # mac self.searchBox.SetMinSize( (450, self.searchBox.GetTextExtent('T')[1] + 5)) else: self.searchBox.SetMinSize((450, -1)) self.searchBox.SetFocus() textSizer.Add(text, 0, wx.EXPAND | wx.RIGHT, 7) scalingSizer = wx.BoxSizer(wx.HORIZONTAL) scalingSizer.Add(self.searchBox) if sys.platform == 'darwin': # mac searchButton = wx.Button(self, -1, '\n') searchButton.SetLabel('Search') else: searchButton = wx.Button(self, -1, 'Search') searchButton.Bind(wx.EVT_BUTTON, self.OnClick) scalingSizer.Add(searchButton, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 3) textSizer.Add(scalingSizer, 0, wx.ALIGN_CENTER_VERTICAL) textSizer.AddSpacer((1, 1)) hSizer = wx.BoxSizer(wx.HORIZONTAL) hSizer.Add(StaticText(self, -1, "Take me to ")) channelLink = LinkStaticText(self, "channels", icon=None) channelLink.Bind(wx.EVT_LEFT_UP, self.OnChannels) hSizer.Add(channelLink) hSizer.Add(StaticText(self, -1, " to see what others are sharing")) textSizer.Add(hSizer) vSizer.Add(textSizer, 0, wx.ALIGN_CENTER) vSizer.AddStretchSpacer() self.aw_panel = ArtworkPanel(self) self.aw_panel.SetMinSize((-1, 275)) # TODO(lipu): enable this when metadata PR is merged #self.aw_panel.Show(self.guiutility.ReadGuiSetting('show_artwork', True)) self.aw_panel.Show(False) vSizer.Add(self.aw_panel, 0, wx.EXPAND) self.SetSizer(vSizer) self.Layout() self.Bind(wx.EVT_RIGHT_UP, self.OnRightClick) self.SearchFocus()
class ChannelFooter(ListFooter): def GetMidPanel(self, hSizer): self.hSizer = hSizer self.message = StaticText(self) self.message.SetMinSize((1, -1)) font = self.message.GetFont() font.SetPointSize(font.GetPointSize() + 2) font.SetWeight(wx.FONTWEIGHT_BOLD) self.message.SetFont(font) self.subtitle = wx.StaticText(self) self.subtitle.SetMinSize((1, -1)) self.manage = wx.Button(self, -1, 'Edit this Channel') self.spam = wx.Button(self, -1, 'Mark as Spam') self.favorite = wx.Button(self, -1, 'Mark as Favorite') self.ortext = None self.subtitle.Show(False) self.favorite.Show(False) self.spam.Show(False) self.manage.Show(False) def SetEvents(self, spam, favorite, remove, manage): self.spam_eventhandler = spam self.favorite_eventhandler = favorite self.remove_eventhandler = remove self.manage.Bind(wx.EVT_BUTTON, manage) def SetStates(self, vote, channelstate, iamModerator): self.Freeze() self.hSizer.Clear() explicit_vote = vote != 0 preview = not explicit_vote and not iamModerator open2edit = channelstate == ChannelCommunity.CHANNEL_CLOSED and iamModerator allow2edit = vote == 2 and channelstate == ChannelCommunity.CHANNEL_OPEN self.favorite.Show(False) self.spam.Show(False) self.manage.Show(False) #clean up old ortext statictext if self.ortext: self.ortext.Destroy() self.ortext = None header = '' msg = '' buttonSizer = None if preview: header = "You are looking at a preview of this Channel." msg = "If you want to see more of it, press the 'Mark as Favorite' button.\nTribler will then more aggressively download updates making sure you always have access to the newest content." self.spam.SetLabel('Mark as Spam') self.spam.Bind(wx.EVT_BUTTON, self.spam_eventhandler) self.spam.Show(True) self.ortext = wx.StaticText(self, -1, 'or') self.favorite.SetLabel('Mark as Favorite') self.favorite.Bind(wx.EVT_BUTTON, self.favorite_eventhandler) self.favorite.Show(True) buttonSizer = wx.BoxSizer(wx.HORIZONTAL) buttonSizer.Add(self.spam) buttonSizer.Add(self.ortext, 0, wx.LEFT | wx.RIGHT | wx.ALIGN_CENTRE_VERTICAL, 3) buttonSizer.Add(self.favorite) else: if open2edit: header = "You can now enable community-features for this Channel." msg = "Allowing other users to comment, modify and improve meta-data will increase the overall community feel. Try it now.\nEdit your channel settings to get started." self.manage.Show(True) buttonSizer = self.manage elif allow2edit: header = "This is an open community. You can modify, comment and add new content. Feel free to do so." self.manage.Show(True) buttonSizer = self.manage if vote == -1: header = '' msg = "You have marked this Channel as Spam." self.spam.SetLabel('This is not Spam') self.spam.Bind(wx.EVT_BUTTON, self.remove_eventhandler) self.spam.Show(True) buttonSizer = self.spam elif vote == 2: if msg == '': msg = "Thank you for marking this Channel as your Favorite." self.favorite.SetLabel('Remove Favorite') self.favorite.Bind(wx.EVT_BUTTON, self.remove_eventhandler) self.favorite.Show(True) if buttonSizer: sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(buttonSizer) sizer.Add(self.favorite) buttonSizer = sizer else: buttonSizer = self.favorite else: if msg == '': msg = "You can edit this channel" self.manage.Show(True) buttonSizer = self.manage if header != '': self.message.SetLabel(header) self.subtitle.SetLabel(msg) self.subtitle.Show(True) vSizer = wx.BoxSizer(wx.VERTICAL) vSizer.Add(self.message, 0, wx.EXPAND) if buttonSizer: if preview: vSizer.Add(self.subtitle, 0, wx.EXPAND) vSizer.Add(buttonSizer, 0, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, 10) else: sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.subtitle, 1, wx.EXPAND) sizer.Add(buttonSizer, 0, wx.TOP | wx.BOTTOM | wx.RIGHT, 3) vSizer.Add(sizer, 0, wx.EXPAND) else: vSizer.Add(self.subtitle, 0, wx.EXPAND) self.hSizer.Add(vSizer, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 7) else: self.message.SetLabel(msg) self.subtitle.Show(False) self.hSizer.Add(self.message, 1, wx.TOP | wx.BOTTOM | wx.ALIGN_BOTTOM | wx.LEFT, 7) self.hSizer.Add(buttonSizer, 0, wx.TOP | wx.BOTTOM | wx.RIGHT, 7) self.hSizer.Layout() self.Layout() self.Thaw() def Reset(self): ListFooter.Reset(self) self.Freeze() self.hSizer.Clear() self.subtitle.Show(False) self.favorite.Show(False) self.spam.Show(False) self.manage.Show(False) self.message.SetLabel('') self.Thaw() def GetStates(self): return (self.spam.GetLabel() == 'This is not Spam', self.favorite.GetLabel() == 'Remove Favorite')