Esempio n. 1
0
    def destroy(self):

        self.kill()
        self.rotate(0)
        self.speed = [0,0]
        f.FX_explosion(self.rect.centerx, self.rect.centery)

        for x in self.shields:
            x.down()

        if self.player == True:

            for x in self.mounts:
                x.kill()
            for x in self.shields:
                x.kill()
            for x in self.player_hull_group:
                x.kill()
            self.lives += -1

            if self.lives > -1:
                #lol =0
                #lol = pygame.event.Event(pygame.USEREVENT)
                pygame.time.set_timer(pygame.USEREVENT+2, 500)

            else:
                Menus.death_menu()
                s = open('C:/vova/scores.txt', 'r')
                if int(s.read()) < score:
                    s.close()
                    s = open('C:/vova/scores.txt', 'w')
                    s.write(str(score))
                s.close()
Esempio n. 2
0
    def run(self, keyhandler):
        self.keyhandler = keyhandler
        self.running = True

        while self.running:
            self.keyhandler.get_events()
            if not self.gamestate["playing"]:
                Menus.Start(self)
            if not self.gamestate["paused"] and self.gamestate["playing"]:
                #if not self.paused and self.playing:
                # 1 Process input/events
                self.clock.tick(
                    settings.FPS
                )  # will make the loop run at the same speed all the time
                # 2 Update
                self.all_sprites.update()

                # 3 Draw/render
                self.Render()
                #pygame.display.flip()
                # Done after drawing everything to the screen
                #
            if self.gamestate["paused"]:
                Menus.Pause(self)

        pygame.quit()
Esempio n. 3
0
 def ProcessInput(self, events):
     for event in events:
         if event.type == pygame.KEYDOWN:
             if event.key == pygame.K_RETURN:
                 self.next = Menus.Title()
             elif event.key == pygame.K_ESCAPE:
                 self.next = Menus.Title()
         if event.type == pygame.MOUSEBUTTONUP and event.button == 1:
             self.next = Menus.Title()
Esempio n. 4
0
def game_loop():
    """ Main game loop. Contains event handling for crashes, moving between menus,
     and score-keeping."""

    # Defines object starting positions.
    chicken_x = random.randrange(25, aspect_ratio[0] - 100)
    chicken_y = -aspect_ratio[1]
    vehicle_x = aspect_ratio[0] * 0.455
    vehicle_y = aspect_ratio[1] * 0.75

    # Defines object rectangles for collision detection.
    chicken = Obstacles.Chicken(game_display, chicken_x, chicken_y, 74, 74)
    car = Obstacles.Vehicle(game_display, vehicle_x, vehicle_y, 81, 240)

    # Vertical displacement of chicken with each frame.
    chicken_speed = aspect_ratio[1] * 0.00833

    # Continuously updating score for the game.
    score = 0

    # Sets maximum number of chickens that will appear in the game.
    chicken_count = 30

    while chicken_count >= 0:

        # Controls event handling for quitting and car movement.
        for event in pygame.event.get():
            Menus.quit_game(event)
            car.move(event)

        # Adds a hard cap to the chicken speed.
        if chicken_speed < 0.02 * aspect_ratio[1]:
            chicken_speed += 0.00075 * aspect_ratio[1]

        chicken.move(chicken_speed)

        # Handles scoring conditions.
        if chicken.collide(car):
            if score >= 50:
                score -= 50
            else:
                score = 0
        elif car.xpos < chicken.xpos < car.xpos + car.width or \
                car.xpos < chicken.xpos + chicken.width + car.xpos + car.width:
            score += int(30**(1 / (car.ypos -
                                   (chicken.ypos + chicken.height))))

        # Draws everything to the game display and updates chicken_count.
        game_display.blit(background, (0, 0))
        chicken_count = chicken.spawn(chicken_count)
        chicken.draw()
        car.draw()

        # Updates the surface display.
        pygame.display.update()
        clock.tick(60)
Esempio n. 5
0
 def searchForPerson(option):
     """ Handles the option to search for a person to print or delete """
     Menus.printSearchMenu()
     while True:
         try:
             selection = int(input())
             checkSearchInput(selection, option)
             break
         except ValueError:
             print("Numbers only.  Try again")
             continue
def searchForPerson(option):
	""" Handles the option to search for a person to print or delete """
	Menus.printSearchMenu()
	while True:
		try:
			selection = int(input())
			checkSearchInput(selection, option)
			break
		except ValueError:
			print("Numbers only.  Try again")
			continue
 def main(self):
     while not self.done:
         self.eventsInput()
         self.displayFrame()
         self.logics()
         self.clock.tick(60)
     Menus.MainMenu(self.screen).main()
Esempio n. 8
0
	def Update(self):
		# Too slow
		#GamePlay.LoadNextTile()
		
		self.counter += 1
		if self.counter > self.duration:
			self.next = Menus.LoadingScreen()
Esempio n. 9
0
 def checkInput(selected):
     """ Checks the input to make sure it is a valid main menu option """
     global quit
     if selected == 1:
         contactList.printToScreen()
     elif selected == 2:
         searchForPerson("search")
     elif selected == 3:
         addNewContact()
     elif selected == 4:
         searchForPerson("delete")
     elif selected == 5:
         printContactsToFile()
     elif selected == 6:
         quit = True
     else:
         Menus.printInvalidOption(selected)
def checkInput(selected):
	""" Checks the input to make sure it is a valid main menu option """
	global quit
	if selected == 1:
		contactList.printToScreen()
	elif selected == 2:
		searchForPerson("search")
	elif selected == 3:
		addNewContact()
	elif selected == 4:
		searchForPerson("delete")
	elif selected == 5:
		printContactsToFile()
	elif selected == 6:
		quit = True
	else:
		Menus.printInvalidOption(selected)
def InitialRun():
    print(colorama.Fore.BLUE + "Kristan's Networking Tool" + "          " +
          colorama.Fore.RED)
    print(
        "This is a prototype piece of software, the program is to be used as is with no support"
    )
    print("Created by Kristan Smout     |    [email protected]")
    Menus.DisplayLocalInformationPanel()
