Best Python code snippet using fMBT_python
default.py
Source:default.py
...145 self.selectedControl = "myPhotos"146 self.currentPage = 1;147 self.maxPages = 1;148 self.currentType = "";149 self.setFocus(self.myPhotos)150 self.photoSetId = "";151152 print str(loginError)153 154 if loginError == 0 :155 self.buddyName = xbmcgui.ControlLabel(int(290*self.X),int(78*self.Y),int(200*self.X),int(30*self.Y),str(user.username) + "'s Photos")156 self.addControl(self.buddyName)157 self.makedir(userID)158 self.setBuddyIcon()159 self.setPhotoSetList(userID)160 self.setMyPhotos(1);161162 163 def onAction(self, action):164 if action == ACTION_PREVIOUS_MENU:165 self.close()166 167 if action == ACTION_PARENT_DIR: 168 self.buddyName.setLabel(self.currentType)169 self.turnPage( "forward")170171 if action in ( ACTION_PAGE_UP, ACTION_NEXT_ITEM ):172 # self.buddyName.setLabel("right trigger")173 self.turnPage("forward")174175 if action in ( ACTION_PAGE_DOWN, ACTION_PREV_ITEM ):176 # self.buddyName.setLabel("left trigger")177 self.turnPage("back")178 179 if action == ACTION_MOVE_RIGHT: 180 if self.selectedControl == "myPhotos":181 self.selectedControl = "myButton0"182 self.setFocus(buttons[0])183 elif self.selectedControl == "myFavorites":184 self.selectedControl = "myButton0"185 self.setFocus(buttons[0])186 elif self.selectedControl == "photoSets":187 self.selectedControl = "myButton0"188 self.setFocus(buttons[0])189 elif self.selectedControl == "publicPhotos":190 self.selectedControl = "myButton0"191 self.setFocus(buttons[0])192 elif self.selectedControl == "settingsButton":193 self.selectedControl = "myButton0"194 self.setFocus(buttons[0])195 elif self.selectedControl == "myFavorites":196 self.selectedControl = "myButton0"197 self.setFocus(buttons[0])198 elif self.selectedControl == "myButton0" and buttons.has_key(1):199 self.selectedControl = "myButton1"200 self.setFocus(buttons[1])201 elif self.selectedControl == "myButton1" and buttons.has_key(2):202 self.selectedControl = "myButton2"203 self.setFocus(buttons[2])204 elif self.selectedControl == "myButton2" and buttons.has_key(3):205 self.selectedControl = "myButton3"206 self.setFocus(buttons[3])207 elif self.selectedControl == "myButton4" and buttons.has_key(5):208 self.selectedControl = "myButton5"209 self.setFocus(buttons[5])210 elif self.selectedControl == "myButton5" and buttons.has_key(6):211 self.selectedControl = "myButton6"212 self.setFocus(buttons[6])213 elif self.selectedControl == "myButton6" and buttons.has_key(7):214 self.selectedControl = "myButton7"215 self.setFocus(buttons[7])216 elif self.selectedControl == "myButton8" and buttons.has_key(9):217 self.selectedControl = "myButton9"218 self.setFocus(buttons[9])219 elif self.selectedControl == "myButton9" and buttons.has_key(10):220 self.selectedControl = "myButton10"221 self.setFocus(buttons[10])222 elif self.selectedControl == "myButton10" and buttons.has_key(11):223 self.selectedControl = "myButton11"224 self.setFocus(buttons[11])225 elif self.selectedControl == "nextArrow":226 self.selectedControl = "previousArrow"227 self.setFocus(self.previousArrow)228 elif self.selectedControl == "previousArrow":229 self.selectedControl = "nextArrow"230 self.setFocus(self.nextArrow)231232 if action == ACTION_MOVE_DOWN: 233 if self.selectedControl == "myButton0" and buttons.has_key(4):234 self.selectedControl = "myButton4"235 self.setFocus(buttons[4])236 elif self.selectedControl == "myButton4" and buttons.has_key(8):237 self.selectedControl = "myButton8"238 self.setFocus(buttons[8])239 elif self.selectedControl == "myButton1" and buttons.has_key(5):240 self.selectedControl = "myButton5"241 self.setFocus(buttons[5])242 elif self.selectedControl == "myButton5" and buttons.has_key(9):243 self.selectedControl = "myButton9"244 self.setFocus(buttons[9])245 elif self.selectedControl == "myButton2" and buttons.has_key(6):246 self.selectedControl = "myButton6"247 self.setFocus(buttons[6])248 elif self.selectedControl == "myButton6" and buttons.has_key(10):249 self.selectedControl = "myButton10"250 self.setFocus(buttons[10])251 elif self.selectedControl == "myButton3" and buttons.has_key(7):252 self.selectedControl = "myButton7"253 self.setFocus(buttons[7])254 elif self.selectedControl == "myButton7" and buttons.has_key(11):255 self.selectedControl = "myButton11"256 self.setFocus(buttons[11])257 elif self.selectedControl == "myButton8" or self.selectedControl == "myButton9" :258 self.selectedControl = "previousArrow"259 self.setFocus(self.previousArrow) 260 elif self.selectedControl == "previousArrow":261 self.selectedControl = "myButton0"262 self.setFocus(buttons[0]) 263 elif self.selectedControl == "myButton10" or self.selectedControl == "myButton11" :264 self.selectedControl = "nextArrow"265 self.setFocus(self.nextArrow)266 elif self.selectedControl == "myPhotos":267 self.selectedControl = "myFavorites"268 self.setFocus(self.myFavorites)269 elif self.selectedControl == "myFavorites":270 self.selectedControl = "photoSets"271 self.setFocus(self.photoSets)272 elif self.selectedControl == "photoSets":273 self.selectedControl = "publicPhotos"274 self.setFocus(self.publicPhotos)275 elif self.selectedControl == "publicPhotos":276 self.selectedControl = "settingsButton"277 self.setFocus(self.settingsButton)278 elif self.selectedControl == "settingsButton":279 self.selectedControl = "myPhotos"280 self.setFocus(self.myPhotos)281282 if action == ACTION_MOVE_UP: 283 if self.selectedControl == "myButton8" and buttons.has_key(4):284 self.selectedControl = "myButton4"285 self.setFocus(buttons[4])286 elif self.selectedControl == "myButton4" and buttons.has_key(0):287 self.selectedControl = "myButton0"288 self.setFocus(buttons[0])289 elif self.selectedControl == "myButton0":290 self.selectedControl = "previousArrow"291 self.setFocus(self.previousArrow)292 elif self.selectedControl == "myButton9" and buttons.has_key(5):293 self.selectedControl = "myButton5"294 self.setFocus(buttons[5])295 elif self.selectedControl == "myButton5" and buttons.has_key(1):296 self.selectedControl = "myButton1"297 self.setFocus(buttons[1])298 elif self.selectedControl == "myButton10" and buttons.has_key(6):299 self.selectedControl = "myButton6"300 self.setFocus(buttons[6])301 elif self.selectedControl == "myButton6" and buttons.has_key(2):302 self.selectedControl = "myButton2"303 self.setFocus(buttons[2])304 elif self.selectedControl == "myButton11" and buttons.has_key(7):305 self.selectedControl = "myButton7"306 self.setFocus(buttons[7])307 elif self.selectedControl == "myButton7" and buttons.has_key(3):308 self.selectedControl = "myButton3"309 self.setFocus(buttons[3])310 elif self.selectedControl == "myPhotos":311 self.selectedControl = "settingsButton"312 self.setFocus(self.settingsButton)313 elif self.selectedControl == "myFavorites":314 self.selectedControl = "myPhotos"315 self.setFocus(self.myPhotos)316 elif self.selectedControl == "photoSets":317 self.selectedControl = "myFavorites"318 self.setFocus(self.myFavorites)319 elif self.selectedControl == "publicPhotos":320 self.selectedControl = "photoSets"321 self.setFocus(self.photoSets)322 elif self.selectedControl == "settingsButton":323 self.selectedControl = "publicPhotos"324 self.setFocus(self.publicPhotos)325 elif self.selectedControl == "previousArrow":326 self.selectedControl = "myButton8"327 self.setFocus(buttons[8]) 328 elif self.selectedControl == "nextArrow" and buttons.has_key(10):329 self.selectedControl = "myButton10"330 self.setFocus(buttons[10]) 331 elif self.selectedControl == "nextArrow" and buttons.has_key(9):332 self.selectedControl = "myButton9"333 self.setFocus(buttons[9]) 334 elif self.selectedControl == "nextArrow" and buttons.has_key(8):335 self.selectedControl = "myButton8"336 self.setFocus(buttons[8]) 337 338339340 if action == ACTION_MOVE_LEFT: 341 if self.selectedControl == "myButton3" and buttons.has_key(2):342 self.selectedControl = "myButton2"343 self.setFocus(buttons[2])344 elif self.selectedControl == "myButton2" and buttons.has_key(1):345 self.selectedControl = "myButton1"346 self.setFocus(buttons[1])347 elif self.selectedControl == "myButton1" and buttons.has_key(0):348 self.selectedControl = "myButton0"349 self.setFocus(buttons[0])350 elif self.selectedControl == "myButton0":351 self.selectedControl = "myPhotos"352 self.setFocus(self.myPhotos)353 elif self.selectedControl == "myButton7" and buttons.has_key(6):354 self.selectedControl = "myButton6"355 self.setFocus(buttons[6])356 elif self.selectedControl == "myButton6" and buttons.has_key(5):357 self.selectedControl = "myButton5"358 self.setFocus(buttons[5])359 elif self.selectedControl == "myButton5" and buttons.has_key(4):360 self.selectedControl = "myButton4"361 self.setFocus(buttons[4])362 elif self.selectedControl == "myButton4":363 self.selectedControl = "myPhotos"364 self.setFocus(self.myPhotos)365 elif self.selectedControl == "myButton11" and buttons.has_key(10):366 self.selectedControl = "myButton10"367 self.setFocus(buttons[10])368 elif self.selectedControl == "myButton10" and buttons.has_key(9):369 self.selectedControl = "myButton9"370 self.setFocus(buttons[9])371 elif self.selectedControl == "myButton9" and buttons.has_key(8):372 self.selectedControl = "myButton8"373 self.setFocus(buttons[8])374 elif self.selectedControl == "myButton8":375 self.selectedControl = "myPhotos"376 self.setFocus(self.myPhotos)377 elif self.selectedControl == "nextArrow":378 self.selectedControl = "previousArrow"379 self.setFocus(self.previousArrow)380 elif self.selectedControl == "previousArrow":381 self.selectedControl = "nextArrow"382 self.setFocus(self.nextArrow)383 384 385386 def onControl(self, control):387 if control == self.photoSets:388 self.choosePhotoSet()389 if control == self.publicPhotos:390 self.setPublicPhotos(1)391 if control == self.myPhotos:392 self.setMyPhotos(1)393 if control == self.myFavorites:394 self.setMyFavorites(1)395 if control == self.settingsButton:396 if(settingsmgr.OpenControlPanel(SETTINGS_FILE)):
...
main_ui.py
Source:main_ui.py
1"""2@ File: main_ui.py.py3@ Author: pleiadesian4@ Datetime: 2020-02-02 11:025"""6import sys7import time8import multiprocessing9import main as backend10import frontend.main as frontend11from frontend import setfocus12from random import randint13from multiprocessing import Value, Manager14from PyQt5.QtWidgets import QApplication, QMainWindow, QMessageBox, QWidget15from PyQt5.QtCore import QTimer, Qt16INTERVAL = 30017INTERVAL_CLEAR = 30018INTERVAL_RECENT = 6000019BUTTON_X = 6020BUTTON_NONE_X = -20021class MainUi(QMainWindow, frontend.Ui_Dialog):22 def __init__(self):23 super(MainUi, self).__init__()24 self.setupUi(self)25 self.button_list = [self.pushButton_0, self.pushButton_1, self.pushButton_2, self.pushButton_3,26 self.pushButton_4, self.pushButton_5, self.pushButton_6, self.pushButton_7,27 self.pushButton_8, self.pushButton_9, self.pushButton_10, self.pushButton_11]28 self.code_list = [''] * 1229 self.spilled_codes = []30 self.recent_codes = []31 self.clear_signals = []32 self.replay_code = '000001'33 for button in self.button_list:34 button.move(BUTTON_NONE_X, button.y())35 self.window_info = setfocus.init_fs()36 self.pushButton_0.clicked.connect(lambda: self.click_code(0))37 self.pushButton_1.clicked.connect(lambda: self.click_code(1))38 self.pushButton_2.clicked.connect(lambda: self.click_code(2))39 self.pushButton_3.clicked.connect(lambda: self.click_code(3))40 self.pushButton_4.clicked.connect(lambda: self.click_code(4))41 self.pushButton_5.clicked.connect(lambda: self.click_code(5))42 self.pushButton_6.clicked.connect(lambda: self.click_code(6))43 self.pushButton_7.clicked.connect(lambda: self.click_code(7))44 self.pushButton_8.clicked.connect(lambda: self.click_code(8))45 self.pushButton_9.clicked.connect(lambda: self.click_code(9))46 self.pushButton_10.clicked.connect(lambda: self.click_code(10))47 self.pushButton_11.clicked.connect(lambda: self.click_code(11))48 self.timer = QTimer(self)49 self.timer.timeout.connect(self.checkall)50 self.timer.start(INTERVAL)51 self.timer_clear = QTimer(self)52 self.timer_clear.timeout.connect(self.clear_code)53 self.timer_clear.start(INTERVAL_CLEAR)54 self.timer_recent = QTimer(self)55 self.timer_recent.timeout.connect(self.clear_recent)56 self.timer_recent.start(INTERVAL_RECENT)57 def strong(self):58 if self.pushButton_strong.text() == '强å¸æ¨¡å¼':59 self.pushButton_strong.setText('åæ¶')60 strong.value = 161 else:62 self.pushButton_strong.setText('强å¸æ¨¡å¼')63 strong.value = 064 def reset(self):65 self.code_list = [''] * 1266 self.spilled_codes = []67 self.recent_codes = []68 self.clear_signals = []69 def replay(self):70 setfocus.open_code(self.replay_code, self.window_info)71 def click_code(self, code_slot):72 setfocus.open_code(self.code_list[code_slot], self.window_info)73 self.recent_codes.append(self.code_list[code_slot])74 self.clear_signals.append(self.code_list[code_slot])75 self.replay_code = self.code_list[code_slot]76 def clear_code(self):77 i = 078 for button, code in zip(self.button_list, self.code_list):79 if code in self.clear_signals:80 button.setText('None')81 button.move(BUTTON_NONE_X, self.button_list[i].y())82 self.code_list[i] = ''83 i += 184 self.clear_signals = []85 def clear_recent(self):86 self.recent_codes = []87 def checkall(self):88 new_codes = list(set(codes) - set(self.code_list))89 displaying_codes = [code for code in self.code_list if code != '']90 old_codes = [code for code in displaying_codes + self.spilled_codes if code not in new_codes]91 display_codes = new_codes + old_codes92 if len(display_codes) > 12:93 self.spilled_codes = display_codes[12:]94 display_codes = display_codes[:12]95 else:96 self.spilled_codes = []97 i = 098 display_codes = [code for code in display_codes if code not in self.recent_codes]99 for button, code in zip(self.button_list, display_codes):100 button.setText(code)101 self.code_list[i] = code102 button.move(BUTTON_X, button.y())103 i += 1104 for j in range(i, 12):105 self.code_list[j] = ''106 alert_codes = len(display_codes)107 for button in self.button_list:108 alert_codes -= 1109 if alert_codes < 0:110 button.setText('None')111 button.move(BUTTON_NONE_X, button.y())112 def select_zx(self):113 if self.radioButton_zx.isChecked():114 self.window_info = setfocus.change_fs('ä¸ä¿¡')115 def select_ct(self):116 if self.radioButton_ct.isChecked():117 self.window_info = setfocus.change_fs('è´¢é')118 def select_tdx(self):119 if self.radioButton_tdx.isChecked():120 self.window_info = setfocus.change_fs('éè¾¾')121 def ask5(self):122 setfocus.open_code('.+5', self.window_info)123 def ask4(self):124 setfocus.open_code('.+4', self.window_info)125 def ask3(self):126 setfocus.open_code('.+3', self.window_info)127 def ask2(self):128 setfocus.open_code('.+2', self.window_info)129 def ask1(self):130 setfocus.open_code('.+1', self.window_info)131 def bid1(self):132 setfocus.open_code('.-1', self.window_info)133 def bid2(self):134 setfocus.open_code('.-2', self.window_info)135 def bid3(self):136 setfocus.open_code('.-3', self.window_info)137 def bid4(self):138 setfocus.open_code('.-4', self.window_info)139 def bid5(self):140 setfocus.open_code('.-5', self.window_info)141if __name__ == '__main__':142 manager = Manager()143 codes = manager.list()144 strong = manager.Value('i', 0)145 p = multiprocessing.Process(target=backend.mainloop, args=(codes, strong,))146 p.start()147 app = QApplication(sys.argv)148 main_ui = MainUi()149 main_ui.show()...
slots.py
Source:slots.py
...6class MainWindowSlots(Ui_main_window):7 calc = Calculator()8 def numberEilerClicked(self):9 self.input_order.setText(self.input_order.text()+" e ")10 self.input_order.setFocus()11 return None12 def numberPiClicked(self):13 self.input_order.setText(self.input_order.text()+" pi ")14 self.input_order.setFocus()15 return None16 def numberZeroClicked(self):17 self.input_order.setText(self.input_order.text()+"0")18 self.input_order.setFocus()19 return None20 def numberOneClicked(self):21 self.input_order.setText(self.input_order.text()+"1")22 self.input_order.setFocus()23 return None24 def numberTwoClicked(self):25 self.input_order.setText(self.input_order.text()+"2")26 self.input_order.setFocus()27 return None28 def numberThreeClicked(self):29 self.input_order.setText(self.input_order.text()+"3")30 self.input_order.setFocus()31 return None32 def numberFourClicked(self):33 self.input_order.setText(self.input_order.text()+"4")34 self.input_order.setFocus()35 return None36 def numberFiveClicked(self):37 self.input_order.setText(self.input_order.text()+"5")38 self.input_order.setFocus()39 return None40 def numberSixClicked(self):41 self.input_order.setText(self.input_order.text()+"6")42 self.input_order.setFocus()43 return None 44 def numberSevenClicked(self):45 self.input_order.setText(self.input_order.text()+"7")46 self.input_order.setFocus()47 return None48 def numberEightClicked(self):49 self.input_order.setText(self.input_order.text()+"8")50 self.input_order.setFocus()51 return None52 def numberNineClicked(self):53 self.input_order.setText(self.input_order.text()+"9")54 self.input_order.setFocus()55 return None56 57 def operationPlusClicked(self):58 self.input_order.setText(self.input_order.text()+" + ")59 self.input_order.setFocus()60 return None61 def operationMinusClicked(self):62 self.input_order.setText(self.input_order.text()+" - ")63 self.input_order.setFocus()64 return None65 def operationMultiplyClicked(self):66 self.input_order.setText(self.input_order.text()+" * ")67 self.input_order.setFocus()68 return None69 def operationDevideClicked(self):70 self.input_order.setText(self.input_order.text()+" / ")71 self.input_order.setFocus()72 return None73 def operationExpClicked(self):74 self.input_order.setText(self.input_order.text()+"^")75 self.input_order.setFocus()76 return None77 78 def absBraces(self):79 self.input_order.setText(self.input_order.text()+"|")80 self.input_order.setFocus()81 return None82 def leftBrace(self):83 self.input_order.setText(self.input_order.text()+"(")84 self.input_order.setFocus()85 return None86 def rightBrace(self):87 self.input_order.setText(self.input_order.text()+")")88 self.input_order.setFocus()89 return None90 91 def funcSinClicked(self):92 self.input_order.setText(self.input_order.text()+"sin(")93 self.input_order.setFocus()94 return None95 def funcCosClicked(self):96 self.input_order.setText(self.input_order.text()+"cos(")97 self.input_order.setFocus()98 return None99 def funcTgClicked(self):100 self.input_order.setText(self.input_order.text()+"tg(")101 self.input_order.setFocus()102 return None103 def funcLogClicked(self):104 self.input_order.setText(self.input_order.text()+"log(")105 self.input_order.setFocus()106 return None107 def clearInput(self):108 self.input_order.setText("")109 self.input_order.setFocus()110 return None111 def clearAll(self):112 self.clearInput()113 self.last_operation.setText('')114 self.calc.ans = 0.0115 self.input_order.setFocus()116 return None117 def deleteSymbol(self):118 self.input_order.setText(self.input_order.text()[:-1])119 self.input_order.setFocus()120 return None121 def ansButtonClicked(self):122 self.input_order.setText(self.input_order.text()+"Ans")123 self.input_order.setFocus()124 return None125 def show_history_window(self):126 if not self.is_history_window_open:127 self.history_window = HistoryWindow()128 self.history_window.setGeometry(500, 300, 300, 300)129 self.history_window.setWindowTitle('History')130 self.history_window.show()131 self.is_history_window_open = True132 self.history_window.addNewOrderInHistory(self.last_operation.text())133 def calculateResult(self):134 inp = self.input_order.text()135 if not inp=='':136 try:137 res = self.calc.run(inp)138 assert(not res is None)139 140 self.clearInput()141 self.last_operation.setText(str(inp) +' = '+ str(res) )142 self.show_history_window()143 except AssertionError:144 msg = QMessageBox()145 msg.setWindowTitle("")146 msg.setText("Input isn't correct")147 msg.setIcon(QMessageBox.Warning)148 msg.exec_()149 except ZeroDivisionError:150 msg = QMessageBox()151 msg.setWindowTitle("")152 msg.setText("Devision by zero")153 msg.setIcon(QMessageBox.Warning)154 msg.exec_()155 self.input_order.setFocus()...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!