Ejemplo n.º 1
0
    def __init__(self):
        pygame.init()
        pygame.font.init()

        self.screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
        self.end_game = False
        self.clock = pygame.time.Clock()

        pygame.display.set_caption('Dreamer')

        background_img = pygame.image.load(
            './assets/backgrounds/background.png')
        self.background = pygame.transform.scale(background_img,
                                                 (SCREEN_WIDTH, SCREEN_HEIGHT))

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

        self.splash_screen = Splash(self.screen, 'start')

        self.main_game = GameLevel(self.screen)

        self.tick = 0

        self.final_score = 0

        self.game_screen = 1
        return
Ejemplo n.º 2
0
def main():
    app = QApplication(sys.argv)
    # window = Library()
    # window = Login()
    window = Splash()
    window.show()
    app.exec_()
Ejemplo n.º 3
0
def main(path=None, logging=False):
    latitude, elevation, outdir, outfile, year = parse_path(path)
    if os.path.exists('%s/%s' % (outdir, outfile)):
        print('File %s exists, continuing...' % outfile)
        return

    # Create a root logger:
    if logging:
        root_logger = logging.getLogger()
        root_logger.setLevel(logging.INFO)

        # Instantiating logging handler and record format:
        root_handler = logging.FileHandler("main.log")
        rec_format = "%(asctime)s:%(levelname)s:%(name)s:%(funcName)s:%(message)s"
        formatter = logging.Formatter(rec_format, datefmt="%Y-%m-%d %H:%M:%S")
        root_handler.setFormatter(formatter)

        # Send logging handler to root logger:
        root_logger.addHandler(root_handler)

    my_data = Data()
    my_data.read_csv(path, y=year)
    print('Computing Splash Evapotranspiration with:\n'
          '  lat: %.2f\n  elevation: %.2f\n'
          'and writing to %s/%s...\n' % (latitude, elevation, outdir, outfile))
    my_class = Splash(latitude, elevation)
    my_class.spin_up(my_data)
    if not os.path.isdir(outdir):
        os.makedirs(outdir)
    write_data(my_data, my_class, outdir, outfile, year)
    del my_data
    del my_class
Ejemplo n.º 4
0
def create_splash(input_file, output_file, separator, spectrum_type, spectrum_col, origin_col):
    start_time = time.time()
    splasher = Splash()

    with open(input_file, 'r') as f, \
        (open(output_file, 'w') if output_file is not None else sys.stdout) as fout:

        for i, line in enumerate(f):
            # Handle input
            line = line.strip().split(separator)

            origin = line[origin_col - 1]
            spectrum_string = line[spectrum_col - 1]

            spectrum = Spectrum(spectrum_string, spectrum_type)
            splash_code = splasher.splash(spectrum)

            # Print the spectrum id with the calculated splash id
            print(splash_code, *line, sep = separator, file = fout)

            if (i + 1) % 10000 == 0:
                print('processed %d spectra, %.2f ms average time to splash a spectrum' % (i + 1, 1000 * (time.time() - start_time) / (i + 1)), file = sys.stderr)

    print('finished processing, processing took: %.2f s' % (time.time() - start_time), file = sys.stderr)
    print('processed %d spectra' % (i + 1), file = sys.stderr)
    print('average time including io to splash a spectra is %.2f ms' % (1000 * (time.time() - start_time) / (i + 1)), file = sys.stderr)
Ejemplo n.º 5
0
class Controller:
    def __init__(self):
        self.login = None
        self.register = None
        self.window = None
        self.splashscreen = None

    def show_splash(self):
        self.splashscreen = Splash()
        self.splashscreen.show()
        app.processEvents()
        self.show_login_page()

    def show_login_page(self):
        self.login = Login()
        self.login.switch_register.connect(self.show_register_page)
        self.login.switch_mainwindow[str].connect(self.show_mainwindow)
        if self.register:
            self.register.close()
        self.login.show()
        if self.splashscreen:
            self.splashscreen.finish(self.login)

    def show_register_page(self):
        self.register = Register()
        self.register.switch_login.connect(self.show_login_page)
        self.login.close()
        self.register.show()

    def show_mainwindow(self, user):
        self.window = Window(user)
        self.window.switch_login.connect(self.show_login_page)
        self.login.close()
        self.window.show()
Ejemplo n.º 6
0
class Application(tk.Frame):
    def __init__(self, *args, **kwargs):
        tk.Frame.__init__(self, *args, **kwargs)
        self.root = root

        menubar = tk.Menu(self.root)
        filemenu = tk.Menu(menubar, tearoff=0)
        filemenu.add_command(label="New Character",
                             command=self.createNewCharacter)
        filemenu.add_command(label="Open File")
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.root.destroy)
        menubar.add_cascade(label="File", menu=filemenu)
        self.root.config(menu=menubar)

        self.nb = ttk.Notebook(self.root)
        self.nb.grid(row=0, column=0, sticky="NSEW")

        self.createNewCharacter()

    def createNewCharacter(self):
        self.splash = Splash(self.root)

        controller = CharacterController(self.nb)
        controller.char.charName.trace("w",
                                       lambda i, o, x, name=controller.char.
                                       charName: self.changeTabText(name))
        self.nb.add(controller.view, text="New Character", padding=5)

        self.splash.destroy()

    def changeTabText(self, name):
        self.nb.tab(self.nb.select(), text=name.get())