Esempio n. 12
0
def menu(L, title, xcons=0):
    root = rooter(title)
    root.protocol("WM_DELETE_WINDOW", Xprot())

    x = 270 + xcons
    y = 28 * len(L)

    root.geometry(str(x) + "x" + str(y))
    Menus.Frame(root, L).mainloop()
Esempio n. 13
0
    def __init__(self):
        super(PlayerWindow, self).__init__()

        global __MAIN_WINDOW__
        __MAIN_WINDOW__ = self

        global __SETTINGS_WINDOW__
        __SETTINGS_WINDOW__ = Menus.SettingsWindow()

        self.initUI()
        self.initializePlugins()
    def ProcessInput(self, events):

        for event in events:
            if event.type == pygame.KEYUP and event.key == pygame.K_ESCAPE:
                self.next = Menus.Title()

        if (self._page == 0):
            self._MapUIInput(events)
        elif (self._page == 1):
            self._ProgTimeUIInput(events)
        elif (self._page == 2):
            self._ZoomLevelUIInput(events)
Esempio n. 15
0
    def createMenu(self, menu: M.Menu, choice):


        if menu.menuType() == "ErrorMenu": 
            return M.ChoiceMenu(choice,Menufactory.QUESTION_OPTION)
        
        elif menu.menuType() == "ChoiceMenu":
            if (choice == "Yes"):
                return M.KeywordMenu()
            else: 
               return M.SearchResultsMenu() 
        
        elif menu.menuType() == "KeywordMenu": 
            return M.SearchResultsMenu(choice) 
       
        elif menu.menuType() == "SearchResultsMenu":
            menu.usersChoice(choice)
            return menu
        
        else:
            return M.ErrorMenu(choice)
Esempio n. 16
0
def checkInput(selected):
    # Checks the input to make sure it is a valid main menu option
    global quit
    if selected == "pr":
        contactList.printToScreen()
    elif selected == "s":
        search_for_person("search")
    elif selected == "a":
        addNewContact()
    elif selected == "d":
        search_for_person("delete")
    elif selected == "sv":
        printContactsToFile()
    elif selected == "h":
        print(
            "Please direct all questions to Matt Cowsert @ [email protected]"
        )
    elif selected == "q":
        quit = True
    else:
        Menus.printInvalidOption(selected)
Esempio n. 17
0
    def ProcessInput(self, events):
        for event in events:
            if event.type == pygame.KEYDOWN and event.key == pygame.K_F8:
                self.next = Menus.GameWin(self)

            if event.type == pygame.MOUSEMOTION and self._story_r:
                x = event.pos[0]
                y = event.pos[1]

                if (self._story_r.collidepoint(x, y)):
                    self._hover = STORY
                elif (self._custom_r.collidepoint(x, y)):
                    self._hover = CUSTOM
                elif (self._intro_r.collidepoint(x, y)):
                    self._hover = INTRO
                elif (self._credits_r.collidepoint(x, y)):
                    self._hover = CREDITS
                elif (self._quit_r.collidepoint(x, y)):
                    self._hover = QUIT
                else:
                    self._hover = NONE

            elif event.type == pygame.MOUSEBUTTONUP and event.button == 1:
                x = event.pos[0]
                y = event.pos[1]

                if not self._story_r:
                    return

                if (self._story_r.collidepoint(x, y)):
                    self.next = PlayScene(LevelSeed('level1', None))
                elif (self._custom_r.collidepoint(x, y)):
                    self.next = Menus.MapOptions()
                elif (self._intro_r.collidepoint(x, y)):
                    self.next = Menus.Intro()
                elif (self._credits_r.collidepoint(x, y)):
                    self.next = Menus.Credits()
                elif (self._quit_r.collidepoint(x, y)):
                    self.next = None
Esempio n. 18
0
 def loadSinks(self):
     self.sink_list.add(Info.init())
     self.sink_list.add(Buttons.init())
     self.sink_list.add(Menus.init())
     self.sink_list.add(Images.init())
     self.sink_list.add(Layouts.init())
     self.sink_list.add(Lists.init())
     self.sink_list.add(Popups.init())
     self.sink_list.add(Tables.init())
     self.sink_list.add(Text.init())
     self.sink_list.add(Trees.init())
     self.sink_list.add(Frames.init())
     self.sink_list.add(Tabs.init())
Esempio n. 19
0
def main():
    Menus.printMu()
    quit = False
    issuedCommands = []
    while quit == False:
        command = input("Enter command >>").lower()
        if command == "q":
            print("Good bye!")
            quit = True
        elif command == "hist":
            if len(issuedCommands) > 0:
                for cmd in issuedCommands:
                    print("- ", cmd)
            else:
                print("No history to show")

        else:
            issuedCommands.append(command)
            InputHandler.handleInput(command)

        if len(issuedCommands) >= 20:
            issuedCommands.pop(0)
Esempio n. 20
0
 def loadSinks(self):
     self.sink_list.addSink(Info.init())
     self.sink_list.addSink(Buttons.init())
     self.sink_list.addSink(Menus.init())
     self.sink_list.addSink(Images.init())
     self.sink_list.addSink(Layouts.init())
     self.sink_list.addSink(Lists.init())
     self.sink_list.addSink(Popups.init())
     self.sink_list.addSink(Tables.init())
     self.sink_list.addSink(Text.init())
     self.sink_list.addSink(Trees.init())
     self.sink_list.addSink(Frames.init())
     self.sink_list.addSink(Tabs.init())
Esempio n. 21
0
def start():
    global userman
    sqlSetup()
    userman = Manager()
    userman.load(sqlman)
    Menus.load(userman)
    data = userman.getUsers()
    if (len(data) == 0):
        Menus.first()
    else:
        Menus.main()
Esempio n. 22
0
    def ProcessInput(self, events):
        skip = False
        for event in events:

            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_RETURN:
                    skip = True
                if event.key == pygame.K_ESCAPE:
                    skip = True
            if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
                skip = True

        if skip:
            self.next = Menus.Title()
            c = open('cookie.txt', 'wt')
            c.write("Cookie Good! Mmmmmm...")
            c.close()
