Пример #1
0
    def __init__(self,
                 parent,
                 name,
                 height_num_chars,
                 sizing_column_initial_width_num_chars,
                 columns,
                 data_to_tuples_func,
                 delete_key_callback=None,
                 activation_callback=None):

        wx.ListCtrl.__init__(self, parent, style=wx.LC_REPORT)
        ListCtrlAutoWidthMixin.__init__(self)

        self._data_to_tuples_func = data_to_tuples_func

        self._sort_column = 0
        self._sort_asc = True

        # eventually have it look up 'name' in some options somewhere and see previous height, width, and column selection
        # this thing should deal with missing entries but also have some filtered defaults for subs listctrl, which will have a bunch of possible columns

        self._indices_to_data_info = {}
        self._data_to_indices = {}

        (total_width, height) = ClientData.ConvertTextToPixels(
            self, (sizing_column_initial_width_num_chars, height_num_chars))

        resize_column = 1

        for (i, (name, width_num_chars)) in enumerate(columns):

            if width_num_chars == -1:

                width = -1

                resize_column = i + 1

            else:

                width = ClientData.ConvertTextToPixelWidth(
                    self, width_num_chars)

                total_width += width

            self.InsertColumn(i, name, width=width)

        self.setResizeColumn(resize_column)

        self.SetInitialSize((total_width, height))

        self._delete_key_callback = delete_key_callback
        self._activation_callback = activation_callback

        self.Bind(wx.EVT_KEY_DOWN, self.EventKeyDown)
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.EventItemActivated)

        self.Bind(wx.EVT_LIST_COL_BEGIN_DRAG, self.EventBeginColDrag)
        self.Bind(wx.EVT_LIST_COL_CLICK, self.EventColumnClick)
Пример #2
0
    def __init__(self, parent):

        wx.Panel.__init__(self, parent, style=wx.BORDER_DOUBLE)

        self._network_job = None
        self._download_started = False

        self._auto_override_bandwidth_rules = False

        self._left_text = ClientGUICommon.BetterStaticText(self)
        self._right_text = ClientGUICommon.BetterStaticText(
            self, style=wx.ALIGN_RIGHT)

        # 512/768KB - 200KB/s
        right_width = ClientData.ConvertTextToPixelWidth(self._right_text, 20)

        self._right_text.SetMinSize((right_width, -1))

        self._gauge = ClientGUICommon.Gauge(self)

        menu_items = []

        invert_call = self.FlipOverrideBandwidthForCurrentJob
        value_call = self.CurrentJobOverridesBandwidth

        check_manager = ClientGUICommon.CheckboxManagerCalls(
            invert_call, value_call)

        menu_items.append((
            'check', 'override bandwidth rules for this job',
            'Tell the current job to ignore existing bandwidth rules and go ahead anyway.',
            check_manager))

        menu_items.append(('separator', 0, 0, 0))

        invert_call = self.FlipAutoOverrideBandwidth
        value_call = self.AutoOverrideBandwidth

        check_manager = ClientGUICommon.CheckboxManagerCalls(
            invert_call, value_call)

        menu_items.append((
            'check',
            'auto-override bandwidth rules for all jobs here after five seconds',
            'Ignore existing bandwidth rules for all jobs under this control, instead waiting a flat five seconds.',
            check_manager))

        self._cog_button = ClientGUICommon.MenuBitmapButton(
            self, CC.GlobalBMPs.cog, menu_items)
        self._cancel_button = ClientGUICommon.BetterBitmapButton(
            self, CC.GlobalBMPs.stop, self.Cancel)

        #

        self._Update()

        #

        st_hbox = wx.BoxSizer(wx.HORIZONTAL)

        st_hbox.AddF(self._left_text, CC.FLAGS_EXPAND_BOTH_WAYS)
        st_hbox.AddF(self._right_text, CC.FLAGS_VCENTER)

        left_vbox = wx.BoxSizer(wx.VERTICAL)

        left_vbox.AddF(st_hbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)
        left_vbox.AddF(self._gauge, CC.FLAGS_EXPAND_PERPENDICULAR)

        hbox = wx.BoxSizer(wx.HORIZONTAL)

        hbox.AddF(left_vbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)
        hbox.AddF(self._cog_button, CC.FLAGS_VCENTER)
        hbox.AddF(self._cancel_button, CC.FLAGS_VCENTER)

        self.SetSizer(hbox)

        #

        self.Bind(wx.EVT_TIMER, self.TIMEREventUpdate)

        self._update_timer = wx.Timer(self)