How to use getwindowsize method in pyatom

Best Python code snippet using pyatom_python

MainWindow.py

Source:MainWindow.py Github

copy

Full Screen

1#!/usr/bin/env python2# -*- coding: utf-8 -*-3from tkinter import *4import os5from tkinter.filedialog import *6from tkinter import messagebox7from PIL import ImageTk, Image8from threading import Thread9from FrameContent import FrameContent10from MenuButton import MenuButton11from MenuLabel import MenuLabel12from ButtonMaker import ButtonMaker13from SubMenu import SubMenu14from tkinter.simpledialog import *15from tkinter.filedialog import *16from tkinter import messagebox17class MainWindow:18 def __init__(self, loader):19 self.dead = False20 self.__loader = loader21 self.__loader.mainWindow = self22 self.__loopColor = "#000000"23 self.__config = self.__loader.config24 self.__dictionaries = self.__loader.dictionaries25 self.__screenSize = self.__loader.screenSize26 self.__soundPlayer = self.__loader.soundPlayer27 self.__fileDialogs = self.__loader.fileDialogs28 self.__colorDict = self.__loader.colorDict29 self.__colors = self.__loader.colorPalettes30 self.__mainFocus = None31 self.__subMenuOpened = False32 self.__setProjectPath(None)33 self.focused = None34 self.clipBoardText = None35 self.__loader.mainWindowHander.mainWindow = self36 self.editor = self.__loader.tk37 self.__scaleX=138 self.__scaleY=139 self.editor.protocol('WM_DELETE_WINDOW', self.__closeWindow)40 self.editor.title("Fortari2600 v"+self.__config.getValueByKey("version"))41 __w = self.__loader.screenSize[0]-15042 __h = self.__loader.screenSize[1]-20043 self.editor.geometry("%dx%d+%d+%d" % (__w, __h, (44 self.__loader.screenSize[0] / 2-__w/2), (self.__loader.screenSize[1]/2-__h/2-25)))45 self.editor.config(bg=self.__loader.colorPalettes.getColor("window"))46 #self.editor.attributes('-toolwindow', True)47 self.editor.overrideredirect(False)48 #self.editor.resizable(True, True)49 self.editor.minsize(1000,720)50 self.editor.pack_propagate(False)51 self.editor.grid_propagate(False)52 self.editor.iconbitmap("others/img/icon.ico")53 self.__originalW = self.getWindowSize()[0]54 self.__originalH = self.getWindowSize()[1]55 self.__lastW = self.getWindowSize()[0]56 self.__lastH = self.getWindowSize()[1]57 from FontManager import FontManager58 self.__fontManager = FontManager(self.__loader)59 self.__fontSize = int(self.__screenSize[0]/1300 * self.__screenSize[1]/1050*14)60 self.__normalFont = self.__fontManager.getFont(self.__fontSize, False, False, False)61 self.__smallFont = self.__fontManager.getFont(int(self.__fontSize*0.80), False, False, False)62 self.__miniFont = self.__fontManager.getFont(int(self.__fontSize*0.65), False, False, False)63 self.__tinyFont = self.__fontManager.getFont(int(self.__fontSize*0.45), False, False, False)64 self.__halfFont = self.__fontManager.getFont(int(self.__fontSize*0.57), False, False, False)65 self.__createFrames()66 #self.selectedItem = ["bank1", "global_variables"]67 self.bindThings()68 from threading import Thread69 self.__soundPlayer.playSound("Start")70 #align = Thread(target=self.__scales)71 #align.daemon = True72 #align.start()73 self.editor.deiconify()74 self.editor.focus()75 self.__loader.tk.iconify()76 t = Thread(target=self.__loopColorThread)77 t.daemon = True78 t.start()79 self.__loader.tk.deiconify()80 self.__loader.tk.focus()81 def getLoopColor(self):82 return self.__loopColor83 def bindThings(self):84 self.__pressedHome = False85 self.__pressedShiftL = False86 self.editor.bind("<Key>", self.pressed)87 self.editor.bind("<KeyRelease>", self.released)88 t = Thread(target=self.__checkBinded)89 t.daemon = True90 t.start()91 def __setProjectPath(self, path):92 self.projectPath=path93 self.__loader.bindedVariables["projectPath"] = path94 def __closeWindow(self):95 self.editor.destroy()96 def getWindowSize(self):97 return (self.editor.winfo_width(), self.editor.winfo_height())98 def __scales(self):99 from time import sleep100 while self.dead == False:101 if self.__mainFocus == None:102 self.__mainFocus = self.editor.focus_get()103 if self.editor.focus_get() == self.__mainFocus:104 if self.__loader.subMenuDict == {} and self.__subMenuOpened == True:105 self.__subMenuOpened = False106 self.__killRemaining()107 else:108 self.__subMenuOpened = True109 if (self.__lastW==self.getWindowSize()[0] and self.__lastH==self.getWindowSize()[1]):110 sleep(0.05)111 continue112 self.__lastW = self.getWindowSize()[0]113 self.__lastH = self.getWindowSize()[1]114 self.__scaleX = self.__lastW / self.__originalW115 self.__scaleY = self.__lastH / self.__originalH116 sleep(0.025)117 def __killRemaining(self):118 import gc119 self.__loader.subMenus = []120 for item in gc.get_objects():121 if "filedialog" in str(type(item)):122 print(str(type(item)))123 def getScales(self):124 return([self.__scaleX, self.__scaleY])125 def __createFrames(self):126 self.__fullEditor = Frame(self.editor, width=self.getWindowSize()[0],127 height=self.getWindowSize()[1],128 bg=self.__colors.getColor("window"))129 self.__fullEditor.pack_propagate(False)130 self.__fullEditor.pack(side=TOP, anchor = N, fill=BOTH)131 self.__buttonMenu = Frame(self.__fullEditor, width=self.getWindowSize()[0],132 height=self.getWindowSize()[1]//11.25,133 bg=self.__colors.getColor("window"))134 self.__buttonMenu.pack_propagate(False)135 self.__buttonMenu.pack(side=TOP, anchor = N, fill=X)136 self.__createMenuFrame()137 self.__controllerMenu = Frame(self.__fullEditor, width=self.getWindowSize()[0],138 height=self.getWindowSize()[1]//30,139 bg=self.__colors.getColor("window"))140 self.__controllerMenu.pack_propagate(False)141 self.__controllerMenu.pack(side=TOP, anchor = N, fill=X)142 self.__changerButtons = []143 for num in range(1,9):144 f = Frame(self.__controllerMenu, width=self.getWindowSize()[0]//8,145 height=self.getWindowSize()[1]//30,146 bg=self.__colors.getColor("window"))147 f.pack_propagate(False)148 f.pack(side=LEFT, anchor = E, fill=Y)149 if num == 1:150 name = "global"151 else:152 name = 'bank'+str(num)153 b = Button(f, bg=self.__loader.colorPalettes.getColor("window"),154 text = name[0].upper()+name[1:], name = name,155 fg = self.__loader.colorPalettes.getColor("font"),156 width=99999, font=self.__normalFont,157 state=DISABLED, command = None)158 b.pack_propagate(False)159 b.pack(side=LEFT, anchor=E, fill=BOTH)160 self.__changerButtons.append(b)161 __keys = list(self.__loader.virtualMemory.codes["bank2"].keys())162 __keys.remove('local_variables')163 __keys.remove('special_read_only')164 __keys.remove('screen_top')165 __keys.remove('screen_bottom')166 self.__controllerMenu2 = Frame(self.__fullEditor, width=self.getWindowSize()[0],167 height=self.getWindowSize()[1]//30,168 bg=self.__colors.getColor("window"))169 self.__controllerMenu2.pack_propagate(False)170 self.__controllerMenu2.pack(side=TOP, anchor = N, fill=X)171 self.__sectionButtons = []172 for num in range(0, len(__keys)):173 f = Frame(self.__controllerMenu2, width=self.getWindowSize()[0]//len(__keys),174 height=self.getWindowSize()[1]//30,175 bg=self.__colors.getColor("window"))176 f.pack_propagate(False)177 f.pack(side=LEFT, anchor = E, fill=Y)178 try:179 text = self.__dictionaries.getWordFromCurrentLanguage(__keys[num])180 except:181 text = __keys[num][0].upper() + __keys[num][1:]182 b = Button(f, bg=self.__loader.colorPalettes.getColor("window"),183 text = text, name = __keys[num],184 fg = self.__loader.colorPalettes.getColor("font"),185 width=99999, font=self.__normalFont,186 state=DISABLED, command = None)187 b.pack_propagate(False)188 b.pack(side=LEFT, anchor=E, fill=BOTH)189 self.__changerButtons.append(b)190 from EditorBigFrame import EditorBigFrame191 self.__bigFrame = EditorBigFrame(self.__loader, self.__fullEditor)192 self.__loader.bigFrame = self.__bigFrame193#self.__createSelectorFrame()194 #from BFG9000 import BFG9000195 #self.__BFG9000 = BFG9000(self.__loader, self.editor, self,196 # self.__buttonMenu.getFrameSize()[1]+self.__selectMenu1.getFrameSize()[1]197 # )198 def __createMenuFrame(self):199 #self.__buttonMenu = FrameContent(self.__loader, "buttonMenu",200 # self.getWindowSize()[0]/3*2, self.getWindowSize()[1]/11.25, 5, 5,201 # 99999, 150, 400, 60)202 self.__places = {}203 __vals = [0, 6.5, 11, 18.5]204 self.__buttonMaker = ButtonMaker(self.__loader, self.__buttonMenu, self.__createLabel, self.__destroyLabel)205 self.__newButton = self.__buttonMaker.createButton("new", 0,206 self.__newButtonFunction, "projectPath" ,207 True, None, self.__places, __vals[0])208 self.__openButton = self.__buttonMaker.createButton("open", 1,209 self.__openButtonFunction, "projectPath",210 True, None, self.__places, __vals[0])211 self.__saveButton = self.__buttonMaker.createButton("save", 2,212 self.__saveButtonFunction, "projectPath",213 False, None, self.__places, __vals[0])214 self.__saveAllButton = self.__buttonMaker.createButton("saveAll", 3,215 self.__saveAllButtonFunction, "projectPath",216 False, None, self.__places, __vals[0])217 self.__closeProjectButton = self.__buttonMaker.createButton("closeProject", 4,218 self.__closeProjectButtonFunction, "projectPath",219 False, None, self.__places, __vals[0])220 self.__archiveButton = self.__buttonMaker.createButton("archive", 5,221 self.__achiveButtonFunction, "projectPath",222 False, None, self.__places, __vals[0])223 self.__copyButton = self.__buttonMaker.createButton("copy", 6.5,224 self.__copyButtonFunction, None,225 False, self.setCopyButton, self.__places, __vals[1])226 self.__pasteButton = self.__buttonMaker.createButton("paste", 7.5,227 self.__pasteButtonFunction, None,228 False, self.setPasteButton, self.__places, __vals[1])229 self.__undoButton = self.__buttonMaker.createButton("undo", 8.5,230 self.__undoButtonFunction, None,231 False, self.__undoButtonHandler, self.__places, __vals[1])232 self.__redoButton = self.__buttonMaker.createButton("redo", 9.5,233 self.__redoButtonFunction, None,234 False, self.__redoButtonHandler, self.__places, __vals[1])235 self.__spriteButton = self.__buttonMaker.createButton("spriteEditor", 11,236 self.__openSpriteEditor, "projectPath",237 False, None, self.__places, __vals[2])238 self.__pfButton = self.__buttonMaker.createButton("playfieldEditor", 12,239 self.__openPFEditor, "projectPath",240 False, None, self.__places, __vals[2])241 self.__musicButton = self.__buttonMaker.createButton("music", 13,242 self.__openMusicComposer, "projectPath",243 False, None, self.__places, __vals[2])244 self.__64pxPictureButton = self.__buttonMaker.createButton("64pxPicture", 14,245 self.__openPictureConverter, "projectPath",246 False, None, self.__places, __vals[2])247 self.__soundPlayerButton = self.__buttonMaker.createButton("soundPlayer", 15,248 self.__openSoundPlayer, "projectPath",249 False, None, self.__places, __vals[2])250 self.__bigSpriteButton = self.__buttonMaker.createButton("bigSprite", 16,251 self.__openBigSpriteEditor, "projectPath",252 False, None, self.__places, __vals[2])253 self.__menuMaker = self.__buttonMaker.createButton("menuMaker", 17,254 self.__openMenuMaker, "projectPath",255 False, None, self.__places, __vals[2])256 self.__lockManagerButton = self.__buttonMaker.createButton("lockManager", 18.5,257 self.__openLockManager, "projectPath",258 False, None, self.__places, __vals[3])259 self.__memoryManagerButton = self.__buttonMaker.createButton("memoryManager", 19.5,260 self.openMemoryManager, "projectPath",261 False, None, self.__places, __vals[3])262 self.__screenTopBottomButton = self.__buttonMaker.createButton("screenTopBottom", 20.5,263 self.__openScreenTopBottom, "projectPath",264 False, None, self.__places, __vals[3])265 self.__menuLabel = [None]266 self.__menuLabel[0] = MenuLabel(self.__loader, self.__buttonMenu, "", 0, self.__fontManager)267 """268 def __createSelectorFrame(self):269 self.__selectMenu1 = FrameContent(self.__loader, "bankMenu",270 self.getWindowSize()[0] / 7, self.getWindowSize()[1] / 5, 5,271 self.__buttonMenu.getFrameSize()[1]+10,272 99999, 550, 80, 100)273 from SelectLabel import SelectLabel274 from NewListBoxInFrame import NewListBoxInFrame275 self.__bankLabel = SelectLabel(self.__loader, self.__selectMenu1,276 self.__dictionaries.getWordFromCurrentLanguage("selectedBank"),277 self.__fontManager278 )279 listBoxItems = []280 for num in range(1,9):281 listBoxItems.append("bank"+str(num))282 self.__bankBox = NewListBoxInFrame("bankBox", self.__loader,283 self.__selectMenu1, listBoxItems, self.checkIfBankChanged, LEFT)284 self.__selectMenu2 = FrameContent(self.__loader, "sectionMenu",285 self.getWindowSize()[0] / 6, self.getWindowSize()[1] / 5,286 self.__selectMenu1.getFrameSize()[0]+10 ,287 self.__buttonMenu.getFrameSize()[1]+10,288 99999, 550, 80, 100)289 self.__sectionLabel = SelectLabel(self.__loader, self.__selectMenu2,290 self.__dictionaries.getWordFromCurrentLanguage("selectedSection"),291 self.__fontManager292 )293 self.__tempList = []294 for item in self.__loader.sections:295 if item != "special_read_only":296 self.__tempList.append(item)297 self.__sectionBox = NewListBoxInFrame("sectionBox", self.__loader,298 self.__selectMenu2, self.__tempList, self.checkIfSectionChanged, LEFT)299 self.__lockMenu = FrameContent(self.__loader, "lockMenu",300 self.getWindowSize()[0] / 8, self.getWindowSize()[1] / 5,301 (self.__selectMenu1.getFrameSize()[0]+10)*2.25 ,302 self.__buttonMenu.getFrameSize()[1]+10,303 99999, 550, 80, 100)304 from LockFrame import LockFrame305 self.__lockFrame = LockFrame(self.__loader, self, self.__lockMenu, self.__fontManager)306 self.__changedSelection = Thread(target=self.__listBoxChanges)307 self.__changedSelection.daemon = True308 self.__changedSelection.start()309 """310 def __loopColorThread(self):311 from time import sleep312 colorNum = 0313 while self.__loader.mainWindow.dead == False and self.dead == False:314 try:315 colorNum += 1316 if colorNum == 256: colorNum = 0317 hexaNum = hex(colorNum-colorNum%2).replace("0x", "$")318 if len(hexaNum) == 2: hexaNum = "$0"+hexaNum[1]319 self.__loopColor = self.__colorDict.getHEXValueFromTIA(hexaNum)320 except:321 pass322 for item in self.__loader.stopThreads:323 try:324 if item.stopThread == True:325 self.__loader.stopThreads.remove(item)326 break327 except:328 self.__loader.stopThreads.remove(item)329 break330 sleep(0.025)331 def __createLabel(self, event):332 try:333 name = str(event.widget).split(".")[-1]334 button = self.__loader.menuButtons[name].getButton()335 if button.cget("state") == DISABLED:336 self.__menuLabel[0].changeColor(self.__loader.colorPalettes.getColor("fontDisabled"))337 else:338 self.__menuLabel[0].changeColor(self.__loader.colorPalettes.getColor("font"))339 self.__menuLabel[0].setText(self.__dictionaries.getWordFromCurrentLanguage(name))340 self.__menuLabel[0].changePlace(self.__places[name])341 except:342 try:343 self.__menuLabel[0].setText("")344 self.__menuLabel[0].dead = True345 except:346 pass347 self.__menuLabel[0] = MenuLabel(self.__loader, self.__buttonMenu, "", 0, self.__fontManager)348 def setMode(self, mode):349 self.__bigFrame.setMode(mode)350 def __destroyLabel(self, event):351 try:352 self.__menuLabel[0].setText("")353 except:354 try:355 self.__menuLabel[0].setText("")356 self.__menuLabel[0].dead = True357 except:358 pass359 self.__menuLabel[0] = MenuLabel(self.__loader, self.__buttonMenu, "", 0, self.__fontManager)360 def __newButtonFunction(self):361 from NewProjectWindow import NewProjectWindow362 NewProjectWindow(self.__loader)363 def projectOpenedWantToSave(self):364 if self.projectPath!=None and self.__getIfThereIsUnsavedItem() == True:365 return(self.__fileDialogs.askYesOrNo("unsaved","unsavedText"))366 else:367 return("No")368 def __getIfThereIsUnsavedItem(self):369 for bank in self.__loader.virtualMemory.codes.keys():370 for item in self.__loader.virtualMemory.codes[bank].keys():371 if self.__loader.virtualMemory.codes[bank][item].changed == True:372 return True373 return False374 def checkIfBankChanged(self, listBox):375 if self.projectPath == None:376 self.__loader.listBoxes["bankBox"].getListBoxAndScrollBar()[0].config(state=DISABLED)377 else:378 self.__loader.listBoxes["bankBox"].getListBoxAndScrollBar()[0].config(state=NORMAL)379 num = 0380 for bank in self.__loader.virtualMemory.codes.keys():381 num += 1382 color1 = self.__loader.colorPalettes.getColor("boxBackNormal")383 color2 = self.__loader.colorPalettes.getColor("boxFontNormal")384 for item in self.__loader.virtualMemory.codes[bank].keys():385 if self.__loader.virtualMemory.codes[bank][item].changed == True:386 color1=self.__loader.colorPalettes.getColor("boxBackUnSaved")387 color2=self.__loader.colorPalettes.getColor("boxFontUnSaved")388 break389 listBox.itemconfig(num-1, {"bg": color1})390 listBox.itemconfig(num-1, {"fg": color2})391 def checkIfSectionChanged(self, listBox):392 if (self.__loader.listBoxes["bankBox"].getSelectedName() == "bank1" or393 self.projectPath == None or394 self.__loader.virtualMemory.locks[self.__loader.listBoxes["bankBox"].getSelectedName()]!=None):395 self.__loader.listBoxes["sectionBox"].getListBoxAndScrollBar()[0].config(state=DISABLED)396 else:397 self.__loader.listBoxes["sectionBox"].getListBoxAndScrollBar()[0].config(state=NORMAL)398 num=0399 bank =self.__loader.listBoxes["bankBox"].getSelectedName()400 for item in self.__loader.virtualMemory.codes[bank].keys():401 if item == "special_read_only":402 continue403 num += 1404 if self.__loader.virtualMemory.codes[bank][item].changed == True:405 color1 = self.__loader.colorPalettes.getColor("boxBackUnSaved")406 color2 = self.__loader.colorPalettes.getColor("boxFontUnSaved")407 else:408 color1 = self.__loader.colorPalettes.getColor("boxBackNormal")409 color2 = self.__loader.colorPalettes.getColor("boxFontNormal")410 listBox.itemconfig(num-1, {"bg": color1})411 listBox.itemconfig(num-1, {"fg": color2})412 def __listBoxChanges(self):413 bankBox = self.__loader.listBoxes["bankBox"]414 sectionBox = self.__loader.listBoxes["sectionBox"]415 self.__bankSelected = bankBox.getSelectedName()416 self.__sectionSelected = sectionBox.getSelectedName()417 while self.dead == False:418 from time import sleep419 if self.__bankSelected != bankBox.getSelectedName() or self.__sectionSelected != sectionBox.getSelectedName():420 self.__bankSelected = bankBox.getSelectedName()421 try:422 self.__sectionSelected = sectionBox.getSelectedName()423 except:424 continue425 sleep(0.05)426 def changeAliasInCodes(self):427 for bank in self.__loader.virtualMemory.codes.keys():428 for section in self.__loader.virtualMemory.codes[bank].keys():429 for command in self.__loader.syntaxList.keys():430 self.__loader.virtualMemory.codes[bank][section].code = (431 self.__loader.syntaxList[command].changeAliasToName(432 command, self.__loader.virtualMemory.codes[bank][section].code433 ))434 def openProject(self, path):435 try:436 projectPath=path.replace("\\", "/")437 from re import sub438 projectPath = sub("/+", "/", projectPath)439 self.__setProjectPath(projectPath)440 #file = open(self.projectPath+os.sep+name+".project2600", "w")441 #file.write(self.projectPath)442 #file.close()443 self.__loader.config.addProjectPath(projectPath)444 self.__setVirtualMemoryItem("bank1", "bank_configurations")445 self.__setVirtualMemoryItem("bank1", "global_variables")446 for num in range(2,9):447 bank = "bank"+str(num)448 for section in self.__loader.sections:449 self.__setVirtualMemoryItem(bank, section)450 self.__loader.virtualMemory.setLocksAfterLoading()451 self.__loader.virtualMemory.setVariablesFromMemory("all")452 self.__loader.virtualMemory.archieve()453 self.__soundPlayer.playSound("Success")454 self.__bigFrame.setMode("empty")455 except Exception as e:456 self.__fileDialogs.displayError("projectOpenError", "projectOpenErrorText",457 {458 "name": self.projectPath.split("/")[-2]459 },460 str(e)461 )462 try:463 self.__closeProject()464 except Exception as e:465 print(str(e))466 self.projectPath=""467 def __setVirtualMemoryItem(self, bank, variable):468 path = str(self.projectPath+bank+os.sep+variable+".a26")469 item = self.__loader.virtualMemory.codes[bank][variable]470 item.code = self.__loader.io.loadWholeText(path).replace("%DELIMINATOR%", self.__config.getValueByKey("deliminator"))471 if bank=="bank1" and variable =="bank_configurations":472 old = self.__loader.virtualMemory.kernel473 for line in item.code.split(os.linesep):474 if line.startswith("bank1"):475 new = line.split("=")[1].replace("\n", "").replace("\r", "")476 if old != new:477 self.__loader.virtualMemory.changeKernelMemory(old, new)478 item.changed = False479 def __saveOnlyOne(self, bank, variable):480 try:481 if bank == "bank1":482 variable = "global_variables"483 path = self.projectPath+bank+os.sep+variable+".a26"484 file = open(path, "w", encoding="latin-1")485 BFG9000 = self.__loader.BFG9000.saveFrameToMemory(bank, variable)486 if bank == "bank1" or variable == "local_variables":487 self.__loader.virtualMemory.setVariablesFromMemory(bank)488 file.write(self.__changeFirstValidDeliminator(self.__loader.virtualMemory.codes[bank][variable].code, variable))489 file.close()490 self.__loader.virtualMemory.codes[bank][variable].changed = False491 #self.__loader.virtualMemory.emptyArchieved()492 #item.archived = []493 #item.cursor = 0494 except Exception as e:495 self.__fileDialogs.displayError("projectOpenError", "projectOpenErrorText",496 {497 "name": variable,498 "bank": bank499 },500 str(e)501 )502 def __changeFirstValidDeliminator(self, text, section):503 if section not in ["subroutines","vblank", "enter", "leave", "overscan", "screen_bottom"]:504 return (text)505 newText=[]506 delimiter = self.__config.getValueByKey("deliminator")507 for line in text.split("\n"):508 if line.startswith("*") or line.startswith("#"):509 newText.append(line)510 else:511 valid = 0512 for position in range(0, len(line)-len(delimiter)+1):513 if line[position] == "(":514 valid+=1515 elif line[position] == ")":516 valid-=1517 elif valid == 0:518 if line[position:position+len(delimiter)] == delimiter:519 line = line[:position] + "%DELIMINATOR%" + line[position+len(delimiter):]520 break521 newText.append(line)522 return(os.linesep.join(newText))523 #return(self.__config.getValueByKey("deliminator"))524 def __saveProject(self):525 self.__saveOnlyOne("bank1", "bank_configurations")526 self.__saveOnlyOne("bank1", "global_variables")527 for num in range(2, 9):528 bank = "bank" + str(num)529 for section in self.__loader.sections:530 self.__saveOnlyOne(bank, section)531 self.__soundPlayer.playSound("Success")532 def closeProject(self):533 self.__soundPlayer.playSound("Close")534 self.__setProjectPath(None)535 self.__loader.virtualMemory.emptyArchieved()536 self.__loader.virtualMemory.resetMemory()537 self.stopThreads()538 self.__bigFrame.setMode("intro")539 def stopThreads(self):540 for item in self.__loader.stopThreads:541 item.stopThread=True542 self.__loader.stopThreads = []543 def __openButtonFunction(self):544 if self.projectOpenedWantToSave()=="Yes":545 self.__saveProject()546 from OpenProjectWindow import OpenProjectWindow547 OpenProjectWindow(self.__loader, self, self.openProject)548 def __openMusicComposer(self):549 from MusicComposer import MusicComposer550 MusicComposer(self.__loader, self, None)551 def __openPictureConverter(self):552 from PictureToCode import PictureToCode553 PictureToCode(self.__loader, "common", "64pxPicture" , None, None)554 def __openSoundPlayer(self):555 from SoundPlayerEditor import SoundPlayerEditor556 SoundPlayerEditor(self.__loader, self)557 def __openPFEditor(self):558 from PlayfieldEditor import PlayfieldEditor559 PlayfieldEditor(self.__loader, self)560 def __openSpriteEditor(self):561 from SpriteEditor import SpriteEditor562 SpriteEditor(self.__loader, self)563 def __openBigSpriteEditor(self):564 from BigSpriteMaker import BigSpriteMaker565 BigSpriteMaker(self.__loader)566 def __openScreenTopBottom(self):567 from TopBottomEditor import TopBottomEditor568 TopBottomEditor(self.__loader)569 def __openMenuMaker(self):570 from MenuMaker import MenuMaker571 MenuMaker(self.__loader)572 def __saveButtonFunction(self):573 #self.__saveOnlyOne(self.selectedItem[0], self.selectedItem[1])574 self.__saveOnlyOne(self.__loader.listBoxes["bankBox"].getSelectedName(),575 self.__loader.listBoxes["sectionBox"].getSelectedName())576 def __saveAllButtonFunction(self):577 self.__saveProject()578 def __closeProjectButtonFunction(self):579 if self.projectOpenedWantToSave()=="Yes":580 self.__saveProject()581 self.closeProject()582 def __achiveButtonFunction(self):583 from ArchiveWindow import ArchiveWindow584 ArchiveWindow(self.__loader)585 def __copyButtonFunction(self):586 import clipboard587 clipboard.copy(self.focused.selection_get())588 self.clipBoardText = clipboard.paste()589 def __pasteButtonFunction(self):590 self.focused.insert(INSERT, self.clipBoardText)591 def __undoButtonFunction(self):592 self.__loader.virtualMemory.getArcPrev()593 def __redoButtonFunction(self):594 self.__loader.virtualMemory.getArcNext()595 def __undoButtonHandler(self, button):596 from time import sleep597 while self.dead==False:598 try:599 if len(self.__loader.virtualMemory.archieved)>0 and self.__loader.virtualMemory.cursor>0:600 self.__undoButton.getButton().config(state=NORMAL)601 else:602 self.__undoButton.getButton().config(state=DISABLED)603 except:604 pass605 sleep(0.0025)606 def __redoButtonHandler(self, button):607 from time import sleep608 while self.dead==False:609 try:610 if self.__loader.virtualMemory.cursor<len(self.__loader.virtualMemory.archieved)-1:611 self.__redoButton.getButton().config(state=NORMAL)612 else:613 self.__redoButton.getButton().config(state=DISABLED)614 except:615 pass616 sleep(0.0025)617 def getConstant(self):618 scalerX = self.getWindowSize()[0]/1300619 scalerY = self.getWindowSize()[1]/1150620 num = round(32*scalerX*scalerY)621 if num>32:622 num=32623 elif num<18:624 num=18625 return(num)626 def focusIn(self, event):627 self.focused = event.widget628 def focusOut(self, event):629 self.focused = None630 def setCopyButton(self, button):631 from time import sleep632 sleep(2)633 while self.dead==False:634 if self.focused == None:635 self.__copyButton.getButton().config(state=DISABLED)636 else:637 self.__copyButton.getButton().config(state=NORMAL)638 sleep(0.0025)639 def setPasteButton(self, button):640 from time import sleep641 sleep(2)642 while self.dead==False:643 if self.focused == None:644 self.__pasteButton.getButton().config(state=DISABLED)645 else:646 if self.clipBoardText == None:647 self.__pasteButton.getButton().config(state=DISABLED)648 else:649 self.__pasteButton.getButton().config(state=NORMAL)650 sleep(0.0025)651 def pressed(self, event):652 key = event.keysym653 if key == "Home":654 self.__pressedHome = True655 elif key == "Shift_L" or key == "Shift_R":656 self.__pressedShiftL = True657 658 def released(self, event):659 key = event.keysym660 if key == "Home":661 self.__pressedHome = False662 elif key == "Shift_L" or key == "Shift_R":663 self.__pressedShiftL = False664 def __checkBinded(self):665 from time import sleep666 from threading import Thread667 def __openLockManager(self):668 from LockManagerWindow import LockManagerWindow669 LockManagerWindow(self.__loader)670 def openMemoryManager(self):671 from MemoryManagerWindow import MemoryManagerWindow...