Esempio n. 23
0
	def __init__(self, game, keys, name, color):
		self.game = game
		self.keys = keys
		self.name = name
		self.color = color

		self.lives = Settings.lives
		self.kills = 0

		self.active = True
		self.winner = False

		self.shoot1 = False
		self.shoot2 = False

		self.respawnWait = 200

		self.menuStage = 1
		self.menu = Menus.shipChooser()
    def ProcessInput(self, events):

        for event in events:
            if event.type == pygame.MOUSEBUTTONUP and event.button == 1:
                x = event.pos[0] + self.cameraX
                y = event.pos[1] + self.cameraY

                pressed = pygame.key.get_pressed()
                if pressed[pygame.K_LCTRL] or pressed[
                        pygame.K_RCTRL] or pressed[pygame.K_LSHIFT] or pressed[
                            pygame.K_RSHIFT]:
                    #TODO: figure out why this gets called even when shift/ctrl isn't pressed
                    #self.ToggleSelection(self.dragStart, (x, y))
                    self.SetSelection(self.dragStart, (x, y))
                else:
                    self.SetSelection(self.dragStart, (x, y))
                self.dragStart = None

            elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
                x = event.pos[0] + self.cameraX
                y = event.pos[1] + self.cameraY
                self.dragStart = (x, y)
                self.suppressDragDraw = False

            elif event.type == pygame.MOUSEMOTION:
                self.cursorScreenPosition = event.pos
                x = event.pos[0] + self.cameraX
                y = event.pos[1] + self.cameraY
                self.cursorLogicalPosition = (x, y)

            elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 3:
                self.MoveSelectionToTarget(event.pos[0] + self.cameraX,
                                           event.pos[1] + self.cameraY)

            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    self.next = Menus.GamePauseMenu(self)
                if event.key == pygame.K_F7:
                    for sprite in self.level.citizens:
                        sprite.Decolorize()
                if event.key == pygame.K_F8:
                    self.next = GamePlay.WinScene(self)
Esempio n. 25
0
 def loadSinks(self):
     #self.sink_list.addSink(DataTree.init())
     #self.sink_list.addSink(RecipeSystemIFACE.init())
     self.sink_list.addSink(ADViewerIFACE.init())
     self.sink_list.addSink(RecipeViewer.init())
     self.sink_list.addSink(FITSStoreFACE.init())
     self.sink_list.addSink(DisplayIFACE.init())
     self.sink_list.addSink(Info.init())
     if False:
         self.sink_list.addSink(Buttons.init())
         self.sink_list.addSink(Menus.init())
         self.sink_list.addSink(Images.init())
         self.sink_list.addSink(Layouts.init())
         self.sink_list.addSink(Lists.init())
         self.sink_list.addSink(Popups.init())
         self.sink_list.addSink(Tables.init())
         self.sink_list.addSink(Text.init())
     if False: #preserving originaly order
         self.sink_list.addSink(Frames.init())
         self.sink_list.addSink(Tabs.init())
    def Render(self, screen):
        cnt = self._counter
        fadeDone = BG_FADE_TIME

        bgimg = Resources.ImageLibrary.Get('MapOptions/sc4.png')

        l3p = (260, 285)
        l4p = (l3p[0] + self.preHope.get_width(), 285)
        bgimg.blit(self.hope, l4p)

        if cnt < fadeDone:
            screen.fill((0, 0, 0))
            offsetcnt = cnt
            op = _f2op(1 - _op(offsetcnt, BG_FADE_TIME))
            self.bg.set_alpha(op)
            self.bg.blit(bgimg, (0, 0))
            screen.blit(self.bg, (0, 0))
            return

        if not self._advance:
            self._advance = Menus.Credits()
Esempio n. 27
0
def checkSearchInput(selected, option):
    # Handles the input for searching.
    if selected == "fn":
        Menus.printSearchCriteria("First Name")
        search_str = input()
        peep = contactList.matchPersonByFirstName(search_str)
        handleFoundPerson(peep, option)
    elif selected == "ln":
        Menus.printSearchCriteria("Last Name")
        search_str = input()
        peep = contactList.matchPersonByLastName(search_str)
        handleFoundPerson(peep, option)
    elif selected == "pn":
        Menus.printSearchCriteria("Phone Number")
        search_str = input()
        peep = contactList.matchPersonByPhoneNumber(search_str)
        handleFoundPerson(peep, option)
    elif selected == "e":
        Menus.printSearchCriteria("Email")
        search_str = input()
        peep = contactList.matchPersonByEmail(search_str)
        handleFoundPerson(peep, option)
    else:
        print("That is not a valid selection")
def checkSearchInput(selected, option):
	""" Handles the input for searching. """
	if selected == 0:
		Menus.printSearchCriteria("First Name")
		searchStr = input()
		peep = contactList.matchPersonByFirstName(searchStr)
		handleFoundPerson(peep, option)
	elif selected == 1:
		Menus.printSearchCriteria("Last Name")
		searchStr = input()
		peep = contactList.matchPersonByLastName(searchStr)
		handleFoundPerson(peep, option)
	elif selected == 2:
		Menus.printSearchCriteria("Email")
		searchStr = input()
		peep = contactList.matchPersonByEmail(searchStr)
		handleFoundPerson(peep, option)
	else:
		print("That is not a valid selection")
Esempio n. 29
0
 def checkSearchInput(selected, option):
     """ Handles the input for searching. """
     if selected == 0:
         Menus.printSearchCriteria("First Name")
         searchStr = input()
         peep = contactList.matchPersonByFirstName(searchStr)
         handleFoundPerson(peep, option)
     elif selected == 1:
         Menus.printSearchCriteria("Last Name")
         searchStr = input()
         peep = contactList.matchPersonByLastName(searchStr)
         handleFoundPerson(peep, option)
     elif selected == 2:
         Menus.printSearchCriteria("Email")
         searchStr = input()
         peep = contactList.matchPersonByEmail(searchStr)
         handleFoundPerson(peep, option)
     else:
         print("That is not a valid selection")
