How to use _navigation method in play_selenium

Best Python code snippet using play_selenium_python

KeyLabEssProcess.py

Source:KeyLabEssProcess.py Github

copy

Full Screen

1import channels2import midi3import mixer4import patterns5import transport6import ui7import device8import plugins9import ArturiaCrossKeyboardEss as AKLESS10import KeyLabEssPlugin11from KeyLabEssDispatch import MidiEventDispatcher12from KeyLabEssDispatch import send_to_device13from KeyLabEssDisplay import KeyLabDisplay14from KeyLabEssPages import KeyLabPagedDisplay15from KeyLabEssNavigation import NavigationMode16## CONSTANT17PORT_MIDICC_ANALOGLAB = 1018WidMixer = 019WidChannelRack = 120WidPlaylist = 221WidBrowser = 422WidPlugin = 523ANALOGLAB_KNOB_ID = [0x4A, 0x47, 0x4C, 0x4D, 0x5D, 0x49, 0x4B]24# Event code indicating stop event25SS_STOP = 026# Event code indicating start start event27SS_START = 228# MIXER29MIXER_MODE = 030# Max Tracks31MAX_TRACKS = 12532FPC_MAP = {33 "36":40,34 "37":38,35 "38":46,36 "39":44,37 "40":37,38 "41":36,39 "42":42,40 "43":5441 }42# This class processes all CC coming from the controller43# The class creates new handler for each function44# The class calls the right fonction depending on the incoming CC45class KeyLabEssMidiProcessor:46 @staticmethod47 def _is_pressed(event):48 return event.controlVal != 049 def __init__(self, ess):50 def by_midi_id(event) : return event.midiId51 def by_control_num(event) : return event.controlNum52 def by_velocity(event) : return event.data253 def by_status(event) : return event.status54 def by_sysex(event) : return event.sysex55 def ignore_release(event): return self._is_pressed(event)56 def ignore_press(event): return not self._is_pressed(event)57 self._ess = ess58 self._midi_id_dispatcher = (59 MidiEventDispatcher(by_midi_id)60 .NewHandler(144, self.OnCommandEvent)61 .NewHandler(176, self.OnKnobEvent)62 .NewHandler(224, self.OnSliderEvent)63 .NewHandler(153, self.OnDrumEvent)64 .NewHandler(137, self.OnDrumEvent)65 )66 67 68 self._sysex_dispatcher = (69 MidiEventDispatcher(by_sysex)70 .NewHandler(b'\xf0\x00 k\x7fB\x02\x00\x00\x18\x00\xf7', self.previousPreset, ignore_press)71 .NewHandler(b'\xf0\x00 k\x7fB\x02\x00\x00\x19\x00\xf7', self.nextPreset, ignore_press)72 )73 74 self._midi_command_dispatcher = (75 MidiEventDispatcher(by_control_num)76 77 .NewHandler(0x5E, self.Start, ignore_press)78 .NewHandler(0x5D, self.Stop, ignore_release)79 .NewHandler(0x5F, self.Record, ignore_press)80 .NewHandler(0x58, self.Overdub, ignore_press)81 .NewHandler(0x56, self.Loop, ignore_press)82 .NewHandler(0x59, self.SetClick, ignore_press)83 .NewHandler(0x51, self.Undo, ignore_press)84 .NewHandler(0x50, self.Cut, ignore_press)85 .NewHandler(0x5B, self.Rewind)86 .NewHandler(0x5C, self.FastForward)87 .NewHandler(0x54, self.SwitchWindow, ignore_release)88 .NewHandler(0x2E, self.BankSelect, ignore_release)89 .NewHandler(0x2F, self.BankSelect, ignore_release)90 .NewHandler(0x62, self.previousPattern, ignore_release)91 .NewHandler(0x63, self.nextPattern, ignore_release)92 .NewHandler(0x64, self.ToggleMixerChannelRack, ignore_release)93 .NewHandler(0x65, self.ToggleBrowserChannelRack, ignore_release)94 )95 96 self._slider_dispatcher = (97 MidiEventDispatcher(by_status)98 .NewHandlerForKeys(range(224,233), self.SetVolumeTrack) 99 )100 101 102 self._plugin_dispatcher = (103 MidiEventDispatcher(by_control_num)104 .NewHandler(0x4A, self.Plugin)105 .NewHandler(71, self.Plugin)106 .NewHandler(76, self.Plugin)107 .NewHandler(77, self.Plugin)108 .NewHandler(93, self.Plugin)109 .NewHandler(18, self.Plugin)110 .NewHandler(19, self.Plugin)111 .NewHandler(16, self.Plugin)112 113 .NewHandler(73, self.Plugin)114 .NewHandler(75, self.Plugin)115 .NewHandler(79, self.Plugin)116 .NewHandler(72, self.Plugin)117 .NewHandler(80, self.Plugin)118 .NewHandler(81, self.Plugin)119 .NewHandler(82, self.Plugin)120 .NewHandler(83, self.Plugin)121 .NewHandler(17, self.Plugin)122 .NewHandler(1, self.Plugin)123 124 .NewHandler(0x1C, self.previousPreset, ignore_release)125 .NewHandler(0x1D, self.nextPreset, ignore_release)126 )127 128 129 self._knob_dispatcher = (130 MidiEventDispatcher(by_control_num)131 .NewHandler(60, self.OnKnobNavEvent)132 .NewHandler(60, self.OnKnobNavEvent)133 .NewHandlerForKeys(range(16,24), self.SetPanTrack)134 )135 self._knob_nav_dispatcher = (136 MidiEventDispatcher(by_velocity)137 .NewHandler(1, self.TrackSelectMainKnob)138 .NewHandler(65, self.TrackSelectMainKnob)139 )140 # NAVIGATION141 142 self._navigation = NavigationMode(self._ess.paged_display())143 # DISPATCH144 def ProcessEvent(self, event) :145 if event.status in [153,137] :146 #print("status",event.status,"\t",event.data1,"\t",event.controlNum,"\t",event.data2,"\t",event.midiId)147 return self.OnDrumEvent(event)148 elif (event.status != event.midiId and event.midiId != 224) :149 #print("plugin",event.status,"\t",event.data1,"\t",event.controlNum,"\t",event.data2,"\t",event.midiId)150 return self._plugin_dispatcher.Dispatch(event)151 else :152 #print("midi id",event.status,"\t",event.data1,"\t",event.controlNum,"\t",event.data2,"\t",event.midiId)153 return self._midi_id_dispatcher.Dispatch(event)154 155 def OnCommandEvent(self, event) :156 event.handled = True157 if event.status == event.midiId :158 device.processMIDICC(event)159 self._midi_command_dispatcher.Dispatch(event)160 def OnKnobEvent(self, event):161 event.handled = True162 self._knob_dispatcher.Dispatch(event)163 164 def OnKnobNavEvent(self, event):165 event.handled = True166 self._knob_nav_dispatcher.Dispatch(event)167 168 def OnPluginEvent(self, event) :169 event.handled = True170 self._plugin_dispatcher.Dispatch(event)171 172 def OnSliderEvent(self, event) :173 event.handled = True174 self._slider_dispatcher.Dispatch(event)175 def OnDrumEvent(self, event) :176 if event.status == 153 :177 event.data1 = FPC_MAP.get(str(event.data1))178 event.data2 = midi.MIDI_NOTEON179 elif event.status == 137 :180 event.data1 = FPC_MAP.get(str(event.data1))181 event.data2 = midi.MIDI_NOTEOFF182 event.handled = False183 # WINDOW184 def _show_and_focus(self, window):185 if not ui.getVisible(window):186 ui.showWindow(window)187 if not ui.getFocused(window):188 ui.setFocused(window)189 def _hideAll(self, event) :190 for i in range (channels.channelCount()) :191 channels.showEditor(i,0)192 def SwitchWindow(self, event) :193 if (ui.getFocused(WidChannelRack) or ui.getFocused(WidPlugin)) :194 self.showPlugin(event)195 elif ui.getFocused(WidMixer) :196 track = mixer.trackNumber()197 mixer.armTrack(track)198 self._navigation.ArmRefresh(track)199 # for i in range(plugins.getParamCount(plugin)) :200 # print(i, plugins.getParamName(i,plugin), plugins.getParamValue(i,plugin))201 else :202 nodeFileType = ui.getFocusedNodeFileType()203 if nodeFileType == -1:204 return205 if nodeFileType <= -100:206 transport.globalTransport(midi.FPT_Enter, 1)207 else:208 ui.selectBrowserMenuItem()209 if not ui.isInPopupMenu() :210 self._navigation.PressRefresh()211 212 def showPlugin(self, event) :213 channels.showEditor(channels.channelNumber())214 215 216 def ToggleBrowserChannelRack(self, event) :217 if ui.getFocused(4) != True :218 self._show_and_focus(4)219 self._navigation.BrowserRefresh()220 else :221 self._show_and_focus(1)222 self._navigation.ChannelRackRefresh()223 224 225 def ToggleMixerChannelRack(self, event) :226 self.FakeMIDImsg()227 self._hideAll(event)228 global MIXER_MODE229 if MIXER_MODE == 0 :230 MIXER_MODE = 1231 self._show_and_focus(WidMixer)232 else :233 MIXER_MODE = 0234 self._show_and_focus(WidChannelRack)235 self._navigation.MixerToggleRefresh()236 # NAVIGATION237 def TrackSelectMainKnob(self, event):238 if ui.getFocused(WidPlugin) == True :239 self._hideAll(event) 240 elif ui.getFocused(WidBrowser) == True :241 if ui.isInPopupMenu() : 242 if event.data2 == 65 :243 ui.up()244 elif event.data2 == 1 :245 ui.down()246 self._navigation.HintRefresh(ui.getFocusedNodeCaption())247 else :248 if event.data2 == 65 :249 ui.previous()250 elif event.data2 == 1 :251 ui.next()252 self._navigation.HintRefresh(ui.getFocusedNodeCaption())253 elif ui.getFocused(WidMixer) == True :254 if event.data2 == 65 :255 self._show_and_focus(WidMixer)256 self._hideAll(event)257 ui.previous()258 259 elif event.data2 == 1 : 260 self._show_and_focus(WidMixer)261 self._hideAll(event)262 ui.next()263 else :264 if event.data2 == 65 :265 self._show_and_focus(WidChannelRack)266 self._hideAll(event)267 ui.previous()268 mixer.setTrackNumber(channels.getTargetFxTrack(channels.channelNumber()),3)269 elif event.data2 == 1 : 270 self._show_and_focus(WidChannelRack)271 self._hideAll(event)272 ui.next()273 mixer.setTrackNumber(channels.getTargetFxTrack(channels.channelNumber()),3)274 def BankSelect(self, event) :275 if MIXER_MODE == 1 :276 self.FakeMIDImsg()277 if event.controlNum == 0x2E :278 AKLESS.MX_OFFSET -= 1279 if AKLESS.MX_OFFSET < 0 :280 AKLESS.MX_OFFSET = 0281 self._navigation.BankMixRefresh()282 elif event.controlNum == 0x2F :283 if (AKLESS.MX_OFFSET + 1)*8 < MAX_TRACKS :284 AKLESS.MX_OFFSET += 1285 self._navigation.BankMixRefresh()286 #ui.miDisplayRect(1+(AKLESS.MX_OFFSET*8),9+(AKLESS.MX_OFFSET*8),100) # does not seem to work287 else :288 self.FakeMIDImsg()289 if event.controlNum == 0x2E :290 AKLESS.CH_OFFSET -= 1291 if AKLESS.CH_OFFSET < 0 :292 AKLESS.CH_OFFSET = 0293 self._navigation.BankChanRefresh()294 elif event.controlNum == 0x2F :295 if (AKLESS.CH_OFFSET + 1)*8 < channels.channelCount() :296 AKLESS.CH_OFFSET += 1297 self._navigation.BankChanRefresh()298 299 def previousPattern(self, event) :300 if ui.getFocused(5) :301 self.previousPreset(event)302 else :303 pattern = patterns.patternNumber()304 patterns.jumpToPattern(pattern - 1)305 306 307 def nextPattern(self, event) :308 if ui.getFocused(5) :309 self.nextPreset(event)310 else :311 pattern = patterns.patternNumber()312 patterns.jumpToPattern(pattern + 1)313 314 315 316 # PLUGIN317 # def NewPlugin(self, event) :318 # transport.globalTransport(67,1)319 def nextPreset(self, event) :320 if ui.getFocused(5) :321 plugins.nextPreset(channels.channelNumber())322 def previousPreset(self, event) :323 if ui.getFocused(5) :324 plugins.prevPreset(channels.channelNumber())325 def Plugin(self, event, clef) :326 if ui.getFocused(5) :327 param, value = KeyLabEssPlugin.Plugin(event,clef)328 if event.controlNum != 1 :329 self._navigation.PluginRefresh(param, value)330 # FUNCTIONS331 def Record(self, event) :332 transport.record()333 self._navigation.RecordRefresh()334 335 336 def Start(self, event) :337 transport.start()338 self._navigation.PlayRefresh() 339 340 341 def Stop(self, event) :342 transport.stop()343 self._navigation.StopRefresh()344 345 def FastForward(self, event) :346 if self._is_pressed(event):347 transport.continuousMove(1, SS_START)348 self._navigation.FastForwardRefresh()349 else:350 transport.continuousMove(1, SS_STOP)351 self._navigation.FastForwardRefresh()352 353 def Rewind(self, event) :354 if self._is_pressed(event):355 transport.continuousMove(-1, SS_START)356 self._navigation.RewindRefresh()357 else:358 transport.continuousMove(-1, SS_STOP)359 self._navigation.RewindRefresh()360 361 def Loop(self, event) :362 transport.globalTransport(midi.FPT_LoopRecord,1)363 self._navigation.LoopRefresh()364 def Overdub(self, event) :365 transport.globalTransport(midi.FPT_Overdub,1)366 self._navigation.OverdubRefresh()367 368 def SetClick(self, event) :369 transport.globalTransport(midi.FPT_Metronome,1)370 self._navigation.MetronomeRefresh() 371 372 def Undo(self, event) :373 transport.globalTransport(midi.FPT_Undo, midi.FPT_Undo, event.pmeFlags)374 self._navigation.UndoRefresh() 375 def Cut(self, event) :376 self._show_and_focus(midi.widChannelRack)377 ui.cut()378 self._navigation.CutRefresh() 379 def TapTempo(self, event) :380 transport.globalTransport(midi.FPT_TapTempo,1)381 self._navigation.TapTempoRefresh()382 def SnapMode(self, event) :383 ui.snapMode(1)384 self._navigation.SnapModeRefresh()385 386 387 def SetVolumeTrack(self, event) :388 if MIXER_MODE == 1 :389 if event.status == 232 and event.midiId == 224 :390 event.data1 = 1391 event.midiId = midi.MIDI_CONTROLCHANGE392 AKLESS.SetVolumeTrack(event) 393 value = round(mixer.getTrackVolume(0)*100)394 perc = str(value)395 self._navigation.VolumeMixerRefresh(event, perc)396 else :397 event.data1 = 2 + event.status - event.midiId398 event.midiId = midi.MIDI_CONTROLCHANGE399 track = (event.controlNum - 1) + (8*AKLESS.MX_OFFSET)400 if track < 126 :401 AKLESS.SetVolumeTrack(event)402 value = round(mixer.getTrackVolume(event.data1 - 1 + (8*AKLESS.MX_OFFSET)) * 100)403 perc = str(value)404 self._navigation.VolumeMixerRefresh(event, perc)405 else :406 if event.status != 232 :407 self.Plugin(event, clef = event.status)408 self._navigation.NoPlugin()409 else :410 value = event.data2/127411 mixer.setTrackVolume(mixer.trackNumber(),0.8*value)412 value = round(mixer.getTrackVolume(mixer.trackNumber())*100)413 perc = str(value)414 self._navigation.VolumeChRefresh(perc)415 def SetPanTrack(self, event) :416 if MIXER_MODE == 1 :417 track = (event.controlNum - 15) + (8*AKLESS.MX_OFFSET)418 AKLESS.SetPanTrack(event)419 value = round(mixer.getTrackPan(track) * 100)420 perc = str(value)421 self._navigation.PanMixerRefresh(event, perc)422 else :423 if event.controlNum != 24 :424 self.Plugin(event, clef = event.controlNum)425 self._navigation.NoPlugin()426 else :427 data = 0428 if event.data2 > 0x40 : data = -1429 elif event.data2 < 0x40 : data = 1430 mixer.setTrackPan(mixer.trackNumber(),mixer.getTrackPan(mixer.trackNumber())+ (data/20))431 value = round(mixer.getTrackPan(mixer.trackNumber()) * 100)432 perc = str(value)433 self._navigation.PanChRefresh(perc)434 435 436 437 # UTILITY438 439 440 441 def FakeMIDImsg(self) :...