Full Screen

Full Screen

EditorBigFrame.py

Source:EditorBigFrame.py Github

copy

Full Screen

1from tkinter import *2class EditorBigFrame:3 def __init__(self, loader, frame):4 self.__loader = loader5 self.__editor = self.__loader.mainWindow6 self.__config = self.__loader.config7 self.__dictionaries = self.__loader.dictionaries8 self.__screenSize = self.__loader.screenSize9 self.__soundPlayer = self.__loader.soundPlayer10 self.__fileDialogs = self.__loader.fileDialogs11 self.__fontManager = self.__loader.fontManager12 self.__fontSize = int(self.__screenSize[0]/1300 * self.__screenSize[1]/1050*14)13 self.__colors = self.__loader.colorPalettes14 self.__colorDict = self.__loader.colorDict15 self.__memory = self.__loader.virtualMemory.memory16 self.__arrays = self.__loader.virtualMemory.arrays17 self.__virtualMemory = self.__loader.virtualMemory18 self.__focused = None19 self.__screenSize = self.__loader.screenSize20 self.__destroyables = {}21 self.__normalFont = self.__fontManager.getFont(self.__fontSize, False, False, False)22 self.__smallFont = self.__fontManager.getFont(int(self.__fontSize*0.80), False, False, False)23 self.__miniFont = self.__fontManager.getFont(int(self.__fontSize*0.65), False, False, False)24 self.__tinyFont = self.__fontManager.getFont(int(self.__fontSize*0.45), False, False, False)25 self.__halfFont = self.__fontManager.getFont(int(self.__fontSize*0.57), False, False, False)26 self.__changed = False27 self.__frame = Frame(frame, width=self.__editor.getWindowSize()[0],28 height=self.__editor.getWindowSize()[1],29 bg=self.__colors.getColor("window"))30 self.__frame.pack_propagate(False)31 self.__frame.pack(side=TOP, anchor = N, fill=BOTH)32 sizes = (0.20, 0.60, 0.20)33 self.__leftFrame = Frame(self.__frame, width=round(self.__editor.getWindowSize()[0]*sizes[0]),34 height=self.__editor.getWindowSize()[1],35 bg=self.__colors.getColor("window"))36 self.__leftFrame.pack_propagate(False)37 self.__leftFrame.pack(side=LEFT, anchor = E, fill=Y)38 self.__mainFrame = Frame(self.__frame, width=round(self.__editor.getWindowSize()[0]*sizes[1]),39 height=self.__editor.getWindowSize()[1],40 bg=self.__colors.getColor("window"))41 self.__mainFrame.pack_propagate(False)42 self.__mainFrame.pack(side=LEFT, anchor = E, fill=Y)43 self.__rightFrame = Frame(self.__frame, width=round(self.__editor.getWindowSize()[0]*sizes[2]),44 height=self.__editor.getWindowSize()[1],45 bg=self.__colors.getColor("window"))46 self.__rightFrame.pack_propagate(False)47 self.__rightFrame.pack(side=LEFT, anchor = E, fill=Y)48 self.activeMode = None49 # Valid modes: intro, editor, locked, empty50 self.__selectedMode = "intro"51 from threading import Thread52 t = Thread(target=self.loop)53 t.daemon = True54 t.start()55 def loop(self):56 from time import sleep57 while self.__editor.dead == False:58 if self.activeMode != self.__selectedMode:59 if self.activeMode != None:60 self.__removeSlaves()61 self.activeMode = self.__selectedMode62 if self.__selectedMode == "intro":63 self.__createIntroScreen()64 elif self.__selectedMode == "empty":65 pass66 sleep(0.0005)67 def __removeSlaves(self):68 self.__mainFrame.config(bg = self.__loader.colorPalettes.getColor("window"))69 self.__leftFrame.config(bg = self.__loader.colorPalettes.getColor("window"))70 self.__rightFrame.config(bg = self.__loader.colorPalettes.getColor("window"))71 self.__destroyables = {}72 for slave in self.__leftFrame.pack_slaves():73 slave.destroy()74 for slave in self.__mainFrame.pack_slaves():75 slave.destroy()76 for slave in self.__rightFrame.pack_slaves():77 slave.destroy()78 def __createIntroScreen(self):79 from AtariLogo import AtariLogo80 self.__mainFrame.config(bg = "black")81 self.__leftFrame.config(bg = "black")82 self.__rightFrame.config(bg = "black")83 atariLogo = AtariLogo(self.__loader, self.__mainFrame, self.__leftFrame, self.__rightFrame)84 self.__destroyables["AtariLogo"] = atariLogo85 def setMode(self, mode):86 self.__selectedMode = mode87 def getMode(self):...