Esempio n. 30
0
class iPht3dGui(wx.Frame):
    ID_CHRONIQUE = 122
    ID_PROFIL = 123
    ID_OPTIONS = 125
    ID_RT3D = 126

    def __init__(self, titre, lang="fr"):
        wx.Frame.__init__(self, None, 1, title=titre, style=wx.DEFAULT_FRAME_STYLE)
        self.Maximize(True)
        self.titre = titre
        self.demo = False
        self.icones = self.creerIcones()
        self.mainDir = os.getcwd()
        self.model = iPht3dModel(self, self.mainDir)
        self.lg = langue()  # dico contient les mots et leur traduction
        self.invdico = dict()
        for i in self.lg.dict.iteritems():
            self.invdico[i[1][0]] = i[0]  # dictionneir inverse
        self.LANG = lang  # nom de la langue

        self.creerPanelMatplotlib()
        self.creerTopBar()
        self.creerPanelParametres()
        self.creerPanelAffiche()
        self.creerMenus()

        self.afficheSizer = wx.BoxSizer(wx.VERTICAL)
        self.afficheSizer.Add(self.affiche, 0, wx.EXPAND)

        frameSizer = wx.BoxSizer(wx.HORIZONTAL)
        frameSizer.Add(self.paramSizer, 12, wx.EXPAND)
        frameSizer.Add(self.matplot, 76, wx.EXPAND)
        frameSizer.Add(self.afficheSizer, 15, wx.EXPAND)

        globalSizer = wx.BoxSizer(wx.VERTICAL)
        globalSizer.Add(self.barSizer, 4)
        globalSizer.Add(frameSizer, 96, wx.EXPAND)

        globalSizer.SetSizeHints(self)
        self.SetSizer(globalSizer)
        self.control = Controller(self)
        wx.EVT_CLOSE(self, self.OnExit)

    def traduit(self, mot):
        mot2 = []
        if self.LANG == "fr":
            return mot
        if type(mot) == type("abc"):
            return self.lg.getMot(mot)  # pour l'instant que anglais donc pas choix
        else:
            for m in mot:
                mot2.append(self.lg.getMot(m))  # pour des listes
            return mot2

    def tradinverse(self, mot):
        if self.invdico.has_key(mot):
            return str(self.invdico[mot])  # pour l'instant que anglais donc pas choix
        else:
            return mot

    def OnRepondre(self, texte):
        texte = self.traduit(texte)
        message = wx.MessageDialog(self, texte, "Attention", style=wx.ICON_INFORMATION | wx.CENTRE | wx.OK | wx.CANCEL)
        retour = message.ShowModal()
        message.Destroy()
        return retour

    def OnMessage(self, text):
        if text == None:
            return
        text = self.traduit(text)
        if type(text) == type("ab"):
            w = max(len(text) * 5, 80)
            h = 1
            text = [text]
        elif type(text) == type([3, 4]):
            h = len(text)
            w = 80
            for i in range(len(text)):
                w = max(w, len(text[i]) * 5)
        dlg = wx.Dialog(self, -1, "", size=(min(w + 30, 450), h * 30 + 80))
        dlgSizer = wx.BoxSizer(wx.VERTICAL)
        for i in range(len(text)):
            dlgSizer.Add(wx.StaticText(dlg, -1, text[i]))
        dlgSizer.Add(dlg.CreateButtonSizer(wx.OK), -1, wx.ALIGN_BOTTOM | wx.ALIGN_CENTER)
        dlg.SetSizer(dlgSizer)
        dlg.ShowModal()
        dlg.Destroy()

    ####################################################
    #                   creer menus
    ####################################################
    def creerMenus(self):
        self.menus = Menus(self)
        # file menu
        menuFichier = wx.Menu()
        menuFichier.Append(wx.ID_NEW, "&" + self.traduit("Nouveau") + "\tCTRL+n")
        menuFichier.AppendSeparator()
        menuFichier.Append(wx.ID_OPEN, "&" + self.traduit("Ouvrir") + "\tCTRL+o")
        menuFichier.Append(wx.ID_SAVE, "&" + self.traduit("Enregistrer") + "\tCTRL+s")
        menuFichier.Append(wx.ID_SAVEAS, "&" + self.traduit("Enregistrer sous"))
        menuFichier.AppendSeparator()
        menuFichier.Append(wx.ID_EXIT, "&" + self.traduit("Quitter") + "\tCTRL+q")

        wx.EVT_MENU(self, wx.ID_NEW, self.menus.OnNew)
        wx.EVT_MENU(self, wx.ID_OPEN, self.menus.OnOpen)
        wx.EVT_MENU(self, wx.ID_SAVE, self.menus.OnSave)
        wx.EVT_MENU(self, wx.ID_SAVEAS, self.menus.OnSaveAs)
        wx.EVT_MENU(self, wx.ID_EXIT, self.OnExit)

        listeVar = self.model.Aquifere.getParm("Variable")[1]
        listeVar.extend(["Transport", "Tr_Rech", "PHT3D", "PH_Rech", "Observation"])

        # Import
        menuImport = wx.Menu()
        submenu = wx.Menu()
        for i in range(len(listeVar)):
            id = submenu.Append(-1, self.traduit(listeVar[i]))
            self.Bind(wx.EVT_MENU, self.menus.OnImportVar, id)
        menuImport.AppendMenu(710, "Grid", submenu)
        submenu = wx.Menu()
        for i in range(len(listeVar)):
            id = submenu.Append(-1, self.traduit(listeVar[i]))
            self.Bind(wx.EVT_MENU, self.menus.OnImportZones, id)
        menuImport.AppendMenu(730, "Zones", submenu)
        id = menuImport.Append(-1, self.traduit("Donnees"))
        self.Bind(wx.EVT_MENU, self.menus.OnImportData, id)
        id = menuImport.Append(-1, self.traduit("Solutions"))
        self.Bind(wx.EVT_MENU, self.menus.OnImportSolutions, id)
        # Export
        menuExport = wx.Menu()
        submenu = wx.Menu()
        for i in range(len(listeVar)):
            submenu.Append(751 + i, self.traduit(listeVar[i]))
        menuExport.AppendMenu(750, "Variables", submenu)
        menuExport.Append(771, self.traduit("Vitesses"))
        menuExport.Append(772, "Transport")
        menuExport.Append(773, "PHT3D")
        for i in range(len(listeVar)):
            wx.EVT_MENU(self, 751 + i, self.menus.OnExportResultat)
        for i in range(771, 774):
            wx.EVT_MENU(self, i, self.menus.OnExportResultat)

        # Outils
        menuOutils = wx.Menu()
        oc = menuOutils.Append(-1, "Options calcul")
        ov = menuOutils.Append(-1, "Options Visu")
        of = menuOutils.Append(-1, "Options Modflow")
        omt = menuOutils.Append(-1, "Options Mt3dms")
        opht = menuOutils.Append(-1, "Options Pht3d")
        oim = menuOutils.Append(-1, self.traduit("Import Donnees"))
        self.Bind(wx.EVT_MENU, self.menus.OnCalcOpt, oc)
        self.Bind(wx.EVT_MENU, self.menus.OnVisuOpt, ov)
        self.Bind(wx.EVT_MENU, self.menus.OnModflowOpt, of)
        self.Bind(wx.EVT_MENU, self.menus.OnMt3dmsOpt, omt)
        self.Bind(wx.EVT_MENU, self.menus.OnPht3dOpt, opht)
        self.Bind(wx.EVT_MENU, self.menus.OnImportData, oim)
        # Add-ins
        self.menuAddins = wx.Menu()

        # Aide
        menuAide = wx.Menu()
        if self.LANG == "fr":
            menuAide.Append(131, "Aide")
        if self.LANG == "en":
            menuAide.Append(131, "Help")
        wx.EVT_MENU(self, 131, self.menus.OnAide)
        ##        menuAide.Append(132,"Video1 Tutorial")
        ##        menuAide.Append(133,"Video2 Zones")
        ##        wx.EVT_MENU(self, 132, self.menus.OnVideo)
        ##        wx.EVT_MENU(self, 133, self.menus.OnVideo)
        menuAide.Append(133, "&Donwload new")
        wx.EVT_MENU(self, 133, self.menus.OnDownload)
        menuAide.Append(134, "&Back to old")
        wx.EVT_MENU(self, 134, self.menus.OnBackVersion)
        self.menuBarre = wx.MenuBar()

        self.menuBarre.Append(menuFichier, "&" + self.traduit("Fichier"))
        self.menuBarre.Append(menuImport, "&Import")
        self.menuBarre.Append(menuExport, "&Export")
        self.menuBarre.Append(menuOutils, "&" + self.traduit("Outils"))
        self.menuBarre.Append(self.menuAddins, "&Add-in")
        self.menuBarre.Append(menuAide, "&?")
        self.SetMenuBar(self.menuBarre)
        addin = Addins(self)
        addin.build()

    def enableMenu(self, nomM, bool):
        id = self.menuBarre.FindMenu(nomM)
        if id != -1:
            self.menuBarre.EnableTop(id, bool)  # pour les griser

    def OnExit(self, evt):
        self.menus.askSave(evt)
        self.Destroy()

    #####################################################
    #                   Panel Matplotlib
    ######################################################
    def creerPanelMatplotlib(self):

        # initialisation de la visualisation
        self.Visu = Visualisation(self, self.model.Aquifere.getVarList())
        sizerVisu = wx.BoxSizer(wx.VERTICAL)

        # ajout d'un item avec une proportion dans le sizer (95% et 5% ici) avec comme flag wxExpand
        sizerVisu.Add(self.Visu, 95, wx.EXPAND)
        basSizer = wx.BoxSizer(wx.HORIZONTAL)
        basSizer.Add(self.Visu.GetToolBar(), 0)
        self.pos = wx.StaticText(self, -1, " x: y:", size=(100, 40))
        self.pos.SetOwnBackgroundColour("LIGHT GRAY")
        basSizer.Add(self.pos, 5, wx.EXPAND)
        self.notify = wx.StaticText(self, -1, "")
        font = wx.Font(16, wx.SWISS, wx.NORMAL, wx.NORMAL)
        self.notify.SetFont(font)
        self.notify.SetOwnForegroundColour("RED")
        basSizer.AddSpacer((0, 5), 0)
        basSizer.Add(self.notify, 5, wx.EXPAND)
        sizerVisu.Add(basSizer, 5, wx.EXPAND)
        self.matplot = sizerVisu
        self.model.setVisu(self.Visu)
        self.Visu.setVisu(self.model, self.model.getGlist())

        # On Windows, default frame size behaviour is incorrect
        # you don't need this under Linux
        # tw, th = self.Visu.GetToolBar().GetSizeTuple()
        # fw, fh = self.Visu.GetSizeTuple()
        # self.Visu.GetToolBar().SetSize(wx.Size(fw, th))

    def getModel(self):
        return self.model

    def getVisu(self):
        return self.Visu

    def onNotify(self, text):
        self.notify.SetLabel(text)

    def onPosition(self, text):
        self.pos.SetLabel(text)

    # affiche le titre ainsi que le path complet du projet
    def updateTitle(self):
        self.SetTitle(self.titre + " - " + self.model.getProjectName())

    #####################################################
    #                   Panel Top et Parametres
    #####################################################
    def creerTopBar(self):
        self.barSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.zoneBox = zoneBox(self)
        self.barSizer.Add(self.zoneBox, 0)
        self.barSizer.Add(wx.StaticLine(self, -1), 0, wx.ALIGN_CENTER | wx.EXPAND)
        self.modifBox = modifBox(self)
        self.barSizer.Add(self.modifBox, 0)

    def creerPanelParametres(self):
        # Creation des differents Panels
        self.paramSizer = wx.BoxSizer(wx.VERTICAL)
        self.parametresGui = parametresGui(self, self.model)
        self.paramSizer.Add(self.parametresGui)

    #####################################################
    #                   Panel Vue
    #####################################################
    def creerPanelAffiche(self):
        self.afficheTree = visuGui(self, self.model)
        self.affiche = wx.BoxSizer(wx.VERTICAL)
        self.affiche.Add(self.afficheTree, -1, wx.EXPAND)

    ######################## ICONES ############################
    import sys

    os.path.join(os.path.dirname(sys.executable), "utils")

    def creerIcones(self):
        noms = [
            "blanc",
            "bBleu",
            "Mo_zList",
            "Mo_Carte",
            "Mo_Domaine",
            "Mo_Grille",
            "Mo_GriVar",
            "Mo_Unites",
            "Aq_Zone",
            "Aq_layLock",
            "Aq_layUnlock",
            "Top_Point",
            "Top_Ligne",
            "Top_Rect",
            "Top_Poly",
            "Top_PolyV",
            "Top_Interp",
            "Top_move",
            "Top_modifPoly",
            "Top_modifPolyRed",
            "Top_supprime",
            "Top_zoneLay",
            "Top_Histo",
            "Top_supprimeAll",
            "Ec_SolvListe",
            "Ec_Solver",
            "Ec_Temps",
            "Ec_Write",
            "Ec_Run",
            "Ec_Particule",
            "Tr_ZoneT",
            "Tr_Transp",
            "Tr_Temps",
            "Tr_Methodes",
            "Tr_Recharge",
            "Tr_Solver",
            "Tr_Particules",
            "Tr_Write",
            "Tr_Run",
            "PH_Import",
            "PH_Chemistry",
            "PH_ZoneP",
            "PH_Write",
            "PH_Run",
            "PH_PHparm",
            "PH_Recharge",
            "PH_Immobile",
            "PH_ImmobileDisable",
            "Ob_ZoneO",
            "Vis_OriX",
            "Vis_OriY",
            "Vis_OriZ",
            "Vis_SwiImg",
            "Vis_SwiCont",
        ]
        dIcones = {}
        for n in noms:
            img = "utils" + os.sep + n + ".gif"
            dIcones[n] = wx.Bitmap(img, wx.BITMAP_TYPE_GIF)
        return dIcones
