def addColumn(key): strkey = key.replace("_", " ").capitalize() header = StaticText(self.panel, -1, strkey) _set_font(header, fontweight=wx.FONTWEIGHT_BOLD) self.gridSizer.Add(header) self.textdict[key] = StaticText(self.panel, -1, '') self.gridSizer.Add(self.textdict[key])
def SetBundleState(self, newstate, refresh=True, reset=False): if newstate is None: auto_guess = self.guiutility.utility.config.Read('use_bundle_magic', "boolean") newstate = Bundler.ALG_OFF # default stored_state = None if not reset: keywords = self.torrentsearch_manager.getSearchKeywords()[0] if keywords != '': try: stored_state = self.bundle_db.getPreference(keywords) except: pass #if db interaction fails, ignore local_override = stored_state is not None if local_override: newstate = stored_state elif auto_guess: newstate = Bundler.ALG_MAGIC self.bundlestate = newstate self.selected_bundle_mode = None self.Freeze() if newstate != Bundler.ALG_OFF: self.bundlestatetext.SetLabel(' by %s' % self.bundlestates_str[newstate]) else: self.bundlestatetext.SetLabel(' is %s' % self.bundlestates_str[newstate]) self.torrentsearch_manager.setBundleMode(newstate, refresh) self.bundleSizer.ShowItems(False) self.bundleSizer.Clear(deleteWindows = True) self.bundletexts = [] self.bundleSizer.Add(StaticText(self, -1, 'Bundle by ')) for i, state in enumerate(self.bundlestates): if newstate == state: text = StaticText(self, -1, self.bundlestates_str[state]) self.bundleSizer.Add(text) self.bundletexts.append(text) else: link = LinkStaticText(self, self.bundlestates_str[state], "wand.png") link.ShowIcon(False) link.SetIconToolTipString('Selected by Magic') link.Bind(wx.EVT_LEFT_UP, self.OnRebundle) link.action = state self.bundleSizer.Add(link) self.bundletexts.append(link) if i+1 < len(self.bundlestates): self.bundleSizer.AddSpacer((1, -1)) self.Layout() self.Thaw()
def GetMidPanel(self, hSizer): hSizer.AddStretchSpacer() self.title = StaticText(self) hSizer.Add(self.title) self.scrollBar = hSizer.AddSpacer((0,0)) self.scrollBar.sizer = hSizer
def _DoInit(self): try: disp = DispersyPanel(self) except: #Dispersy not ready, try again in 5s if self.createTimer is None: self.createTimer = wx.CallLater(5000, self._DoInit) else: self.createTimer.Restart(5000) print_exc() return self.SetBackgroundColour(DEFAULT_BACKGROUND) vSizer = wx.BoxSizer(wx.VERTICAL) self.dowserStatus = StaticText(self, -1, 'Dowser is not running') dowserButton = wx.Button(self, -1, 'Start dowser') dowserButton.Bind(wx.EVT_BUTTON, self.OnDowser) hSizer = wx.BoxSizer(wx.HORIZONTAL) hSizer.Add(self.dowserStatus, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 3) hSizer.Add(dowserButton) vSizer.Add(hSizer, 0, wx.ALIGN_RIGHT | wx.RIGHT | wx.BOTTOM, 10) vSizer.Add(disp, 1, wx.EXPAND | wx.BOTTOM, 10) hSizer = wx.BoxSizer(wx.HORIZONTAL) hSizer.Add(NetworkPanel(self), 1, wx.EXPAND | wx.BOTTOM | wx.RIGHT, 10) self.activity = ActivityPanel(self) hSizer.Add(self.activity, 1, wx.EXPAND | wx.BOTTOM, 10) vSizer.Add(hSizer, 0, wx.EXPAND) # ProxyService 90s Test_ # # hSizer = wx.BoxSizer(wx.HORIZONTAL) # hSizer.Add(NetworkTestPanel(self), 1, wx.EXPAND|wx.BOTTOM|wx.RIGHT, 10) # hSizer.Add(ProxyDiscoveryPanel(self), 1, wx.EXPAND|wx.BOTTOM, 10) # vSizer.Add(hSizer, 0, wx.EXPAND) # # _ProxyService 90s Test hSizer = wx.BoxSizer(wx.HORIZONTAL) hSizer.Add(NewTorrentPanel(self), 1, wx.EXPAND | wx.RIGHT, 10) hSizer.Add(PopularTorrentPanel(self), 1, wx.EXPAND | wx.RIGHT, 10) # boudewijn: disabled TopContributorsPanel, getTopNPeers is a very expensive call # hSizer.Add(TopContributorsPanel(self), 1, wx.EXPAND) vSizer.Add(hSizer, 0, wx.EXPAND) self.SetSizer(vSizer) self.Layout() self.Bind(wx.EVT_KEY_UP, self.onKey) if sys.platform.startswith('win'): # on Windows, the panel doesn't respond to keypresses self.Bind(wx.EVT_MOUSE_EVENTS, self.onMouse) self.isReady = True
def AddHeader(self): sizer = wx.BoxSizer(wx.HORIZONTAL) self.header = StaticText(self.parent, -1, ' ') self.info_icon = wx.StaticBitmap(self.parent, -1, self.icons['info']) sizer.Add(self.header, 0, wx.RIGHT, 7) sizer.Add(self.info_icon, 0, wx.ALIGN_CENTER_VERTICAL) self.vsizer.Add(sizer, 0, wx.BOTTOM, 3)
def GetSubTitlePanel(self, parent): hSizer = wx.BoxSizer(wx.HORIZONTAL) self.ff = StaticText(parent) self.ffbutton = LinkStaticText(parent, '', None) self.ffbutton.Bind(wx.EVT_LEFT_UP, self.toggleFamilyFilter) self._SetLabels() hSizer.Add(self.ff) hSizer.Add(self.ffbutton) return hSizer
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 AddComponents(self, columns, spacers): vSizer = wx.BoxSizer(wx.VERTICAL) vSizer.AddSpacer((-1, 3)) self.title = StaticText(self) _set_font(self.title, self.font_increment, self.fontweight) titlePanel = self.GetTitlePanel(self) subtitlePanel = self.GetSubTitlePanel(self) righttitlePanel = self.GetRightTitlePanel(self) belowPanel = self.GetBelowPanel(self) if titlePanel: subSizer = wx.BoxSizer(wx.HORIZONTAL) subSizer.Add(self.title) subSizer.Add(titlePanel, 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 3) titlePanel = subSizer else: titlePanel = self.title if subtitlePanel: subSizer = wx.BoxSizer(wx.VERTICAL) subSizer.Add(titlePanel, 0, wx.BOTTOM, 3) subSizer.Add(subtitlePanel) subtitlePanel = subSizer else: subtitlePanel = titlePanel subSizer = wx.BoxSizer(wx.HORIZONTAL) subSizer.Add(subtitlePanel) if righttitlePanel: subSizer.Add(righttitlePanel, 1, wx.LEFT, 3) righttitlePanel = subSizer vSizer.Add(righttitlePanel, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, self.radius + spacers[0]) if belowPanel: vSizer.Add(belowPanel, 1, wx.EXPAND | wx.TOP, 3) vSizer.AddSpacer((-1, 3)) if len(columns) > 0: hSizer = wx.BoxSizer(wx.HORIZONTAL) self.AddColumns(hSizer, self, columns) vSizer.Add(hSizer, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, self.radius + spacers[0]) self.SetSizer(vSizer)
def GetBelowPanel(self, parent): self.descriptionPanel = ImageScrollablePanel(parent) self.descriptionPanel.SetBackgroundColour(DEFAULT_BACKGROUND) self.description = StaticText(self.descriptionPanel) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.description, 1, wx.EXPAND | wx.ALL, 3) self.descriptionPanel.SetSizer(sizer) self.descriptionPanel.Hide() self.descriptionPanel.Bind(wx.EVT_SIZE, self.SetHeight) self.descriptionPanel.Bind(wx.EVT_SHOW, self.SetHeight) hSizer = wx.BoxSizer(wx.HORIZONTAL) hSizer.Add(self.descriptionPanel, 1, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, self.radius + 3) return hSizer
def GetMidPanel(self, hSizer): self.totals = [] for i in xrange(len(self.columns)): if self.columns[i]['width'] == wx.LIST_AUTOSIZE: option = 1 size = wx.DefaultSize else: option = 0 size = (self.columns[i]['width'],-1) label = StaticText(self, i, '', style = self.columns[i].get('footer_style',0)|wx.ST_NO_AUTORESIZE, size = size) hSizer.Add(label, option, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.TOP|wx.BOTTOM, 3) if self.columns[i]['width'] == wx.LIST_AUTOSIZE: label.SetMinSize((1,-1)) self.totals.append(label) self.scrollBar = hSizer.AddSpacer((3,0)) self.scrollBar.sizer = hSizer
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 __init__(self, parent, torrent): canEdit = canComment = False if torrent.hasChannel(): state, iamModerator = torrent.channel.getState() canEdit = state >= ChannelCommunity.CHANNEL_OPEN height = 125 if canEdit: height = 200 wx.Dialog.__init__(self, parent, -1, 'Are you sure you want to remove this torrent?', size=(600, height)) hSizer = wx.BoxSizer(wx.HORIZONTAL) hSizer.Add( wx.StaticBitmap( self, -1, wx.ArtProvider.GetBitmap(wx.ART_QUESTION, wx.ART_MESSAGE_BOX)), 0, wx.RIGHT, 10) vSizer = wx.BoxSizer(wx.VERTICAL) firstLine = StaticText( self, -1, "Delete '%s' from disk, or just remove them from your downloads?" % torrent.name) _set_font(firstLine, fontweight=wx.FONTWEIGHT_BOLD) firstLine.SetMinSize((1, -1)) vSizer.Add(firstLine, 0, wx.EXPAND | wx.BOTTOM, 3) vSizer.Add( StaticText( self, -1, "Removing from disk will move the selected item to your trash." ), 0, wx.EXPAND) vSizer.AddStretchSpacer() self.newName = None if canEdit: vSizer.Add( StaticText( self, -1, "While we're at it, can you improve the name of this torrent?" ), 0, wx.EXPAND | wx.BOTTOM, 3) self.newName = EditText(self, torrent.name) vSizer.Add(self.newName, 0, wx.EXPAND) vSizer.AddStretchSpacer() bSizer = wx.BoxSizer(wx.HORIZONTAL) bSizer.AddStretchSpacer() bSizer.Add(wx.Button(self, wx.ID_CANCEL), 0, wx.RIGHT, 3) bSizer.Add( wx.Button(self, wx.ID_DEFAULT, 'Only delete from downloads'), 0, wx.RIGHT, 3) bSizer.Add(wx.Button(self, wx.ID_DELETE, 'Also delete from disk')) vSizer.Add(bSizer, 0, wx.ALIGN_RIGHT | wx.TOP, 7) hSizer.Add(vSizer, 1, wx.EXPAND) border = wx.BoxSizer() border.Add(hSizer, 1, wx.ALL | wx.EXPAND, 10) self.Bind(wx.EVT_BUTTON, lambda event: self.EndModal(event.GetId())) self.SetSizer(border) self.Layout() self.CenterOnParent()
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()
def CreatePanel(self): panel = wx.Panel(self) panel.SetBackgroundColour(DEFAULT_BACKGROUND) vSizer = wx.BoxSizer(wx.VERTICAL) self.nrTorrents = StaticText(panel) self.nrFiles = StaticText(panel) self.totalSize = StaticText(panel) self.queueSize = StaticText(panel) self.nrChannels = StaticText(panel) self.incomplete = StaticText(panel) self.freeMem = None try: if wx.GetFreeMemory() != -1: self.freeMem = StaticText(panel) except: pass gridSizer = wx.FlexGridSizer(0, 2, 3, 10) gridSizer.AddGrowableCol(1) gridSizer.Add(StaticText(panel, -1, 'Number files')) gridSizer.Add(self.nrFiles, 0, wx.EXPAND) gridSizer.Add(StaticText(panel, -1, 'Total size')) gridSizer.Add(self.totalSize, 0, wx.EXPAND) gridSizer.Add(StaticText(panel, -1, 'Torrents collected')) gridSizer.Add(self.nrTorrents, 0, wx.EXPAND) gridSizer.Add(StaticText(panel, -1, 'Torrents in queue')) gridSizer.Add(self.queueSize, 0, wx.EXPAND) gridSizer.Add(StaticText(panel, -1, 'Channels found')) gridSizer.Add(self.nrChannels, 0, wx.EXPAND) gridSizer.Add( StaticText(panel, -1, 'Incomplete limit (cur, max, history, maxhistory)')) gridSizer.Add(self.incomplete, 0, wx.EXPAND) if self.freeMem: gridSizer.Add(StaticText(panel, -1, 'WX:Free memory')) gridSizer.Add(self.freeMem, 0, wx.EXPAND) vSizer.Add(gridSizer, 0, wx.EXPAND | wx.LEFT, 10) panel.SetSizer(vSizer) return panel
def GetSubTitlePanel(self, parent): self.subtitle = StaticText(parent) return self.subtitle
def __init__(self, parent, configfile, fileconfigfile, suggestedTrackers, toChannel=False): wx.Dialog.__init__(self, parent, -1, 'Create a .torrent', size=(600, 200)) self.guiutility = GUIUtility.getInstance() self.toChannel = toChannel vSizer = wx.BoxSizer(wx.VERTICAL) header = wx.StaticText(self, -1, 'Browse for a file or files') _set_font(header, fontweight=wx.FONTWEIGHT_BOLD) vSizer.Add(header, 0, wx.EXPAND | wx.BOTTOM, 3) self.locationText = StaticText(self, -1, '') vSizer.Add(self.locationText, 0, wx.EXPAND | wx.BOTTOM, 3) browseButton = wx.Button(self, -1, 'Browse') browseButton.Bind(wx.EVT_BUTTON, self.OnBrowse) browseDirButton = wx.Button(self, -1, 'Browse for a Directory') browseDirButton.Bind(wx.EVT_BUTTON, self.OnBrowseDir) hSizer = wx.BoxSizer(wx.HORIZONTAL) hSizer.Add(browseButton) hSizer.Add(browseDirButton) vSizer.Add(hSizer, 0, wx.ALIGN_RIGHT | wx.BOTTOM, 3) #self.recursive = wx.CheckBox(self, -1, 'Include all subdirectories') #self.recursive.Bind(wx.EVT_CHECKBOX, self.OnRecursive) #vSizer.Add(self.recursive, 0, wx.ALIGN_RIGHT|wx.BOTTOM, 3) vSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10) header = wx.StaticText(self, -1, '.Torrent details') _set_font(header, fontweight=wx.FONTWEIGHT_BOLD) vSizer.Add(header, 0, wx.EXPAND | wx.BOTTOM, 3) self.foundFilesText = StaticText( self, -1, 'Please select a file or files first') vSizer.Add(self.foundFilesText, 0, wx.EXPAND | wx.BOTTOM, 3) self.combineRadio = wx.RadioButton( self, -1, 'Combine files into a single .torrent', style=wx.RB_GROUP) self.combineRadio.Bind(wx.EVT_RADIOBUTTON, self.OnCombine) self.combineRadio.Enable(False) self.sepRadio = wx.RadioButton( self, -1, 'Create separate .torrent for every file') self.sepRadio.Bind(wx.EVT_RADIOBUTTON, self.OnCombine) self.sepRadio.Enable(False) vSizer.Add(self.combineRadio, 0, wx.EXPAND | wx.BOTTOM, 3) vSizer.Add(self.sepRadio, 0, wx.EXPAND | wx.BOTTOM, 3) self.specifiedName = wx.TextCtrl(self, -1, '') self.specifiedName.Enable(False) hSizer = wx.BoxSizer(wx.HORIZONTAL) hSizer.Add(wx.StaticText(self, -1, 'Specify a name'), 0, wx.ALIGN_CENTER_VERTICAL) hSizer.Add(self.specifiedName, 1, wx.EXPAND) vSizer.Add(hSizer, 0, wx.EXPAND | wx.BOTTOM, 3) vSizer.Add(StaticText(self, -1, 'Trackers')) self.trackerList = wx.TextCtrl(self, -1, '', style=wx.TE_MULTILINE) self.trackerList.SetMinSize((500, -1)) self.trackerHistory = wx.FileHistory(10) self.config = wx.FileConfig(appName="Tribler", localFilename=configfile) self.trackerHistory.Load(self.config) if self.trackerHistory.GetCount() > 0: trackers = [ self.trackerHistory.GetHistoryFile(i) for i in range(self.trackerHistory.GetCount()) ] if len(trackers) < len(suggestedTrackers): trackers.extend(suggestedTrackers[:len(suggestedTrackers) - len(trackers)]) else: trackers = suggestedTrackers for tracker in trackers: self.trackerList.AppendText(tracker + "\n") vSizer.Add(self.trackerList, 0, wx.EXPAND | wx.BOTTOM, 3) vSizer.Add(StaticText(self, -1, 'Comment')) self.commentList = wx.TextCtrl(self, -1, '', style=wx.TE_MULTILINE) vSizer.Add(self.commentList, 0, wx.EXPAND, 3) vSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 10) header = wx.StaticText(self, -1, 'Advanced options') _set_font(header, fontweight=wx.FONTWEIGHT_BOLD) vSizer.Add(header, 0, wx.EXPAND | wx.BOTTOM | wx.TOP, 3) abbrev_mb = " " + self.guiutility.utility.lang.get('MB') abbrev_kb = " " + self.guiutility.utility.lang.get('KB') piece_choices = [ self.guiutility.utility.lang.get('automatic'), '4' + abbrev_mb, '2' + abbrev_mb, '1' + abbrev_mb, '512' + abbrev_kb, '256' + abbrev_kb, '128' + abbrev_kb, '64' + abbrev_kb, '32' + abbrev_kb ] self.pieceChoice = wx.Choice(self, -1, choices=piece_choices) self.pieceChoice.SetSelection(0) hSizer = wx.BoxSizer(wx.HORIZONTAL) hSizer.Add(StaticText(self, -1, 'Piecesize'), 1) hSizer.Add(self.pieceChoice) vSizer.Add(hSizer, 0, wx.EXPAND | wx.BOTTOM, 3) vSizer.Add(StaticText(self, -1, 'Webseed')) self.webSeed = wx.TextCtrl(self, -1, 'Please select a file or files first') self.webSeed.Enable(False) vSizer.Add(self.webSeed, 0, wx.EXPAND | wx.BOTTOM, 3) cancel = wx.Button(self, wx.ID_CANCEL) cancel.Bind(wx.EVT_BUTTON, self.OnCancel) create = wx.Button(self, wx.ID_OK, 'Create .torrent(s)') create.Bind(wx.EVT_BUTTON, self.OnOk) bSizer = wx.StdDialogButtonSizer() bSizer.AddButton(cancel) bSizer.AddButton(create) bSizer.Realize() vSizer.Add(bSizer, 0, wx.EXPAND) sizer = wx.BoxSizer() sizer.Add(vSizer, 1, wx.EXPAND | wx.ALL, 10) self.SetSizerAndFit(sizer) self.selectedPaths = [] self.createdTorrents = [] self.cancelEvent = Event() self.filehistory = wx.FileHistory(1) self.fileconfig = wx.FileConfig(appName="Tribler", localFilename=fileconfigfile) self.filehistory.Load(self.fileconfig) if self.filehistory.GetCount() > 0: self.latestFile = self.filehistory.GetHistoryFile(0) else: self.latestFile = '' self.paths = None
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()
def __init__(self, parent_list, columns, leftSpacer=0, rightSpacer=0, singleExpanded=False, showChange=False, list_item_max=None, hasFilter=True, listRateLimit=LIST_RATE_LIMIT): self.columns = columns self.leftSpacer = leftSpacer self.rightSpacer = rightSpacer self.parent_list = parent_list self.singleExpanded = singleExpanded self.showChange = showChange self.list_selected = LIST_SELECTED self.listRateLimit = listRateLimit if not list_item_max: list_item_max = LIST_ITEM_MAX_SIZE self.list_item_max = list_item_max self.list_cur_max = self.list_item_max self.hasFilter = hasFilter hSizer = wx.BoxSizer(wx.HORIZONTAL) self.listpanel = wx.Panel(self, name="LIST") #vertical sizer containing all items self.vSizer = wx.BoxSizer(wx.VERTICAL) self.listpanel.SetSizer(self.vSizer) hSizer.Add(self.listpanel, 1) self.SetSizer(hSizer) #messagePanel text self.messagePanel = wx.Panel(self.listpanel) self.messagePanel.SetBackgroundColour(DEFAULT_BACKGROUND) self.messagePanel.Show(False) messageVSizer = wx.BoxSizer(wx.VERTICAL) self.headerText = StaticText(self.messagePanel) _set_font(self.headerText, fontweight=wx.FONTWEIGHT_BOLD) self.messageText = StaticText(self.messagePanel) self.loadNext = wx.Button(self.messagePanel) self.loadNext.Bind(wx.EVT_BUTTON, self.OnLoadMore) self.loadNext.Hide() messageVSizer.Add(self.headerText, 0, wx.EXPAND) messageVSizer.Add(self.messageText, 0, wx.EXPAND) messageVSizer.Add(self.loadNext, 0, wx.ALIGN_CENTER) self.messageText.sizer = messageVSizer self.messageText.altControl = None messageSizer = wx.BoxSizer(wx.HORIZONTAL) messageSizer.AddStretchSpacer() messageSizer.Add(messageVSizer, 0, wx.TOP | wx.BOTTOM, 7) messageSizer.AddStretchSpacer() self.messagePanel.SetSizer(messageSizer) #vertical scrollrate self.rate = None #states self.cur_expanded = None #quick filter self.filter = None self.filterMessage = None #sorting self.sortcolumn = None #queue lists self.done = True self.lastData = 0 self.dataTimer = None self.data = None self.raw_data = None self.items = {} # Allow list-items to store the most recent mouse left-down events: self.lastMouseLeftDownEvent = None self.curWidth = -1 self.Bind(wx.EVT_SIZE, self.OnEventSize)
def AddComponents(self, leftSpacer, rightSpacer): if leftSpacer > 0: self.hSizer.AddSpacer((leftSpacer, -1)) for i in xrange(len(self.columns)): if self.columns[i]['width'] == wx.LIST_AUTOSIZE: option = 1 size = wx.DefaultSize else: option = 0 size = (self.columns[i]['width'], -1) type = self.columns[i].get('type', 'label') if type == 'label': str_data = self.columns[i].get('fmt', unicode)(self.data[i]) control = StaticText(self, style=self.columns[i].get('style', 0) | wx.ST_NO_AUTORESIZE | wx.ST_DOTS_END, size=size) fontWeight = self.columns[i].get('fontWeight', wx.FONTWEIGHT_NORMAL) if fontWeight != wx.FONTWEIGHT_NORMAL: _set_font(control, fontweight=fontWeight) #niels: wx magic prevents us from passing this string with the constructor, ampersands will not work control.SetLabel(str_data.replace('&', "&&")) elif type == 'method': control = self.columns[i]['method'](self, self) if control: control.icon = self._get_icon(i, 'icon') control.icon_right = self._get_icon(i, 'icon_right') self.controls.append(control) if i != 0: self.hSizer.AddSpacer((3, -1)) if control.icon: self.hSizer.Add(control.icon, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 3) self.hSizer.Add( control, option, wx.RESERVE_SPACE_EVEN_IF_HIDDEN | wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.BOTTOM, 3) if control.icon_right: self.hSizer.Add(control.icon_right, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 3) if self.columns[i]['width'] == wx.LIST_AUTOSIZE: control.SetMinSize((1, -1)) elif self.columns[i]['width'] == LIST_AUTOSIZEHEADER: self.columns[i]['width'] = control.GetSize()[0] if self.parent_list.parent_list.header: self.parent_list.parent_list.header.ResizeColumn( i, self.columns[i]['width']) else: if self.columns[i]['width'] != LIST_AUTOSIZEHEADER: self.hSizer.Add((self.columns[i]['width'], -1), 0, wx.LEFT, 3) if rightSpacer > 0: self.hSizer.AddSpacer((rightSpacer, -1)) self.hSizer.Layout() self.AddEvents(self)