Beispiel #1
0
    def __init__(self, main_window, config, setfunc):
        BTDialog.__init__(self,
                          main_window,
                          style=wx.DEFAULT_DIALOG_STYLE | wx.CLIP_CHILDREN
                          | wx.WANTS_CHARS)
        self.Bind(wx.EVT_CLOSE, self.close)
        self.Bind(wx.EVT_CHAR, self.key)
        self.SetTitle(_("%s Settings") % app_name)

        self.setfunc = setfunc
        self.config = config

        self.notebook = wx.Notebook(self)

        self.notebook.Bind(wx.EVT_CHAR, self.key)

        self.general_panel = GeneralSettingsPanel(self.notebook)
        self.saving_panel = SavingSettingsPanel(self.notebook)
        self.network_panel = NetworkSettingsPanel(self.notebook)
        self.appearance_panel = AppearanceSettingsPanel(self.notebook)
        self.language_panel = LanguageSettingsPanel(self.notebook)

        self.vbox = VSizer()
        self.vbox.AddFirst(self.notebook, proportion=1, flag=wx.GROW)

        self.vbox.Layout()

        self.SetSizerAndFit(self.vbox)
        self.SetFocus()
    def __init__(self, parent, file_list, announce, piece_length, title,
                 comment, config):
        BTDialog.__init__(self, parent=parent, size=(400, -1))
        self.parent = parent
        self.SetTitle(_("Building torrents..."))
        self.file_list = file_list
        self.announce = deunicode(announce)
        self.piece_length = piece_length
        self.title = deunicode(title)
        self.comment = deunicode(comment)
        self.config = config

        self.flag = Event()  # ???

        self.vbox = VSizer()
        self.label = wx.StaticText(self, label=_("Checking file sizes..."))
        #self.label.set_line_wrap(True)

        self.vbox.AddFirst(self.label, flag=wx.ALIGN_LEFT)

        self.progressbar = wx.Gauge(self,
                                    range=1000,
                                    size=(400, 25),
                                    style=wx.GA_SMOOTH)
        self.vbox.Add(self.progressbar, flag=wx.GROW)

        self.vbox.Add(wx.StaticLine(self, style=wx.LI_HORIZONTAL),
                      flag=wx.GROW)

        self.action_area = wx.BoxSizer(wx.HORIZONTAL)

        self.cancelbutton = wx.Button(self, label=_("&Abort"))
        self.cancelbutton.Bind(wx.EVT_BUTTON, self.cancel)
        self.action_area.Add(self.cancelbutton,
                             flag=wx.LEFT | wx.RIGHT | wx.BOTTOM,
                             border=SPACING)

        self.done_button = wx.Button(self, label=_("&Ok"))
        self.done_button.Bind(wx.EVT_BUTTON, self.cancel)
        self.action_area.Add(self.done_button,
                             flag=wx.LEFT | wx.RIGHT | wx.BOTTOM,
                             border=SPACING)

        self.action_area.Show(self.done_button, False)

        self.seed_button = wx.Button(self, label=_("&Start seeding"))
        self.seed_button.Bind(wx.EVT_BUTTON, self.seed)
        self.action_area.Add(self.seed_button,
                             flag=wx.RIGHT | wx.BOTTOM,
                             border=SPACING)

        self.action_area.Show(self.seed_button, False)

        self.Bind(wx.EVT_CLOSE, self.cancel)

        self.vbox.Add(self.action_area, flag=wx.ALIGN_RIGHT, border=0)

        self.SetSizerAndFit(self.vbox)
        self.Show()
