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 _PostInit(self): self.guiutility = GUIUtility.getInstance() self.SetBackgroundColour(DEFAULT_BACKGROUND) vSizer = wx.BoxSizer(wx.VERTICAL) vSizer.AddStretchSpacer() text = StaticText(self, -1, self.guiutility.utility.lang.get('title')) 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=self.parent.top_bg.complete, selectcallback=self.parent.top_bg.OnAutoComplete) 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() buzzpanel = BuzzPanel(self) vSizer.Add(buzzpanel, 0, wx.EXPAND) self.SetSizer(vSizer) self.Layout() 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')
def __init__(self, parent, parent_list, size): wx.Panel.__init__(self, parent, size = size) self.SetForegroundColour(parent.GetForegroundColour()) self.guiutility = GUIUtility.getInstance() self.torrentsearch_manager = self.guiutility.torrentsearch_manager self.parent = parent self.parent_list = parent_list self.nrfiltered = 0 self.family_filter = True self.bundlestates = [Bundler.ALG_MAGIC, Bundler.ALG_NAME, Bundler.ALG_NUMBERS, Bundler.ALG_SIZE, Bundler.ALG_OFF] self.bundlestates_str = {Bundler.ALG_NAME: 'Name', Bundler.ALG_NUMBERS: 'Numbers', Bundler.ALG_SIZE: 'Size', Bundler.ALG_MAGIC: 'Magic', Bundler.ALG_OFF: 'Off'} self.bundletexts = [] self.bundle_db = BundlerPreferenceDBHandler.getInstance() self.uelog = UserEventLogDBHandler.getInstance() self.vSizer = wx.BoxSizer(wx.VERTICAL) hSizer = wx.BoxSizer(wx.HORIZONTAL) header = StaticText(self, -1, 'Search') if SearchSideBar.HEADER_FONT_WEIGHT != wx.FONTWEIGHT_NORMAL: font = header.GetFont() font.SetWeight(SearchSideBar.HEADER_FONT_WEIGHT) header.SetFont(font) hSizer.Add(header, 0, wx.ALIGN_CENTER_VERTICAL) self.searchState = StaticText(self) hSizer.Add(self.searchState, 1, wx.ALIGN_CENTER_VERTICAL) ag_fname = os.path.join(self.guiutility.utility.getPath(), LIBRARYNAME, 'Main', 'vwxGUI', 'images', 'search_new.gif') self.ag = wx.animate.GIFAnimationCtrl(self, -1, ag_fname) self.ag.UseBackgroundColour(True) self.ag.Hide() hSizer.Add(self.ag, 0, wx.RESERVE_SPACE_EVEN_IF_HIDDEN) self.vSizer.Add(hSizer, 0, wx.EXPAND|wx.BOTTOM, 3) self.vSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.BOTTOM, 3) self.searchGauge = wx.Gauge(self, size = (-1, 7)) self.vSizer.Add(self.searchGauge, 0, wx.EXPAND|wx.RESERVE_SPACE_EVEN_IF_HIDDEN) self.vSizer.AddSpacer((-1,15)) hSizer = wx.BoxSizer(wx.HORIZONTAL) header = StaticText(self, -1, 'Family Filter') if SearchSideBar.HEADER_FONT_WEIGHT != wx.FONTWEIGHT_NORMAL: font = header.GetFont() font.SetWeight(SearchSideBar.HEADER_FONT_WEIGHT) header.SetFont(font) hSizer.Add(header) self.ffstate = StaticText(self) hSizer.Add(self.ffstate) self.vSizer.Add(hSizer, 0, wx.EXPAND|wx.BOTTOM, 3) self.vSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.BOTTOM, 3) self.ffblocked = StaticText(self) self.vSizer.Add(self.ffblocked, 0, wx.EXPAND|wx.LEFT, SearchSideBar.INDENT) self.ffbutton = LinkStaticText(self, '', None) self.ffbutton.Bind(wx.EVT_LEFT_UP, self.toggleFamilyFilter) self.vSizer.Add(self.ffbutton, 0, wx.EXPAND|wx.LEFT, SearchSideBar.INDENT) self.vSizer.AddSpacer((-1,15)) hSizer = wx.BoxSizer(wx.HORIZONTAL) header = StaticText(self, -1, 'Bundling') if SearchSideBar.HEADER_FONT_WEIGHT != wx.FONTWEIGHT_NORMAL: font = header.GetFont() font.SetWeight(SearchSideBar.HEADER_FONT_WEIGHT) header.SetFont(font) hSizer.Add(header) #keep longest text in bundlestatetext, to define bestsize (width) for sidepanel self.bundlestatetext = StaticText(self, -1, ' by Numbers') hSizer.Add(self.bundlestatetext) self.vSizer.Add(hSizer, 0, wx.EXPAND|wx.BOTTOM, 3) self.vSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.BOTTOM, 3) self.bundleSizer = wx.FlexGridSizer(0, 2, 0, 0) self.SetBundleState(None, reset = True) self.vSizer.Add(self.bundleSizer, 0, wx.EXPAND|wx.LEFT, SearchSideBar.INDENT) self.vSizer.AddSpacer((-1,15)) header = StaticText(self, -1, 'Associated Channels') if SearchSideBar.HEADER_FONT_WEIGHT != wx.FONTWEIGHT_NORMAL: font = header.GetFont() font.SetWeight(SearchSideBar.HEADER_FONT_WEIGHT) header.SetFont(font) self.vSizer.Add(header, 0, wx.EXPAND|wx.BOTTOM, 3) self.vSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.BOTTOM, 3) self.nochannels = StaticText(self, -1, 'None') self.vSizer.Add(self.nochannels, 0, wx.EXPAND|wx.LEFT, SearchSideBar.INDENT) self.channels = [LinkStaticText(self, '', icon = None) for _ in range(3)] for channel in self.channels: self.vSizer.Add(channel, 0, wx.EXPAND|wx.LEFT, SearchSideBar.INDENT) channel.Bind(wx.EVT_LEFT_UP, self.OnChannel) borderSizer = wx.BoxSizer(wx.VERTICAL) borderSizer.AddSpacer((-1, 3)) borderSizer.Add(self.vSizer, 1, wx.EXPAND|wx.LEFT|wx.RIGHT, 7) self.SetSizer(borderSizer) self.SetMinSize((self.GetBestSize()[0], -1)) self.Reset()