Full Screen

Full Screen

functions.js

Source:functions.js Github

copy

Full Screen

1function getWindowSize() {2 return $(window).width()3}4function getLang() {5 return $('html').attr('lang');6}7function getPageDirection() {8 let lang = getLang();9 return lang = 'ar' ? 'rtl' : 'ltr';10}11function openSidebar(sidebar) {12 if (getWindowSize() <= 576) {13 sidebar.animate({14 width: '100vw'15 }, 600, function () {16 $(".sidebar-header").fadeIn(300)17 setTimeout(function () {18 $(".sidebar-body").fadeIn(300)19 }, 400)20 })21 }22 else if (getWindowSize() > 576 && getWindowSize() <= 768) {23 sidebar.animate({24 width: '75vw'25 }, 600, function () {26 $(".sidebar-header").fadeIn(300)27 setTimeout(function () {28 $(".sidebar-body").fadeIn(300)29 }, 400)30 })31 }32 else if (getWindowSize() > 768 && getWindowSize() <= 992) {33 sidebar.animate({34 width: '40vw'35 }, 600, function () {36 $(".sidebar-header").fadeIn(300)37 setTimeout(function () {38 $(".sidebar-body").fadeIn(300)39 }, 400)40 })41 }42 else if (getWindowSize() > 992 && getWindowSize() <= 1200) {43 sidebar.animate({44 width: '30vw'45 }, 600, function () {46 $(".sidebar-header").fadeIn(300)47 setTimeout(function () {48 $(".sidebar-body").fadeIn(300)49 }, 400)50 })51 }52 else if (getWindowSize() > 1200) {53 sidebar.animate({54 width: '20vw'55 }, 600, function () {56 $(".sidebar-header").fadeIn(300)57 setTimeout(function () {58 $(".sidebar-body").fadeIn(300)59 }, 400)60 })61 }62}63function closeSidebar(sidebar) {64 $(".sidebar-body").fadeOut(300)65 setTimeout(function () {66 $(".sidebar-header").fadeOut(300)67 }, 700)68 setTimeout(function () {69 sidebar.animate({70 width: '0'71 }, 700)72 })73}74function animateOnView(animatableElment, offset) {75 if (window.pageYOffset > offset - $(window).height()) {76 $(animatableElment).addClass("fade-in-class");77 }...

Full Screen

Full Screen

test-tty-window-size.js

Source:test-tty-window-size.js Github

copy

Full Screen

1// Flags: --expose-internals --no-warnings2'use strict';3const common = require('../common');4const assert = require('assert');5const { WriteStream } = require('tty');6const { internalBinding } = require('internal/test/binding');7const { TTY } = internalBinding('tty_wrap');8const getWindowSize = TTY.prototype.getWindowSize;9function monkeyPatchGetWindowSize(fn) {10 TTY.prototype.getWindowSize = function() {11 TTY.prototype.getWindowSize = getWindowSize;12 return fn.apply(this, arguments);13 };14}15{16 // tty.WriteStream constructor does not define columns and rows if an error17 // occurs while retrieving the window size from the handle.18 monkeyPatchGetWindowSize(function() {19 return -1;20 });21 const stream = WriteStream(1);22 assert(stream instanceof WriteStream);23 assert.strictEqual(stream.columns, undefined);24 assert.strictEqual(stream.rows, undefined);25}26{27 // _refreshSize() emits an error if an error occurs while retrieving the28 // window size from the handle.29 const stream = WriteStream(1);30 stream.on('error', common.mustCall((err) => {31 assert.strictEqual(err.syscall, 'getWindowSize');32 }));33 monkeyPatchGetWindowSize(function() {34 return -1;35 });36 stream._refreshSize();37}38{39 // _refreshSize() emits a 'resize' event when the window size changes.40 monkeyPatchGetWindowSize(function(size) {41 size[0] = 80;42 size[1] = 24;43 return 0;44 });45 const stream = WriteStream(1);46 stream.on('resize', common.mustCall(() => {47 assert.strictEqual(stream.columns, 82);48 assert.strictEqual(stream.rows, 26);49 }));50 assert.strictEqual(stream.columns, 80);51 assert.strictEqual(stream.rows, 24);52 monkeyPatchGetWindowSize(function(size) {53 size[0] = 82;54 size[1] = 26;55 return 0;56 });57 stream._refreshSize();58}59{60 // WriteStream.prototype.getWindowSize() returns the current columns and rows.61 monkeyPatchGetWindowSize(function(size) {62 size[0] = 99;63 size[1] = 32;64 return 0;65 });66 const stream = WriteStream(1);67 assert.strictEqual(stream.columns, 99);68 assert.strictEqual(stream.rows, 32);69 assert.deepStrictEqual(stream.getWindowSize(), [99, 32]);...

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