Beispiel #3
0
class SettingsWindow(BTDialog):
    def __init__(self, main_window, config, setfunc):
        BTDialog.__init__(self,
                          main_window,
                          style=wx.DEFAULT_DIALOG_STYLE | wx.CLIP_CHILDREN
                          | wx.WANTS_CHARS)
        self.Bind(wx.EVT_CLOSE, self.close)
        self.Bind(wx.EVT_CHAR, self.key)
        self.SetTitle(_("%s Settings") % app_name)

        self.setfunc = setfunc
        self.config = config

        self.notebook = wx.Notebook(self)

        self.notebook.Bind(wx.EVT_CHAR, self.key)

        self.general_panel = GeneralSettingsPanel(self.notebook)
        self.saving_panel = SavingSettingsPanel(self.notebook)
        self.network_panel = NetworkSettingsPanel(self.notebook)
        self.appearance_panel = AppearanceSettingsPanel(self.notebook)
        self.language_panel = LanguageSettingsPanel(self.notebook)

        self.vbox = VSizer()
        self.vbox.AddFirst(self.notebook, proportion=1, flag=wx.GROW)

        self.vbox.Layout()

        self.SetSizerAndFit(self.vbox)
        self.SetFocus()

    def key(self, event):
        c = event.GetKeyCode()
        if c == wx.WXK_ESCAPE:
            self.close()
        event.Skip()

    def get_save_in(self, *e):
        d = wx.DirDialog(self,
                         "",
                         style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
        d.SetPath(self.config['save_in'])
        if d.ShowModal() == wx.ID_OK:
            path = d.GetPath()
            self.saving_panel.save_in_button.SetLabel(path)
            self.setfunc('save_in', path)

    def start_torrent_behavior_changed(self, event):
        widget = event.GetEventObject()
        state_name = widget.state_name
        self.setfunc('start_torrent_behavior', state_name)

    def close(self, *e):
        self.Hide()
Beispiel #4
0
    def __init__(self, parent, *a, **k):
        style = k.get('style', 0)
        k['style'] = style | wx.CLIP_CHILDREN | wx.TAB_TRAVERSAL
        # aarrg
        self.settings_window = parent.GetParent()

        wx.Panel.__init__(self, parent, *a, **k)
        parent.AddPage(self, self.label)

        self.sizer = VSizer()
        self.SetSizerAndFit(self.sizer)
    def __init__(self, parent, *a, **k):
        wx.Panel.__init__(self, parent, *a, **k)
        self.sizer = VSizer()
        self.SetSizer(self.sizer)
        if 'errback' in k:
            self.errback = k.pop('errback')
        else:
            self.errback = self.set_language_failed

        # widgets
        self.box = wx.StaticBox(self, label="Translate %s into:" % app_name)

        self.language_names = [
            "System default",
        ] + [language_names[l] for l in languages]
        languages.insert(0, '')
        self.languages = languages
        self.choice = wx.Choice(self, choices=self.language_names)
        self.Bind(wx.EVT_CHOICE, self.set_language, self.choice)

        restart = wx.StaticText(
            self, -1, "You must restart %s for the\nlanguage "
            "setting to take effect." % app_name)

        self.bottom_error = wx.StaticText(self, -1, '')
        self.bottom_error.SetForegroundColour(error_color)

        # sizers
        self.box_sizer = wx.StaticBoxSizer(self.box, wx.VERTICAL)

        # set menu selection and warning item if necessary
        self.valid = True
        lang = read_language_file()
        if lang is not None:
            try:
                i = self.languages.index(lang)
                self.choice.SetSelection(i)
            except ValueError, e:
                self.top_error = wx.StaticText(
                    self,
                    -1,
                    "This version of %s does not \nsupport the language '%s'."
                    % (app_name, lang),
                )
                self.top_error.SetForegroundColour(error_color)

                self.box_sizer.Add(self.top_error,
                                   flag=wx.TOP | wx.LEFT | wx.RIGHT,
                                   border=SPACING)
                # BUG add menu separator
                # BUG change color of extra menu item
                self.choice.Append(lang)
                self.choice.SetSelection(len(self.languages))
                self.valid = False
class ProgressDialog(BTDialog):
    def __init__(self, parent, file_list, announce, piece_length, title,
                 comment, config):
        BTDialog.__init__(self, parent=parent, size=(400, -1))
        self.parent = parent
        self.SetTitle(_("Building torrents..."))
        self.file_list = file_list
        self.announce = deunicode(announce)
        self.piece_length = piece_length
        self.title = deunicode(title)
        self.comment = deunicode(comment)
        self.config = config

        self.flag = Event()  # ???

        self.vbox = VSizer()
        self.label = wx.StaticText(self, label=_("Checking file sizes..."))
        #self.label.set_line_wrap(True)

        self.vbox.AddFirst(self.label, flag=wx.ALIGN_LEFT)

        self.progressbar = wx.Gauge(self,
                                    range=1000,
                                    size=(400, 25),
                                    style=wx.GA_SMOOTH)
        self.vbox.Add(self.progressbar, flag=wx.GROW)

        self.vbox.Add(wx.StaticLine(self, style=wx.LI_HORIZONTAL),
                      flag=wx.GROW)

        self.action_area = wx.BoxSizer(wx.HORIZONTAL)

        self.cancelbutton = wx.Button(self, label=_("&Abort"))
        self.cancelbutton.Bind(wx.EVT_BUTTON, self.cancel)
        self.action_area.Add(self.cancelbutton,
                             flag=wx.LEFT | wx.RIGHT | wx.BOTTOM,
                             border=SPACING)

        self.done_button = wx.Button(self, label=_("&Ok"))
        self.done_button.Bind(wx.EVT_BUTTON, self.cancel)
        self.action_area.Add(self.done_button,
                             flag=wx.LEFT | wx.RIGHT | wx.BOTTOM,
                             border=SPACING)

        self.action_area.Show(self.done_button, False)

        self.seed_button = wx.Button(self, label=_("&Start seeding"))
        self.seed_button.Bind(wx.EVT_BUTTON, self.seed)
        self.action_area.Add(self.seed_button,
                             flag=wx.RIGHT | wx.BOTTOM,
                             border=SPACING)

        self.action_area.Show(self.seed_button, False)

        self.Bind(wx.EVT_CLOSE, self.cancel)

        self.vbox.Add(self.action_area, flag=wx.ALIGN_RIGHT, border=0)

        self.SetSizerAndFit(self.vbox)
        self.Show()

    def main(self):
        self.complete()

    def seed(self, widget=None):
        for f in self.file_list:
            if self.parent.parent:
                launch_coroutine(wx.the_app.gui_wrap,
                                 wx.the_app.publish_torrent, f + EXTENSION, f)
            else:
                btspawn('bittorrent', f + EXTENSION, '--publish', f)
        self.cancel()

    def cancel(self, widget=None):
        self.flag.set()
        self.Destroy()

    def set_progress_value(self, value):
        self.progressbar.SetValue(value * 1000)
        self._update_gui()

    def set_file(self, filename):
        self.label.SetLabel(_("building: ") + filename + EXTENSION)
        self.vbox.Layout()
        self.Fit()
        self._update_gui()

    def _update_gui(self):
        wx.GetApp().Yield(True)

    def complete(self):
        try:
            make_meta_files(
                self.announce.encode('utf8'),
                self.file_list,
                flag=self.flag,
                progressfunc=self.set_progress_value,
                filefunc=self.set_file,
                piece_len_pow2=self.piece_length,
                title=self.title,
                comment=self.comment,
                use_tracker=self.config['use_tracker'],
                data_dir=self.config['data_dir'],
            )
            if not self.flag.isSet():
                self.SetTitle(_("Done."))
                self.label.SetLabel(_("Done building torrents."))
                self.set_progress_value(1)
                self.action_area.Show(self.cancelbutton, False)
                self.action_area.Show(self.seed_button, True)
                self.action_area.Show(self.done_button, True)
                self.vbox.Layout()
        except (OSError, IOError), e:
            self.SetTitle(_("Error!"))
            self.label.SetLabel(
                _("Error building torrents: ") + unicode(e.args[0]))
Beispiel #7
0
    def __init__(self, parent, *a, **k):
        SettingsPanel.__init__(self, parent, *a, **k)

        # widgets
        self.gauge_box = wx.StaticBox(self, label=_("Progress bar style:"))

        self.gauge_sizer = wx.StaticBoxSizer(self.gauge_box, wx.VERTICAL)

        self.null_radio = wx.RadioButton(
            self,
            label=_("&None (just show percent complete)"),
            style=wx.RB_GROUP)
        self.null_radio.value = 0

        self.simple_radio = wx.RadioButton(self,
                                           label=_("&Ordinary progress bar"))
        self.simple_radio.value = 1
        self.simple_sample = self.new_sample(SimpleDownloadGauge, 1)

        self.moderate_radio = wx.RadioButton(self,
                                             label=_("&Detailed progress bar"))
        self.moderate_radio.value = 2
        msg = _(
            "(shows the percentage of complete, transferring, available and missing pieces in the torrent)"
        )
        if not text_wrappable:
            half = len(msg) // 2
            for i in xrange(half):
                if msg[half + i] == ' ':
                    msg = msg[:half + i + 1] + '\n' + msg[half + i + 1:]
                    break
                elif msg[half - i] == ' ':
                    msg = msg[:half - i + 1] + '\n' + msg[half - i + 1:]
                    break
        self.moderate_text = ElectroStaticText(self, wx.ID_ANY, msg)

        if text_wrappable: self.moderate_text.Wrap(250)
        self.moderate_sample = self.new_sample(ModerateDownloadGauge, 2)

        self.fancy_radio = wx.RadioButton(self, label=_("&Piece bar"))
        self.fancy_radio.value = 3
        self.fancy_text = ElectroStaticText(
            self, wx.ID_ANY,
            _("(shows the status of each piece in the torrent)"))
        if text_wrappable: self.fancy_text.Wrap(250)

        # generate random sample data
        r = set(xrange(200))
        self.sample_data = {}

        for key, count in (('h', 80), ('t', 20)) + tuple([(i, 5)
                                                          for i in range(19)]):
            self.sample_data[key] = SparseSet()
            for d in random.sample(r, count):
                self.sample_data[key].add(d)
                r.remove(d)
        for d in r:
            self.sample_data[0].add(d)

        self.fancy_sample = self.new_sample(FancyDownloadGauge, 3)

        # sizers
        gauge = wx.TOP | wx.LEFT | wx.RIGHT
        extra = wx.TOP | wx.LEFT | wx.RIGHT | wx.GROW
        self.gauge_sizer.Add(self.null_radio, flag=gauge, border=SPACING)
        self.gauge_sizer.AddSpacer((SPACING, SPACING))

        self.gauge_sizer.Add(self.simple_radio, flag=gauge, border=SPACING)
        self.gauge_sizer.Add(self.simple_sample, flag=extra, border=SPACING)
        self.gauge_sizer.AddSpacer((SPACING, SPACING))

        self.gauge_sizer.Add(self.moderate_radio, flag=gauge, border=SPACING)
        self.gauge_sizer.Add(self.moderate_sample, flag=extra, border=SPACING)
        self.gauge_sizer.Add(self.moderate_text, flag=extra, border=SPACING)
        self.gauge_sizer.AddSpacer((SPACING, SPACING))

        self.gauge_sizer.Add(self.fancy_radio, flag=gauge, border=SPACING)
        self.gauge_sizer.Add(self.fancy_sample, flag=extra, border=SPACING)
        self.gauge_sizer.Add(self.fancy_text, flag=extra, border=SPACING)

        self.sizer.AddFirst(self.gauge_sizer, flag=wx.GROW)

        # setup
        self.pb_group = (self.null_radio, self.simple_radio,
                         self.moderate_radio, self.fancy_radio)

        for r in self.pb_group:
            r.Bind(wx.EVT_RADIOBUTTON, self.radio)
            if r.value == wx.the_app.config[self.pb_config_key]:
                r.SetValue(True)
            else:
                r.SetValue(False)

        # toolbar widgets
        self.toolbar_box = wx.StaticBox(self, label=_("Toolbar style:"))
        self.toolbar_text = CheckButton(
            self, _("Show text"), self.settings_window, 'toolbar_text',
            self.settings_window.config['toolbar_text'],
            wx.the_app.reset_toolbar_style)
        self.toolbar_size_text = ElectroStaticText(self,
                                                   id=wx.ID_ANY,
                                                   label=_("Icon size:"))
        self.toolbar_size_choice = wx.Choice(self,
                                             choices=(_("Small"), _("Normal"),
                                                      _("Large")))
        self.toolbar_config_to_choice(wx.the_app.config['toolbar_size'])
        self.toolbar_size_choice.Bind(wx.EVT_CHOICE,
                                      self.toolbar_choice_to_config)

        # toolbar sizers
        self.toolbar_sizer = HSizer()
        self.toolbar_sizer.AddFirst(self.toolbar_text,
                                    flag=wx.ALIGN_CENTER_VERTICAL)
        line = wx.StaticLine(self, id=wx.ID_ANY, style=wx.VERTICAL)
        self.toolbar_sizer.Add(line, flag=wx.ALIGN_CENTER_VERTICAL | wx.GROW)
        self.toolbar_sizer.Add(self.toolbar_size_text,
                               flag=wx.ALIGN_CENTER_VERTICAL)
        self.toolbar_sizer.Add(self.toolbar_size_choice,
                               flag=wx.GROW | wx.ALIGN_TOP,
                               proportion=1)

        self.toolbar_box_sizer = wx.StaticBoxSizer(self.toolbar_box,
                                                   wx.VERTICAL)
        self.toolbar_box_sizer.Add(self.toolbar_sizer, flag=wx.GROW)

        self.sizer.Add(self.toolbar_box_sizer, flag=wx.GROW)

        if wx.the_app.config['debug']:
            # the T-Word widgets
            self.themes = []
            self.theme_choice = wx.Choice(self, choices=[])
            self.theme_choice.Enable(False)
            self.theme_choice.Bind(wx.EVT_CHOICE, self.set_theme)
            self.restart_hint = ElectroStaticText(
                self,
                id=wx.ID_ANY,
                label=_("(Changing themes requires restart.)"))
            self.theme_static_box = wx.StaticBox(self, label=_("Theme:"))

            # the T-Word sizers
            self.theme_sizer = VSizer()
            self.theme_sizer.AddFirst(self.theme_choice,
                                      flag=wx.GROW | wx.ALIGN_RIGHT)
            self.theme_sizer.Add(self.restart_hint,
                                 flag=wx.GROW | wx.ALIGN_RIGHT)

            self.theme_static_box_sizer = wx.StaticBoxSizer(
                self.theme_static_box, wx.VERTICAL)
            self.theme_static_box_sizer.Add(self.theme_sizer, flag=wx.GROW)
            self.sizer.Add(self.theme_static_box_sizer, flag=wx.GROW)

            self.get_themes()
Beispiel #8
0
class AppearanceSettingsPanel(SettingsPanel):
    label = _("Appearance")
    pb_config_key = 'progressbar_style'
    # sample data
    sample_value = 0.4

    sample_data = {
        'h': SparseSet(),
        't': SparseSet(),
    }

    sample_data['h'].add(0, 80)
    sample_data['t'].add(80, 100)

    for i in range(20, 0, -1):
        s = SparseSet()
        s.add(200 - i * 5, 200 - (i - 1) * 5)
        sample_data[i - 1] = s
    del i, s

    def __init__(self, parent, *a, **k):
        SettingsPanel.__init__(self, parent, *a, **k)

        # widgets
        self.gauge_box = wx.StaticBox(self, label=_("Progress bar style:"))

        self.gauge_sizer = wx.StaticBoxSizer(self.gauge_box, wx.VERTICAL)

        self.null_radio = wx.RadioButton(
            self,
            label=_("&None (just show percent complete)"),
            style=wx.RB_GROUP)
        self.null_radio.value = 0

        self.simple_radio = wx.RadioButton(self,
                                           label=_("&Ordinary progress bar"))
        self.simple_radio.value = 1
        self.simple_sample = self.new_sample(SimpleDownloadGauge, 1)

        self.moderate_radio = wx.RadioButton(self,
                                             label=_("&Detailed progress bar"))
        self.moderate_radio.value = 2
        msg = _(
            "(shows the percentage of complete, transferring, available and missing pieces in the torrent)"
        )
        if not text_wrappable:
            half = len(msg) // 2
            for i in xrange(half):
                if msg[half + i] == ' ':
                    msg = msg[:half + i + 1] + '\n' + msg[half + i + 1:]
                    break
                elif msg[half - i] == ' ':
                    msg = msg[:half - i + 1] + '\n' + msg[half - i + 1:]
                    break
        self.moderate_text = ElectroStaticText(self, wx.ID_ANY, msg)

        if text_wrappable: self.moderate_text.Wrap(250)
        self.moderate_sample = self.new_sample(ModerateDownloadGauge, 2)

        self.fancy_radio = wx.RadioButton(self, label=_("&Piece bar"))
        self.fancy_radio.value = 3
        self.fancy_text = ElectroStaticText(
            self, wx.ID_ANY,
            _("(shows the status of each piece in the torrent)"))
        if text_wrappable: self.fancy_text.Wrap(250)

        # generate random sample data
        r = set(xrange(200))
        self.sample_data = {}

        for key, count in (('h', 80), ('t', 20)) + tuple([(i, 5)
                                                          for i in range(19)]):
            self.sample_data[key] = SparseSet()
            for d in random.sample(r, count):
                self.sample_data[key].add(d)
                r.remove(d)
        for d in r:
            self.sample_data[0].add(d)

        self.fancy_sample = self.new_sample(FancyDownloadGauge, 3)

        # sizers
        gauge = wx.TOP | wx.LEFT | wx.RIGHT
        extra = wx.TOP | wx.LEFT | wx.RIGHT | wx.GROW
        self.gauge_sizer.Add(self.null_radio, flag=gauge, border=SPACING)
        self.gauge_sizer.AddSpacer((SPACING, SPACING))

        self.gauge_sizer.Add(self.simple_radio, flag=gauge, border=SPACING)
        self.gauge_sizer.Add(self.simple_sample, flag=extra, border=SPACING)
        self.gauge_sizer.AddSpacer((SPACING, SPACING))

        self.gauge_sizer.Add(self.moderate_radio, flag=gauge, border=SPACING)
        self.gauge_sizer.Add(self.moderate_sample, flag=extra, border=SPACING)
        self.gauge_sizer.Add(self.moderate_text, flag=extra, border=SPACING)
        self.gauge_sizer.AddSpacer((SPACING, SPACING))

        self.gauge_sizer.Add(self.fancy_radio, flag=gauge, border=SPACING)
        self.gauge_sizer.Add(self.fancy_sample, flag=extra, border=SPACING)
        self.gauge_sizer.Add(self.fancy_text, flag=extra, border=SPACING)

        self.sizer.AddFirst(self.gauge_sizer, flag=wx.GROW)

        # setup
        self.pb_group = (self.null_radio, self.simple_radio,
                         self.moderate_radio, self.fancy_radio)

        for r in self.pb_group:
            r.Bind(wx.EVT_RADIOBUTTON, self.radio)
            if r.value == wx.the_app.config[self.pb_config_key]:
                r.SetValue(True)
            else:
                r.SetValue(False)

        # toolbar widgets
        self.toolbar_box = wx.StaticBox(self, label=_("Toolbar style:"))
        self.toolbar_text = CheckButton(
            self, _("Show text"), self.settings_window, 'toolbar_text',
            self.settings_window.config['toolbar_text'],
            wx.the_app.reset_toolbar_style)
        self.toolbar_size_text = ElectroStaticText(self,
                                                   id=wx.ID_ANY,
                                                   label=_("Icon size:"))
        self.toolbar_size_choice = wx.Choice(self,
                                             choices=(_("Small"), _("Normal"),
                                                      _("Large")))
        self.toolbar_config_to_choice(wx.the_app.config['toolbar_size'])
        self.toolbar_size_choice.Bind(wx.EVT_CHOICE,
                                      self.toolbar_choice_to_config)

        # toolbar sizers
        self.toolbar_sizer = HSizer()
        self.toolbar_sizer.AddFirst(self.toolbar_text,
                                    flag=wx.ALIGN_CENTER_VERTICAL)
        line = wx.StaticLine(self, id=wx.ID_ANY, style=wx.VERTICAL)
        self.toolbar_sizer.Add(line, flag=wx.ALIGN_CENTER_VERTICAL | wx.GROW)
        self.toolbar_sizer.Add(self.toolbar_size_text,
                               flag=wx.ALIGN_CENTER_VERTICAL)
        self.toolbar_sizer.Add(self.toolbar_size_choice,
                               flag=wx.GROW | wx.ALIGN_TOP,
                               proportion=1)

        self.toolbar_box_sizer = wx.StaticBoxSizer(self.toolbar_box,
                                                   wx.VERTICAL)
        self.toolbar_box_sizer.Add(self.toolbar_sizer, flag=wx.GROW)

        self.sizer.Add(self.toolbar_box_sizer, flag=wx.GROW)

        if wx.the_app.config['debug']:
            # the T-Word widgets
            self.themes = []
            self.theme_choice = wx.Choice(self, choices=[])
            self.theme_choice.Enable(False)
            self.theme_choice.Bind(wx.EVT_CHOICE, self.set_theme)
            self.restart_hint = ElectroStaticText(
                self,
                id=wx.ID_ANY,
                label=_("(Changing themes requires restart.)"))
            self.theme_static_box = wx.StaticBox(self, label=_("Theme:"))

            # the T-Word sizers
            self.theme_sizer = VSizer()
            self.theme_sizer.AddFirst(self.theme_choice,
                                      flag=wx.GROW | wx.ALIGN_RIGHT)
            self.theme_sizer.Add(self.restart_hint,
                                 flag=wx.GROW | wx.ALIGN_RIGHT)

            self.theme_static_box_sizer = wx.StaticBoxSizer(
                self.theme_static_box, wx.VERTICAL)
            self.theme_static_box_sizer.Add(self.theme_sizer, flag=wx.GROW)
            self.sizer.Add(self.theme_static_box_sizer, flag=wx.GROW)

            self.get_themes()

    def get_themes(self):
        def _callback(themes):
            self.themes.extend(themes)
            self.theme_choice.AppendItems(strings=themes)

            curr_theme = wx.the_app.config['theme']
            if curr_theme not in self.themes:
                self.settings_window.setfunc('theme', 'default')
                curr_theme = wx.the_app.config['theme']

            curr_idx = self.themes.index(curr_theme)
            self.theme_choice.SetSelection(curr_idx)
            self.theme_choice.Enable(True)

        def callback(themes):
            gui_wrap(_callback, themes)

        df = list_themes()
        df.addCallback(callback)
        df.getResult()

    def set_theme(self, e):
        i = self.theme_choice.GetSelection()
        t = self.themes[i]
        self.settings_window.setfunc('theme', t)

    def toolbar_choice_to_config(self, *a):
        i = self.toolbar_size_choice.GetSelection(),
        size = 8 * (i[0] + 2)
        self.settings_window.setfunc('toolbar_size', size)
        wx.the_app.reset_toolbar_style()

    def toolbar_config_to_choice(self, value):
        i = (value // 8) - 2
        self.toolbar_size_choice.SetSelection(i)

    def new_sample(self, sample_class, value):
        sample = sample_class(self,
                              size=wx.Size(-1, 20),
                              style=wx.SUNKEN_BORDER)
        # I happen to know 200 is the right number because I looked.
        sample.SetValue(self.sample_value, 'running',
                        (200, 0, self.sample_data))
        sample.Bind(wx.EVT_LEFT_DOWN, self.sample)
        sample.Bind(wx.EVT_CONTEXT_MENU, None)
        sample.value = value
        return sample

    def radio(self, event):
        widget = event.GetEventObject()
        value = widget.value
        self.settings_window.setfunc(self.pb_config_key, value)
        gui_wrap(wx.the_app.main_window.torrentlist.change_gauge_type, value)

    def sample(self, event):
        self.radio(event)
        pb = event.GetEventObject()
        value = pb.value
        for p in self.pb_group:
            if p.value == value:
                p.SetValue(True)
                break