Ejemplo n.º 7
0
class GameMenu():
    def __init__(self, window):
        self._window = window
        self._points = 0
        self._splash = Splash(window, self)
        self._game = Game(window, self)
        self._highscore = Highscore_menu(window, self)
        self._gameover = Gameover_menu(window, self)
        self._background = Background(window)
        self._help = Help_Menu(window, self)

        self.show_splash()

    def dispatch(self):
        self.handle_events()

        if (self._current_screen == "splash"):  #splash = menu
            self._splash.loop(self._background)
        elif (self._current_screen == "game"):
            self._game.loop()
        elif (self._current_screen == "highscore"):
            self._highscore.loop(self._background)
        elif (self._current_screen == "gameover"):
            self._gameover.loop(self._background)
        elif (self._current_screen == "help"):
            self._help.loop(self._background)

    def handle_events(self):
        for event in self._window.events:
            self._event_listener.listen_for_event(event)
            self._close_listener(event)

    def show_splash(self):
        self._current_screen = "splash"
        self._event_listener = self._splash

    def start_game(self):
        self._current_screen = "game"
        self._event_listener = self._game

    def show_highscore(self):
        self._current_screen = "highscore"
        self._event_listener = self._highscore

    def show_gameover(self, points):
        self._current_screen = "gameover"
        self._event_listener = self._gameover
        self._points = points

    def show_help(self):
        self._current_screen = "help"
        self._event_listener = self._help

    def close(self):
        self._window.close()

    def _close_listener(self, event):
        if type(event) is sf.CloseEvent:
            self.close()
Ejemplo n.º 8
0
    def createNewCharacter(self):
        self.splash = Splash(self.root)

        controller = CharacterController(self.nb)
        controller.char.charName.trace("w",
                                       lambda i, o, x, name=controller.char.
                                       charName: self.changeTabText(name))
        self.nb.add(controller.view, text="New Character", padding=5)

        self.splash.destroy()
Ejemplo n.º 9
0
    def define (self, dwg):

        for element in range(0,1000):
            circle = Circle()
            line = Line()
            parabola = Parabola()
            splash = Splash()
            circle.define(dwg)
            line.define(dwg)
            parabola.define(dwg)
            splash.define(dwg)
Ejemplo n.º 10
0
    def __init__(self, window):
        self._window = window
        self._points = 0
        self._splash = Splash(window, self)
        self._game = Game(window, self)
        self._highscore = Highscore_menu(window, self)
        self._gameover = Gameover_menu(window, self)
        self._background = Background(window)
        self._help = Help_Menu(window, self)

        self.show_splash()
Ejemplo n.º 11
0
    def test_spectrum_1(self):
        spectrum_string = '66.0463:2.1827 105.0698:7.9976 103.0541:4.5676 130.065:8.6025 93.0572:0.2544 79.0542:4.4657 91.0541:2.5671 131.0728:2.6844 115.0541:1.3542 65.0384:0.6554 94.0412:0.5614 116.0494:1.2008 95.049:2.1338 117.0572:100 89.0385:11.7808 77.0385:3.3802 90.0463:35.6373 132.0806:2.343 105.0446:1.771'
        splash_code = 'splash10-014i-4900000000-889a38f7ace2626a0435'

        self.assertEqual(
            Splash().splash(Spectrum(spectrum_string, SpectrumType.MS)),
            splash_code)