Full Screen

Full Screen

logic.py

Source:logic.py Github

copy

Full Screen

1from enum import Enum2from PIL import Image, ImageDraw, ImageFont3from krv2.hmi.hmi import Hmi4from krv2.music_collection import Database, Navigation5from krv2.hardware.port_expander import Buttons6class States(Enum):7 mode_selection = 08 navigation = 19class Logic:10 def __init__(self, hmi: Hmi, cfg_logic: dict) -> None:11 self._hmi = hmi12 self._db = Database(cfg_db=cfg_logic["database"])13 self._navigation = Navigation(cfg_nav=cfg_logic["navigation"], db=self._db)14 self._state = States.navigation15 self.connect_signals()16 self.visualize_list_slice()17 self._button_mapping = {18 States.navigation: {19 Buttons.enc0_sw: self._navigation.into,20 Buttons.enc1_sw: lambda: None,21 Buttons.button_back: self._navigation.out,22 Buttons.button_pause_play: lambda: None,23 Buttons.button_prev_song: lambda: None,24 Buttons.button_next_song: lambda: None,25 Buttons.button_shuffle_repeat: lambda: None,26 Buttons.button_spare: lambda: None,27 Buttons.button_next_source: lambda: None,28 Buttons.dummy: lambda: None,29 Buttons.button_exit: lambda: None,30 }31 }32 self._hmi.start()33 def connect_signals(self) -> None:34 self._hmi.enc0.connect(self.on_enc_movement)35 self._hmi.enc0_sw.connect(self.on_enc0_sw_pressed)36 self._hmi.button.connect(self.on_button_pressed)37 def on_enc_movement(self, amount, **kwargs): # type: ignore38 if self._state == States.navigation:39 if amount < 0:40 self._navigation.up()41 elif amount > 0:42 self._navigation.down()43 # Fixme: include this into on_Button_pressed below!!!44 def on_enc0_sw_pressed(self, **kwargs): # type: ignore45 if self._state == States.navigation:46 self._navigation.into()47 def on_button_pressed(self, name, **kwargs): # type: ignore48 name: Buttons49 self._button_mapping[self._state][name]()50 print(f"Button {name} pressed")51 def visualize_list_slice(self) -> None:52 fnt = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 9)53 display_content = Image.new(mode="1", size=(128, 64), color=0)54 canvas = ImageDraw.Draw(display_content)55 posy = 056 for line in self._navigation.current_slice:57 # if line == self._nav.cursor_text:58 # self._place_cursor(nav_display, posy)59 canvas.text((5, posy), line, fill="white", font=fnt)60 posy += 1161 self._hmi.show_on_display(0, display_content)62 def _place_cursor(self, nav_display, posy):...