Esempio n. 31
0
import os

os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
import sys
import Menus

#--------------------------
# Main Statement
#--------------------------
if __name__ == '__main__':
    Menus.background_music_loop()
    Menus.main_menu()
Esempio n. 32
0
import Game
import Menus

game = Game.GameLoop('Shattered Silence', 640, 480, 30)
titlescreen = Menus.Logo()

game.Start(titlescreen)

Esempio n. 33
0
sensorFrame.grid(column=0, row=1, sticky=(tk.N, tk.W, tk.E, tk.S))
sensorFrame.columnconfigure(0, weight=1)
sensorFrame.rowconfigure(0, weight=1)

client = mqtt.Client()
client.connect("10.32.98.69", 1883, 60)
client.loop_start()

s = ttk.Style()
s.configure('Info.TLabel', font='helvetica 16')
s.configure('Data.TLabel', font='helvetica 24')
s.configure('TCheckbutton', font='helvetica 16')
s.configure('TEntry', font='helvetica 16')

PM = Panels.PanelManager()
LM = Menus.LoggingMenu(rootWindow, PM)

sensorList = []


def processSensorList(client, userdata, message):
    payload = message.payload.decode('utf-8')

    splitMessage = payload.split(",")

    sensorList.clear()

    for sensorID in splitMessage:
        if sensorID == "sensors":
            continue
	if selected == 1:
		contactList.printToScreen()
	elif selected == 2:
		searchForPerson("search")
	elif selected == 3:
		addNewContact()
	elif selected == 4:
		searchForPerson("delete")
	elif selected == 5:
		printContactsToFile()
	elif selected == 6:
		quit = True
	else:
		Menus.printInvalidOption(selected)
		