Ejemplo n.º 12
0
    def test_spectrum_3(self):
        spectrum_string = '85:1095.0 86:185.0 87:338.0 88:20.0 89:790.0 91:7688.0 92:1208.0 93:5630.0 94:838.0 95:7354.0 96:661.0 97:1634.0 99:410.0 101:712.0 102:182.0 103:1080.0 104:304.0 105:7310.0 106:1494.0 107:4463.0 108:768.0 109:2996.0 110:466.0 111:771.0 112:27.0 113:317.0 114:66.0 115:1485.0 116:673.0 117:2789.0 118:719.0 119:4687.0 120:2294.0 121:4237.0 122:489.0 123:1162.0 124:120.0 125:335.0 126:204.0 128:1042.0 129:15126.0 130:2142.0 131:3635.0 132:966.0 133:2697.0 134:681.0 135:1701.0 136:205.0 137:360.0 139:199.0 141:544.0 142:147.0 143:2163.0 144:394.0 145:3924.0 146:869.0 147:1624.0 148:615.0 149:1321.0 150:88.0 151:373.0 152:109.0 153:268.0 154:84.0 155:770.0 156:266.0 157:859.0 158:486.0 159:2227.0 160:1288.0 161:1723.0 162:387.0 163:949.0 164:178.0 165:359.0 166:52.0 167:62.0 168:118.0 169:352.0 170:79.0 171:675.0 172:238.0 173:1051.0 174:364.0 175:465.0 176:140.0 177:434.0 178:137.0 179:218.0 180:65.0 181:195.0 182:77.0 183:215.0 184:104.0 185:341.0 186:141.0 187:327.0 188:104.0 189:376.0 190:42.0 191:261.0 193:13.0 195:79.0 196:99.0 197:70.0 198:120.0 199:378.0 200:216.0 201:267.0 202:67.0 203:596.0 204:151.0 205:153.0 206:184.0 208:85.0 209:132.0 212:62.0 213:724.0 214:270.0 215:238.0 216:119.0 217:433.0 218:81.0 219:258.0 220:22.0 221:1.0 224:42.0 225:23.0 227:142.0 228:122.0 229:159.0 231:15.0 232:25.0 233:240.0 235:101.0 236:39.0 237:47.0 239:47.0 240:64.0 241:37.0 242:31.0 243:58.0 244:16.0 245:199.0 246:47.0 247:433.0 248:60.0 249:16.0 250:34.0 251:30.0 255:636.0 256:151.0 257:20.0 258:30.0 259:138.0 260:66.0 261:79.0 264:13.0 267:85.0 268:41.0 271:32.0 273:128.0 274:117.0 275:182.0 279:40.0 280:24.0 282:74.0 284:40.0 287:36.0 288:49.0 289:79.0 291:50.0 295:55.0 296:23.0 297:67.0 298:55.0 300:30.0 301:74.0 303:67.0 304:31.0 306:10.0 311:73.0 312:61.0 313:87.0 314:32.0 317:7.0 318:33.0 326:127.0 327:192.0 328:272.0 329:1729.0 330:473.0 331:136.0 339:47.0 340:21.0 342:30.0 349:32.0 351:29.0 353:641.0 354:300.0 355:14.0 368:1096.0 369:424.0 370:76.0 382:32.0 407:19.0 415:29.0 416:8.0 429:90.0 430:28.0 440:8.0 442:10.0 443:31.0 444:63.0 447:36.0 451:31.0 454:7.0 456:40.0 458:354.0 459:298.0 460:83.0 461:57.0 468:23.0 469:29.0 472:16.0 484:19.0 486:27.0'
        splash_code = 'splash10-056v-2900000000-f47edee35669c8f014c2'

        self.assertEqual(
            Splash().splash(Spectrum(spectrum_string, SpectrumType.MS)),
            splash_code)
Ejemplo n.º 13
0
    def test_spectrum_2(self):
        spectrum_string = '303.07:100 662.26:1.2111 454.91:1.2023 433.25:0.8864 432.11:2.308 592.89:3.9052 259.99:0.6406 281.14:1.2549 451.34:1.1847 499.85:1.2374 482.14:2.4133 450:23.5191 483:1.0004 285.25:1.448 253.1:46.5731 254.11:3.247 259.13:6.9241 304.14:17.2795'
        splash_code = 'splash10-0udi-0049200000-ef488ecacceeaaadb4a2'

        self.assertEqual(
            Splash().splash(Spectrum(spectrum_string, SpectrumType.MS)),
            splash_code)
Ejemplo n.º 14
0
 def callback(msms: PySpectrum, file_name: str):
     if msms is not None:
         highest = msms.highest_peaks(1)[0]
         spectra = msms.convert(msms).spectra
         splash = Splash().splash(Spectrum(spectra,
                                           SpectrumType.MS))
         out.write("{};{};{};{};{};{}\n".format(
             msms.ms_level, highest[0], highest[1],
             msms.scan_time[0], splash, spectra))
Ejemplo n.º 15
0
    def __init__(self):
        pygame.init()

        self.settings = Settings()
        self.game_state = GameState()
        self.fullscreen = False

        self.screen = pygame.display.set_mode(
            (self.settings.screen_width, self.settings.screen_height))
        pygame.display.set_caption("Peace-Death")

        self.ship = Ship(self)
        self.splash = Splash(self)
        self.bullets = pygame.sprite.Group()
        self.hint = Hint(self)

        self.current_hint = self.hint.get_current_hint()

        # Media
        self.pew_sound = pygame.mixer.Sound("sounds/pew.wav")
Ejemplo n.º 16
0
    def get_text(self, url):
        response = Splash.get(url)
        if response.headers.get('content-type') == "pplication/json":
            r = json.loads(response.content)
            error = r.get("error")
            if error:
                raise Exception(error)

        soup = BeautifulSoup(response.content, "html.parser")
        remove_exclude_tags(soup)
        return soup.get_text()
Ejemplo n.º 17
0
def get_splash(peaks):

    peak_data = []
    for peak in peaks:
        row = (peak[0], peak[1]) # mz, intensity
        print row
        peak_data.append(row)

    spectrum = Spectrum(peak_data, SpectrumType.MS)
    hash = Splash().splash(spectrum)
    print hash
    return hash
Ejemplo n.º 18
0
    def __init__(self, window):
        self._window = window
        self._points = 0
        self._splash = Splash(window, self)
        self._game = Game(window, self)
        self._highscore = Highscore_menu(window, self)
        self._gameover = Gameover_menu(window, self)
        self._background = Background(window)
        self._help = Help_Menu(window, self)
        

        self.show_splash()