Full Screen

Full Screen

day2.py

Source:day2.py Github

copy

Full Screen

1from copy import deepcopy2from utils import read3navigation = {4 'horizontal': 0,5 'depth': 0,6 'aim': 0,7}8def challenge1(filepath):9 instructions = read(filepath)10 _navigation = deepcopy(navigation)11 for instruction in instructions:12 direction, amount = instruction.split(' ')13 if direction == 'forward':14 _navigation['horizontal'] += float(amount)15 elif direction == 'down':16 _navigation['depth'] += float(amount)17 elif direction == 'up':18 _navigation['depth'] -= float(amount)19 else:20 print(direction)21 22 print(_navigation)23 return _navigation['horizontal'] * _navigation['depth']24def challenge2(filepath):25 instructions = read(filepath)26 _navigation = deepcopy(navigation)27 for instruction in instructions:28 direction, amount = instruction.split(' ')29 if direction == 'down':30 _navigation['aim'] += float(amount)31 elif direction == 'up':32 _navigation['aim'] -= float(amount) 33 elif direction == 'forward':34 _navigation['horizontal'] += float(amount)35 _navigation['depth'] += (_navigation['aim'] * float(amount))36 else:37 print(direction)38 39 print(_navigation)40 return _navigation['horizontal'] * _navigation['depth']41if __name__== '__main__':42 print(challenge1('day2/day2.txt'))...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run play_selenium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful