def confirmationMenu(acc): def press(button): if button == "Continue": app.stop() actionMenu(acc) elif button == "Switch Account": app.stop() mainMenu() else: app.stop() updateFile(acc.toString(), acc) app = gui("Automated Teller Machine", "400x200") app.setBg("red") app.addLabel("confirm", "Confirmation Page") app.setLabelBg("confirm", "white") app.addLabel("msg", "Transaction Complete") app.setLabelBg("msg", "white") app.addButtons(["Continue", "Switch Account"], press) app.addButtons(["Quit"], press) app.go()
def actionMenu(acc): def press(button): if button == "Deposit": app.stop() transactionMenu("To", True, acc) elif button == "Withdraw": app.stop() transactionMenu("From", True, acc) elif button == "Transfer": app.stop() transactionMenu("From", False, acc) else: app.stop() mainMenu() app = gui("Automated Teller Machine", "400x200") app.setBg("blue") app.addLabel("savingsBal", ("Savings Account Balance:", acc.getSavings())) app.setLabelBg("savingsBal", "white") app.addLabel("checkingBal", ("Checking Account Balance:", acc.getChecking())) app.setLabelBg("checkingBal", "white") app.addButtons(["Deposit", "Withdraw", "Transfer", "Back"], press) app.go()
def mainMenu(): def press(button): if button == "Quit": app.stop() elif button == "Submit": if checkCredentials(app.getEntry("User ID"), app.getEntry("PIN")): accountsFile = open("accounts.txt", "r") for i in accountsFile: a = createAccount(i.split("\t")) if app.getEntry("User ID") == a.getID(): if app.getEntry("PIN") == a.getPIN(): accountsFile.close() app.stop() actionMenu(a) else: app.startSubWindow("error") app.errorBox("loginError", "Invalid login credentials!") app.destroyAllSubWindows() app = gui("Automated Teller Machine", "400x200") app.setBg("orange") app.addLabelEntry("User ID") app.addLabelSecretEntry("PIN") app.addButtons(["Submit", "Quit"], press) app.setFocus("User ID") app.go()
def start(self): self.win = gui("board system", "500x400") self.update( self.file ) # read the boards from excel and the posts from "posts.txt". update boards, regions and idies self.win.addLabelAutoEntry("board id:", self.idies, row=1) self.win.setEntryDefault( "board id:", "If empty, action will aplly to all boards/region.") self.win.addLabelAutoEntry("region:", self.regions, row=5) self.win.setEntryDefault( "region:", "If region and id field are empty, action will aplly to all boards." ) self.win.addLabelEntry("post's name:") self.win.addLabelEntry("post's width:") self.win.setEntryDefault( "post's width:", "If width and high field are empty, the size will be A3.") self.win.addLabelEntry("post's high:") self.win.setEntryDefault( "post's high:", "If high and width field are empty, the size will be A3.") self.win.addButton("add post automatic", self.buttonAddPostAutomatic) self.win.addButton("add post", self.buttonAddPost) self.win.addButton("show board", self.buttonShowBoard) self.win.addButton("remove post", self.buttonRemovePost) self.win.addButton("remove all posts", self.buttonRemoveAllPosts) self.win.addButton("save", self.save) self.win.setStopFunction(self.remindSaving) self.win.go()
def __init__(self, ip="127.0.0.1", port=2345): """Server IP and Port variables""" self.ip = ip self.port = port # Initializes GUI # Program title 'Thesaurus Program', # Size '600x400' self.obj = gui('Thesaurus Program', '800x400')
def create_new_user(): def main(): create_gui() #End of Program print "anything" #validate_password() if __name__ == '__main__': app = gui("Login Form") Usernames = ["Aquoya", "Nat", "Luke", "Pat", "Alex", "Travis"] passwordLine = [5] * len(Usernames) paths = [".\\test.txt"] * len(Usernames) main()
def __init__(self): def pressEnter(btn): submit = self.app.getEntry("chatBox") self.app.addListItem("chatWindow", submit) self.app = gui("Chat Server") self.app.setFont(12) self.app.addLabelOptionBox("Servers", ["Default"]) self.app.addListBox("chatWindow") self.app.addEntry("chatBox", 2) self.app.addButton("Send", pressEnter, 2, 1) self.app.setEntryDefault("chatBox", "/help for list of commands") self.app.go()
def makeGUI(): def redisplayReg(): app.setLabel( "Registers", "R0 = " + str(sim.regfile.get(0)) + " \nR1 = " + str(sim.regfile.get(1)) + " \nR2 = " + str(sim.regfile.get(2)) + "\nR3 = " + str(sim.regfile.get(3)) + " \nR4 = " + str(sim.regfile.get(4)) + " \nR5 = " + str(sim.regfile.get(5)) + "\nR6 = " + str(sim.regfile.get(6)) + " \nR7 = " + str(sim.regfile.get(7)) + " \nR8 = " + str(sim.regfile.get(8)) + "\nR9 = " + str(sim.regfile.get(9)) + " \nR10 = " + str(sim.regfile.get(10))) app.setLabel( "Registers1", "R11 = " + str(sim.regfile.get(11)) + " \nR12 = " + str(sim.regfile.get(12)) + " \nR13 = " + str(sim.regfile.get(13)) + "\nR14 = " + str(sim.regfile.get(14)) + " \nR15 = " + str(sim.regfile.get(15)) + " \nR16 = " + str(sim.regfile.get(16)) + "\nR17 = " + str(sim.regfile.get(17)) + " \nR18 = " + str(sim.regfile.get(18)) + " \nR19 = " + str(sim.regfile.get(19)) + "\nR18 = " + str(sim.regfile.get(20)) + " \nR21 = " + str(sim.regfile.get(21))) app.setLabel( "Registers2", "R22 = " + str(sim.regfile.get(22)) + " \nR23 = " + str(sim.regfile.get(23)) + " \nR24 = " + str(sim.regfile.get(24)) + "\nR25 = " + str(sim.regfile.get(25)) + " \nR26 = " + str(sim.regfile.get(26)) + " \nR27 = " + str(sim.regfile.get(17)) + "\nR28 = " + str(sim.regfile.get(28)) + " \nR29 = " + str(sim.regfile.get(29)) + " \nR30 = " + str(sim.regfile.get(30)) + "\nR31 = " + str(sim.regfile.get(31))) def redisplayMem(): #This is a naaive way it can be optimized, no time app.openScrollPane("memPane") index = 0 for x in sim.mem.theBytes: name = str(index) + "c1" app.setLabel(name, sim.mem.theBytes[index]) index += 1 app.stopScrollPane() def openFile(): global filename openfilename = askopenfilename() if openfilename is not None: filename = openfilename asmfile = open(filename, "r") asmfile.seek(0) asmdata = asmfile.read() textArea.delete("1.0", "end - 1c") textArea.insert("1.0", asmdata) asmfile.close() filemenu.entryconfig(filemenu.index("Save"), state=NORMAL) frame.title("muCPU Assembler [" + filename + "]") frame.focus() def saveFile(): global filename asmdata = textArea.get("1.0", "end - 1c") asmfile = open(filename, "w") asmfile.seek(0) asmfile.truncate() asmfile.write(asmdata) asmfile.close() def saveFileAs(): global filename global fileexists saveasfilename = asksaveasfilename() if saveasfilename is not None: filename = saveasfilename fileexists = True asmdata = textArea.get("1.0", "end - 1c") asmfile = open(filename, "w") asmfile.seek(0) asmfile.truncate() asmfile.write(asmdata) asmfile.close() filemenu.entryconfig(filemenu.index("Save"), state=NORMAL) frame.title("muCPU Assembler [" + filename + "]") frame.focus() def exitApp(): frame.destroy() sys.exit() def compileASM_GUI(): return compileASM(app.getTextArea("title")) def menuPress(name): print("Hello") if (name == "Open"): print("Open") elif (name == "Close"): app.stop() def toolPress(name): if (name == "Compile"): sim.__init__(compileASM_GUI(), app) print("#ToDo compile") elif name == "Execute": sim.runAll() print("#ToDo Execute") elif name == "Execute Next": sim.step() print("#ToDo Execute Next") app = gui("M-Architecture Simulation ", "800x675") app.setSticky("news") app.setExpand("both") app.setFont(14) fileMenus = ["Open", "Save", "Save as...", "-", "Close"] app.addMenuList("File", fileMenus, menuPress) # Parameters passed are (row column columnSpan) #app.addLabel("Input", "Input Assembly code here", 0, 0, 2) app.addScrolledTextArea("title", 0, 0, 2, text="Input code here") app.addLabel("Registers", "", 0, 1, 1) app.addLabel("Registers1", "", 0, 2, 1) app.addLabel("Registers2", "", 0, 3, 1) #app.addLabel("Memory", "Memory Content", 1, 0, 3) app.startScrollPane("memPane") for x in range(1000): name = str(x) app.addLabel(name, name, row=x) app.addLabel(name + "c1", "Memory content to be inserted here", row=x, column=1, colspan=4) app.setLabelBg(name, ("grey")) app.stopScrollPane() redisplayReg() redisplayMem() #app.setLabelBg("Input", "white") app.setLabelBg("Registers", "grey") app.setLabelBg("Registers2", "grey") #app.setLabelBg("Memory", "Red") tools = ["Compile", "Execute", "Execute Next"] app.addToolbar(tools, toolPress) #app.showSplash("M-Architecture Simulator", fill='blue', stripe='black', fg='white', font=44) app.go()
def transactionMenu(type, boo, acc): def press(button): if boo: if button == type + " savings": if type == "To": acc.deposit(True, app.getEntry("Ammount")) app.stop() confirmationMenu(acc) else: if int(app.getEntry("Ammount")) < acc.getSavings(): acc.withdraw(True, app.getEntry("Ammount")) app.stop() confirmationMenu(acc) else: app.startSubWindow("error") app.errorBox("TransactionError", "Not enough funds in savings account!") app.destroyAllSubWindows() elif button == type + " checking": if type == "To": acc.deposit(False, app.getEntry("Ammount")) app.stop() confirmationMenu(acc) else: if int(app.getEntry("Ammount")) < acc.getChecking(): acc.withdraw(False, app.getEntry("Ammount")) app.stop() confirmationMenu(acc) else: app.startSubWindow("error") app.errorBox("TransactionError", "Not enough funds in checking account!") app.destroyAllSubWindows() else: if button == type + " savings to checking": if int(app.getEntry("Ammount")) < acc.getSavings(): acc.transfer(True, app.getEntry("Ammount")) app.stop() confirmationMenu(acc) else: app.startSubWindow("error") app.errorBox("TransactionError", "Not enough funds in savings account!") app.destroyAllSubWindows() elif button == type + " checking to savings": if int(app.getEntry("Ammount")) < acc.getChecking(): acc.transfer(False, (app.getEntry("Ammount"))) app.stop() confirmationMenu(acc) else: app.startSubWindow("error") app.errorBox("TransactionError", "Not enough funds in checking account!") if button == "Back": app.stop() actionMenu(acc) app = gui("Automated Teller Machine", "400x200") app.setBg("green") app.addLabelEntry("Ammount") app.setFocus("Ammount") if boo: app.addButtons([(type + " savings"), (type + " checking")], press) app.addButtons(["Back"], press) else: app.addButtons([(type + " savings to checking"), (type + " checking to savings")], press) app.addButtons(["Back"], press) app.go()
from appjar import gui import backend import datetime app = gui("Check-in Application") app.setIcon("images/appLogo.ico") backend.saveLogs( "<====================================<>====================================>" ) backend.saveLogs("======> This session starts at " + str(datetime.datetime.now())) ###################################################################################################################### these go in the sub windows ###################### function of all buttons of sub windows ( launch , launch setting , launch exit , launch adding ) def launch(win): try: app.showSubWindow(win) except: pass # if win == 'exit' : # app.showSubWindow('exit') # elif win == 'Setting' : # app.showSubWindow('Setting')
def makeGUI(cmd_args): app = gui("M-Architecture Simulation ", "800x675") app.setSticky("news") app.setExpand("both") app.setFont(14) sim.gui = app def openFile(): openfilename = askopenfilename() if openfilename is not None: cmd_args.outfile = openfilename with open(cmd_args.outfile, "r") as asmfile: asmfile.seek(0) asmdata = asmfile.read() textArea.delete("1.0", "end - 1c") textArea.insert("1.0", asmdata) filemenu.entryconfig(filemenu.index("Save"), state=NORMAL) frame.title("muCPU Assembler [" + cmd_args.outfile + "]") frame.focus() def menuPress(name): if name == "Open": print("Open") fileLocation = app.openBox(title=None, dirName=None, fileTypes=[('text', '*.txt')], asFile=False, parent=None) fileObject = open(fileLocation,"r") code = fileObject.read() app.setTextArea("code", code) elif name == "Save as...": fileLocation = app.saveBox(title="Save as...", fileName=None, dirName=None, fileExt=".txt", fileTypes=None, asFile=None, parent=None) fileObject = open(fileLocation,"w") fileObject.write(app.getTextArea("code")) elif name == "Close": app.stop() def saveFile(): asmdata = textArea.get("1.0", "end - 1c") asmfile = open(cmd_args.outfile, "w") asmfile.seek(0) asmfile.truncate() asmfile.write(asmdata) asmfile.close() def saveFileAs(): saveasfilename = asksaveasfilename() if saveasfilename is not None: cmd_args.outfile = saveasfilename asmdata = textArea.get("1.0", "end - 1c") asmfile = open(cmd_args.outfile, "w") asmfile.seek(0) asmfile.truncate() asmfile.write(asmdata) asmfile.close() filemenu.entryconfig(filemenu.index("Save"), state=NORMAL) frame.title("muCPU Assembler [" + cmd_args.outfile + "]") frame.focus() def exitApp(): frame.destroy() sys.exit() def compileASM_GUI(): return compileASM(app.getTextArea("code"), cmd_args.outfile) app.addScrolledTextArea("code", 0, 0, 2, text=cmd_args.startText) def toolPress(name): if name == "Compile": sim.init(compileASM_GUI(), app) elif name == "Execute": sim.runAll() elif name == "Execute Next": sim.step() fileMenus = ["Open", "Save", "Save as...", "-", "Close"] app.addMenuList("File", fileMenus, menuPress) # building regfile gui app.startScrollPane(sim.regfile.name, row=0, column=2) sim.regfile.buildGUI() # building memory gui app.startScrollPane(sim.mem.name, row=1) sim.mem.buildGUI() app.addScrolledTextArea("console", row=1, column=1, colspan=2) tools = ["Compile", "Execute", "Execute Next"] app.addToolbar(tools, toolPress) # app.showSplash("M-Architecture Simulator", fill='blue', stripe='black', fg='white', font=44) app.go()
from appjar import gui app = gui("calculator", "300x300") app.setSticky("news") app.setExpand("both") app.setFont(20) global operation operation = [] def press(btn): operation.append(btn) ans = "" i = 0 while i < len(operation): ans += operation[i] i += 1 app.setLabel("t1", ans) app.playSound("roblox-death-sound-effect.wav") print(btn) def answer(btn): i = 0 ans = 0 while i < len(operation): ans += int(operation[i])