Ejemplo n.º 19
0
    def run(self):
        while not self.end_game:

            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    sys.exit()

            self.clock.tick(LOOP_FREQUENCY)

            if self.game_screen == 1:
                self.splash()

            elif self.game_screen == 2:
                self.final_score = self.main_game.final_score
                self.splash_screen = Splash(self.screen, 'playing',
                                            str(self.final_score))
                self.splash_screen.draw()
                if self.main_game.update_state(self.tick):
                    # print("Final score: {}pts.".format(self.final_score))
                    # sys.exit()
                    self.game_screen = 3

            elif self.game_screen == 3:
                self.splash_screen = Splash(self.screen, 'end',
                                            str(self.final_score))
                self.splash()

            elif self.game_screen == 4:
                sys.exit()

            pygame.display.update()
            if self.tick == TARGET_UPDATE_DELAY:
                self.tick = -1

            self.tick += 1

            self.screen.blit(self.background, (0, 0))
        return
Ejemplo n.º 20
0
def get_SPLASH_from_pySPLASH(ion_list: List[Tuple[float, float]]) -> str:
    """ This function will generate a SPLASH key using pySPLASH installed in
    the local env.

    Args:
        List[Tuple[float, float]]: List of mass and intensity values.
    """

    # Initialize the return
    splash_string = None
    spectra = Spectrum(ion_list, SpectrumType.MS)
    splash_string = Splash().splash(spectra)

    return splash_string
Ejemplo n.º 21
0
    def main_loop(self):
        """ Pętla główna gry. """

        self.__timeElapsed = 0.0  # czas jaki upłynął od początku gry
        splash = Splash(self, self.__camera, config.SPLASH_DISPLAY_TIME)

        while not self.__window.has_exit:
            self.__window.dispatch_events()

            # update świata i HUDa
            dt = clock.tick() * config.DTIME_MULTIPLY
            self.__timeElapsed += dt

            if config.PRINT_FPS and dt > 0.001:
                print "FPS:", 1.0 / dt

            # ustaw kamerę
            self.__camera.set3d()

            # narysuj splash screen albo grę
            if self.__timeElapsed < config.SPLASH_DISPLAY_TIME:
                splash.update(dt)
                splash.draw()
            else:
                self.__world.update(dt)
                #                 self.__hud.update( dt )

                # narysuj świat
                self.__camera.set3d()
                self.__world.draw()

            #                 # narysuj HUD
            #                 self.__camera.set2d()
            #                 self.__hud.draw()

            self.__window.flip()
Ejemplo n.º 22
0
def main_loop(games):
  keep_running = True
  show_splash = True
  ticks = 0
  banana = Banana()
  splash = Splash()

  while show_splash:
    delta = timer.tick(fps)
    splash.draw(delta)
    screen.blit(splash.surface, (0, 0))
    splash.new_generation()
    splash.iterate()
    pygame.display.flip()

    for e in pygame.event.get():
      if e.type is pygame.KEYDOWN and e.key == pygame.K_SPACE:
        show_splash = False
      if e.type is pygame.KEYDOWN and e.key == pygame.K_ESCAPE:
        keep_running = False
        show_splash = False

  while keep_running:
    timer.tick(fps)
    screen.fill(black)

    for e in pygame.event.get():
      if e.type is pygame.KEYDOWN and (e.key == pygame.K_ESCAPE or e.key == pygame.K_SPACE):
        keep_running = False

    for i, game in enumerate(games):
      game.playSound(ticks)
      game.change_column_color(ticks)
      game.draw()
      screen.blit(game.surface, ((i%2)*game_screen_width,(i/2)*game_screen_height))

    banana.draw(ticks)
    screen.blit(banana.surface, (game_screen_width, game_screen_height))
    pygame.draw.line(screen, white, (0, game_screen_height), (2*game_screen_width, game_screen_height))
    pygame.draw.line(screen, white, (game_screen_width, 0), (game_screen_width, 2*game_screen_height))
    pygame.display.flip()

    ticks += 1

    if ticks == 16:
      ticks = 0

      for game in games:
        game.new_generation()
        game.iterate()
Ejemplo n.º 23
0
        def callback(msms: PySpectrum, file_name: str):
            with db.atomic() as transaction:
                if msms is None:
                    self.extract_record(file_name)

                else:
                    # 3. load sample object
                    record = MZMLSampleRecord.get(
                        MZMLSampleRecord.file_name == file_name)
                    # 3. associated msms spectra to it

                    try:
                        # 4. commit transaction
                        highest = msms.highest_peaks(1)[0]
                        spectra = msms.convert(msms, mode="raw").spectra
                        precurosr = msms.selected_precursors[0] if len(
                            msms.selected_precursors) > 0 else {}
                        scannumber = msms.index

                        splash = Splash().splash(
                            Spectrum(spectra, SpectrumType.MS))

                        spectra = MZMLMSMSSpectraRecord.create(
                            sample=record,
                            msms=spectra,
                            rt=msms.scan_time[0],
                            splash=splash,
                            scan_number=scannumber,
                            level=msms.ms_level,
                            base_peak=highest[0],
                            base_peak_intensity=highest[1],
                            precursor=precurosr['mz']
                            if 'mz' in precurosr else 0,
                            precursor_intensity=precurosr['i']
                            if 'i' in precurosr else 0,
                            precursor_charge=precurosr['charge']
                            if 'charge' in precurosr else 0,
                            ion_count=len(msms.peaks("centroided")))
                    except IndexError as e:
                        # not able to find highest peak
                        pass