#####################
# The Main function
####################

if __name__ == "__main__":
	readInContacts()

	while (quit == False):
		Menus.printMainMenu()
		try:
			selection = int(input())
			checkInput(selection)
		except ValueError:
			continue
Esempio n. 35
0
frameCount = 0  #Frame Counter

collidablePolygons = []  #Objects that can collide

visiblePolygons = []  #Polygons that are visible
visibleCircles = []  #Circles that are visible
visibleText = []
visibleSurface = []  #List of surfaces that are visible

runAlways = []  #functions that run every frame

lvlInfo = initLevel()  #Info needed for the level scripts

pauseFunction, callPause = Menus.init(
    lvlInfo
)  #Init menues and level scripts. Return value is the pause function
setPause(True, 0)  #call the main menu
#runAlways.append((lvlFunc[0], lvlFunc[1])) #level function that will run every iteration

keyEventFunc = Menus.getKeyEvent()  #function that handles key presses

paused = True  #is game paused

while (playing):
    clk.tick()
    if (not (paused)):
        frameCount += 1

    for event in pg.event.get():  #Event Handling
        if (event.type == pg.QUIT):
Esempio n. 36
0
 def onModuleLoad(self):
   self.sink_list = SinkList()
   self.sink_list.add(Menus.init())
Esempio n. 37
0
    def Render(self, screen):
        counter = self.counter

        screen.fill((0, 0, 0))

        acounter = counter
        bcounter = acounter - 50
        ccounter = bcounter - 300
        dcounter = ccounter - 255 // 6 + 20
        ecounter = dcounter - 4 * 30 - 7 * 30

        dimVal = 0
        if ccounter >= 0:
            dimVal = ccounter * 10
            if dimVal > 255:
                dimVal = 255
            if dimVal < 0: dimVal = 0

        if acounter >= 0:
            av = acounter * 7
            if av > 255: av = 255
            self.bg.set_alpha(av)

        if bcounter >= 0:
            av = bcounter * 10
            ax = 100
            ay = 300 - bcounter // 3
            if av > 255: av = 255
            self.BlitText(self.lineA, (ax, ay), av - dimVal)
            self.BlitText(self.lineB, (ax, ay + 20), av - dimVal)
            self.BlitText(self.lineC, (ax + 100, ay + 40), av - dimVal)

        if ccounter >= 0:
            cv = ccounter * 6
            if cv > 255: cv = 255
            self.RenderBG(cv)

        screen.blit(self.bg, (0, 0))

        dim2 = 0
        if ecounter >= 0:
            #self.bg.blit(screen, (0, 0))
            opacity = 255 - ecounter * 4
            if opacity < 0: opacity = 0
            self.bg.set_alpha(opacity)
            screen.fill((0, 0, 0))
            screen.blit(self.bg, (0, 0))
            dim2 = ecounter * 8
            if dim2 > 255: dim2 = 255
            if ecounter >= 110:
                self.next = Menus.Title()
                c = open('cookie.txt', 'wt')
                c.write("Cookie Good! Mmmmmm...")
                c.close()

        if dcounter >= 0:

            text = self.nar
            limit = dcounter
            if limit > len(text): limit = len(text)
            display = text[:limit].split('\n')
            y = 300 - dcounter // 2
            x = 50
            for d in display:

                self.BlitText(self.MakeText((160, 225, 255), d), (x, y),
                              255 - dim2)
                x += 100
                y += 40

        self.DoBlits(screen)
