def CreatePlotPanel(self, main_sizer): sizer = wx.BoxSizer(wx.VERTICAL) #control_sizer = wx.BoxSizer(wx.HORIZONTAL) control_sizer = wx.GridSizer(cols=4, vgap=10, hgap=5) panel = wx.Panel(self, -1) button_panel = wx.Panel(panel, -1) self.canvas = CanvasPanel(panel) btn_save_plot = wx.Button(button_panel, -1, "Export Image") btn_save_csv = wx.Button(button_panel, -1, "Export CSV") legend_chk = wx.CheckBox(button_panel, -1, "Legend") btn_edit_label = wx.Button(button_panel, -1, "Edit Labels") legend_pos_text = wx.StaticText(button_panel, -1, "Location: ", style=wx.ALIGN_RIGHT) legend_font_text = wx.StaticText(button_panel, -1, "Font Size: ", style=wx.ALIGN_RIGHT) legend_font_ctrl = IntCtrl(button_panel, -1, LEGEND_FONT_SIZE, min=1, max=100, allow_none=False, style=wx.TE_PROCESS_ENTER) self.legend_pos = wx.Choice(button_panel, -1, choices=legend_positions) self.legend_pos.SetSelection(0) btn_save_plot.Bind(wx.EVT_BUTTON, self.SavePlot) btn_save_csv.Bind(wx.EVT_BUTTON, self.SaveCSV) legend_chk.Bind(wx.EVT_CHECKBOX, self.toggleLegend) self.legend_pos.Bind(wx.EVT_CHOICE, self.set_legend_position) btn_edit_label.Bind(wx.EVT_BUTTON, self.open_label_dialog) legend_font_ctrl.Bind(wx.EVT_TEXT_ENTER, self.onFontChange) legend_font_ctrl.Bind(wx.EVT_TEXT, self.onFontChange) #main_sizer.Add(panel, 5, wx.EXPAND | wx.ALL) main_sizer.Add(panel, 4) sizer.Add(self.canvas, 6, wx.EXPAND) sizer.Add(button_panel, 1, wx.EXPAND | wx.ALL | wx.GROW) control_sizer.Add(legend_chk, 1) control_sizer.Add(btn_edit_label, 1) control_sizer.Add(legend_pos_text, 1, wx.ALIGN_RIGHT) control_sizer.Add(self.legend_pos, 1, wx.ALIGN_LEFT) control_sizer.Add(legend_font_text, 1) control_sizer.Add(legend_font_ctrl, 1) control_sizer.Add(btn_save_plot, 1) control_sizer.Add(btn_save_csv, 1) button_panel.SetSizer(control_sizer) panel.SetSizer(sizer)
class AudioOptions(SizedFrame): def __init__(self): super(AudioOptions, self).__init__(application.frame, title='Audio Options') p = self.GetContentsPane() add_accelerator(self, 'ESCAPE', lambda event: self.Close(True)) self.default_volume = config.system['volume'] self.default_frequency = config.system['frequency'] self.default_pan = config.system['pan'] p.SetSizerType('form') wx.StaticText(p, label='&Output Device') self.device = wx.Choice(p, choices=sorted( application.output.get_device_names())) self.device.SetStringSelection(config.system['output_device_name']) self.device.Bind( wx.EVT_CHOICE, lambda event: set_output_device(self.device.GetStringSelection())) wx.StaticText(p, label='&Volume') self.volume = wx.Slider(p, style=wx.VERTICAL) self.volume.SetValue(self.default_volume) self.volume.Bind(wx.EVT_SLIDER, lambda event: set_volume(self.volume.GetValue())) wx.StaticText(p, label='&Pan') self.pan = wx.Slider(p, style=wx.HORIZONTAL) self.pan.SetValue(self.default_pan) self.pan.Bind(wx.EVT_SLIDER, lambda event: set_pan(self.pan.GetValue())) wx.StaticText(p, label='&Frequency') self.frequency = IntCtrl(p, value=self.default_frequency, min=min_frequency, max=max_frequency, limited=True) self.frequency.Bind(EVT_INT, set_frequency(self.frequency.GetValue())) add_accelerator( self.frequency, 'UP', lambda event: self.update_frequency( min(self.frequency.GetMax(), self.frequency.GetValue() + 100))) add_accelerator( self.frequency, 'DOWN', lambda event: self.update_frequency( max(self.frequency.GetMin(), self.frequency.GetValue() - 100))) self.ok = wx.Button(p, label='&OK') self.ok.Bind(wx.EVT_BUTTON, lambda event: self.Close(True)) self.restore = wx.Button(p, label='&Restore Defaults') self.restore.Bind(wx.EVT_BUTTON, self.on_restore) self.Show(True) self.Maximize(True) def update_frequency(self, value): """Update frequency.""" self.frequency.SetValue(value) set_frequency(value) def on_restore(self, event): """Cancel button was pressed.""" set_volume(100) set_pan(50) set_frequency(44100)
class SetQuantity(wx.Frame): def __init__(self, parent): self.main_frame = gui.main_frame.MainFrame.get_instance() super().__init__(parent, id=wx.ID_ANY, title='Edit frame', style=wx.BORDER_THEME | wx.FRAME_NO_WINDOW_MENU, size=(165, 40)) self.sizer = wx.BoxSizer(wx.VERTICAL) self.data_sizer = wx.BoxSizer() self.control_sizer = wx.BoxSizer() self.label = wx.StaticText(self, id=wx.ID_ANY, label='Установить кол-во: ') self.int_ctrl = IntCtrl(self, id=wx.ID_ANY, default_color=wx.SystemSettings.GetColour( wx.SYS_COLOUR_HIGHLIGHTTEXT)) self.btn_submit = wx.Button(self, id=101, label='Submit') self.btn_cancel = wx.Button(self, id=102, label='Cancel') self.btn_submit.Bind(wx.EVT_BUTTON, self._action) self.btn_cancel.Bind(wx.EVT_BUTTON, self._action) self.int_ctrl.Bind(wx.EVT_KEY_DOWN, self._btn_push) self.data_sizer.Add(self.label) self.data_sizer.Add(self.int_ctrl) self.sizer.Add(self.data_sizer) self.control_sizer.Add(self.btn_submit, flag=wx.ALIGN_CENTRE) self.control_sizer.Add(self.btn_cancel, flag=wx.ALIGN_CENTRE) self.sizer.Add(self.control_sizer) self.SetSizer(self.sizer) def _action(self, evt): if evt.GetId() == 101: wx.PostEvent( self.main_frame, SelViewAction(action='quantity', object=str(self.int_ctrl.GetValue()))) self.Close() elif evt.GetId() == 102: self.Close() def _btn_push(self, evt): if evt.GetKeyCode() == 13: self.btn_submit.GetEventHandler().ProcessEvent( wx.PyCommandEvent(wx.EVT_BUTTON.typeId, self.btn_submit.GetId())) elif evt.GetKeyCode() == 27: self.Close() else: evt.Skip()
def create_df_head(self, parent): rb1 = wx.RadioButton(parent, 11, label="Head", style=wx.RB_GROUP) rb2 = wx.RadioButton(parent, 22, label="Tail") l1 = wx.StaticText(parent, -1, "No. of records: ") tc1 = IntCtrl(parent, -1, value=5, size=(40, -1), style=wx.TE_PROCESS_ENTER, min=1, max=50) tc1.Bind(wx.EVT_TEXT_ENTER, self.on_records_no) df_filter_sizer = wx.BoxSizer(wx.HORIZONTAL) df_filter_sizer.Add(rb1) df_filter_sizer.Add(rb2) df_filter_sizer.Add(l1) df_filter_sizer.Add(tc1) return df_filter_sizer
class PFMarketPref(PreferenceView): title = "Market & Prices" def __init__(self): self.priceSettings = MarketPriceSettings.getInstance() def populatePanel(self, panel): self.mainFrame = gui.mainFrame.MainFrame.getInstance() self.sFit = Fit.getInstance() helpCursor = wx.Cursor(wx.CURSOR_QUESTION_ARROW) mainSizer = wx.BoxSizer(wx.VERTICAL) self.stTitle = wx.StaticText(panel, wx.ID_ANY, "Market && Prices", wx.DefaultPosition, wx.DefaultSize, 0) self.stTitle.Wrap(-1) self.stTitle.SetFont(wx.Font(12, 70, 90, 90, False, wx.EmptyString)) mainSizer.Add(self.stTitle, 0, wx.ALL, 5) self.m_staticline1 = wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) mainSizer.Add(self.m_staticline1, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) delayTimer = wx.BoxSizer(wx.HORIZONTAL) self.stMarketDelay = wx.StaticText(panel, wx.ID_ANY, "Market Search Delay (ms):", wx.DefaultPosition, wx.DefaultSize, 0) self.stMarketDelay.Wrap(-1) if "wxGTK" not in wx.PlatformInfo: self.stMarketDelay.SetCursor(helpCursor) self.stMarketDelay.SetToolTip( wx.ToolTip( 'The delay between a keystroke and the market search. Can help reduce lag when typing fast in the market search box.' )) delayTimer.Add(self.stMarketDelay, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.intDelay = IntCtrl(panel, max=1000, limited=True) delayTimer.Add(self.intDelay, 0, wx.ALL, 5) mainSizer.Add(delayTimer, 0, wx.EXPAND | wx.TOP | wx.RIGHT, 10) self.intDelay.SetValue( self.sFit.serviceFittingOptions["marketSearchDelay"]) self.intDelay.Bind(wx.lib.intctrl.EVT_INT, self.onMarketDelayChange) self.cbMarketShortcuts = wx.CheckBox(panel, wx.ID_ANY, "Show market shortcuts", wx.DefaultPosition, wx.DefaultSize, 0) mainSizer.Add(self.cbMarketShortcuts, 0, wx.EXPAND | wx.TOP | wx.RIGHT, 10) self.cbMarketShortcuts.SetValue( self.sFit.serviceFittingOptions["showMarketShortcuts"] or False) self.cbMarketShortcuts.Bind(wx.EVT_CHECKBOX, self.onCBShowShortcuts) priceSizer = wx.BoxSizer(wx.HORIZONTAL) self.stDefaultSystem = wx.StaticText(panel, wx.ID_ANY, "Default Market Prices:", wx.DefaultPosition, wx.DefaultSize, 0) self.stDefaultSystem.Wrap(-1) priceSizer.Add(self.stDefaultSystem, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) if "wxGTK" not in wx.PlatformInfo: self.stDefaultSystem.SetCursor(helpCursor) self.stDefaultSystem.SetToolTip( wx.ToolTip( 'The source you choose will be tried first, but subsequent sources will be used if the preferred source fails. ' 'The system you choose will also be tried first, and if no data is available, global price will be used.' )) self.chPriceSource = wx.Choice(panel, choices=sorted(Price.sources.keys())) self.chPriceSystem = wx.Choice(panel, choices=list(Price.systemsList.keys())) priceSizer.Add(self.chPriceSource, 1, wx.ALL | wx.EXPAND, 5) priceSizer.Add(self.chPriceSystem, 1, wx.ALL | wx.EXPAND, 5) mainSizer.Add(priceSizer, 0, wx.EXPAND | wx.TOP | wx.RIGHT, 10) self.chPriceSource.SetStringSelection( self.sFit.serviceFittingOptions["priceSource"]) self.chPriceSource.Bind(wx.EVT_CHOICE, self.onPricesSourceSelection) self.chPriceSystem.SetStringSelection( self.sFit.serviceFittingOptions["priceSystem"]) self.chPriceSystem.Bind(wx.EVT_CHOICE, self.onPriceSelection) self.tbTotalPriceBox = wx.StaticBoxSizer(wx.VERTICAL, panel, "Total Price Includes") self.tbTotalPriceDrones = wx.CheckBox(panel, -1, "Drones", wx.DefaultPosition, wx.DefaultSize, 1) self.tbTotalPriceDrones.SetValue(self.priceSettings.get("drones")) self.tbTotalPriceDrones.Bind(wx.EVT_CHECKBOX, self.OnTotalPriceDroneChange) self.tbTotalPriceBox.Add(self.tbTotalPriceDrones, 0, wx.LEFT | wx.RIGHT | wx.TOP, 5) self.tbTotalPriceCargo = wx.CheckBox(panel, -1, "Cargo", wx.DefaultPosition, wx.DefaultSize, 1) self.tbTotalPriceCargo.SetValue(self.priceSettings.get("cargo")) self.tbTotalPriceCargo.Bind(wx.EVT_CHECKBOX, self.OnTotalPriceCargoChange) self.tbTotalPriceBox.Add(self.tbTotalPriceCargo, 0, wx.LEFT | wx.RIGHT, 5) self.tbTotalPriceCharacter = wx.CheckBox(panel, -1, "Implants && Boosters", wx.DefaultPosition, wx.DefaultSize, 1) self.tbTotalPriceCharacter.SetValue( self.priceSettings.get("character")) self.tbTotalPriceCharacter.Bind(wx.EVT_CHECKBOX, self.OnTotalPriceCharacterChange) self.tbTotalPriceBox.Add(self.tbTotalPriceCharacter, 0, wx.LEFT | wx.RIGHT | wx.BOTTOM, 5) mainSizer.Add(self.tbTotalPriceBox, 0, wx.EXPAND | wx.TOP | wx.RIGHT, 10) self.rbMarketSearch = wx.RadioBox( panel, -1, "Market Search && Recent Items", wx.DefaultPosition, wx.DefaultSize, [ "No changes to meta buttons", "Enable all meta buttons for a duration of search / recents", "Enable all meta buttons" ], 1, wx.RA_SPECIFY_COLS) self.rbMarketSearch.SetSelection( self.priceSettings.get('marketMGSearchMode')) mainSizer.Add(self.rbMarketSearch, 0, wx.RIGHT | wx.TOP | wx.EXPAND, 10) self.rbMarketSearch.Bind(wx.EVT_RADIOBOX, self.OnMarketSearchChange) self.rbMarketEmpty = wx.RadioBox( panel, -1, "Market Group Selection", wx.DefaultPosition, wx.DefaultSize, ["No changes to meta buttons", "Enable all meta buttons"], 1, wx.RA_SPECIFY_COLS) self.rbMarketEmpty.SetSelection( self.priceSettings.get('marketMGMarketSelectMode')) mainSizer.Add(self.rbMarketEmpty, 0, wx.EXPAND | wx.TOP | wx.RIGHT, 10) self.rbMarketEmpty.Bind(wx.EVT_RADIOBOX, self.OnMarketGroupSelectionChange) self.rbMarketEmpty = wx.RadioBox( panel, -1, "Empty Market View", wx.DefaultPosition, wx.DefaultSize, [ "No changes to meta buttons", "Enable leftmost available meta button", "Enable all available meta buttons" ], 1, wx.RA_SPECIFY_COLS) self.rbMarketEmpty.SetSelection( self.priceSettings.get('marketMGEmptyMode')) mainSizer.Add(self.rbMarketEmpty, 0, wx.EXPAND | wx.TOP | wx.RIGHT, 10) self.rbMarketEmpty.Bind(wx.EVT_RADIOBOX, self.OnMarketEmptyChange) self.rbMarketJump = wx.RadioBox( panel, -1, "Item Market Group Jump", wx.DefaultPosition, wx.DefaultSize, [ "No changes to meta buttons", "Enable item's meta button", "Enable item's meta button, disable others", "Enable all meta buttons" ], 1, wx.RA_SPECIFY_COLS) self.rbMarketJump.SetSelection( self.priceSettings.get('marketMGJumpMode')) mainSizer.Add(self.rbMarketJump, 0, wx.EXPAND | wx.TOP | wx.RIGHT | wx.BOTTOM, 10) self.rbMarketJump.Bind(wx.EVT_RADIOBOX, self.OnMarketJumpChange) panel.SetSizer(mainSizer) panel.Layout() def onMarketDelayChange(self, event): self.sFit.serviceFittingOptions[ "marketSearchDelay"] = self.intDelay.GetValue() event.Skip() def onCBShowShortcuts(self, event): self.sFit.serviceFittingOptions[ "showMarketShortcuts"] = self.cbMarketShortcuts.GetValue() def getImage(self): return BitmapLoader.getBitmap("settings_market", "gui") def onPriceSelection(self, event): system = self.chPriceSystem.GetString( self.chPriceSystem.GetSelection()) self.sFit.serviceFittingOptions["priceSystem"] = system fitID = self.mainFrame.getActiveFit() self.sFit.refreshFit(fitID) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) event.Skip() def onPricesSourceSelection(self, event): source = self.chPriceSource.GetString( self.chPriceSource.GetSelection()) self.sFit.serviceFittingOptions["priceSource"] = source def OnTotalPriceDroneChange(self, event): self.priceSettings.set('drones', event.GetInt()) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit())) def OnTotalPriceCargoChange(self, event): self.priceSettings.set('cargo', event.GetInt()) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit())) def OnTotalPriceCharacterChange(self, event): self.priceSettings.set('character', event.GetInt()) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit())) def OnMarketJumpChange(self, event): self.priceSettings.set('marketMGJumpMode', event.GetInt()) def OnMarketEmptyChange(self, event): self.priceSettings.set('marketMGEmptyMode', event.GetInt()) def OnMarketSearchChange(self, event): self.priceSettings.set('marketMGSearchMode', event.GetInt()) def OnMarketGroupSelectionChange(self, event): self.priceSettings.set('marketMGMarketSelectMode', event.GetInt())
class PFFittingEnginePref(PreferenceView): title = "Fitting Engine" def __init__(self): self.dirtySettings = False def refreshPanel(self, fit): pass # noinspection PyAttributeOutsideInit def populatePanel(self, panel): self.mainFrame = gui.mainFrame.MainFrame.getInstance() mainSizer = wx.BoxSizer(wx.VERTICAL) helpCursor = wx.Cursor(wx.CURSOR_QUESTION_ARROW) self.engine_settings = EOSSettings.getInstance() self.stTitle = wx.StaticText(panel, wx.ID_ANY, self.title, wx.DefaultPosition, wx.DefaultSize, 0) self.stTitle.Wrap(-1) self.stTitle.SetFont(wx.Font(12, 70, 90, 90, False, wx.EmptyString)) mainSizer.Add(self.stTitle, 0, wx.EXPAND | wx.ALL, 5) self.m_staticline1 = wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) mainSizer.Add(self.m_staticline1, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) self.cbGlobalForceReload = wx.CheckBox(panel, wx.ID_ANY, "Factor in reload time when calculating capacitor usage, damage, and tank.", wx.DefaultPosition, wx.DefaultSize, 0) mainSizer.Add(self.cbGlobalForceReload, 0, wx.ALL | wx.EXPAND, 5) self.cbStrictSkillLevels = wx.CheckBox(panel, wx.ID_ANY, "Enforce strict skill level requirements", wx.DefaultPosition, wx.DefaultSize, 0) self.cbStrictSkillLevels.SetCursor(helpCursor) self.cbStrictSkillLevels.SetToolTip(wx.ToolTip( 'When enabled, skills will check their dependencies\' requirements when their levels change and reset ' + 'skills that no longer meet the requirement.\neg: Setting Drones from level V to IV will reset the Heavy ' + 'Drone Operation skill, as that requires Drones V')) mainSizer.Add(self.cbStrictSkillLevels, 0, wx.ALL | wx.EXPAND, 5) self.cbUniversalAdaptiveArmorHardener = wx.CheckBox(panel, wx.ID_ANY, "When damage profile is Uniform, set Reactive Armor " + "Hardener to match (old behavior).", wx.DefaultPosition, wx.DefaultSize, 0) mainSizer.Add(self.cbUniversalAdaptiveArmorHardener, 0, wx.ALL | wx.EXPAND, 5) spoolup_sizer = wx.BoxSizer(wx.HORIZONTAL) self.spool_up_label = wx.StaticText(panel, wx.ID_ANY, "Global Default Spoolup Percentage:", wx.DefaultPosition, wx.DefaultSize, 0) self.spool_up_label.Wrap(-1) self.spool_up_label.SetCursor(helpCursor) self.spool_up_label.SetToolTip( wx.ToolTip('The amount of spoolup to use by default on module which support it. Can be changed on a per-module basis')) spoolup_sizer.Add(self.spool_up_label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.spoolup_value = IntCtrl(panel, min=0, max=100, limited=True) spoolup_sizer.Add(self.spoolup_value , 0, wx.ALL, 5) mainSizer.Add(spoolup_sizer, 0, wx.ALL | wx.EXPAND, 0) # Future code once new cap sim is implemented ''' self.cbGlobalForceReactivationTimer = wx.CheckBox( panel, wx.ID_ANY, "Factor in reactivation timer", wx.DefaultPosition, wx.DefaultSize, 0 ) mainSizer.Add( self.cbGlobalForceReactivationTimer, 0, wx.ALL|wx.EXPAND, 5 ) text = " Ignores reactivation timer when calculating capacitor usage,\n damage, and tank." self.cbGlobalForceReactivationTimerText = wx.StaticText( panel, wx.ID_ANY, text, wx.DefaultPosition, wx.DefaultSize, 0 ) self.cbGlobalForceReactivationTimerText.Wrap( -1 ) self.cbGlobalForceReactivationTimerText.SetFont( wx.Font( 10, 70, 90, 90, False, wx.EmptyString ) ) mainSizer.Add( self.cbGlobalForceReactivationTimerText, 0, wx.ALL, 5 ) ''' # Future code for mining laser crystal ''' self.cbGlobalMiningSpecialtyCrystal = wx.CheckBox( panel, wx.ID_ANY, "Factor in reactivation timer", wx.DefaultPosition, wx.DefaultSize, 0 ) mainSizer.Add( self.cbGlobalMiningSpecialtyCrystal, 0, wx.ALL|wx.EXPAND, 5 ) text = " If enabled, displays the Specialty Crystal mining amount.\n This is the amount mined when using crystals and mining the matching asteroid." self.cbGlobalMiningSpecialtyCrystalText = wx.StaticText( panel, wx.ID_ANY, text, wx.DefaultPosition, wx.DefaultSize, 0 ) self.cbGlobalMiningSpecialtyCrystalText.Wrap( -1 ) self.cbGlobalMiningSpecialtyCrystalText.SetFont( wx.Font( 10, 70, 90, 90, False, wx.EmptyString ) ) mainSizer.Add( self.cbGlobalMiningSpecialtyCrystalText, 0, wx.ALL, 5 ) ''' self.sFit = Fit.getInstance() self.cbGlobalForceReload.SetValue(self.sFit.serviceFittingOptions["useGlobalForceReload"]) self.cbGlobalForceReload.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalForceReloadStateChange) self.cbStrictSkillLevels.SetValue(self.engine_settings.get("strictSkillLevels")) self.cbStrictSkillLevels.Bind(wx.EVT_CHECKBOX, self.OnCBStrictSkillLevelsChange) self.cbUniversalAdaptiveArmorHardener.SetValue(self.engine_settings.get("useStaticAdaptiveArmorHardener")) self.cbUniversalAdaptiveArmorHardener.Bind(wx.EVT_CHECKBOX, self.OnCBUniversalAdaptiveArmorHardenerChange) self.spoolup_value.SetValue(int(self.engine_settings.get("globalDefaultSpoolupPercentage") * 100)) self.spoolup_value.Bind(wx.lib.intctrl.EVT_INT, self.OnSpoolupChange) panel.SetSizer(mainSizer) panel.Layout() def OnSpoolupChange(self, event): self.engine_settings.set("globalDefaultSpoolupPercentage", self.spoolup_value.GetValue() / 100) def OnCBGlobalForceReloadStateChange(self, event): fitIDs = self.sFit.toggleFactorReload(value=bool(self.cbGlobalForceReload.GetValue())) wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=tuple(fitIDs))) def OnCBStrictSkillLevelsChange(self, event): self.engine_settings.set("strictSkillLevels", self.cbStrictSkillLevels.GetValue()) def OnCBUniversalAdaptiveArmorHardenerChange(self, event): self.engine_settings.set("useStaticAdaptiveArmorHardener", self.cbUniversalAdaptiveArmorHardener.GetValue()) def getImage(self): return BitmapLoader.getBitmap("settings_fitting", "gui") def OnWindowLeave(self, event): # We don't want to do anything when they leave, # but in the future we might. pass
class PFGeneralPref(PreferenceView): title = "General" def populatePanel(self, panel): self.mainFrame = gui.mainFrame.MainFrame.getInstance() self.dirtySettings = False self.openFitsSettings = SettingsProvider.getInstance().getSettings( "pyfaPrevOpenFits", { "enabled": False, "pyfaOpenFits": [] }) helpCursor = wx.StockCursor(wx.CURSOR_QUESTION_ARROW) mainSizer = wx.BoxSizer(wx.VERTICAL) self.stTitle = wx.StaticText(panel, wx.ID_ANY, self.title, wx.DefaultPosition, wx.DefaultSize, 0) self.stTitle.Wrap(-1) self.stTitle.SetFont(wx.Font(12, 70, 90, 90, False, wx.EmptyString)) mainSizer.Add(self.stTitle, 0, wx.ALL, 5) self.m_staticline1 = wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) mainSizer.Add(self.m_staticline1, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) self.cbGlobalChar = wx.CheckBox(panel, wx.ID_ANY, u"Use global character", wx.DefaultPosition, wx.DefaultSize, 0) mainSizer.Add(self.cbGlobalChar, 0, wx.ALL | wx.EXPAND, 5) self.cbGlobalDmgPattern = wx.CheckBox(panel, wx.ID_ANY, u"Use global damage pattern", wx.DefaultPosition, wx.DefaultSize, 0) mainSizer.Add(self.cbGlobalDmgPattern, 0, wx.ALL | wx.EXPAND, 5) self.cbCompactSkills = wx.CheckBox(panel, wx.ID_ANY, u"Compact skills needed tooltip", wx.DefaultPosition, wx.DefaultSize, 0) mainSizer.Add(self.cbCompactSkills, 0, wx.ALL | wx.EXPAND, 5) self.cbFitColorSlots = wx.CheckBox(panel, wx.ID_ANY, u"Color fitting view by slot", wx.DefaultPosition, wx.DefaultSize, 0) mainSizer.Add(self.cbFitColorSlots, 0, wx.ALL | wx.EXPAND, 5) self.cbReopenFits = wx.CheckBox(panel, wx.ID_ANY, u"Reopen previous fits on startup", wx.DefaultPosition, wx.DefaultSize, 0) mainSizer.Add(self.cbReopenFits, 0, wx.ALL | wx.EXPAND, 5) self.cbRackSlots = wx.CheckBox(panel, wx.ID_ANY, u"Separate Racks", wx.DefaultPosition, wx.DefaultSize, 0) mainSizer.Add(self.cbRackSlots, 0, wx.ALL | wx.EXPAND, 5) labelSizer = wx.BoxSizer(wx.VERTICAL) self.cbRackLabels = wx.CheckBox(panel, wx.ID_ANY, u"Show Rack Labels", wx.DefaultPosition, wx.DefaultSize, 0) labelSizer.Add(self.cbRackLabels, 0, wx.ALL | wx.EXPAND, 5) mainSizer.Add(labelSizer, 0, wx.LEFT | wx.EXPAND, 30) self.cbShowTooltip = wx.CheckBox(panel, wx.ID_ANY, u"Show tab tooltips", wx.DefaultPosition, wx.DefaultSize, 0) mainSizer.Add(self.cbShowTooltip, 0, wx.ALL | wx.EXPAND, 5) self.cbMarketShortcuts = wx.CheckBox(panel, wx.ID_ANY, u"Show market shortcuts", wx.DefaultPosition, wx.DefaultSize, 0) mainSizer.Add(self.cbMarketShortcuts, 0, wx.ALL | wx.EXPAND, 5) self.cbGaugeAnimation = wx.CheckBox(panel, wx.ID_ANY, u"Animate gauges", wx.DefaultPosition, wx.DefaultSize, 0) mainSizer.Add(self.cbGaugeAnimation, 0, wx.ALL | wx.EXPAND, 5) self.cbExportCharges = wx.CheckBox(panel, wx.ID_ANY, u"Export loaded charges", wx.DefaultPosition, wx.DefaultSize, 0) mainSizer.Add(self.cbExportCharges, 0, wx.ALL | wx.EXPAND, 5) self.cbOpenFitInNew = wx.CheckBox( panel, wx.ID_ANY, u"Open fittings in a new page by default", wx.DefaultPosition, wx.DefaultSize, 0) mainSizer.Add(self.cbOpenFitInNew, 0, wx.ALL | wx.EXPAND, 5) self.cbShowShipBrowserTooltip = wx.CheckBox( panel, wx.ID_ANY, u"Show ship browser tooltip", wx.DefaultPosition, wx.DefaultSize, 0) mainSizer.Add(self.cbShowShipBrowserTooltip, 0, wx.ALL | wx.EXPAND, 5) priceSizer = wx.BoxSizer(wx.HORIZONTAL) self.stDefaultSystem = wx.StaticText(panel, wx.ID_ANY, u"Default Market Prices:", wx.DefaultPosition, wx.DefaultSize, 0) self.stDefaultSystem.Wrap(-1) priceSizer.Add(self.stDefaultSystem, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.chPriceSource = wx.Choice(panel, choices=sorted(Price.sources.keys())) self.chPriceSystem = wx.Choice(panel, choices=Price.systemsList.keys()) priceSizer.Add(self.chPriceSource, 1, wx.ALL | wx.EXPAND, 5) priceSizer.Add(self.chPriceSystem, 1, wx.ALL | wx.EXPAND, 5) mainSizer.Add(priceSizer, 0, wx.ALL | wx.EXPAND, 0) delayTimer = wx.BoxSizer(wx.HORIZONTAL) self.stMarketDelay = wx.StaticText(panel, wx.ID_ANY, u"Market Search Delay (ms):", wx.DefaultPosition, wx.DefaultSize, 0) self.stMarketDelay.Wrap(-1) self.stMarketDelay.SetCursor(helpCursor) self.stMarketDelay.SetToolTip( wx.ToolTip( 'The delay between a keystroke and the market search. Can help reduce lag when typing fast in the market search box.' )) delayTimer.Add(self.stMarketDelay, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.intDelay = IntCtrl(panel, max=1000, limited=True) delayTimer.Add(self.intDelay, 0, wx.ALL, 5) mainSizer.Add(delayTimer, 0, wx.ALL | wx.EXPAND, 0) self.sFit = Fit.getInstance() self.cbGlobalChar.SetValue( self.sFit.serviceFittingOptions["useGlobalCharacter"]) self.cbGlobalDmgPattern.SetValue( self.sFit.serviceFittingOptions["useGlobalDamagePattern"]) self.cbFitColorSlots.SetValue( self.sFit.serviceFittingOptions["colorFitBySlot"] or False) self.cbRackSlots.SetValue(self.sFit.serviceFittingOptions["rackSlots"] or False) self.cbRackLabels.SetValue( self.sFit.serviceFittingOptions["rackLabels"] or False) self.cbCompactSkills.SetValue( self.sFit.serviceFittingOptions["compactSkills"] or False) self.cbReopenFits.SetValue(self.openFitsSettings["enabled"]) self.cbShowTooltip.SetValue( self.sFit.serviceFittingOptions["showTooltip"] or False) self.cbMarketShortcuts.SetValue( self.sFit.serviceFittingOptions["showMarketShortcuts"] or False) self.cbGaugeAnimation.SetValue( self.sFit.serviceFittingOptions["enableGaugeAnimation"]) self.cbExportCharges.SetValue( self.sFit.serviceFittingOptions["exportCharges"]) self.cbOpenFitInNew.SetValue( self.sFit.serviceFittingOptions["openFitInNew"]) self.chPriceSource.SetStringSelection( self.sFit.serviceFittingOptions["priceSource"]) self.chPriceSystem.SetStringSelection( self.sFit.serviceFittingOptions["priceSystem"]) self.cbShowShipBrowserTooltip.SetValue( self.sFit.serviceFittingOptions["showShipBrowserTooltip"]) self.intDelay.SetValue( self.sFit.serviceFittingOptions["marketSearchDelay"]) self.cbGlobalChar.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalCharStateChange) self.cbGlobalDmgPattern.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalDmgPatternStateChange) self.cbFitColorSlots.Bind(wx.EVT_CHECKBOX, self.onCBGlobalColorBySlot) self.cbRackSlots.Bind(wx.EVT_CHECKBOX, self.onCBGlobalRackSlots) self.cbRackLabels.Bind(wx.EVT_CHECKBOX, self.onCBGlobalRackLabels) self.cbCompactSkills.Bind(wx.EVT_CHECKBOX, self.onCBCompactSkills) self.cbReopenFits.Bind(wx.EVT_CHECKBOX, self.onCBReopenFits) self.cbShowTooltip.Bind(wx.EVT_CHECKBOX, self.onCBShowTooltip) self.cbMarketShortcuts.Bind(wx.EVT_CHECKBOX, self.onCBShowShortcuts) self.cbGaugeAnimation.Bind(wx.EVT_CHECKBOX, self.onCBGaugeAnimation) self.cbExportCharges.Bind(wx.EVT_CHECKBOX, self.onCBExportCharges) self.cbOpenFitInNew.Bind(wx.EVT_CHECKBOX, self.onCBOpenFitInNew) self.chPriceSource.Bind(wx.EVT_CHOICE, self.onPricesSourceSelection) self.chPriceSystem.Bind(wx.EVT_CHOICE, self.onPriceSelection) self.cbShowShipBrowserTooltip.Bind(wx.EVT_CHECKBOX, self.onCBShowShipBrowserTooltip) self.intDelay.Bind(wx.lib.intctrl.EVT_INT, self.onMarketDelayChange) self.cbRackLabels.Enable(self.sFit.serviceFittingOptions["rackSlots"] or False) panel.SetSizer(mainSizer) panel.Layout() def onMarketDelayChange(self, event): self.sFit.serviceFittingOptions[ "marketSearchDelay"] = self.intDelay.GetValue() event.Skip() def onCBGlobalColorBySlot(self, event): self.sFit.serviceFittingOptions[ "colorFitBySlot"] = self.cbFitColorSlots.GetValue() fitID = self.mainFrame.getActiveFit() self.sFit.refreshFit(fitID) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) event.Skip() def onCBGlobalRackSlots(self, event): self.sFit.serviceFittingOptions[ "rackSlots"] = self.cbRackSlots.GetValue() self.cbRackLabels.Enable(self.cbRackSlots.GetValue()) fitID = self.mainFrame.getActiveFit() self.sFit.refreshFit(fitID) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) event.Skip() def onCBGlobalRackLabels(self, event): self.sFit.serviceFittingOptions[ "rackLabels"] = self.cbRackLabels.GetValue() fitID = self.mainFrame.getActiveFit() self.sFit.refreshFit(fitID) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) event.Skip() def OnCBGlobalCharStateChange(self, event): self.sFit.serviceFittingOptions[ "useGlobalCharacter"] = self.cbGlobalChar.GetValue() event.Skip() def OnCBGlobalDmgPatternStateChange(self, event): self.sFit.serviceFittingOptions[ "useGlobalDamagePattern"] = self.cbGlobalDmgPattern.GetValue() event.Skip() def onCBCompactSkills(self, event): self.sFit.serviceFittingOptions[ "compactSkills"] = self.cbCompactSkills.GetValue() fitID = self.mainFrame.getActiveFit() self.sFit.refreshFit(fitID) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) event.Skip() def onCBReopenFits(self, event): self.openFitsSettings["enabled"] = self.cbReopenFits.GetValue() def onCBShowTooltip(self, event): self.sFit.serviceFittingOptions[ "showTooltip"] = self.cbShowTooltip.GetValue() def onCBShowShortcuts(self, event): self.sFit.serviceFittingOptions[ "showMarketShortcuts"] = self.cbMarketShortcuts.GetValue() def onCBGaugeAnimation(self, event): self.sFit.serviceFittingOptions[ "enableGaugeAnimation"] = self.cbGaugeAnimation.GetValue() def onCBExportCharges(self, event): self.sFit.serviceFittingOptions[ "exportCharges"] = self.cbExportCharges.GetValue() def onCBOpenFitInNew(self, event): self.sFit.serviceFittingOptions[ "openFitInNew"] = self.cbOpenFitInNew.GetValue() def onCBShowShipBrowserTooltip(self, event): self.sFit.serviceFittingOptions[ "showShipBrowserTooltip"] = self.cbShowShipBrowserTooltip.GetValue( ) def getImage(self): return BitmapLoader.getBitmap("prefs_settings", "gui") def onPriceSelection(self, event): system = self.chPriceSystem.GetString( self.chPriceSystem.GetSelection()) self.sFit.serviceFittingOptions["priceSystem"] = system fitID = self.mainFrame.getActiveFit() self.sFit.refreshFit(fitID) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) event.Skip() def onPricesSourceSelection(self, event): source = self.chPriceSource.GetString( self.chPriceSource.GetSelection()) self.sFit.serviceFittingOptions["priceSource"] = source
class ControlPanel(wx.Panel): """""" def __init__(self, parent, *args, **kwargs): """""" self.parent = parent self.stitch_plan = kwargs.pop('stitch_plan') self.target_stitches_per_second = kwargs.pop('stitches_per_second') self.target_duration = kwargs.pop('target_duration') kwargs['style'] = wx.BORDER_SUNKEN wx.Panel.__init__(self, parent, *args, **kwargs) self.statusbar = self.GetTopLevelParent().statusbar self.drawing_panel = None self.num_stitches = 1 self.current_stitch = 1 self.speed = 1 self.direction = 1 # Widgets self.btnMinus = wx.Button(self, -1, label='-') self.btnMinus.Bind(wx.EVT_BUTTON, self.animation_slow_down) self.btnMinus.SetToolTip(_('Slow down (arrow down)')) self.btnPlus = wx.Button(self, -1, label='+') self.btnPlus.Bind(wx.EVT_BUTTON, self.animation_speed_up) self.btnPlus.SetToolTip(_('Speed up (arrow up)')) self.btnBackwardStitch = wx.Button(self, -1, label='<|') self.btnBackwardStitch.Bind(wx.EVT_BUTTON, self.animation_one_stitch_backward) self.btnBackwardStitch.SetToolTip(_('Go on step backward (-)')) self.btnForwardStitch = wx.Button(self, -1, label='|>') self.btnForwardStitch.Bind(wx.EVT_BUTTON, self.animation_one_stitch_forward) self.btnForwardStitch.SetToolTip(_('Go on step forward (+)')) self.directionBtn = wx.Button(self, -1, label='<<') self.directionBtn.Bind(wx.EVT_BUTTON, self.on_direction_button) self.directionBtn.SetToolTip( _('Switch direction (arrow left | arrow right)')) self.pauseBtn = wx.Button(self, -1, label=_('Pause')) self.pauseBtn.Bind(wx.EVT_BUTTON, self.on_pause_start_button) self.pauseBtn.SetToolTip(_('Pause (P)')) self.restartBtn = wx.Button(self, -1, label=_('Restart')) self.restartBtn.Bind(wx.EVT_BUTTON, self.animation_restart) self.restartBtn.SetToolTip(_('Restart (R)')) self.quitBtn = wx.Button(self, -1, label=_('Quit')) self.quitBtn.Bind(wx.EVT_BUTTON, self.animation_quit) self.quitBtn.SetToolTip(_('Quit (Q)')) self.slider = wx.Slider(self, -1, value=1, minValue=1, maxValue=2, style=wx.SL_HORIZONTAL | wx.SL_LABELS) self.slider.Bind(wx.EVT_SLIDER, self.on_slider) self.stitchBox = IntCtrl(self, -1, value=1, min=1, max=2, limited=True, allow_none=False) self.stitchBox.Bind(wx.EVT_TEXT, self.on_stitch_box) # Layout self.vbSizer = vbSizer = wx.BoxSizer(wx.VERTICAL) self.hbSizer1 = hbSizer1 = wx.BoxSizer(wx.HORIZONTAL) self.hbSizer2 = hbSizer2 = wx.BoxSizer(wx.HORIZONTAL) hbSizer1.Add(self.slider, 1, wx.EXPAND | wx.ALL, 3) hbSizer1.Add(self.stitchBox, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) vbSizer.Add(hbSizer1, 1, wx.EXPAND | wx.ALL, 3) hbSizer2.Add(self.btnMinus, 0, wx.EXPAND | wx.ALL, 2) hbSizer2.Add(self.btnPlus, 0, wx.EXPAND | wx.ALL, 2) hbSizer2.Add(self.btnBackwardStitch, 0, wx.EXPAND | wx.ALL, 2) hbSizer2.Add(self.btnForwardStitch, 0, wx.EXPAND | wx.ALL, 2) hbSizer2.Add(self.directionBtn, 0, wx.EXPAND | wx.ALL, 2) hbSizer2.Add(self.pauseBtn, 0, wx.EXPAND | wx.ALL, 2) hbSizer2.Add(self.restartBtn, 0, wx.EXPAND | wx.ALL, 2) hbSizer2.Add(self.quitBtn, 0, wx.EXPAND | wx.ALL, 2) vbSizer.Add(hbSizer2, 0, wx.EXPAND | wx.ALL, 3) self.SetSizerAndFit(vbSizer) # Keyboard Shortcuts shortcut_keys = [ (wx.ACCEL_NORMAL, wx.WXK_RIGHT, self.animation_forward), (wx.ACCEL_NORMAL, wx.WXK_NUMPAD_RIGHT, self.animation_forward), (wx.ACCEL_NORMAL, wx.WXK_LEFT, self.animation_reverse), (wx.ACCEL_NORMAL, wx.WXK_NUMPAD_LEFT, self.animation_reverse), (wx.ACCEL_NORMAL, wx.WXK_UP, self.animation_speed_up), (wx.ACCEL_NORMAL, wx.WXK_NUMPAD_UP, self.animation_speed_up), (wx.ACCEL_NORMAL, wx.WXK_DOWN, self.animation_slow_down), (wx.ACCEL_NORMAL, wx.WXK_NUMPAD_DOWN, self.animation_slow_down), (wx.ACCEL_NORMAL, ord('+'), self.animation_one_stitch_forward), (wx.ACCEL_NORMAL, ord('='), self.animation_one_stitch_forward), (wx.ACCEL_SHIFT, ord('='), self.animation_one_stitch_forward), (wx.ACCEL_NORMAL, wx.WXK_ADD, self.animation_one_stitch_forward), (wx.ACCEL_NORMAL, wx.WXK_NUMPAD_ADD, self.animation_one_stitch_forward), (wx.ACCEL_NORMAL, wx.WXK_NUMPAD_UP, self.animation_one_stitch_forward), (wx.ACCEL_NORMAL, ord('-'), self.animation_one_stitch_backward), (wx.ACCEL_NORMAL, ord('_'), self.animation_one_stitch_backward), (wx.ACCEL_NORMAL, wx.WXK_SUBTRACT, self.animation_one_stitch_backward), (wx.ACCEL_NORMAL, wx.WXK_NUMPAD_SUBTRACT, self.animation_one_stitch_backward), (wx.ACCEL_NORMAL, ord('r'), self.animation_restart), (wx.ACCEL_NORMAL, ord('p'), self.on_pause_start_button), (wx.ACCEL_NORMAL, wx.WXK_SPACE, self.on_pause_start_button), (wx.ACCEL_NORMAL, ord('q'), self.animation_quit) ] accel_entries = [] for shortcut_key in shortcut_keys: eventId = wx.NewId() accel_entries.append((shortcut_key[0], shortcut_key[1], eventId)) self.Bind(wx.EVT_MENU, shortcut_key[2], id=eventId) accel_table = wx.AcceleratorTable(accel_entries) self.SetAcceleratorTable(accel_table) self.SetFocus() def set_drawing_panel(self, drawing_panel): self.drawing_panel = drawing_panel self.drawing_panel.set_speed(self.speed) def set_num_stitches(self, num_stitches): if num_stitches < 2: # otherwise the slider and intctrl get mad num_stitches = 2 self.num_stitches = num_stitches self.stitchBox.SetMax(num_stitches) self.slider.SetMax(num_stitches) self.choose_speed() def choose_speed(self): if self.target_duration: self.set_speed(int(self.num_stitches / float(self.target_duration))) else: self.set_speed(self.target_stitches_per_second) def animation_forward(self, event=None): self.directionBtn.SetLabel("<<") self.drawing_panel.forward() self.direction = 1 self.update_speed_text() def animation_reverse(self, event=None): self.directionBtn.SetLabel(">>") self.drawing_panel.reverse() self.direction = -1 self.update_speed_text() def on_direction_button(self, event): if self.direction == 1: self.animation_reverse() else: self.animation_forward() def set_speed(self, speed): self.speed = int(max(speed, 1)) self.update_speed_text() if self.drawing_panel: self.drawing_panel.set_speed(self.speed) def update_speed_text(self): self.statusbar.SetStatusText( _('Speed: %d stitches/sec') % (self.speed * self.direction), 0) self.hbSizer2.Layout() def on_slider(self, event): stitch = event.GetEventObject().GetValue() self.stitchBox.SetValue(stitch) if self.drawing_panel: self.drawing_panel.set_current_stitch(stitch) def on_current_stitch(self, stitch, command): if self.current_stitch != stitch: self.current_stitch = stitch self.slider.SetValue(stitch) self.stitchBox.SetValue(stitch) self.statusbar.SetStatusText(COMMAND_NAMES[command], 1) def on_stitch_box(self, event): stitch = self.stitchBox.GetValue() self.slider.SetValue(stitch) if self.drawing_panel: self.drawing_panel.set_current_stitch(stitch) def animation_slow_down(self, event): """""" self.set_speed(self.speed / 2.0) def animation_speed_up(self, event): """""" self.set_speed(self.speed * 2.0) def animation_pause(self, event=None): self.drawing_panel.stop() def animation_start(self, event=None): self.drawing_panel.go() def on_start(self): self.pauseBtn.SetLabel(_('Pause')) def on_stop(self): self.pauseBtn.SetLabel(_('Start')) def on_pause_start_button(self, event): """""" if self.pauseBtn.GetLabel() == _('Pause'): self.animation_pause() else: self.animation_start() def animation_one_stitch_forward(self, event): self.animation_pause() self.drawing_panel.one_stitch_forward() def animation_one_stitch_backward(self, event): self.animation_pause() self.drawing_panel.one_stitch_backward() def animation_quit(self, event): self.parent.quit() def animation_restart(self, event): self.drawing_panel.restart()
class PFCrestPref(PreferenceView): title = "CREST" def populatePanel(self, panel): self.mainFrame = gui.mainFrame.MainFrame.getInstance() self.settings = CRESTSettings.getInstance() self.dirtySettings = False dlgWidth = panel.GetParent().GetParent().ClientSize.width mainSizer = wx.BoxSizer(wx.VERTICAL) self.stTitle = wx.StaticText(panel, wx.ID_ANY, self.title, wx.DefaultPosition, wx.DefaultSize, 0) self.stTitle.Wrap(-1) self.stTitle.SetFont(wx.Font(12, 70, 90, 90, False, wx.EmptyString)) mainSizer.Add(self.stTitle, 0, wx.ALL, 5) self.m_staticline1 = wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) mainSizer.Add(self.m_staticline1, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) self.stInfo = wx.StaticText( panel, wx.ID_ANY, u"Please see the pyfa wiki on GitHub for information regarding these options.", wx.DefaultPosition, wx.DefaultSize, 0) self.stInfo.Wrap(dlgWidth - 50) mainSizer.Add(self.stInfo, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) rbSizer = wx.BoxSizer(wx.HORIZONTAL) self.rbMode = wx.RadioBox(panel, -1, "Mode", wx.DefaultPosition, wx.DefaultSize, ['Implicit', 'User-supplied details'], 1, wx.RA_SPECIFY_COLS) self.rbServer = wx.RadioBox(panel, -1, "Server", wx.DefaultPosition, wx.DefaultSize, ['Tranquility', 'Singularity'], 1, wx.RA_SPECIFY_COLS) self.rbMode.SetSelection(self.settings.get('mode')) self.rbServer.SetSelection(self.settings.get('server')) rbSizer.Add(self.rbMode, 1, wx.TOP | wx.RIGHT, 5) rbSizer.Add(self.rbServer, 1, wx.ALL, 5) self.rbMode.Bind(wx.EVT_RADIOBOX, self.OnModeChange) self.rbServer.Bind(wx.EVT_RADIOBOX, self.OnServerChange) mainSizer.Add(rbSizer, 1, wx.ALL | wx.EXPAND, 0) timeoutSizer = wx.BoxSizer(wx.HORIZONTAL) self.stTimout = wx.StaticText(panel, wx.ID_ANY, u"Timeout (seconds):", wx.DefaultPosition, wx.DefaultSize, 0) self.stTimout.Wrap(-1) timeoutSizer.Add(self.stTimout, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.intTimeout = IntCtrl(panel, max=300000, limited=True, value=self.settings.get('timeout')) timeoutSizer.Add(self.intTimeout, 0, wx.ALL, 5) self.intTimeout.Bind(wx.lib.intctrl.EVT_INT, self.OnTimeoutChange) mainSizer.Add(timeoutSizer, 0, wx.ALL | wx.EXPAND, 0) detailsTitle = wx.StaticText(panel, wx.ID_ANY, "CREST client details", wx.DefaultPosition, wx.DefaultSize, 0) detailsTitle.Wrap(-1) detailsTitle.SetFont(wx.Font(12, 70, 90, 90, False, wx.EmptyString)) mainSizer.Add(detailsTitle, 0, wx.ALL, 5) mainSizer.Add( wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL), 0, wx.EXPAND, 5) fgAddrSizer = wx.FlexGridSizer(2, 2, 0, 0) fgAddrSizer.AddGrowableCol(1) fgAddrSizer.SetFlexibleDirection(wx.BOTH) fgAddrSizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) self.stSetID = wx.StaticText(panel, wx.ID_ANY, u"Client ID:", wx.DefaultPosition, wx.DefaultSize, 0) self.stSetID.Wrap(-1) fgAddrSizer.Add(self.stSetID, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.inputClientID = wx.TextCtrl(panel, wx.ID_ANY, self.settings.get('clientID'), wx.DefaultPosition, wx.DefaultSize, 0) fgAddrSizer.Add(self.inputClientID, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5) self.stSetSecret = wx.StaticText(panel, wx.ID_ANY, u"Client Secret:", wx.DefaultPosition, wx.DefaultSize, 0) self.stSetSecret.Wrap(-1) fgAddrSizer.Add(self.stSetSecret, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.inputClientSecret = wx.TextCtrl(panel, wx.ID_ANY, self.settings.get('clientSecret'), wx.DefaultPosition, wx.DefaultSize, 0) fgAddrSizer.Add(self.inputClientSecret, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5) self.btnApply = wx.Button(panel, wx.ID_ANY, u"Save Client Settings", wx.DefaultPosition, wx.DefaultSize, 0) self.btnApply.Bind(wx.EVT_BUTTON, self.OnBtnApply) mainSizer.Add(fgAddrSizer, 0, wx.EXPAND, 5) mainSizer.Add(self.btnApply, 0, wx.ALIGN_RIGHT, 5) self.ToggleProxySettings(self.settings.get('mode')) panel.SetSizer(mainSizer) panel.Layout() def OnTimeoutChange(self, event): self.settings.set('timeout', event.GetEventObject().GetValue()) def OnModeChange(self, event): self.settings.set('mode', event.GetInt()) self.ToggleProxySettings(self.settings.get('mode')) Crest.restartService() def OnServerChange(self, event): self.settings.set('server', event.GetInt()) Crest.restartService() def OnBtnApply(self, event): self.settings.set('clientID', self.inputClientID.GetValue().strip()) self.settings.set('clientSecret', self.inputClientSecret.GetValue().strip()) sCrest = Crest.getInstance() sCrest.delAllCharacters() def ToggleProxySettings(self, mode): if mode: self.stSetID.Enable() self.inputClientID.Enable() self.stSetSecret.Enable() self.inputClientSecret.Enable() else: self.stSetID.Disable() self.inputClientID.Disable() self.stSetSecret.Disable() self.inputClientSecret.Disable() def getImage(self): return BitmapLoader.getBitmap("eve", "gui")
class DmgPatternEditorDlg(wx.Dialog): def __init__(self, parent): wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title=u"Damage Pattern Editor", size=wx.Size(400, 240)) self.block = False self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize) mainSizer = wx.BoxSizer(wx.VERTICAL) self.headerSizer = headerSizer = wx.BoxSizer(wx.HORIZONTAL) cDP = service.DamagePattern.getInstance() self.choices = cDP.getDamagePatternList() # Remove "Uniform" and "Selected Ammo" Damage Patterns for dp in self.choices: if dp.name in ("Uniform", "Selected Ammo"): self.choices.remove(dp) # Sort the remaining list and continue on self.choices.sort(key=lambda p: p.name) self.ccDmgPattern = wx.Choice(self, choices=map(lambda p: p.name, self.choices)) self.ccDmgPattern.Bind(wx.EVT_CHOICE, self.patternChanged) self.ccDmgPattern.SetSelection(0) self.namePicker = wx.TextCtrl(self, style=wx.TE_PROCESS_ENTER) self.namePicker.Bind(wx.EVT_TEXT_ENTER, self.processRename) self.namePicker.Hide() self.btnSave = wx.Button(self, wx.ID_SAVE) self.btnSave.Hide() self.btnSave.Bind(wx.EVT_BUTTON, self.processRename) size = None headerSizer.Add(self.ccDmgPattern, 1, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.LEFT, 3) buttons = (("new", wx.ART_NEW), ("rename", bitmapLoader.getBitmap("rename", "icons")), ("copy", wx.ART_COPY), ("delete", wx.ART_DELETE)) for name, art in buttons: bitmap = wx.ArtProvider.GetBitmap( art, wx.ART_BUTTON) if name != "rename" else art btn = wx.BitmapButton(self, wx.ID_ANY, bitmap) if size is None: size = btn.GetSize() btn.SetMinSize(size) btn.SetMaxSize(size) btn.Layout() setattr(self, name, btn) btn.Enable(True) btn.SetToolTipString("%s pattern" % name.capitalize()) headerSizer.Add(btn, 0, wx.ALIGN_CENTER_VERTICAL) mainSizer.Add(headerSizer, 0, wx.EXPAND | wx.ALL, 2) self.sl = wx.StaticLine(self) mainSizer.Add(self.sl, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) contentSizer = wx.BoxSizer(wx.VERTICAL) self.embitmap = bitmapLoader.getBitmap("em_big", "icons") self.thermbitmap = bitmapLoader.getBitmap("thermal_big", "icons") self.kinbitmap = bitmapLoader.getBitmap("kinetic_big", "icons") self.expbitmap = bitmapLoader.getBitmap("explosive_big", "icons") dmgeditSizer = wx.FlexGridSizer(2, 4, 0, 2) dmgeditSizer.AddGrowableCol(1) dmgeditSizer.AddGrowableCol(2) dmgeditSizer.SetFlexibleDirection(wx.BOTH) dmgeditSizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) width = -1 defSize = wx.Size(width, -1) self.editEm = IntCtrl(self, wx.ID_ANY, 0, wx.DefaultPosition, defSize, wx.TE_RIGHT) dmgeditSizer.Add(self.editEm, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.bmpEM = wx.StaticBitmap(self, wx.ID_ANY, self.embitmap) dmgeditSizer.Add(self.bmpEM, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5) self.bmpTHERM = wx.StaticBitmap(self, wx.ID_ANY, self.thermbitmap) dmgeditSizer.Add( self.bmpTHERM, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT, 5) self.editThermal = IntCtrl(self, wx.ID_ANY, 0, wx.DefaultPosition, defSize, 0) dmgeditSizer.Add(self.editThermal, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.editKinetic = IntCtrl(self, wx.ID_ANY, 0, wx.DefaultPosition, defSize, wx.TE_RIGHT) dmgeditSizer.Add(self.editKinetic, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.bmpKIN = wx.StaticBitmap(self, wx.ID_ANY, self.kinbitmap) dmgeditSizer.Add(self.bmpKIN, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5) self.bmpEXP = wx.StaticBitmap(self, wx.ID_ANY, self.expbitmap) dmgeditSizer.Add( self.bmpEXP, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT, 5) self.editExplosive = IntCtrl(self, wx.ID_ANY, 0, wx.DefaultPosition, defSize, 0) dmgeditSizer.Add(self.editExplosive, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) contentSizer.Add(dmgeditSizer, 1, wx.EXPAND | wx.ALL, 5) self.slfooter = wx.StaticLine(self) contentSizer.Add(self.slfooter, 0, wx.EXPAND | wx.TOP, 5) footerSizer = wx.BoxSizer(wx.HORIZONTAL) perSizer = wx.BoxSizer(wx.VERTICAL) self.stPercentages = wx.StaticText(self, wx.ID_ANY, u"") self.stPercentages.Wrap(-1) perSizer.Add(self.stPercentages, 0, wx.BOTTOM | wx.LEFT, 5) footerSizer.Add(perSizer, 0, 0, 5) self.totSizer = wx.BoxSizer(wx.VERTICAL) self.stTotal = wx.StaticText(self, wx.ID_ANY, u"") self.stTotal.Wrap(-1) self.totSizer.Add(self.stTotal, 0, wx.ALIGN_RIGHT | wx.BOTTOM | wx.RIGHT, 5) footerSizer.Add(self.totSizer, 1, 0, 5) contentSizer.Add(footerSizer, 0, wx.EXPAND, 5) mainSizer.Add(contentSizer, 1, wx.EXPAND, 0) self.SetSizer(mainSizer) self.Layout() bsize = self.GetBestSize() self.SetSize((-1, bsize.height)) self.editEm.SetLimited(True) self.editThermal.SetLimited(True) self.editKinetic.SetLimited(True) self.editExplosive.SetLimited(True) self.editEm.SetMin(0) self.editThermal.SetMin(0) self.editKinetic.SetMin(0) self.editExplosive.SetMin(0) self.editEm.SetMax(99999) self.editThermal.SetMax(99999) self.editKinetic.SetMax(99999) self.editExplosive.SetMax(99999) self.new.Bind(wx.EVT_BUTTON, self.newPattern) self.rename.Bind(wx.EVT_BUTTON, self.renamePattern) self.copy.Bind(wx.EVT_BUTTON, self.copyPattern) self.delete.Bind(wx.EVT_BUTTON, self.deletePattern) self.editEm.Bind(wx.EVT_TEXT, self.ValuesUpdated) self.editThermal.Bind(wx.EVT_TEXT, self.ValuesUpdated) self.editKinetic.Bind(wx.EVT_TEXT, self.ValuesUpdated) self.editExplosive.Bind(wx.EVT_TEXT, self.ValuesUpdated) self.patternChanged() def ValuesUpdated(self, event=None): if self.block: return p = self.getActivePattern() p.emAmount = self._EM = self.editEm.GetValue() p.thermalAmount = self._THERM = self.editThermal.GetValue() p.kineticAmount = self._KIN = self.editKinetic.GetValue() p.explosiveAmount = self._EXP = self.editExplosive.GetValue() total = self._EM + self._THERM + self._KIN + self._EXP format = "EM: % 3d%% THERM: % 3d%% KIN: % 3d%% EXP: % 3d%%" if total > 0: ltext = format % (self._EM * 100 / total, self._THERM * 100 / total, self._KIN * 100 / total, self._EXP * 100 / total) else: ltext = format % (0, 0, 0, 0) ttext = "Total: % 6d" % (total) self.stPercentages.SetLabel(ltext) self.stTotal.SetLabel(ttext) self.totSizer.Layout() if event is not None: event.Skip() service.DamagePattern.getInstance().saveChanges(p) def restrict(self): self.editEm.Enable(False) self.editExplosive.Enable(False) self.editKinetic.Enable(False) self.editThermal.Enable(False) self.rename.Enable(False) self.delete.Enable(False) def unrestrict(self): self.editEm.Enable() self.editExplosive.Enable() self.editKinetic.Enable() self.editThermal.Enable() self.rename.Enable() self.delete.Enable() def getActivePattern(self): if len(self.choices) == 0: return None return self.choices[self.ccDmgPattern.GetSelection()] def patternChanged(self, event=None): p = self.getActivePattern() if p is None: return if p.name == "Uniform" or p.name == "Selected Ammo": self.restrict() else: self.unrestrict() self.block = True for field in ("em", "thermal", "kinetic", "explosive"): edit = getattr(self, "edit%s" % field.capitalize()) amount = getattr(p, "%sAmount" % field) edit.SetValue(amount) self.block = False self.ValuesUpdated() def newPattern(self, event): cDP = service.DamagePattern.getInstance() p = cDP.newPattern() self.choices.append(p) id = self.ccDmgPattern.Append(p.name) self.ccDmgPattern.SetSelection(id) self.btnSave.SetLabel("Create") self.renamePattern() def renamePattern(self, event=None): if event is not None: self.btnSave.SetLabel("Rename") self.ccDmgPattern.Hide() self.namePicker.Show() self.headerSizer.Replace(self.ccDmgPattern, self.namePicker) self.namePicker.SetFocus() self.namePicker.SetValue(self.getActivePattern().name) for btn in (self.new, self.rename, self.delete, self.copy): btn.Hide() self.headerSizer.Remove(btn) self.headerSizer.Add(self.btnSave, 0, wx.ALIGN_CENTER) self.btnSave.Show() self.headerSizer.Layout() if event is not None: event.Skip() def processRename(self, event): newName = self.namePicker.GetLineText(0) self.stPercentages.SetLabel("") self.stTotal.SetLabel("") p = self.getActivePattern() for pattern in self.choices: if pattern.name == newName and p != pattern: self.stPercentages.SetLabel( "Name already used, please pick another") return cDP = service.DamagePattern.getInstance() cDP.renamePattern(p, newName) self.headerSizer.Replace(self.namePicker, self.ccDmgPattern) self.ccDmgPattern.Show() self.namePicker.Hide() self.btnSave.Hide() self.headerSizer.Remove(self.btnSave) for btn in (self.new, self.rename, self.delete, self.copy): self.headerSizer.Add(btn, 0, wx.ALIGN_CENTER_VERTICAL) btn.Show() sel = self.ccDmgPattern.GetSelection() self.ccDmgPattern.Delete(sel) self.ccDmgPattern.Insert(newName, sel) self.ccDmgPattern.SetSelection(sel) self.ValuesUpdated() def copyPattern(self, event): cDP = service.DamagePattern.getInstance() p = cDP.copyPattern(self.getActivePattern()) self.choices.append(p) id = self.ccDmgPattern.Append(p.name) self.ccDmgPattern.SetSelection(id) self.btnSave.SetLabel("Copy") self.renamePattern() self.patternChanged() def deletePattern(self, event): cDP = service.DamagePattern.getInstance() sel = self.ccDmgPattern.GetSelection() cDP.deletePattern(self.getActivePattern()) self.ccDmgPattern.Delete(sel) self.ccDmgPattern.SetSelection(max(0, sel - 1)) del self.choices[sel] self.patternChanged() def __del__(self): pass
class ScopeConnection(wx.Panel): """This is the view and controller for connecting to the scope""" def __init__(self, parent, env): """Initialize the panel for setting up the scope""" wx.Panel.__init__(self, parent, wx.ID_ANY, style=wx.BORDER_SIMPLE) self.env = env self.scope = self.env.scope_source self.sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.sizer) input_host = wx.BoxSizer(wx.HORIZONTAL) target_cpu = wx.BoxSizer(wx.HORIZONTAL) scope_cpu = wx.BoxSizer(wx.HORIZONTAL) buttons = wx.BoxSizer(wx.HORIZONTAL) self.status = wx.StaticText(self, wx.ID_ANY, "") font = self.status.GetFont() font.SetWeight(wx.BOLD) self.status.SetFont(font) self.btn_enable = wx.Button(self, wx.ID_ANY, "") self.btn_collect = wx.Button(self, wx.ID_ANY, "Collect") buttons.Add(self.btn_enable, 1, wx.ALIGN_CENTER) buttons.Add(self.btn_collect, 1, wx.ALIGN_CENTER) lbl_server = wx.StaticText(self, wx.ID_ANY, "Scope Server") self.txt_server = wx.TextCtrl(self, wx.ID_ANY, self.scope.server) self.btn_connect = wx.Button(self, wx.ID_ANY, "Connect") input_host.Add(lbl_server, 0, wx.ALIGN_CENTER | wx.RIGHT, 5) input_host.Add(self.txt_server, 1, wx.EXPAND) input_host.Add(self.btn_connect, 0, wx.EXPAND) self.sizer.Add(self.status, 0, wx.EXPAND | wx.ALL, 5) self.sizer.Add(input_host, 0, wx.EXPAND | wx.BOTTOM | wx.LEFT | wx.RIGHT, 5) self.choice_t_cpu = wx.Choice(self, wx.ID_ANY) self._add_field("Target CPU", self.choice_t_cpu, small=True) self.choice_s_cpu = wx.Choice(self, wx.ID_ANY) self._add_field("Scope CPU", self.choice_s_cpu, small=True) self.command = wx.TextCtrl(self, wx.ID_ANY, style=wx.TE_RIGHT) self._add_field("Target Command", self.command) self.command.Bind(wx.EVT_TEXT, self.onchange_capture_settings) self.ta = wx.TextCtrl(self, wx.ID_ANY, style=wx.TE_RIGHT) self._add_field("Target App", self.ta) self.ta.Bind(wx.EVT_TEXT, self.onchange_capture_settings) self.target_cbuf = wx.TextCtrl(self, wx.ID_ANY, style=wx.TE_RIGHT) self._add_field("Target Trigger Buffer", self.target_cbuf) self.target_cbuf.Bind(wx.EVT_TEXT, self.onchange_capture_settings) self.msamples = IntCtrl(self, wx.ID_ANY, style=wx.TE_RIGHT) self._add_field("Max # Samples", self.msamples, small=True) self.msamples.Bind(wx.EVT_TEXT, self.onchange_capture_settings) self.delta = IntCtrl(self, wx.ID_ANY, style=wx.TE_RIGHT) self._add_field("Time Step", self.delta, small=True) self.delta.Bind(wx.EVT_TEXT, self.onchange_capture_settings) self.debug = wx.CheckBox(self, wx.ID_ANY) self._add_field("Debug TA Calls", self.debug, small=True) self.debug.Bind(wx.EVT_CHECKBOX, self.onchange_capture_settings) self.sizer.Add(buttons, 0, wx.ALL | wx.CENTER, 5) # Events self.btn_enable.Bind(wx.EVT_BUTTON, self.onclick_btn_enable) self.btn_connect.Bind(wx.EVT_BUTTON, self.onclick_btn_connect) self.choice_t_cpu.Bind(wx.EVT_CHOICE, self.onchoice_t_cpu) self.choice_s_cpu.Bind(wx.EVT_CHOICE, self.onchoice_s_cpu) self.btn_collect.Bind(wx.EVT_BUTTON, self.onclick_btn_collect) pub.subscribe(self.on_enable_changed, ScopeSource.ENABLED_CHANGED) pub.subscribe(self.on_connect_changed, ScopeSource.CONNECTED_CHANGED) pub.subscribe(self.on_capture_settings_changed, ScopeSource.CAPTURE_SETTINGS_CHANGED) pub.subscribe(self.on_readiness_changed, CaptureSource.READINESS_CHANGED) # Initial data self.draw_status() self.draw_capture_settings() self.draw_collect_btn() def _add_field(self, label, item, small=False): """Add a label/element pair to the UI""" szr = wx.BoxSizer(wx.HORIZONTAL) lbl = wx.StaticText(self, wx.ID_ANY, label) szr.Add(lbl, 1 if small else 0, wx.ALIGN_CENTER) szr.Add((15, 15), 0, wx.EXPAND) szr.Add(item, 0 if small else 1, wx.ALIGN_RIGHT) self.sizer.Add(szr, 0, wx.EXPAND | wx.BOTTOM | wx.LEFT | wx.RIGHT, 5) def onclick_btn_connect(self, evt): """Connect button has been clicked.""" server = self.txt_server.GetValue() if self.scope.is_connected(): self.scope.disconnect() self.scope.connect(server) def onclick_btn_enable(self, evt): """Enable button has been clicked.""" if not self.scope.is_enabled(): self.scope.enable() else: self.scope.disable() def onclick_btn_collect(self, evt): """Collect button has been clicked.""" if self.env.get_active_dataset_name() is not None: self.env.collection_pipeline.run(1) def onchoice_t_cpu(self, evt): """The target CPU has changed.""" sel = self.choice_t_cpu.GetSelection() if sel != wx.NOT_FOUND: self.scope.set_target_core(sel) def onchoice_s_cpu(self, evt): """The scope CPU has changed.""" sel = self.choice_s_cpu.GetSelection() if sel != wx.NOT_FOUND: self.scope.set_scope_core(sel) def on_enable_changed(self): """The enable state of the scope has changed.""" self.draw_status() def on_connect_changed(self): """The connection state of the scope has changed.""" self.draw_status() self.draw_capture_settings() def on_capture_settings_changed(self): """The capture settings have changed.""" self.draw_capture_settings() def on_readiness_changed(self): """The readiness of the scope has changed.""" self.draw_collect_btn() def onchange_capture_settings(self, evt): """The user is trying to change the capture settings.""" cmd = self.command.GetValue() ta = self.ta.GetValue() cbuf = self.target_cbuf.GetValue() msamp = self.msamples.GetValue() delta = self.delta.GetValue() debug = self.debug.GetValue() self.scope.set_capture_params(max_samples=msamp, time_delta=delta, ta_command=cmd, ta_name=ta, ta_cbuf=cbuf, debug=debug) def draw_status(self): """Update the state, buttons, and spinners based on current state""" enabled = self.scope.is_enabled() connected = self.scope.is_connected() if enabled and connected: scope_state = "Enabled" elif connected and not enabled: scope_state = "Connected and Disabled" else: scope_state = "Disconnected" btn_label = "Disable" if enabled else "Enable" scope_status = "Scope is %s" % scope_state self.status.SetLabel(scope_status) self.btn_connect.Enable(not enabled or not connected) self.txt_server.Enable(not enabled or not connected) self.btn_enable.SetLabel(btn_label) self.btn_enable.Enable(connected) ncores = self.scope.num_cores cores = ["Core %u" % i for i in range(ncores)] sel = self.choice_t_cpu.GetSelection() if sel == wx.NOT_FOUND: sel = self.scope.get_target_core() self.choice_t_cpu.SetItems(cores) if ncores > 0: self.choice_t_cpu.SetSelection(sel) self.choice_t_cpu.Enable(connected and not enabled) sel = self.choice_s_cpu.GetSelection() if sel == wx.NOT_FOUND: sel = self.scope.get_scope_core() self.choice_s_cpu.SetItems(cores) if ncores > 0: self.choice_s_cpu.SetSelection(sel) self.choice_s_cpu.Enable(connected and not enabled) def draw_capture_settings(self): """Draw the capture settings.""" enabled = self.scope.is_enabled() connected = self.scope.is_connected() self.command.ChangeValue(self.scope.ta_command) self.ta.ChangeValue(self.scope.ta_name) self.target_cbuf.ChangeValue(self.scope.ta_cbuf) self.msamples.ChangeValue(self.scope.max_samples) self.delta.ChangeValue(self.scope.time_delta) self.debug.SetValue(self.scope.debug) self.command.Enable(connected) self.ta.Enable(connected) self.target_cbuf.Enable(connected) self.msamples.Enable(connected) self.delta.Enable(connected) self.debug.Enable(connected) def draw_collect_btn(self): """Enable or disable the collection button""" self.btn_collect.Enable(self.scope.is_ready())