Ejemplo n.º 24
0
    def main_loop(self):
        ''' Pętla główna gry. '''

        self.__timeElapsed = 0.0     # czas jaki upłynął od początku gry
        splash = Splash(self, self.__camera, config.SPLASH_DISPLAY_TIME)

        while not self.__window.has_exit:
            self.__window.dispatch_events()

            # update świata i HUDa
            dt = clock.tick() * config.DTIME_MULTIPLY
            self.__timeElapsed += dt

            if config.PRINT_FPS and dt>0.001:
                print "FPS:", 1.0/dt

            # ustaw kamerę
            self.__camera.set3d()

            # narysuj splash screen albo grę
            if self.__timeElapsed < config.SPLASH_DISPLAY_TIME:
                splash.update(dt)
                splash.draw()
            else:
                self.__world.update( dt )
#                 self.__hud.update( dt )

                # narysuj świat
                self.__camera.set3d()
                self.__world.draw()

#                 # narysuj HUD
#                 self.__camera.set2d()
#                 self.__hud.draw()

            self.__window.flip()
Ejemplo n.º 25
0
 def open_avi(self, checked):
     file_name1, _ = QFileDialog.getOpenFileName(
         parent=self,
         caption="Открыть первый AVI файл",
         filter="AVI (*.avi)",
         directory="data")
     file_name2, _ = QFileDialog.getOpenFileName(
         parent=self,
         caption="Открыть второй AVI файл",
         filter="AVI (*.avi)",
         directory="data")
     cadr_count, ok = QtWidgets.QInputDialog.getInt(
         self, "Defect Detector", "Остановиться после N стыков:")
     if file_name1 and file_name2 and ok:
         from splash import Splash
         splash = Splash()
         splash.set_message("Поиск")
         csv_file_name = self.logic.open_avi(file_name1, file_name2,
                                             cadr_count)
         splash.close_message(self)
         print(csv_file_name)
         if csv_file_name:
             self.logic.open_csv(csv_file_name)
             self.refresh_gaps_list()
Ejemplo n.º 26
0
    def convert(self, pattern: str = "%%"):
        """
        converts the given input and stores it at the defined postgres database location
        :param input:
        :return:
        """

        # 1. query all visble sample information
        db = config.config(filename="database.ini", section="binbase")

        connection = psycopg2.connect(**db)

        cursor = connection.cursor()
        sample_count = connection.cursor()
        spectra = connection.cursor()
        bin = connection.cursor()

        sample_count.execute(
            "select count(*) from samples where sample_name like '{}' and visible = 'TRUE'"
            .format(pattern))
        count = sample_count.fetchone()[0]

        pbar = tqdm(total=count + 1,
                    desc="importing samples for pattern {}".format(pattern))

        cursor.execute(
            "select sample_id, sample_name from samples where sample_name like '{}' and visible = 'TRUE'"
            .format(pattern))

        row = cursor.fetchone()

        while row is not None:
            try:
                try:
                    record = MZMLSampleRecord.get(
                        MZMLSampleRecord.file_name == row[1])
                    record.delete_instance()
                except Exception:
                    # object doesn't exist
                    pass
                # 2. create sample object
                MZMLSampleRecord.create(file_name=row[1],
                                        instrument="gctof",
                                        name=row[1])

                record = MZMLSampleRecord.get(
                    MZMLSampleRecord.file_name == row[1])
                spectra.execute(
                    "select bin_id, spectra_id,spectra, retention_time from spectra where sample_id = {}"
                    .format(row[0]))

                s = spectra.fetchone()

                while s is not None:
                    splash = Splash().splash(Spectrum(s[2], SpectrumType.MS))

                    spectrum = [
                        list(map(float, x.split(':')))
                        for x in s[2].strip().split()
                    ]

                    spectrum_max = max(spectrum, key=itemgetter(1))

                    MZMLMSMSSpectraRecord.create(
                        sample=record,
                        msms=s[2],
                        rt=s[3],
                        splash=splash,
                        level=1,
                        base_peak=spectrum_max[0],
                        base_peak_intensity=spectrum_max[1],
                        precursor=0,
                        precursor_intensity=0,
                        precursor_charge=0,
                        ion_count=len(spectrum),
                        scan_number=int(s[1]))

                    if s[0] is not None:
                        DatesetToPostgresConverter.classify(
                            "bin_id", splash, s[0])
                        bin.execute(
                            "select name from bin where bin_id = {} and bin_id::text != name"
                            .format(s[0]))
                        result = bin.fetchone()
                        if result is not None:
                            DatesetToPostgresConverter.classify(
                                "bin", splash, result[0])

                    s = spectra.fetchone()

                row = cursor.fetchone()
            finally:
                pbar.update(1)
Ejemplo n.º 27
0
 def start_splash(self):
     splash = Splash()
Ejemplo n.º 28
0
     del opts[i]
     if len(opts) > i:
         os_support.set_bkchem_private_dir(opts[i])
         del opts[i]
 if "-b" in opts:
     i = opts.index("-b")
     if len(opts) >= i:
         # Batch mode
         myapp.initialize_batch()
         myapp.process_batch(opts)
     sys.exit()
 else:
     # normal interactive mode
     files = opts
     # splash screen
     splash = Splash()
     splash.withdraw()
     splash.update_idletasks()
     width = splash.winfo_reqwidth()
     height = splash.winfo_reqheight()
     x = (myapp.winfo_screenwidth() - width) / 2 - myapp.winfo_vrootx()
     y = (myapp.winfo_screenheight() - height) / 3 - myapp.winfo_vrooty()
     if x < 0:
         x = 0
     if y < 0:
         y = 0
     geometry = '%dx%d+%d+%d' % (width, height, x, y)
     splash.geometry(geometry)
     splash.update_idletasks()
     splash.deiconify()
     myapp.update()