Esempio n. 38
0
    def creerMenus(self):
        self.menus = Menus(self)
        # file menu
        menuFichier = wx.Menu()
        menuFichier.Append(wx.ID_NEW, "&" + self.traduit("Nouveau") + "\tCTRL+n")
        menuFichier.AppendSeparator()
        menuFichier.Append(wx.ID_OPEN, "&" + self.traduit("Ouvrir") + "\tCTRL+o")
        menuFichier.Append(wx.ID_SAVE, "&" + self.traduit("Enregistrer") + "\tCTRL+s")
        menuFichier.Append(wx.ID_SAVEAS, "&" + self.traduit("Enregistrer sous"))
        menuFichier.AppendSeparator()
        menuFichier.Append(wx.ID_EXIT, "&" + self.traduit("Quitter") + "\tCTRL+q")

        wx.EVT_MENU(self, wx.ID_NEW, self.menus.OnNew)
        wx.EVT_MENU(self, wx.ID_OPEN, self.menus.OnOpen)
        wx.EVT_MENU(self, wx.ID_SAVE, self.menus.OnSave)
        wx.EVT_MENU(self, wx.ID_SAVEAS, self.menus.OnSaveAs)
        wx.EVT_MENU(self, wx.ID_EXIT, self.OnExit)

        listeVar = self.model.Aquifere.getParm("Variable")[1]
        listeVar.extend(["Transport", "Tr_Rech", "PHT3D", "PH_Rech", "Observation"])

        # Import
        menuImport = wx.Menu()
        submenu = wx.Menu()
        for i in range(len(listeVar)):
            id = submenu.Append(-1, self.traduit(listeVar[i]))
            self.Bind(wx.EVT_MENU, self.menus.OnImportVar, id)
        menuImport.AppendMenu(710, "Grid", submenu)
        submenu = wx.Menu()
        for i in range(len(listeVar)):
            id = submenu.Append(-1, self.traduit(listeVar[i]))
            self.Bind(wx.EVT_MENU, self.menus.OnImportZones, id)
        menuImport.AppendMenu(730, "Zones", submenu)
        id = menuImport.Append(-1, self.traduit("Donnees"))
        self.Bind(wx.EVT_MENU, self.menus.OnImportData, id)
        id = menuImport.Append(-1, self.traduit("Solutions"))
        self.Bind(wx.EVT_MENU, self.menus.OnImportSolutions, id)
        # Export
        menuExport = wx.Menu()
        submenu = wx.Menu()
        for i in range(len(listeVar)):
            submenu.Append(751 + i, self.traduit(listeVar[i]))
        menuExport.AppendMenu(750, "Variables", submenu)
        menuExport.Append(771, self.traduit("Vitesses"))
        menuExport.Append(772, "Transport")
        menuExport.Append(773, "PHT3D")
        for i in range(len(listeVar)):
            wx.EVT_MENU(self, 751 + i, self.menus.OnExportResultat)
        for i in range(771, 774):
            wx.EVT_MENU(self, i, self.menus.OnExportResultat)

        # Outils
        menuOutils = wx.Menu()
        oc = menuOutils.Append(-1, "Options calcul")
        ov = menuOutils.Append(-1, "Options Visu")
        of = menuOutils.Append(-1, "Options Modflow")
        omt = menuOutils.Append(-1, "Options Mt3dms")
        opht = menuOutils.Append(-1, "Options Pht3d")
        oim = menuOutils.Append(-1, self.traduit("Import Donnees"))
        self.Bind(wx.EVT_MENU, self.menus.OnCalcOpt, oc)
        self.Bind(wx.EVT_MENU, self.menus.OnVisuOpt, ov)
        self.Bind(wx.EVT_MENU, self.menus.OnModflowOpt, of)
        self.Bind(wx.EVT_MENU, self.menus.OnMt3dmsOpt, omt)
        self.Bind(wx.EVT_MENU, self.menus.OnPht3dOpt, opht)
        self.Bind(wx.EVT_MENU, self.menus.OnImportData, oim)
        # Add-ins
        self.menuAddins = wx.Menu()

        # Aide
        menuAide = wx.Menu()
        if self.LANG == "fr":
            menuAide.Append(131, "Aide")
        if self.LANG == "en":
            menuAide.Append(131, "Help")
        wx.EVT_MENU(self, 131, self.menus.OnAide)
        ##        menuAide.Append(132,"Video1 Tutorial")
        ##        menuAide.Append(133,"Video2 Zones")
        ##        wx.EVT_MENU(self, 132, self.menus.OnVideo)
        ##        wx.EVT_MENU(self, 133, self.menus.OnVideo)
        menuAide.Append(133, "&Donwload new")
        wx.EVT_MENU(self, 133, self.menus.OnDownload)
        menuAide.Append(134, "&Back to old")
        wx.EVT_MENU(self, 134, self.menus.OnBackVersion)
        self.menuBarre = wx.MenuBar()

        self.menuBarre.Append(menuFichier, "&" + self.traduit("Fichier"))
        self.menuBarre.Append(menuImport, "&Import")
        self.menuBarre.Append(menuExport, "&Export")
        self.menuBarre.Append(menuOutils, "&" + self.traduit("Outils"))
        self.menuBarre.Append(self.menuAddins, "&Add-in")
        self.menuBarre.Append(menuAide, "&?")
        self.SetMenuBar(self.menuBarre)
        addin = Addins(self)
        addin.build()
