How to use scrollRight method in taiko

Best JavaScript code snippet using taiko

main.py

Source:main.py Github

copy

Full Screen

1import sys2import random3import matplotlib4matplotlib.use("Qt5Agg")5from PyQt5 import QtCore, QtGui, QtWidgets6from PyQt5.QtWidgets import QLineEdit,QComboBox, QFileDialog, QSlider, QGroupBox, QApplication, QMainWindow, QMenu, QHBoxLayout , QVBoxLayout, QSizePolicy, QMessageBox, QWidget,QPushButton7from numpy import arange, sin, pi,fft8from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas9from matplotlib.figure import Figure10import numpy as np11from matplotlib.backends.backend_pdf import PdfPages12import matplotlib.pyplot as plt13from scipy.signal import butter, lfilter14from matplotlib.widgets import SpanSelector15from functools import partial1617fmax=25018fs=50019period=1/50020class MyMplCanvas(FigureCanvas):21 def __init__(self, parent=None, width=5, height=4, dpi=100,file=None):22 self.file = file23 fig = Figure(figsize=(width, height), dpi=dpi)24 self.axes = fig.add_subplot(111)25 FigureCanvas.__init__(self, fig)26 self.setParent(parent)27 FigureCanvas.setSizePolicy(self,28 QSizePolicy.Expanding,29 QSizePolicy.Expanding)30 FigureCanvas.updateGeometry(self)3132class MyStaticMplCanvas(MyMplCanvas):33 def __init__(self, parent=None, width=5, height=4, dpi=100,file=None):34 super(). __init__(parent=None, width=5, height=4, dpi=100,file=None)35 self.cmap = 'viridis'36 def addSpectrogram(self,lineData,min=None,max=None):37 NFFT = 102438 self.axes.cla()39 self.axes.specgram(lineData, NFFT=NFFT, Fs=fs, noverlap=900,cmap=self.cmap)40 self.draw()41 try:42 self.axes.set_ylim(min,max)43 self.draw()44 except:45 pass4647 def setCmap(self,text):48 self.cmap = text4950class MyDynamicMplCanvas(MyMplCanvas):51 def __init__(self, *args, **kwargs):52 MyMplCanvas.__init__(self, *args, **kwargs)53 self.lines = self.file.readlines()54 self.y = [float(line.split(',')[0]) for line in self.lines]55 x = np.arange(len(self.y))56 self.axes.set_xlim(0,100)57 self.speed = 100058 self.axes.plot(x,self.y, 'r')59 self.draw()60 self.timer = QtCore.QTimer(self)61 self.timer.timeout.connect(self.update_figure)62 self.timer.start(self.speed)63 def Equalizer(self,values):64 main_file=self.y65 fourierTransform = (np.fft.rfft(main_file))66 numberOfPoints = len(main_file)67 x_frequency = np.linspace(0.0, 1.0/(2.0*period), numberOfPoints//2)68 new_frequency=[]69 for slider_counter in range(0,10):70 new_frequency.append([i for i, n in enumerate(x_frequency) if n>=fmax*(slider_counter)/10 and n<=fmax*(slider_counter+1)/10 ])71 slider_number=072 for frequency in new_frequency:73 fourierTransform[frequency] = fourierTransform[frequency]*values[slider_number]74 slider_number+=175 Equalizer_result = np.fft.irfft(fourierTransform) 76 Equalizer_result = np.round(Equalizer_result,2)77 x_equalizer = arange(len(Equalizer_result))78 l,r = self.axes.set_xlim()79 self.axes.cla()80 self.axes.plot(x_equalizer,Equalizer_result)81 self.axes.set_xlim(l,r)82 self.draw()83 def spectrogramRange(self,min,max,speclines):84 numberOfPoints = len(speclines)85 yf=np.fft.rfft(speclines)86 xf = np.linspace(0.0, 1.0/(2.0*period), numberOfPoints//2)87 z=[]88 newyf=[]89 z.append([i for i, n in enumerate(xf) if n>=min[0] and n<=max[0] ])90 for array in z:91 for i in array:92 newyf.append(yf[i])93 return np.fft.irfft(newyf)94 def scrollleft(self):95 self.scroll_helper(-10)96 def scrollright(self):97 self.scroll_helper(10)98 def zoomin(self):99 self.zoom_helper(0)100 def zoomout(self):101 self.zoom_helper(1)102 def scroll_helper(self,number):103 #Number is the number to be added to both limits104 left, right = self.axes.set_xlim()105 if number< 0 and left+number < 0 or right+number>len(self.y) and number>0:106 return107 left+=number108 right+=number109 left, right = self.axes.set_xlim(left,right)110 self.draw()111 def zoom_helper(self,identifier):112 #Identifier 0 for zoomin, 1 for zoomout113 left, right = self.axes.set_xlim()114 average = (left+right)/2115 left_for_calculation = average if identifier == 0 else left116 right_for_calculation = average if identifier ==0 else right117 left_new = left_for_calculation-abs((average - left)/2)118 right_new = right_for_calculation+abs((average - right)/2)119 left,right = self.axes.set_xlim(left_new,right_new)120 if left_new < 0 or right_new > len(self.y):121 return122 self.draw()123 124 def update_figure(self):125 left, right = self.axes.set_xlim()126 if(right+1 > len(self.y)):127 return128 self.axes.set_xlim(left+100,right+100)129 self.draw()130 def pause(self):131 self.timer.stop()132 def play(self):133 self.timer.start(self.speed)134 def getY(self):135 return self.axes.get_lines()[0].get_ydata()136 def setSpeed(self,speed):137 self.speed = speed138 self.timer.start(self.speed)139class ApplicationWindow(QMainWindow):140 def clearLayout(self, layout):141 if layout is not None:142 while layout.count():143 item = layout.takeAt(0)144 widget = item.widget()145 if widget is not None:146 widget.deleteLater()147 else:148 self.clearLayout(item.layout())149 def __init__(self):150 QMainWindow.__init__(self)151 self.children = []152 self.setAttribute(QtCore.Qt.WA_DeleteOnClose)153 self.setWindowTitle("Signal Viewer")154 self.resize(900, 800)155 self.file_menu = QMenu('&File', self)156 self.file_menu.addAction('&Quit', self.fileQuit,157 QtCore.Qt.CTRL + QtCore.Qt.Key_Q)158 self.menuBar().addMenu(self.file_menu)159 self.actionOpen_file = QtWidgets.QAction(self)160 self.actionOpen_file.setObjectName("actionOpen_file")161 self.actionOpen_file.setText("Open file")162 self.actionOpen_file.setShortcut("Ctrl+O")163 self.actionOpen_file.triggered.connect(self.OpenFile)164 self.actionNew_file = QtWidgets.QAction(self)165 self.actionNew_file.setObjectName("actionNew_file")166 self.file_menu.addAction(self.actionOpen_file)167 self.file_menu.addAction(self.actionNew_file)168 self.actionNew_file.setText("New file")169 self.actionNew_file.setShortcut("Ctrl+N")170 self.actionNew_file.triggered.connect(self.NewFile)171 self.main_widget = QWidget(self)172 self.actionReport = QtWidgets.QAction(self)173 self.actionReport.setObjectName("actionReport")174 self.actionReport.setText("Report")175 self.actionReport.setShortcut("Ctrl+R")176 self.actionReport.triggered.connect(self.GenerateReport)177 self.file_menu.addAction(self.actionReport)178 self.main_widget.setFocus()179 self.setCentralWidget(self.main_widget)180 self.layout = QHBoxLayout(self.main_widget)181 def GenerateReport(self):182 filenames = QFileDialog().getOpenFileNames(options=QFileDialog.DontUseNativeDialog)183 i = 0184 fig, axs = plt.subplots(len(filenames[0]),2)185 for filename in filenames[0]:186 file = open(filename)187 datalines = file.readlines()188 y = [float(line.split(',')[0]) for line in datalines]189 x = np.arange(len(y))190 axs[i, 0].plot(x, y)191 dt = 0.0005192 NFFT = 1024193 Fs = int(1.0 / dt)194 Pxx, freqs, bins, im = axs[i, 1].axes.specgram(y, NFFT=NFFT, Fs=Fs, noverlap=900)195 i+=1196 plt.savefig('report.pdf') 197198199200201 def drawButtons(self):202 self.pauseButton = QPushButton(self)203 self.pauseButton.setText("Pause") #text204 self.pauseButton.setShortcut('Ctrl+D') #shortcut key205 self.pauseButton.clicked.connect(self.pause)206 self.pauseButton.setToolTip("Close the widget") #Tool tip207 self.playButton = QPushButton(self)208 self.playButton.setText("Play") #text209 self.playButton.setShortcut('Ctrl+P') #shortcut key210 self.playButton.setToolTip("Close the widget") #Tool tip211 self.playButton.clicked.connect(self.play)212 self.Zoom = QPushButton(self)213 self.Zoom.setText("Zoom In") #text214 self.Zoom.setShortcut('Ctrl+Z') #shortcut key215 self.Zoom.setToolTip("Close the widget") #Tool tip216 self.Zoom.clicked.connect(self.zoomin)217 self.ZoomOut = QPushButton(self)218 self.ZoomOut.setText("Zoom Out") #text219 self.ZoomOut.setShortcut('Ctrl+Z') #shortcut key220 self.ZoomOut.setToolTip("Close the widget") #Tool tip221 self.ZoomOut.clicked.connect(self.zoomout)222 self.scrollLeft = QPushButton(self)223 self.scrollLeft.setText("Scroll Left") #text224 self.scrollLeft.setShortcut('Ctrl+L') #shortcut key225 self.scrollLeft.setToolTip("Close the widget") #Tool tip226 self.scrollLeft.clicked.connect(self.scrollleft)227 self.scrollRight = QPushButton(self)228 self.scrollRight.setText("Scroll Right") #text229 self.scrollRight.setShortcut('Ctrl+R') #shortcut key230 self.scrollRight.setToolTip("Close the widget") #Tool tip231 self.scrollRight.clicked.connect(self.scrollright)232 def drawSliders(self):233 self.sliders = []234 for slider_number in range(0,10):235 self.sliders.append(QSlider(QtCore.Qt.Vertical))236 self.sliders[slider_number].setFocusPolicy(QtCore.Qt.NoFocus)237 self.sliders[slider_number].setRange(0,100)238 self.sliders[slider_number].setMinimum(0)239 self.sliders[slider_number].setMaximum(5)240 self.sliders[slider_number].setSingleStep(1)241 self.sliders[slider_number].setTickInterval(1)242 self.sliders[slider_number].setTickPosition(QSlider.TicksBelow)243 self.sliders[slider_number].setValue(1)244 self.sliders[slider_number].valueChanged.connect(self.Equalizer)245 def Equalizer(self):246 slider_values = [self.sliders[slider_number].value() for slider_number in range(0,10)]247 self.dc2.Equalizer(slider_values)248 self.sc.addSpectrogram(self.dc2.getY())249250 def spectrogram_Sliders(self):251 slider_maxvalue = [self.MaxSlider.value()]252 slider_minvalue = [self.MinSlider.value()]253 resultSignal = self.dc2.spectrogramRange(slider_minvalue, slider_maxvalue,self.dc2.getY())254 self.sc.addSpectrogram(resultSignal,slider_minvalue[0],slider_maxvalue[0])255 def OpenFile(self):256 try:257 self.clearLayout(self.layout)258 except:259 pass260 self.drawButtons()261 self.drawSliders()262 filename = QFileDialog().getOpenFileName(options=QFileDialog.DontUseNativeDialog)263 try:264 f1 = open(filename[0])265 except:266 return267 f2 = open(filename[0])268 self.dc,self.dc2 = MyDynamicMplCanvas(self.main_widget, width=5, height=4, dpi=100,file=f1),MyDynamicMplCanvas(self.main_widget, width=5, height=4, dpi=100,file=f2)269 self.sc = MyStaticMplCanvas(self.main_widget, width=4, height=3, dpi=100,file=f1)270 self.sc.addSpectrogram(self.dc2.getY())271 left = QVBoxLayout()272 buttons = QHBoxLayout()273 buttons.addWidget(self.pauseButton)274 buttons.addWidget(self.playButton)275 buttons.addWidget(self.Zoom)276 buttons.addWidget(self.ZoomOut)277 buttons.addWidget(self.scrollLeft)278 buttons.addWidget(self.scrollRight)279 combo = QComboBox(self)280 combo.addItem("viridis")281 combo.addItem("plasma")282 combo.addItem("inferno")283 combo.addItem("magma")284 combo.addItem("cividis")285 combo.activated[str].connect(self.onChanged)286 textbox = QLineEdit(self)287 textbox.setFixedSize(50,20)288 textbox.setText(str(1000))289 textbox.textChanged[str].connect(self.speedChanged)290 buttons.addWidget(combo)291 buttons.addWidget(textbox)292 horizontalGroupBox = QGroupBox("Controls")293 horizontalGroupBox.setLayout(buttons)294 SlidersgroupBox = QGroupBox("Equalizer")295 sliders = QHBoxLayout()296 for slider_number in range(0,10):297 sliders.addWidget(self.sliders[slider_number])298 SlidersgroupBox.setLayout(sliders)299 SpectrogramSliders = QGroupBox("Spectrogram Sliders")300 self.MaxSlider = QSlider(QtCore.Qt.Vertical)301 self.MaxSlider.setFocusPolicy(QtCore.Qt.NoFocus)302 self.MaxSlider.setRange(0,250)303 self.MaxSlider.setSingleStep(50)304 self.MaxSlider.setTickInterval(50)305 self.MaxSlider.setTickPosition(QSlider.TicksBelow)306 self.MaxSlider.setValue(250)307 self.MinSlider = QSlider(QtCore.Qt.Vertical)308 self.MinSlider.setFocusPolicy(QtCore.Qt.NoFocus)309 self.MinSlider.setRange(0,250)310 self.MinSlider.setSingleStep(50)311 self.MinSlider.setTickInterval(50)312 self.MinSlider.setTickPosition(QSlider.TicksBelow)313 self.MinSlider.setValue(0)314 MinMaxSliders= QHBoxLayout()315 MinMaxSliders.addWidget(self.MinSlider)316 MinMaxSliders.addWidget(self.MaxSlider)317 self.MinSlider.valueChanged.connect(self.spectrogram_Sliders)318 self.MaxSlider.valueChanged.connect(self.spectrogram_Sliders)319 SpectrogramSliders.setLayout(MinMaxSliders)320 left.addWidget(horizontalGroupBox)321 left.addWidget(self.dc)322 left.addWidget(self.dc2)323 left.addWidget(self.sc)324 self.layout.addLayout(left)325 self.layout.addWidget(SlidersgroupBox)326 self.layout.addWidget(SpectrogramSliders)327 def onChanged(self,text):328 self.sc.setCmap(text)329 self.sc.addSpectrogram(self.dc2.getY())330 def speedChanged(self,speed):331 self.dc.setSpeed(int(speed))332 self.dc2.setSpeed(int(speed))333 def zoomin(self):334 self.dc.zoomin(),self.dc2.zoomin()335 def zoomout(self):336 self.dc.zoomout(),self.dc2.zoomout()337 def scrollleft(self):338 self.dc.scrollleft(),self.dc2.scrollleft()339 def scrollright(self):340 self.dc.scrollright(),self.dc2.scrollright()341 def fileQuit(self):342 self.close()343 def pause(self):344 self.dc.pause(),self.dc2.pause()345 def play(self):346 self.dc.play(),self.dc2.play()347 def closeEvent(self, ce):348 self.fileQuit()349 def NewFile(self):350 self.newWindow = ApplicationWindow()351 self.children.append(self.newWindow)352 self.newWindow.setWindowTitle("Signal Viewer")353 self.newWindow.show()354if __name__ == '__main__':355 app = QApplication(sys.argv)356 aw = ApplicationWindow()357 aw.setWindowTitle("Signal Viewer")358 aw.show() ...

Full Screen

Full Screen

examine2.js

Source:examine2.js Github

copy

Full Screen

1$(".downMenuBox div").click(function(){2 $(this).toggleClass('hover').siblings().removeClass('hover');3})4//下拉框滑入滑出效果5$(".downMenuBox div").click(function(){6 //收回7 $(".downMenuBox div").not(this).next(".MenuCenter").slideUp(350);8 //显示9 $(this).next(".MenuCenter").slideToggle(350);10});11//tap切换12$(".tapUl").find("li").click(function(){13 $(this).toggleClass("tapIco").siblings().removeClass('tapIco');14})15//改变审核数量16var num = 0;17$(".address").click(function(){18 num = $(".ListIpt").val();19 num ++;20 $(".ListIpt").val(num);21})22$(".reduce").click(function(){23 num = $(".ListIpt").val();24 if(num <= 0){25 $(".ListIpt").val("0");26 }else{27 num --;28 $(".ListIpt").val(num);29 }30})31//设置弹窗大小32var popupw = $(document).width();33var popuph = $(document).height();34$(".popup1,.popup2,.popup3,.popup4,.popup5").css("width",popupw).css("height",popuph);35//点击查看图片生成弹窗36$(".previewImg").click(function(){37 $(".popup1").show();38})39//关闭图片弹窗40$(".colseBtn1").click(function(){41 $(".popup1").hide();42})43//审核不通过弹窗44$(".newGoods").click(function(){45 $(".popup2").show();46})47//关闭审核不通过弹窗48$(".closeImg,.popup2LeftBtn,.popup2RightBtn").click(function(){49 $(".popup2").hide();50 $(".popup3").hide();51})52//待客户反馈弹窗53$(".feedback").click(function(){54 $(".popup3").show();55})56//客户放弃弹窗57$(".giveUp").click(function(){58 $(".popup4").show();59})60//关闭客户放弃弹窗61$(".closeImg,.popup4LeftBtn,.popup4RightBtn").click(function(){62 $(".popup4").hide();63})64//鼠标移动滚动条事件65$(".scrollRight").mousedown(function(){66 //获取鼠标在滚动条里的位置67 var y = event.clientY - $(this).position().top;68 //鼠标移动事件69 $(document).mousemove(function(){70 //获取滚动条的移动位置71 var y1 = event.clientY - y;72 //设置滚动条的移动73 $(".scrollRight").css("top",y1);74 //获取混动条父级的高75 var h = $(".scrollRightBox").outerHeight();76 //内容移动77 var ch = y1 * $(".scrollLeftUl").outerHeight() / $(".scrollRightBox").outerHeight() + 45;78 $(".scrollLeftUl").css("top",-ch);79 //文本、滚动条碰壁检测80 var bh = $(".scrollRight").position().top;81 if(bh <= 0){82 $(".scrollRight").css("top","0px");83 $(".scrollLeftUl").css("top","0px");84 }else if(bh >= $(".scrollRightBox").outerHeight() - $(".scrollRight").outerHeight()){85 $(".scrollRight").css("top",$(".scrollRightBox").outerHeight() - $(".scrollRight").outerHeight());86 $(".scrollLeftUl").css("top",$(".scrollLeftBox").outerHeight() - $(".scrollLeftUl").outerHeight());87 }88 })89})90//松开鼠标移除移动事件91$(document).mouseup(function(){92 $(document).unbind("mousemove");93})94//滚动条滚动事件95var up = 0;96$(".scrollBox").on("mousewheel DOMMouseScroll", function (e) {97 var delta = (e.originalEvent.wheelDelta && (e.originalEvent.wheelDelta > 0 ? 1 : -1)) || //兼容chrome & ie98 (e.originalEvent.detail && (e.originalEvent.detail > 0 ? -1 : 1));//兼容firefox99 if (delta < 0) {100 //向下滚101 up += 10102 $(".scrollRight").css("top",up);103 $(".scrollLeftUl").css("top",-up * ($(".scrollLeftUl").outerHeight() / ($(".scrollRight").outerHeight())));104 } else if (delta > 0) {105 //向上滚106 up -= 10107 $(".scrollRight").css("top",up);108 $(".scrollLeftUl").css("top",-up * ($(".scrollLeftUl").outerHeight() / ($(".scrollRight").outerHeight())));109 }110 //碰壁检测111 //文本、滚动条碰壁检测112 var bh = $(".scrollRight").position().top;113 if(bh <= 0){114 up = 0;115 $(".scrollRight").css("top","0px");116 $(".scrollLeftUl").css("top","0px");117 }else if(bh >= $(".scrollRightBox").outerHeight() - $(".scrollRight").outerHeight()){118 up = $(".scrollRightBox").outerHeight() - $(".scrollRight").outerHeight();119 $(".scrollRight").css("top",$(".scrollRightBox").outerHeight() - $(".scrollRight").outerHeight());120 $(".scrollLeftUl").css("top",-($(".scrollLeftUl").outerHeight() - $(".scrollLeftBox").outerHeight()));121 }122 //清除默认滚轮事件123 return false;124});125//点击同意客户发货生成弹窗126$(".agreeBtn").click(function(){127 $(".popup5").show();128})129//关闭同意客户审核弹窗130$(".closeImg,.saveBtn").click(function(){131 $(".popup5").hide();132})133var time = setInterval(function(){134 var secdDay = new Date(2018,5,15).getTime();135 var Now = new Date().getTime();136 var oDate = new Date();137 var date = oDate.getDate();138 var h = oDate.getHours();139 var m = oDate.getMinutes();140 var s = oDate.getSeconds();141 //总时间差142 var all = secdDay - Now;143 //秒144 var ses = Math.floor((all/1000)%60);145 //分146 var minu = Math.floor((all/(1000*60))%60);147 //时148 var hour = Math.floor((all/(1000*60*60))%24);149 //天150 var day = Math.floor((all/(1000*60*60*24)));151 $(".dayTxt").text(day);152 $(".hourtxt").text(hour);153 $(".minuTxt").text(minu);154 $(".sesTxt").text(ses);155},1000)156$(".list").show();157//tap切换内容158//获取元素的索引值159$(".tapUl").find("li").click(function(){160 var num = $(this).index();161 $(".List").hide();162 $(".List").eq(num).show(); ...

Full Screen

Full Screen

editor.py

Source:editor.py Github

copy

Full Screen

1from State.state import State2import pygame3# Nowe elementy: tlo, animacja tla, przewijanie, tick Clocka, Nowe rzeczy konstruktor4class Editor(State):5 def __init__(self,game):6 super().__init__(game)7 self.TILESIZE = 328 self.LOWERMARGIN = 1009 self.SIDEMARGIN = 20010 self.COLS = 3011 self.ROWS = (self.game.DISPLAY_WIDTH - self.SIDEMARGIN) // self.TILESIZE12 self.scrollLeft = False13 self.scrollRight = False14 self.leftShift=False15 self.scroll = 016 self.scrollSpeed = 117 self.keyBackspace = False18 self.cloudImage = pygame.image.load('./Sprites/Background/sky_cloud.png').convert_alpha()19 self.skyImage = pygame.image.load('./Sprites/Background/sky.png').convert_alpha()20 #self.skyRect = self.skyImage.get_rect()21 self.mountainImage = pygame.image.load('./Sprites/Background/mountain2.png').convert_alpha()22 #self.mountainRect = self.mountainImage.get_rect()23 self.pineForestImg1 = pygame.image.load('./Sprites/Background/pine2.png').convert_alpha()24 #self.pineRect1 = self.pineForestImg1.get_rect()25 self.pineForestImg2 = pygame.image.load('./Sprites/Background/pine1.png').convert_alpha()26 #self.pineRect2 = self.pineForestImg2.get_rect()27 self.TILE_COUNT = 1628 self.InitTiles()29 def InitTiles(self):30 self.imgList = []31 for x in range(5):32 img = pygame.image.load(f'Sprites/Tiles/grass_{x+1}.png')33 img=pygame.transform.scale(img,(self.TILESIZE,self.TILESIZE))34 self.imgList.append(img)35 for x in range(11):36 img = pygame.image.load(f'Sprites/Tiles/ground_{x+1}.png')37 img = pygame.transform.scale(img, (self.TILESIZE, self.TILESIZE))38 self.imgList.append(img)39 def ResetKeys(self):40 self.keyBackspace = False41 def CheckInput(self):42 if (self.keyBackspace):43 print("Backspace")44 if (self.scrollLeft and self.scroll > 15):45 self.scroll -= 5 * self.scrollSpeed46 if (self.scrollRight):47 self.scroll += 5 * self.scrollSpeed48 if (self.leftShift):49 self.scrollSpeed=550 if (self.leftShift==False):51 self.scrollSpeed=152 def UpdateEvents(self):53 for event in pygame.event.get():54 if event.type == pygame.QUIT:55 self.runDisplay = False56 self.game.start = False57 if event.type == pygame.KEYDOWN:58 if event.key == pygame.K_BACKSPACE:59 self.keyBackspace = True60 print(self.keyBackspace)61 if event.key == pygame.K_LEFT:62 self.scrollLeft = True63 if event.key==pygame.K_LSHIFT:64 self.leftShift=True65 if event.key == pygame.K_RIGHT:66 self.scrollRight = True67 if event.type == pygame.KEYUP:68 if event.key == pygame.K_LEFT:69 self.scrollLeft = False70 if event.key == pygame.K_RIGHT:71 self.scrollRight = False72 if event.key==pygame.K_LSHIFT:73 self.leftShift=False74 def Update(self):75 self.UpdateEvents()76 self.CheckInput()77 self.ResetKeys()78 pygame.display.update()79 def DrawBg(self):80 # ZMIANY81 self.game.display.fill(self.game.COLORS["gray"])82 width = self.skyImage.get_width()83 for x in range(4):84 self.game.display.blit(self.cloudImage, ((x * width)-self.scroll * 0.5,0))85 self.game.display.blit(self.skyImage, ((x * width)-self.scroll * 0.6, self.game.DISPLAY_HEIGHT - self.skyImage.get_height() - 250))86 self.game.display.blit(self.mountainImage,((x * width)-self.scroll * 0.7, self.game.DISPLAY_HEIGHT - self.mountainImage.get_height() - 250))87 self.game.display.blit(self.pineForestImg2, ((x * width)-self.scroll * 0.8,self.game.DISPLAY_HEIGHT - self.pineForestImg2.get_height() - 180))88 self.game.display.blit(self.pineForestImg1, ((x * width)-self.scroll * 0.9,self.game.DISPLAY_HEIGHT - self.pineForestImg2.get_height() - 150))89 def DrawGrid(self):90 for i in range(self.COLS):91 pygame.draw.line(self.game.display,self.game.COLORS["white"],(i * self.TILESIZE - self.scroll,0),(i*self.TILESIZE - self.scroll,self.game.DISPLAY_HEIGHT- self.LOWERMARGIN))92 for i in range(self.ROWS):93 pygame.draw.line(self.game.display,self.game.COLORS["white"],(0,i * self.TILESIZE),(self.game.DISPLAY_WIDTH - self.SIDEMARGIN,i * self.TILESIZE))94 def InitBattons(self):95 pass96 def DrawEditorPanel(self):97 pygame.draw.rect(self.game.display,self.game.COLORS['black'],(self.game.DISPLAY_WIDTH - self.SIDEMARGIN,0,self.SIDEMARGIN,self.game.DISPLAY_HEIGHT + self.LOWERMARGIN))98 pygame.draw.rect(self.game.display,self.game.COLORS["black"],(0,self.game.DISPLAY_HEIGHT - self.LOWERMARGIN,self.game.DISPLAY_WIDTH,self.game.DISPLAY_HEIGHT - self.LOWERMARGIN))99 def Render(self):100 self.DrawBg()101 self.DrawGrid()102 self.DrawEditorPanel()103 self.BlitScreen()104 def DisplayState(self):105 print("Jestem w edytorze.")106 while self.runDisplay:107 self.Update()108 self.Render()109 # ZEGAR...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1const {http} = require('../../request/http');2Component({3 properties: {4 show: {5 type: Boolean,6 value: false7 },8 province:{9 type: String,10 value: ''11 },12 city:{13 type: String,14 value: ''15 }16 },17 data: {18 list:[],19 scrollLeft:[],20 scrollRight:[],21 _index: 022 },23 methods: {24 handleLeft(e){25 console.log(e)26 let {index} = e.currentTarget.dataset;27 let {list,scrollLeft} = this.data;28 scrollLeft.forEach((item,index1)=>{29 if(index1 === index){30 item.active = true31 }else{32 item.active = false33 }34 });35 let scrollRight = (list[index].routeStop).map(item=>{36 return{37 name: item,38 active:false39 }40 });41 this.setData({42 _index:index,43 scrollRight:scrollRight,44 scrollLeft:scrollLeft45 })46 },47 handleRight(e){48 let {index} = e.currentTarget.dataset;49 console.log(index);50 let {scrollRight} = this.data;51 scrollRight[index]['active'] = !scrollRight[index]['active']52 this.setData({53 scrollRight54 });55 },56 getList(){57 let that = this;58 let {province,city} = this.properties;59 http({60 url: '/api/access/v1/house/metro/line/list',61 method: 'GET',62 params:{63 city: city,64 proviince: province65 }66 }).then(res=>{67 console.log(res)68 let scrollLeft = res.map((item,index)=>{69 return {70 lineName: item.lineName,71 active: index===0? true:false72 }73 });74 let scrollRight = (res[0].routeStop).map(item=>{75 return{76 name: item,77 active:false78 }79 });80 that.setData({81 scrollLeft,82 scrollRight,83 list: res84 });85 }).catch(err=>{86 console.log(err)87 });88 },89 onClose(){90 this.triggerEvent('close',{detail:''})91 },92 clear(){93 let {scrollRight} = this.data;94 scrollRight.forEach(item=>{95 item.active=false;96 });97 this.setData({98 _index: -1,99 scrollRight:scrollRight100 });101 },102 sure(){103 if(this.data['list'].length===0){104 this.triggerEvent('close',{detail:[]});105 return;106 }107 let {_index,scrollLeft,scrollRight}=this.data;108 let lineName = scrollLeft[_index]['lineName'];109 console.log(lineName);110 let routeStop = scrollRight.filter(item=>item.active===true);111 if(routeStop.length === 0){112 this.triggerEvent('close',{detail:[]});113 return;114 }115 console.log(routeStop);116 // let chooseSubWay = routeStop.map(item=> lineName+'/'+item.name);117 let chooseSubWay = routeStop.map(item=> {118 return{119 lineName: lineName,120 routeStop: item.name121 }122 });123 this.triggerEvent('close',{detail:chooseSubWay});124 }125 },126 lifetimes:{127 ready() {128 // wx.nextTick(()=>{129 // this.getList();130 // });131 this.getList();132 }133 }...

Full Screen

Full Screen

VoiceAssistant.py

Source:VoiceAssistant.py Github

copy

Full Screen

1import pyautogui 2import speech_recognition3import autopy4from PyQt5 import QtCore 5class VoiceControl():6 start = True7 def __init__(self, LeftCkick=None, RightClick=None,8 DoubleLeftClick=None, ScrollUp=None,9 ScrollDown=None, ScrollLeft=None,10 ScrollRight=None, DragAndDrop=None):11 self.LeftCkick=LeftCkick12 self.RightClick=RightClick13 self.DoubleLeftClick=DoubleLeftClick14 self.ScrollUp=ScrollUp15 self.ScrollDown=ScrollDown16 self.ScrollLeft=ScrollLeft17 self.ScrollRight=ScrollRight18 self.DragAndDrop=DragAndDrop19 self.sr = speech_recognition.Recognizer()20 self.Microphone = speech_recognition.Microphone()21 self.sr.pause_threshold = 0.522 self.listOfCommands = [self.LeftCkick, self.RightClick, 23 self.DoubleLeftClick, self.ScrollUp, 24 self.ScrollDown, self.ScrollLeft, 25 self.ScrollRight, self.DragAndDrop]26 def select_microphone(self, mic):27 mics = self.Microphone.list_microphone_names()28 try:29 index_mic = mics.index(mic)30 self.Microphone = speech_recognition.Microphone(device_index=index_mic)31 except:32 pass33 def show_microphone(self):34 try:35 mics = self.Microphone.list_microphone_names()36 current_mic = mics[self.Microphone.device_index]37 return current_mic38 except:39 pass40 def DoLeftCkick(self):41 autopy.mouse.click()42 43 def DoRightClick(self):44 autopy.mouse.toggle(autopy.mouse.Button.RIGHT, False)45 46 def DoDoubleLeftClick(self):47 autopy.mouse.click()48 autopy.mouse.click()49 50 def DoScrollUp(self):51 pyautogui.scroll(200)52 def DoScrollDown(self):53 pyautogui.scroll(-200)54 def DoScrollLeft(self):55 pyautogui.hscroll(-200)56 def DoScrollRight(self):57 pyautogui.hscroll(200)58 def DoDragAndDrop(self):59 autopy.mouse.toggle(autopy.mouse.Button.LEFT, True)60 61 def MouseAction(self, argument):62 switcher = {63 self.LeftCkick: self.DoLeftCkick,64 self.RightClick: self.DoRightClick,65 self.DoubleLeftClick: self.DoDoubleLeftClick,66 self.ScrollUp: self.DoScrollUp,67 self.ScrollDown: self.DoScrollDown,68 self.ScrollLeft: self.DoScrollLeft,69 self.ScrollRight: self.DoScrollRight,70 self.DragAndDrop: self.DoDragAndDrop71 }72 func = switcher.get(argument)73 func()74 def Start(self):75 with self.Microphone as mic:76 while True:77 if not self.start:78 break79 self.sr.adjust_for_ambient_noise(source=mic, duration=0.5)80 audio=self.sr.listen(mic)81 try:82 command = self.sr.recognize_google(audio_data=audio, language='ru-RU').lower()83 for com in self.listOfCommands:84 if com in command:85 self.MouseAction(com)86 except:...

Full Screen

Full Screen

scrollNav.js

Source:scrollNav.js Github

copy

Full Screen

1/*2* 顶部模块导航滚动3*/4/*scrollNav = function ()5{6 var $box = $("#module-box");//容器7 var boxW = $box.width();//容器宽8 var $module = $("#module");//ul9 var $moduleList = $("#module > li");//li10 var $scrollLeft = $("#scroll-left");11 var $scrollRight = $("#scroll-right");12 var index = 0;//定义索引13 var movWidth = 0;//移动的距离14 var totalWidth = 0;//li总长度15 var scrollWidth = 0;//滑出去的长度16 for (var i = 0; i < $moduleList.length; i++) {17 totalWidth = totalWidth + $moduleList.eq(i).width();18 }19 if(totalWidth < boxW)20 {21 $scrollLeft.hide();22 $scrollRight.hide();23 }24 else if($module[0].style.marginLeft == '')25 {26 $scrollLeft.hide();27 }28 $scrollLeft.click(function()29 {30 var boxW = $box.width();31 $scrollRight.show();32 index = index - 1;33 movWidth = movWidth + $moduleList.eq(index).width();34 $module.stop(true, false).animate({35 "marginLeft": movWidth36 }, 500);37 scrollWidth = scrollWidth - $moduleList.eq(index).width();38 if (index <= 0) {39 $scrollLeft.hide();40 return false;41 }42 });43 $scrollRight.click(function()44 {45 var boxW = $box.width();46 $scrollLeft.show();47 movWidth = movWidth - $moduleList.eq(index).width();48 $module.stop(true, false).animate({49 "marginLeft": movWidth50 }, 500);51 scrollWidth = scrollWidth + $moduleList.eq(index).width();52 index = index + 1;53 if (totalWidth - scrollWidth < boxW) {54 $scrollRight.hide();55 return false;56 }57 });58 $(window).resize(function()59 {60 var boxW = $box.width();61 if (totalWidth - scrollWidth < boxW) {62 $module.stop(true, false).animate({63 "marginLeft": 064 }, 'slow');65 $scrollLeft.hide();66 $scrollRight.show();67 index = 0;68 movWidth = 0;69 scrollWidth = 0;70 }71 if(totalWidth < boxW)72 {73 $scrollLeft.hide();74 $scrollRight.hide();75 }76 else if($module[0].style.marginLeft == '0px')77 {78 $scrollLeft.hide();79 $scrollRight.show();80 }81 })82};83$(window).ajaxStop(function()84{85 scrollNav();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { scrollRight } = require('taiko');2scrollRight();3const { scrollLeft } = require('taiko');4scrollLeft();5const { scrollUp } = require('taiko');6scrollUp();7const { scrollDown } = require('taiko');8scrollDown();9const { scrollTo } = require('taiko');10scrollTo('text');11const { scrollTo } = require('taiko');12scrollTo('text', 'selector');13const { scrollRight } = require('taiko');14scrollRight('selector');15const { scrollLeft } = require('taiko');16scrollLeft('selector');17const { scrollUp } = require('taiko');18scrollUp('selector');19const { scrollDown } = require('taiko');20scrollDown('selector');21const { scrollRight } = require('taiko');22scrollRight(100);23const { scrollLeft } = require('taiko');24scrollLeft(100);25const { scrollUp } = require('taiko');26scrollUp(100);27const { scrollDown } = require('taiko');28scrollDown(100);29const { scrollRight } = require('taiko');30scrollRight('selector', 100);31const { scrollLeft } = require('taiko');32scrollLeft('selector', 100);33const { scrollUp } = require('taiko');34scrollUp('selector', 100);35const { scrollDown } = require('taiko');36scrollDown('selector', 100);37const { scrollTo } = require('taiko');

Full Screen

Using AI Code Generation

copy

Full Screen

1scrollRight();2scrollRight(5);3scrollUp();4scrollUp(5);5scrollDown();6scrollDown(5);7scrollTo("element");8scrollRightTo("element");9scrollLeftTo("element");10scrollUpTo("element");11scrollDownTo("element");12scrollIntoView("element");13scrollTo(10, 10);14scrollRightTo(10, 10);15scrollLeftTo(10, 10);16scrollUpTo(10, 10);17scrollDownTo(10, 10);18scrollIntoView(10, 10);19scrollRight(5, 10);20scrollLeft(5, 10);21scrollUp(5, 10);22scrollDown(5, 10);23scrollTo("element", 10);

Full Screen

Using AI Code Generation

copy

Full Screen

1var { scrollRight } = require('taiko');2scrollRight();3var { scrollLeft } = require('taiko');4scrollLeft();5var { scrollUp } = require('taiko');6scrollUp();7var { scrollDown } = require('taiko');8scrollDown();9var { scrollDown } = require('taiko');10scrollDown();11var { scrollTo } = require('taiko');12scrollTo('text');13var { scrollUp } = require('taiko');14scrollUp();15var { scrollTo } = require('taiko');16scrollTo('text');17var { scrollUp } = require('taiko');18scrollUp();19var { scrollTo } = require('taiko');20scrollTo('text');21var { scrollUp } = require('taiko');22scrollUp();23var { scrollTo } = require('taiko');24scrollTo('text');25var { scrollUp } = require('taiko');26scrollUp();27var { scrollTo } = require('taiko');28scrollTo('text');29var { scrollUp } = require('taiko');30scrollUp();31var { scrollTo } = require('taiko');32scrollTo('text');33var {

Full Screen

Using AI Code Generation

copy

Full Screen

1scrollRight(200);2scrollUp(200);3scrollDown(200);4scrollTo('Element');5scrollTo('Element',200,200);6scrollTo('Element',200,200,'right');7scrollTo('Element',200,200,'left');8scrollTo('Element',200,200,'up');9scrollTo('Element',200,200,'down');10scrollTo('Element',200,200,'center');11scrollTo('Element',200,200,'top');12scrollTo('Element',200,200,'bottom');13scrollTo('Element',200,200,'middle');14scrollTo('Element',200,200,'near');15scrollTo('Element',200,200,'far');16scrollTo('Element',200,200,'nearRight');17scrollTo('Element',200,200,'nearLeft');18scrollTo('Element',200,200,'nearTop');19scrollTo('Element',200,200,'nearBottom');20scrollTo('Element',200,200,'farRight');21scrollTo('Element',200,200,'farLeft');22scrollTo('Element',200,200,'farTop');23scrollTo('Element',200,200,'farBottom');24scrollTo('Element',200,200,'centerRight');25scrollTo('Element',200,200,'

Full Screen

Using AI Code Generation

copy

Full Screen

1await scrollRight();2await scrollRight(5);3await scrollRight("div");4await scrollRight("div",5);5await scrollDown();6await scrollDown(5);7await scrollDown("div");8await scrollDown("div",5);9await scrollLeft();10await scrollLeft(5);11await scrollLeft("div");12await scrollLeft("div",5);13await scrollTo(100);14await scrollTo("div");15await scrollTo("div",100);16await scrollUp();17await scrollUp(5);18await scrollUp("div");19await scrollUp("div",5);20await scrollRight();21await scrollRight(5);22await scrollRight("div");23await scrollRight("div",5);24await scrollDown();25await scrollDown(5);26await scrollDown("div");27await scrollDown("div",5);28await scrollLeft();29await scrollLeft(5);30await scrollLeft("div");31await scrollLeft("div",5);32await scrollTo(100);33await scrollTo("div");34await scrollTo("div",100);35await scrollUp();36await scrollUp(5);37await scrollUp("div");38await scrollUp("div",5);39await scrollRight();40await scrollRight(5);41await scrollRight("div");42await scrollRight("div",5);43await scrollDown();44await scrollDown(5);45await scrollDown("div");46await scrollDown("div",5);47await scrollLeft();48await scrollLeft(5);49await scrollLeft("div");50await scrollLeft("div",

Full Screen

Using AI Code Generation

copy

Full Screen

1scrollRight(100, 100, 100, 100)2scrollRight(100, 100, 100, 100, 100)3const { openBrowser, goto, scrollRight, closeBrowser } = require('taiko');4(async () => {5 try {6 await openBrowser();7 await scrollRight(100, 100, 100, 100, 100);8 } catch (e) {9 console.error(e);10 } finally {11 await closeBrowser();12 }13})();

Full Screen

Using AI Code Generation

copy

Full Screen

1scrollRight();2scrollRight(100);3scrollRight({x:10,y:100});4scrollRight(100,{x:10,y:100});5scrollRight({x:10,y:100},100);6scrollUp();7scrollUp(100);8scrollUp({x:10,y:100});9scrollUp(100,{x:10,y:100});10scrollUp({x:10,y:100},100);11scrollDown();12scrollDown(100);13scrollDown({x:10,y:100});14scrollDown(100,{x:10,y:100});15scrollDown({x:10,y:100},100);16scrollTo('some text');17scrollTo('some text',{x:10,y:100});18scrollTo('some text',100);19scrollTo('some text',{x:10,y:100},100);20scrollTo('some text',100,{x:10,y:100});21scrollTo('some text',right);22scrollTo('some text',right,{x:10,y:100});23scrollTo('some text',right,100);24scrollTo('some text',right,{x:10,y:100},100);25scrollTo('some text',right,100,{x:10,y:100});26scrollTo('some text',left);27scrollTo('some text',left,{x:10,y:100});28scrollTo('some text',left,100);29scrollTo('some text',left,{x:10,y:100},100);30scrollTo('some text',left,100,{x:10,y:100});31scrollTo('some text',up);32scrollTo('some text',up,{x:10,y:100});33scrollTo('some text',up,100);34scrollTo('some text',up,{x:10,y:100},100);35scrollTo('some text',up,100,{x:10,y:100});

Full Screen

Using AI Code Generation

copy

Full Screen

1scrollRight();2scrollRight({speed: 1, timeout: 1000, count: 2, x: 100, y: 100});3scrollRight({speed: 1, timeout: 1000, count: 2, x: 100, y: 100, selector: "element"});4scrollLeft();5scrollLeft({speed: 1, timeout: 1000, count: 2, x: 100, y: 100});6scrollLeft({speed: 1, timeout: 1000, count: 2, x: 100, y: 100, selector: "element"});

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 taiko 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