Ejemplo n.º 29
0
class AlienInvasion:
    """Overall game class"""
    def __init__(self):
        pygame.init()

        self.settings = Settings()
        self.game_state = GameState()
        self.fullscreen = False

        self.screen = pygame.display.set_mode(
            (self.settings.screen_width, self.settings.screen_height))
        pygame.display.set_caption("Peace-Death")

        self.ship = Ship(self)
        self.splash = Splash(self)
        self.bullets = pygame.sprite.Group()
        self.hint = Hint(self)

        self.current_hint = self.hint.get_current_hint()

        # Media
        self.pew_sound = pygame.mixer.Sound("sounds/pew.wav")

    def run_game(self):
        """Start the main loop"""
        while True:
            self._check_events()
            self.ship.update()
            self.bullets.update()
            self._update_screen()

    def _welcome_message(self):
        self.hint.display_text_centered(strings.WELCOME_FIRST_LINE, -32, 48,
                                        (100, 100, 150))
        self.hint.display_text_centered(strings.WELCOME_SECOND_LINE, 32, 64,
                                        (150, 100, 100))

    def _check_events(self):
        """Respond to keypresses and mouse events."""
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()
            elif event.type == pygame.KEYDOWN:
                self._check_key_down_events(event)
            elif event.type == pygame.KEYUP:
                self._check_key_up_events(event)

    def _check_key_down_events(self, event):
        if event.key == pygame.K_RIGHT:
            self.ship.moving_right = True
        elif event.key == pygame.K_LEFT:
            self.ship.moving_left = True
        elif event.key == pygame.K_RETURN:
            self.game_state.started = True
        elif event.key == pygame.K_ESCAPE:
            self._exit_game()
        elif event.key == pygame.K_SPACE:
            self._fire_bullet()
        elif event.key == pygame.K_TAB:
            self.current_hint = self.hint.get_current_hint(1)

        #elif event.key == pygame.K_f:
        #    self._toggle_fullscreen()

    def _exit_game(self):
        self.game_state.running = False
        self.game_state.started = False
        self._update_screen()
        render_image_centered(self.screen, "images/exit_splash.png", 2)
        sys.exit()

    def _check_key_up_events(self, event):
        if event.key == pygame.K_RIGHT:
            self.ship.moving_right = False
        elif event.key == pygame.K_LEFT:
            self.ship.moving_left = False

    def _fire_bullet(self):
        if not self.game_state.started:
            return

        new_bullet = Bullet(self)
        self.bullets.add(new_bullet)
        self._splash()
        self.pew_sound.play()

    def _splash(self):
        event = threading.Event()
        thread = threading.Thread(target=self.splash_timer, args=(event, ))
        thread.start()

    def splash_timer(self, event, seconds=0.3):
        self.splash.visible = True
        event.wait(seconds)
        self.splash.visible = False

    def _update_screen(self):
        """Update images on the screen, and flip to the new screen."""
        self.screen.fill(self.settings.bg_color)
        self.ship.blitme()
        self.splash.blitme(self.ship.rect)
        for bullet in self.bullets:
            bullet.draw_bullet()

        self.hint.display_text(self.current_hint, 20, 20)

        if not self.game_state.started and self.game_state.running:
            self._welcome_message()

        pygame.display.flip()

    def _toggle_fullscreen(self):
        if self.fullscreen:
            self.screen = pygame.display.set_mode(
                (self.settings.SCREEN_WIDTH, self.settings.SCREEN_HEIGHT),
                pygame.RESIZABLE)
            self.settings.screen_width = self.settings.SCREEN_WIDTH
            self.settings.screen_height = self.settings.SCREEN_HEIGHT
        else:
            self.screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
            self.settings.screen_width = self.screen.get_rect().width
            self.settings.screen_height = self.screen.get_rect().height

        self.fullscreen = not self.fullscreen
Ejemplo n.º 30
0
 def search(self, keyword, start=0, num=20):
     query = self.create_search_url(keyword, start=start, num=num)
     return Splash.get(query)
Ejemplo n.º 31
0
class Game():
    def __init__(self):
        pygame.init()
        pygame.font.init()

        self.screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
        self.end_game = False
        self.clock = pygame.time.Clock()

        pygame.display.set_caption('Dreamer')

        background_img = pygame.image.load(
            './assets/backgrounds/background.png')
        self.background = pygame.transform.scale(background_img,
                                                 (SCREEN_WIDTH, SCREEN_HEIGHT))

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

        self.splash_screen = Splash(self.screen, 'start')

        self.main_game = GameLevel(self.screen)

        self.tick = 0

        self.final_score = 0

        self.game_screen = 1
        return

    def splash(self):
        self.splash_screen.draw()
        keys = pygame.key.get_pressed()
        if keys[pygame.K_RETURN]:
            self.game_screen += 1
        return

    def run(self):
        while not self.end_game:

            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    sys.exit()

            self.clock.tick(LOOP_FREQUENCY)

            if self.game_screen == 1:
                self.splash()

            elif self.game_screen == 2:
                self.final_score = self.main_game.final_score
                self.splash_screen = Splash(self.screen, 'playing',
                                            str(self.final_score))
                self.splash_screen.draw()
                if self.main_game.update_state(self.tick):
                    # print("Final score: {}pts.".format(self.final_score))
                    # sys.exit()
                    self.game_screen = 3

            elif self.game_screen == 3:
                self.splash_screen = Splash(self.screen, 'end',
                                            str(self.final_score))
                self.splash()

            elif self.game_screen == 4:
                sys.exit()

            pygame.display.update()
            if self.tick == TARGET_UPDATE_DELAY:
                self.tick = -1

            self.tick += 1

            self.screen.blit(self.background, (0, 0))
        return