Esempio n. 39
0
import Menus
import Matrices

negrita = '\033[1m'
rojo = '\033[31m'
verde = '\033[32m'
amarillo = '\033[33m'
azul = '\033[34m'
magenta = '\033[35m'
verde2 = '\033[36m'
blanco = '\033[37m'
reset = '\033[39m'

print(azul + "HOLA QUERIDO USUARIO, BIENVENIDO")
archivocargado = Menus.cargar_memoria()
MemoriaMatrices = []

while (opcion := Menus.MenuPrincipal()) != "4":
    if opcion == "1":
        while (opcion1 := Menus.IngresarMatrices()) != "3":
            opcion = opcion1
            if opcion1 == "1":
                #Acciones para ingresar matriz en posicion existente

                a = Menus.IngresoNumeroValido(
                    negrita + blanco +
                    "Por favor ingrese el numero de matrices que quiere añadir en la memoria:",
                    "Error!!!! El valor ingresado es incorrecto")
                if len(archivocargado) == 0:
                    MM1 = [[0]] * a
Esempio n. 40
0
def handleInput(command):
    if command.strip() == "help":
        Menus.printHelp()

# print details on a function
    elif command.strip().rfind("detail") == 0:
        print("detail command detected")

# set Precision
    elif command.strip().rfind("set precision") == 0:
        global precision
        precision = int(
            input("How many decimal places should we round to? (0-16) >>"))
        print("Precision set to " + str(precision) + ".\n")

# print functions
    elif command.strip().rfind("funcs") == 0:
        Menus.printFuncs(commands)

# find the hypotenuse
    elif command.strip().rfind("hypot:") == 0:
        vals = command.replace("hypot:", "")
        vals = vals.split(", ")

        cleanedVals = []

        if len(vals) != commands["hypot"]:
            print("Please enter a valid number of arguments.\n")
            return
        else:
            for item in vals:
                item = removeAlpha(item)
                cleanedVals.append(float(item.strip()))

            #print(cleanedVals)
            print(
                round(math.hypot(float(cleanedVals[0]), float(cleanedVals[1])),
                      precision))
            print()

#find the leg of a right triangle
    elif command.strip().rfind("leg:") == 0:
        vals = command.replace("leg:", "")
        vals = vals.split(", ")

        cleanedVals = []

        if len(vals) != commands["leg"]:
            print("Please enter a valid number of arguments.\n")
            return
        else:
            for item in vals:
                item = removeAlpha(item)
                cleanedVals.append(float(item.strip()))

        print(
            round(math.sqrt((max(cleanedVals))**2 - (min(cleanedVals)**2)),
                  precision))
        print()

#find the distance between two points
    elif command.strip().rfind("dist:") == 0:
        vals = command.replace("dist:", "")
        vals = vals.split(", ")

        cleanedVals = []

        if len(vals) != commands["dist"]:
            print("Please enter a valid number of arguments.\n")
            return
        else:
            for item in vals:
                item = removeAlpha(item)
                cleanedVals.append(float(item.strip()))

            print(
                round(
                    math.sqrt(((cleanedVals[0] - cleanedVals[2])**2) +
                              ((cleanedVals[1] - cleanedVals[3])**2)),
                    precision))
            print()

#find the quadratic roots of an equation given the coefficients
    elif command.strip().rfind("qroots:") == 0:
        vals = command.replace("qroots:", "")
        vals = vals.split(", ")

        cleanedVals = []

        if len(vals) != commands["qroots"]:
            print("Please enter a valid number of arguments.\n")
            return
        else:
            for item in vals:
                item = removeAlpha(item)
                cleanedVals.append(float(item.strip()))

            a = cleanedVals[0]
            b = cleanedVals[1]
            c = cleanedVals[2]

            discriminant = (b**2) - 4 * a * c
            if discriminant >= 0:
                root_1 = round(((-1) * b + math.sqrt(discriminant)) / (2 * a),
                               precision)
                root_2 = round(((-1) * b - math.sqrt(discriminant)) / (2 * a),
                               precision)

                print("roots: [{}, {}]\n".format(root_1, root_2))
            else:
                root_1 = (-b + cmath.sqrt(discriminant)) / (2 * a)
                root_2 = (-b - cmath.sqrt(discriminant)) / (2 * a)
                print("roots: [{}, {}]".format(root_1, root_2))

#find the slope given two points
    elif command.strip().rfind("slope:") == 0:
        vals = command.replace("slope:", "")
        vals = vals.split(", ")

        cleanedVals = []

        if len(vals) != commands["slope"]:
            print("Please enter a valid number of arguments.\n")
            return
        else:
            for item in vals:
                item = removeAlpha(item)
                cleanedVals.append(float(item.strip()))

            slope = round((cleanedVals[0] - cleanedVals[2]) /
                          (cleanedVals[1] - cleanedVals[3]), precision)
            print("The slope between({},{}) and ({},{}) is {}\n".format(
                cleanedVals[0], cleanedVals[1], cleanedVals[2], cleanedVals[3],
                slope))

    elif command.strip().rfind("avg:") == 0:
        vals = command.replace("avg:", "")
        vals = vals.split(", ")
        sum = 0
        cleanedVals = []
        for item in vals:
            item = removeAlpha(item)
            cleanedVals.append(float(item.strip()))

        for item in cleanedVals:
            sum += item

        print(round(sum / len(cleanedVals), precision))

    else:
        print("Please enter a valid command\n")