def __init__(self, parent, service): ClientGUICommon.StaticBox.__init__(self, parent, 'repository sync') self._service = service self._my_updater = ClientGUICommon.ThreadToGUIUpdater( self, self._Refresh) self._content_panel = wx.Panel(self) self._metadata_st = wx.StaticText(self) self._download_progress = ClientGUICommon.TextAndGauge(self) self._processing_progress = ClientGUICommon.TextAndGauge(self) self._sync_now_button = ClientGUICommon.BetterButton( self, 'process now', self._SyncNow) self._pause_play_button = ClientGUICommon.BetterButton( self, 'pause', self._PausePlay) self._export_updates_button = ClientGUICommon.BetterButton( self, 'export updates', self._ExportUpdates) self._reset_button = ClientGUICommon.BetterButton( self, 'reset processing cache', self._Reset) # self._Refresh() # hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.AddF(self._sync_now_button, CC.FLAGS_LONE_BUTTON) hbox.AddF(self._pause_play_button, CC.FLAGS_LONE_BUTTON) hbox.AddF(self._export_updates_button, CC.FLAGS_LONE_BUTTON) hbox.AddF(self._reset_button, CC.FLAGS_LONE_BUTTON) self.AddF(self._metadata_st, CC.FLAGS_EXPAND_PERPENDICULAR) self.AddF(self._download_progress, CC.FLAGS_EXPAND_PERPENDICULAR) self.AddF(self._processing_progress, CC.FLAGS_EXPAND_PERPENDICULAR) self.AddF(hbox, CC.FLAGS_BUTTON_SIZER) HydrusGlobals.client_controller.sub(self, 'Update', 'service_updated')
def _Refresh(self): credentials = self._service.GetCredentials() (host, port) = credentials.GetAddress() self._address.SetLabelText(host + ':' + str(port)) status = self._service.GetStatusString() self._functional.SetLabelText(status) bandwidth_summary = self._service.GetBandwidthCurrentMonthSummary() self._bandwidth_summary.SetLabelText(bandwidth_summary) self._bandwidth_panel.DestroyChildren() b_gauges = [] bandwidth_rows = self._service.GetBandwidthStringsAndGaugeTuples() b_vbox = wx.BoxSizer(wx.VERTICAL) for (status, (value, range)) in bandwidth_rows: gauge = ClientGUICommon.TextAndGauge(self._bandwidth_panel) gauge.SetValue(status, value, range) b_vbox.AddF(gauge, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) self._bandwidth_panel.SetSizer(b_vbox) self.Layout() wx.PostEvent(self.GetParent(), CC.SizeChangedEvent(-1))
def _Refresh(self): account = self._service.GetAccount() account_type = account.GetAccountType() title = account_type.GetTitle() expires_status = account.GetExpiresString() self._title_and_expires_st.SetLabelText(title + ' that ' + expires_status) account_status = account.GetStatusString() self._status_st.SetLabelText(account_status) next_sync_status = self._service.GetNextAccountSyncStatus() self._next_sync_st.SetLabelText(next_sync_status) # bandwidth_summary = account.GetBandwidthCurrentMonthSummary() self._bandwidth_summary.SetLabelText(bandwidth_summary) self._bandwidth_panel.DestroyChildren() b_gauges = [] bandwidth_rows = account.GetBandwidthStringsAndGaugeTuples() b_vbox = wx.BoxSizer(wx.VERTICAL) for (status, (value, range)) in bandwidth_rows: gauge = ClientGUICommon.TextAndGauge(self._bandwidth_panel) gauge.SetValue(status, value, range) b_vbox.AddF(gauge, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) self._bandwidth_panel.SetSizer(b_vbox) # self._refresh_account_button.SetLabelText('refresh account') self._refresh_account_button.Enable() account_key = account.GetAccountKey() if account_key is None or account_key == '': self._copy_account_key_button.Disable() else: self._copy_account_key_button.Enable() menu_items = [] p_s = account_type.GetPermissionStrings() if len(p_s) == 0: menu_items.append(('label', 'no special permissions', 'no special permissions', None)) else: for s in p_s: menu_items.append(('label', s, s, None)) self._permissions_button.SetMenuItems(menu_items) self.Layout() wx.PostEvent(self.GetParent(), CC.SizeChangedEvent(-1))