Ejemplo n.º 32
0
 def show_splash(self):
     self.splashscreen = Splash()
     self.splashscreen.show()
     app.processEvents()
     self.show_login_page()
Ejemplo n.º 33
0
    def __init__(self, parent, title):

        wx.Frame.__init__(self, parent, title=title, size=(1200, 600))

        self.splash = Splash(os.path.normpath(
            os.path.join(MEDIA_PATH, "Jormungandr.jpg")),
                             parent=self)

        # Icon
        _icon = wx.NullIcon
        _icon.CopyFromBitmap(
            wx.Bitmap(os.path.normpath(os.path.join(MEDIA_PATH, "icon.png")),
                      wx.BITMAP_TYPE_ANY))
        self.SetIcon(_icon)

        # Status Bar
        self.statusbar = self.CreateStatusBar()

        # Menu Bar
        self.frame_1_menubar = wx.MenuBar()

        # File menu
        wxglade_tmp_menu = wx.Menu()
        ID_FILE_OPEN = wxglade_tmp_menu.Append(wx.ID_ANY, "&Open\tCTRL+O",
                                               "Open a previous session",
                                               wx.ITEM_NORMAL).GetId()
        ID_FILE_SAVE = wxglade_tmp_menu.Append(wx.ID_ANY, "&Save\tCTRL+S",
                                               "Save this session",
                                               wx.ITEM_NORMAL).GetId()
        ID_FILE_SAVEAS = wxglade_tmp_menu.Append(wx.ID_ANY,
                                                 "Save &As\tALT+SHIFT+S",
                                                 "Save this session as...",
                                                 wx.ITEM_NORMAL).GetId()
        ID_FILE_QUIT = wxglade_tmp_menu.Append(wx.ID_ANY, "&Quit\tCTRL+Q",
                                               "Quit this session",
                                               wx.ITEM_NORMAL).GetId()
        self.frame_1_menubar.Append(wxglade_tmp_menu, "&File")

        # Help menu
        wxglade_tmp_menu = wx.Menu()
        ID_HELP_ABOUT = wxglade_tmp_menu.Append(wx.ID_ANY, "&About",
                                                "Display about dialog",
                                                wx.ITEM_NORMAL).GetId()
        self.frame_1_menubar.Append(wxglade_tmp_menu, "&Help")
        self.SetMenuBar(self.frame_1_menubar)

        # Splitter Window
        self.sp = wx.SplitterWindow(self, style=wx.SUNKEN_BORDER)
        self.p2 = PlotPanel(self.sp, self.statusbar)
        self.p1 = PropertyGridPanel(self.sp, self.p2.updatePlot)
        self.sp.SplitVertically(self.p1, self.p2, 400)

        # Event Bindings
        self.Bind(wx.EVT_MENU, self.OnOpen, id=ID_FILE_OPEN)
        self.Bind(wx.EVT_MENU, self.OnSave, id=ID_FILE_SAVE)
        self.Bind(wx.EVT_MENU, self.OnSaveAs, id=ID_FILE_SAVEAS)
        self.Bind(wx.EVT_MENU, self.OnExit, id=ID_FILE_QUIT)
        self.Bind(wx.EVT_MENU, self.OnAbout, id=ID_HELP_ABOUT)

        # Open Menu Wildcard
        self.wildcard = "GUI Save File (*.map)|*.map"

        # Current Working File
        self.working_file = None

        # update the plot
        self.p2.plot(self.p1.pg.GetPropertyValues())

        # Set Statusbar text
        self.statusbar.SetStatusText('Ready')
Ejemplo n.º 34
0
 if "-b" in opts:
   i = opts.index("-b")
   if len( opts) >= i:
     
     # we are in batch mode
     #import time
     #t = time.time()
     myapp.initialize_batch()
     myapp.process_batch( opts)
     #print " %f ms" % (1000*(time.time()-t))
   sys.exit()
 else:
   # normal interactive mode
   files = opts
   # splash screen
   splash = Splash()
   splash.withdraw()
   #splash.overrideredirect( 1)
   splash.update_idletasks()
   width = splash.winfo_reqwidth()
   height = splash.winfo_reqheight()
   x = (myapp.winfo_screenwidth() - width) / 2 - myapp.winfo_vrootx()
   y = (myapp.winfo_screenheight() - height) / 3 - myapp.winfo_vrooty()
   if x < 0:
       x = 0
   if y < 0:
       y = 0
   geometry = '%dx%d+%d+%d' % (width, height, x, y)
   splash.geometry(geometry)
   splash.update_idletasks()
   splash.deiconify()
