Home | Trees | Indices | Help |
|
---|
|
1 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Rickard Lindberg, Roger Lindberg 2 # 3 # This file is part of Timeline. 4 # 5 # Timeline is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # Timeline is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with Timeline. If not, see <http://www.gnu.org/licenses/>. 17 18 19 import wx 20 import webbrowser 21 22 from timelinelib.wxgui.components.propertyeditors.baseeditor import BaseEditor 23 2426 29 3281 8234 self.btn_add = self._create_id_button(wx.ID_ADD, self._btn_add_on_click) 35 self.btn_clear = self._create_id_button(wx.ID_CLEAR, self._btn_clear_on_click) 36 self.btn_append = self._create_button(_("&Append"), self._btn_append_on_click) 37 self.btn_remove = self._create_button(_("&Remove"), self._btn_remove_on_click) 38 self.btn_test = self._create_button(_("Te&st"), self._btn_test_on_click) 39 self.url_panel = self._create_input_controls() 40 return (self.btn_add, self.btn_clear, self.btn_test, self.url_panel)4143 self.btn_add, self.btn_clear, self.btn_test, self.url_panel = controls 44 box_sizer = wx.BoxSizer(wx.HORIZONTAL) 45 box_sizer.Add(self.btn_add) 46 box_sizer.Add(self.btn_clear) 47 box_sizer.Add(self.btn_append) 48 box_sizer.Add(self.btn_remove) 49 box_sizer.Add(self.btn_test) 50 sizer.Add(box_sizer, wx.GBPosition(0, 0), wx.GBSpan(1, 1)) 51 sizer.Add(self.url_panel, wx.GBPosition(1, 0), wx.GBSpan(4, 5), wx.EXPAND | wx.ALL) 52 sizer.AddGrowableRow(1) 53 sizer.AddGrowableCol(0)54 59 6466 TEXT_WIDTH = 300 67 panel = wx.Panel(self) 68 label = wx.StaticText(panel, label=_("URL:")) 69 self.data = wx.TextCtrl(panel, size=(TEXT_WIDTH, 20)) 70 self.list = wx.ListBox(panel, wx.ID_ANY, size=(TEXT_WIDTH, -1)) 71 sizer = wx.GridBagSizer(5, 10) 72 sizer.Add(label, wx.GBPosition(0, 0), wx.GBSpan(1, 1)) 73 sizer.Add(self.data, wx.GBPosition(0, 1), wx.GBSpan(1, 9), wx.EXPAND | wx.ALL, 1) 74 sizer.Add(self.list, wx.GBPosition(1, 1), wx.GBSpan(1, 9), wx.EXPAND | wx.ALL, 1) 75 sizer.AddGrowableRow(1) 76 sizer.AddGrowableCol(1) 77 panel.SetSizerAndFit(sizer) 78 self.Bind(wx.EVT_LISTBOX, self._lb_on_click, self.list) 79 self.data.Bind(wx.EVT_SET_FOCUS, self._txt_on_focus) 80 return panel8416186 BaseEditor.__init__(self, parent, editor) 87 HyperlinkEditorGuiCreator.__init__(self, parent) 88 self.create_gui() 89 self._set_visible(False)9092 if self.url_visible: 93 urls = [item for item in self.list.GetItems() if len(item.strip()) > 0] 94 if len(urls) > 0: 95 return ";".join(urls) 96 else: 97 return None 98 else: 99 return None100102 if data is None: 103 self._set_visible(False) 104 else: 105 self._set_visible(True) 106 self.list.InsertItems(data.split(";"), 0)107 110112 self.clear_data()113115 if len(self.data.GetValue().strip()) > 0: 116 self.list.Append(self.data.GetValue()) 117 self.data.SetValue("") 118 self._change_btn_visibility() 119 self.data.SetFocus()120122 try: 123 self.list.Delete(self.list.GetSelection()) 124 except: 125 pass 126 self.data.SetFocus()127 132 135 139 142144 self.url_visible = value 145 self.url_panel.Show(self.url_visible) 146 self.btn_add.Enable(not value) 147 self.btn_clear.Enable(value) 148 self.btn_append.Enable(value) 149 self.GetSizer().Layout() 150 self.data.SetFocus()151
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Mar 25 02:55:27 2020 | http://epydoc.sourceforge.net |