Ejemplo n.º 35
0
class GameMenu():

    def __init__(self, window):
        self._window = window
        self._points = 0
        self._splash = Splash(window, self)
        self._game = Game(window, self)
        self._highscore = Highscore_menu(window, self)
        self._gameover = Gameover_menu(window, self)
        self._background = Background(window)
        self._help = Help_Menu(window, self)
        

        self.show_splash()

    def dispatch(self):
        self.handle_events();
        
        if(self._current_screen == "splash"): #splash = menu
            self._splash.loop(self._background)
        elif(self._current_screen == "game"):
            self._game.loop()
        elif(self._current_screen == "highscore"):
            self._highscore.loop(self._background)
        elif(self._current_screen == "gameover"):
            self._gameover.loop(self._background)
        elif(self._current_screen == "help"):
            self._help.loop(self._background)

    def handle_events(self):
        for event in self._window.events:
            self._event_listener.listen_for_event(event)
            self._close_listener(event)

    def show_splash(self):
        self._current_screen = "splash"
        self._event_listener = self._splash

    def start_game(self):
        self._current_screen = "game"
        self._event_listener = self._game

    def show_highscore(self):
        self._current_screen = "highscore"
        self._event_listener = self._highscore

    def show_gameover(self,points):
        self._current_screen = "gameover"
        self._event_listener =  self._gameover
        self._points = points

    def show_help(self):
        self._current_screen = "help"
        self._event_listener = self._help

    def close(self):
        self._window.close()

    def _close_listener(self, event):
        if type(event) is sf.CloseEvent:
            self.close()
Ejemplo n.º 36
0
    def _encode(self,
                spec: Spectra,
                prefix: str = None,
                store_string: bool = False):
        """
        encodes the given spectra
        :param spec: spectra
        :param prefix: prefix
        :param store_string: do you also want to store the spectra string for each spectra?
        :return: an image representation of the encoded spectra in form of a string
        """
        # dumb approach to find max mz
        data = []

        pairs = spec.spectra.split(" ")

        # convert spectra to arrays
        for pair in pairs:
            try:
                mass, intensity = pair.split(":")

                frac, whole = math.modf(float(mass))

                data.append({
                    "intensity": float(intensity),
                    "mz": float(mass),
                    "nominal": int(whole),
                    "frac": round(float(frac), 4)
                })
            except ValueError:
                pass

        try:
            dataframe = pd.DataFrame(
                data, columns=["intensity", "mz", "nominal", "frac"])

            # group by 5 digits
            dataframe = dataframe.groupby(
                dataframe['mz'].apply(lambda x: round(x, 5))).sum()

            # drop data outside min and max
            dataframe = dataframe[(dataframe['nominal'] >= self.min_mz)
                                  & (dataframe['nominal'] <= self.max_mz)]

            dataframe['intensity_min_max'] = (
                dataframe['intensity'] - dataframe['intensity'].min()
            ) / (dataframe['intensity'].max() - dataframe['intensity'].min())

            # formatting
            fig = plt.figure(figsize=(self.height / self.dpi,
                                      self.width / self.dpi),
                             dpi=self.dpi)

            self._encode_dataframe(dataframe, fig)

            plt.tight_layout()
            fig.canvas.draw()

            spectra_string = fig.canvas.tostring_rgb()

            if self.directory is not None:
                name = Splash().splash(Spectrum(spec.spectra, SpectrumType.MS))
                plt.subplots_adjust(left=0, right=1, top=1, bottom=0)

                directory = self.directory if prefix is None else "{}/{}".format(
                    self.directory, prefix)
                pathlib.Path(directory).mkdir(parents=True, exist_ok=True)
                plt.savefig("{}/{}.png".format(directory, name), dpi=self.dpi)

                plt.close(fig=fig)

                if store_string:
                    with open("{}/{}.txt".format(directory, name),
                              'w') as the_file:
                        the_file.write(spec.spectra)
                return None

            return spectra_string
        except ValueError:
            pass
Ejemplo n.º 37
0
		if tipo == 0:
			self.animacion.set_from_file("hontza_espera.gif")
		elif tipo == 1:
			self.animacion.set_from_file("hontza_busca.gif")
		elif tipo == 2:
			self.animacion.set_from_file("hontza_analiza.gif")
		self.animacion.show()
		return
		
if __name__ == "__main__":
	db = Db("hontza.db")
	mainGlade = gtk.glade.XML("hontza.glade")
	fuentes = Fuentes(mainGlade, db)
	conexion = Conexion(db)
	configuracion = Configuracion(mainGlade, db)
	splash = Splash(mainGlade)
	error = Error(mainGlade)
	status = Status(mainGlade)
	principal = Principal()
	if os.path.isfile("hontza.db") == False:
		fichero = open("inicializacion.sql", "r")
		datos = fichero.readlines()
		fichero.close()
		db.inicializa(datos)
		configuracion.mostrar()
		while configuracion.abierta:
			gtk.main_iteration()
	splash.set_texto("Conectando al servidor WSDL...")
	splash.mostrar()
	while conexion.inicializa() == False:
		splash.ocultar()