Ejemplo n.º 1
0
 def do_kill(self):
     if self.status == 'Alarm':
         self.app.comms.write('$X\n')
     else:
         # are you sure?
         mb = MessageBox(text='KILL - Are you Sure?', cb=self._do_kill)
         mb.open()
    def _loaded(self, path):
        if self.failed:
            mb = MessageBox(text='File Chooser {} failed - try a different one'.format(NativeFileChooser.type_name))
            mb.open()
            return

        if path:
            dr= os.path.dirname(path)
            if self.cb:
                self.cb(path, dr)
Ejemplo n.º 3
0
    def _load_file(self, ll):
        self._loaded_ok = False
        try:
            self.parse_gcode_file(self.app.gcode_file, ll, True)
        except Exception:
            print(traceback.format_exc())
            mb = MessageBox(
                text='File not found: {}'.format(self.app.gcode_file))
            mb.open()

        self._loaded()
Ejemplo n.º 4
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__()

        self.setObjectName("MainWindow")

        self.centralwidget = QtWidgets.QWidget()
        self.setCentralWidget(self.centralwidget)

        self.message = MessageBox()

        self.grid_central = QtWidgets.QGridLayout(self.centralwidget)
        self.grid_central.setObjectName("grid_central")

        self._translate = QtCore.QCoreApplication.translate

        self.visible_geom = None
        self.visible_calc = None
        self.visible_post = None
        self.statusbar = None

        self.create_actions_menubar()
        self.create_actions_toolbar()
        self.create_menubar()
        self.create_toolbar()
        self.change_statusbar()
Ejemplo n.º 5
0
    def show_treasures(self) -> bool:
        message = ['Treasures found', '', '']
        found = False
        for tribe in self.mine.tribes:
            treasures = []
            for c in self.mine.creatures:
                if c.tribe == tribe:
                    treasures.extend(i.type for i in c.items
                                     if isinstance(i, Treasure))

            if not treasures:
                continue

            found = True

            message.append(f'{tribe.name} team ({len(treasures)}):')
            c = Counter(treasures)
            for t, count in c.items():
                if count == 1:
                    message.append('- A {}'.format(t))
                else:
                    message.append('- {} {}s'.format(count, t))
            message.append('')

        if found:
            MessageBox(self.screen, '\n'.join(message))
        return found
Ejemplo n.º 6
0
    def show_knowledge(self) -> bool:
        message = ['Things learnt', '', '']
        found = False
        for tribe in self.mine.tribes:
            knowledge = []
            for c in self.mine.creatures:
                if c.tribe == tribe:
                    knowledge.extend(i.type for i in c.knowledge)

            if not knowledge:
                continue

            found = True

            message.append(f'{tribe.name} team ({len(knowledge)}):')
            c = Counter(knowledge)
            for t, count in c.items():
                if count == 1:
                    message.append('- {}'.format(t))
                else:
                    message.append('- {} {}s'.format(count, t))
            message.append('')

        if found:
            MessageBox(self.screen, '\n'.join(message))
        return found
Ejemplo n.º 7
0
def main():
    # ready
    manager = Manager()
    upen = UnderlinePen('~')
    mbox = MessageBox('*')
    sbox = MessageBox('/')
    manager.register('strong message', upen)
    manager.register('warning box', mbox)
    manager.register('slash box', sbox)

    # create
    p1 = manager.create('strong message')
    p1.use('Hello, world.')
    p2 = manager.create('warning box')
    p2.use('Hello, world.')
    p3 = manager.create('slash box')
    p3.use('Hello, world.')
Ejemplo n.º 8
0
    def connect(self):
        if self.app.is_connected:
            if self.is_printing:
                mb = MessageBox(
                    text=
                    'Cannot Disconnect while printing - Abort first, then wait'
                )
                mb.open()
            else:
                self._disconnect()

        else:
            port = self.config.get(
                'General', 'serial_port'
            ) if not self.app.use_com_port else self.app.use_com_port
            self.add_line_to_log("Connecting to {}...".format(port))
            self.app.comms.connect(port)
Ejemplo n.º 9
0
    def finish_repo(self, widget):
        """quit dialog automatically if add it OK"""
        del widget
        new_repo_name = self.new_repo_name.get_text().strip()
        new_repo_url = self.new_repo_url.get_text().strip()

        status, output = commands.getstatusoutput(
            '%s/scripts/pkg_relate.sh add %s %s' %
            (ABSPATH, new_repo_name, new_repo_url))
        if status == 0:
            self.repo_dlg.destroy()
        else:
            del output
            msg = MessageBox(self.repo_dlg, _('Add repo'),
                             _('Repo not installed'),
                             _('The repo name or URL is invalid.'))
            msg.run()
        return True
Ejemplo n.º 10
0
def show_message(message):
    """ Originally popped up a message box. Now just logs to console """
    global main_window
    init_gui()
    log_info(message)
    if (hasattr(main_window, 'messagebox')):
        main_window.messagebox.update(message)
    else:
        main_window.messagebox = MessageBox()
Ejemplo n.º 11
0
 def start_game(self):
     start_game_info = MessageBox(self.game)
     start_game_info.startgame()
     self.usercounter_ships = 20  #ilosc wszystkich kafelek na statki
     self.compcounter_ships = 20
     #counter do zliczania strzalow by zatopic konkretny statek
     self.fourcounter = 0
     self.threecounter_o = 0
     self.threecounter_t = 0
     self.twocounter_o = 0
     self.twocounter_t = 0
     self.twocounter_th = 0
     self.shot = True  #flaga strzalu komputera
     self.Xright = True
     self.Xleft = False
     self.Yup = False
     self.Ydown = False
     self.s = 0
     self.dx = 0
     self.dy = 0
Ejemplo n.º 12
0
 def ask_exit(self, restart=False):
     # are you sure?
     if restart:
         mb = MessageBox(text='Restart - Are you Sure?',
                         cb=self._do_restart)
     else:
         mb = MessageBox(text='Exit - Are you Sure?', cb=self._do_exit)
     mb.open()
Ejemplo n.º 13
0
 def show_deaths(self) -> bool:
     message = ['Creatures died', '', '']
     c = Counter(self.deaths)
     found = False
     for t, count in c.items():
         found = True
         if count == 1:
             message.append('- A {} {}'.format(t[0], t[1]))
         else:
             message.append('- {} {}s {}'.format(
                 count, t[0], t[1].replace('was', 'were')))
     if found:
         MessageBox(self.screen, '\n'.join(message))
     return found
Ejemplo n.º 14
0
    def search(self):
        """ Search for things """
        map_layers = self.map_list[self.cur_map_name].map_layers
        if 'searchable' not in map_layers:
            print(f"No searchable sprites on {self.cur_map_name} map layer.")
            return

        searchable_sprites = map_layers['searchable']
        sprites_in_range = arcade.check_for_collision_with_list(self.player_sprite, searchable_sprites)
        print(f"Found {len(sprites_in_range)} searchable sprite(s) in range.")
        for sprite in sprites_in_range:
            if 'item' in sprite.properties:
                self.message_box = MessageBox(self, f"Found: {sprite.properties['item']}")
                sprite.remove_from_sprite_lists()
                lookup_item = self.item_dictionary[sprite.properties['item']]
                self.player_sprite.inventory.append(lookup_item)
            else:
                print("The 'item' property was not set for the sprite. Can't get any items from this.")
Ejemplo n.º 15
0
    def show(self):
        shown_something = False
        if self.show_treasures():
            shown_something = True
            self.mine.print_current_level()

        if self.show_items():
            shown_something = True
            self.mine.print_current_level()

        if self.show_knowledge():
            shown_something = True
            self.mine.print_current_level()

        if self.show_deaths():
            shown_something = True
            self.mine.print_current_level()

        if not shown_something:
            MessageBox(self.screen, 'Our story has just begun...')
Ejemplo n.º 16
0
    def __init__(self, parent_window, version_number):
        # Create pop-up box for entering data
        from message_box import MyEntryWindow
        self.data_entry = MyEntryWindow(parent_window, version=version_number)

        # Create log file pop-up box
        from message_box import MessageBox, MyHandlerText
        self.my_message = MessageBox(parent_window, version=version_number)
        self.module_logger = logging.getLogger(__name__)
        self.module_logger.setLevel(logging.DEBUG)

        # Create handler to route messages to popup
        gui_handler = MyHandlerText(self.my_message.popup_text)
        gui_handler.setLevel(logging.INFO)
        self.module_logger.addHandler(gui_handler)

        # Create handler to route messages to file
        file_handler = logging.FileHandler(
            os.path.join(os.getcwd(), ReportCruk.log_file))
        file_handler.setLevel(logging.DEBUG)
        self.module_logger.addHandler(file_handler)
Ejemplo n.º 17
0
 def _assert(self, tf, msg):
     if self._checknext:
         self._accept = tf
         if not tf:
             self._checknext = False
             MessageBox(msg)
Ejemplo n.º 18
0
#!/usr/bin/env python
# coding: utf-8

from framework.manager import Manager
from message_box import MessageBox
from underline_pen import UnderlinePen

manager = Manager()

upen = UnderlinePen('~')
mbox = MessageBox('*')
sbox = MessageBox('/')

manager.register("strong message", upen)
manager.register("warning box", mbox)
manager.register("slash box", sbox)

p1 = manager.create("strong message")
p1.use("こんにちは")
p2 = manager.create("warning box")
p2.use("Hello, world")
p3 = manager.create("slash box")
p3.use("Hello, world.")
Ejemplo n.º 19
0
 def run(self):
     showinformation = MessageBox(self.game)
     showinformation.preparinggame()
     gametableview = GameTableView(self.game, 10)
Ejemplo n.º 20
0
    def movement(self, i, j):

        if (self.playerField[j][i] != 'W' and self.playerField[j][i] != '0'):
            self.buttons[i][j].config(bg='red')
            self.buttons[i][j].config(state='disabled')
            self.compcounter_ships -= 1
            #sprawdzenie czy statek jest zatopiony, nie moze byc
            if self.destroyed_enemyShips(i, j) == True:
                self.label2.config(text='Trafiony zatopiony', fg='green')
            else:
                self.label2.config(text='Trafiony')
            self.playerField[j][i] = 'X'
        else:
            self.buttons[i][j].config(bg='blue')
            self.buttons[i][j].config(state='disabled')
            self.label2.config(text='Pudło', fg='black')

        for x in range(10):
            for y in range(10):
                print(self.playerField[x][y], end='')
            print('')
        print('\n')

        if self.shot == True:
            self.rand_x = random.randint(0, 9)
            self.rand_y = random.randint(0, 9)
        if (self.GameTableView.playerField[self.rand_y][self.rand_x] == 'X'
                or self.GameTableView.playerField[self.rand_y][self.rand_x]
                == 'U') and self.shot == True:
            tmp = True
            while tmp == True:
                self.rand_x = random.randint(0, 9)
                self.rand_y = random.randint(0, 9)
                if (self.GameTableView.playerField[self.rand_y][self.rand_x] !=
                        'X' and self.GameTableView.playerField[self.rand_y][
                            self.rand_x] != 'U'):
                    tmp = False

        if (self.GameTableView.playerField[self.rand_y][self.rand_x] != 'W' and
                self.GameTableView.playerField[self.rand_y][self.rand_x] != '0'
                and self.GameTableView.playerField[self.rand_y][self.rand_x] !=
                'U'):
            self.GameTableView.buttons[self.rand_x][self.rand_y].config(
                bg='red')
            self.usercounter_ships -= 1
            if self.destroyed_myShips(self.rand_x, self.rand_y) == True:
                self.GameTableView.label2.config(text='Trafiony zatopiony !!!',
                                                 fg='green')
                self.shot = True
                self.Xright = True
                self.Xleft = False
                self.Yup = False
                self.Ydown = False
                self.GameTableView.playerField[self.rand_y][self.rand_x] = 'X'
                #jesli vertical to caly statek dookola oznaczam litera U tak jak przy nietrafieniu, aby losowe strzaly nie obejmowaly wiadomych miejsc gdzie nie moze byc statku.

                try:
                    if (self.GameTableView.playerField[self.dy +
                                                       1][self.dx] == 'X'):
                        for a in range(self.dy - 1, self.dy + self.s + 1):
                            for b in range(self.dx - 1, self.dx + 2):
                                if a > -1 and b > -1 and a < 10 and b < 10:
                                    self.GameTableView.playerField[a][b] = 'U'
                    elif (self.GameTableView.playerField[self.dy][self.dx +
                                                                  1] == 'X'):
                        for a in range(self.dy - 1, self.dy + 2):
                            for b in range(self.dx - 1, self.dx + self.s + 1):
                                if a > -1 and b > -1 and a < 10 and b < 10:
                                    self.GameTableView.playerField[a][b] = 'U'
                    #jesli to byl jednomasztowiec
                    else:
                        for a in range(self.rand_y - 1, self.rand_y + 2):
                            for b in range(self.rand_x - 1, self.rand_x + 2):
                                if a > -1 and b > -1 and a < 10 and b < 10:
                                    self.GameTableView.playerField[a][b] = 'U'
                except IndexError:
                    pass

            else:
                self.GameTableView.label2.config(text="Trafiony", fg='black')
                self.shot = False
                self.GameTableView.playerField[self.rand_y][self.rand_x] = 'X'

                if self.rand_x < 9 and self.Xright == True:
                    if self.GameTableView.playerField[self.rand_y][self.rand_x
                                                                   + 1] != 'U':
                        self.rand_x = self.rand_x + 1
                        self.Xright = True
                    elif self.GameTableView.playerField[self.rand_y][
                            self.rand_x + 1] == 'U':
                        self.Xright = False
                        if self.rand_x == 0:
                            self.Xleft = False
                            if self.GameTableView.playerField[self.rand_y + 1][
                                    self.rand_x] != 'U' and self.rand_y < 9:
                                self.Yup = True
                                self.rand_y = self.rand_y + 1
                            elif self.GameTableView.playerField[
                                    self.rand_y +
                                    1][self.rand_x] == 'U' or self.rand_y == 9:
                                self.Yup = False
                                self.Ydown = True
                                self.rand_y = self.rand_y - 1
                        elif self.GameTableView.playerField[self.rand_y][
                                self.rand_x -
                                1] != 'U' and self.GameTableView.playerField[
                                    self.rand_y][self.rand_x - 1] != 'X':
                            self.Xleft = True
                            self.rand_x = self.rand_x - 1
                        elif self.GameTableView.playerField[self.rand_y][
                                self.rand_x -
                                2] != 'U' and self.GameTableView.playerField[
                                    self.rand_y][
                                        self.rand_x -
                                        2] != 'X' and self.GameTableView.playerField[
                                            self.rand_y][self.rand_x -
                                                         1] == 'X':
                            self.Xleft = True
                            self.rand_x = self.rand_x - 2
                        elif self.GameTableView.playerField[self.rand_y][
                                self.rand_x -
                                3] != 'U' and self.GameTableView.playerField[
                                    self.rand_y][
                                        self.rand_x -
                                        3] != 'X' and self.GameTableView.playerField[
                                            self.rand_y][
                                                self.rand_x -
                                                1] == 'X' and self.GameTableView.playerField[
                                                    self.rand_y][self.rand_x -
                                                                 2] == 'X':
                            self.Xleft = True
                            self.rand_x = self.rand_x - 3
                        elif self.GameTableView.playerField[self.rand_y][
                                self.rand_x - 1] == 'U':
                            self.Xleft = False
                            if self.rand_y == 9:
                                self.Yup = False
                                self.Ydown = True
                                self.rand_y = self.rand_y - 1
                            elif self.GameTableView.playerField[
                                    self.rand_y + 1][self.rand_x] == 'U':
                                self.Yup = False
                                self.Ydown = True
                                self.rand_y = self.rand_y - 1
                            elif self.GameTableView.playerField[
                                    self.rand_y + 1][self.rand_x] != 'U':
                                self.Yup = True
                                self.Ydown = False
                                self.rand_y = self.rand_y + 1

                elif self.rand_x == 9 and self.Xright == True:
                    if self.GameTableView.playerField[self.rand_y][
                            self.rand_x -
                            2] != 'X' and self.GameTableView.playerField[
                                self.rand_y][self.rand_x - 1] == 'X':
                        self.rand_x = self.rand_x - 2
                        self.Xright = False
                        self.Xleft = True
                    elif self.GameTableView.playerField[self.rand_y][
                            self.rand_x -
                            3] != 'X' and self.GameTableView.playerField[
                                self.rand_y][self.rand_x - 2] == 'X':
                        self.rand_x = self.rand_x - 3
                        self.Xright = False
                        self.Xleft = True
                    elif self.GameTableView.playerField[self.rand_y][
                            self.rand_x - 1] != 'U':
                        self.Xright = False
                        self.Xleft = True
                        self.rand_x = self.rand_x - 1

                    elif self.rand_y < 9:
                        if self.GameTableView.playerField[self.rand_y + 1][
                                self.rand_x] != 'U':
                            self.rand_y = self.rand_y + 1
                            self.Xright = False
                            self.Xleft = False
                            self.Yup = True
                        else:
                            self.rand_y = self.rand_y - 1
                            self.Xright = False
                            self.Xleft = False
                            self.Yup = False
                            self.Ydown = True
                    elif self.rand_y == 9:
                        self.rand_y = self.rand_y - 1
                        self.Xright = False
                        self.Xleft = False
                        self.Ydown = True
                        self.Yup = False

                elif self.rand_x > 0 and self.Xleft == True:
                    if self.GameTableView.playerField[self.rand_y][self.rand_x
                                                                   - 1] != 'U':
                        self.rand_x = self.rand_x - 1
                        self.Xleft = True
                    else:
                        self.Xleft = False
                        self.Yup = True
                elif self.rand_x == 0 and self.Xleft == True:
                    if self.GameTableView.playerField[self.rand_y + 1][
                            self.rand_x] != 'U' and self.rand_y < 9:
                        self.Xleft = False
                        self.Yup = True
                    elif self.GameTableView.playerField[self.rand_y + 1][
                            self.rand_x] == 'U' or self.rand_y == 9:
                        self.Yup = False
                        self.Ydown = True

                elif self.rand_y < 9 and self.Yup == True:
                    if self.GameTableView.playerField[self.rand_y +
                                                      1][self.rand_x] != 'U':
                        self.rand_y = self.rand_y + 1
                        self.Yup = True
                    else:
                        self.Yup = False
                        self.Ydown = True
                        if self.GameTableView.playerField[self.rand_y - 2][
                                self.rand_x] == 'X':
                            if self.GameTableView.playerField[self.rand_y - 3][
                                    self.rand_x] != 'X':
                                self.rand_y = self.rand_y - 3
                        elif self.GameTableView.playerField[self.rand_y - 2][
                                self.rand_x] != 'X':
                            self.rand_y = self.rand_y - 2
                elif self.rand_y == 9 and self.Yup == True:
                    self.Yup = False
                    self.Ydown = True
                    if self.GameTableView.playerField[self.rand_y -
                                                      1][self.rand_x] != 'X':
                        self.rand_y = self.rand_y - 1
                    elif self.GameTableView.playerField[self.rand_y -
                                                        2][self.rand_x] != 'X':
                        self.rand_y = self.rand_y - 2
                    elif self.GameTableView.playerField[self.rand_y -
                                                        3][self.rand_x] != 'X':
                        self.rand_y = self.rand_y - 3
                elif self.rand_y > 0 and self.Ydown == True:
                    self.rand_y = self.rand_y - 1
                    self.Ydown = True
        else:
            self.GameTableView.buttons[self.rand_x][self.rand_y].config(
                bg='blue')
            self.GameTableView.label2.config(text='Pudło', fg='black')
            self.GameTableView.playerField[self.rand_y][self.rand_x] = 'U'

            if self.shot == False and self.Xright == True:
                self.Xright = False
                if self.rand_x > 1 and self.GameTableView.playerField[
                        self.rand_y][
                            self.rand_x -
                            2] != 'X' and self.GameTableView.playerField[
                                self.rand_y][self.rand_x - 2] != 'U':
                    self.rand_x = self.rand_x - 2
                    self.Xleft = True
                elif self.rand_x == 1:
                    self.Xleft = False
                    self.rand_x = self.rand_x - 1
                    if self.rand_y < 9 and self.GameTableView.playerField[
                            self.rand_y + 1][self.rand_x] != 'U':
                        self.Yup = True
                        self.rand_y = self.rand_y + 1
                    else:
                        self.rand_y = self.rand_y - 1
                        self.Ydown = True
                elif self.GameTableView.playerField[self.rand_y][self.rand_x -
                                                                 2] == 'U':
                    self.Xleft = False
                    self.rand_x = self.rand_x - 1
                    if self.rand_y == 9:
                        self.Yup = False
                        self.Ydown = True
                        self.rand_y = self.rand_y - 1
                    elif self.GameTableView.playerField[self.rand_y + 1][
                            self.rand_x] != 'U' and self.rand_y < 9:
                        self.rand_y = self.rand_y + 1
                        self.rand_x = self.rand_x
                        self.Yup = True
                    elif self.GameTableView.playerField[self.rand_y +
                                                        1][self.rand_x] == 'U':
                        self.Yup = False
                        self.rand_y = self.rand_y - 1
                        self.Ydown = True
                elif self.GameTableView.playerField[self.rand_y][self.rand_x -
                                                                 3] != 'X':
                    self.rand_x = self.rand_x - 3
                    self.Xleft = True
                elif self.GameTableView.playerField[self.rand_y][self.rand_x -
                                                                 4] != 'X':
                    self.rand_x = self.rand_x - 4
                    self.Xleft = True

            elif self.shot == False and self.Xleft == True:
                if self.rand_y < 9 and self.GameTableView.playerField[
                        self.rand_y + 1][self.rand_x + 1] != 'U':
                    self.rand_x = self.rand_x + 1
                    self.rand_y = self.rand_y + 1
                    self.Xleft = False
                    self.Yup = True
                elif self.rand_y == 9:
                    self.rand_x = self.rand_x + 1
                    self.rand_y = self.rand_y - 1
                    self.Xleft = False
                    self.Yup = False
                    self.Ydown = True
                elif self.GameTableView.playerField[self.rand_y +
                                                    1][self.rand_x + 1] == 'U':
                    self.rand_x = self.rand_x + 1
                    self.rand_y = self.rand_y - 1
                    self.Xleft = False
                    self.Yup = False
                    self.Ydown = True

            elif self.shot == False and self.Yup == True:
                if self.GameTableView.playerField[self.rand_y -
                                                  2][self.rand_x] != 'X':
                    self.rand_y = self.rand_y - 2
                    self.rand_x = self.rand_x
                    self.Yup = False
                    self.Ydown = True
                elif self.GameTableView.playerField[self.rand_y -
                                                    3][self.rand_x] != 'X':
                    self.rand_y = self.rand_y - 3
                    self.rand_x = self.rand_x
                    self.Yup = False
                    self.Ydown = True
                elif self.GameTableView.playerField[self.rand_y -
                                                    4][self.rand_x] != 'X':
                    self.rand_y = self.rand_y - 4
                    self.rand_x = self.rand_x
                    self.Yup = False
                    self.Ydown = True

            elif self.shot == False and self.Ydown == True:
                if self.GameTableView.playerField[self.rand_y +
                                                  2][self.rand_x] != 'X':
                    self.rand_y = self.rand_y + 2
                    self.Ydown = False
                elif self.GameTableView.playerField[self.rand_y +
                                                    3][self.rand_x] != 'X':
                    self.rand_y = self.rand_y + 3
                    self.Ydown = False
                elif self.GameTableView.playerField[self.rand_y +
                                                    4][self.rand_x] != 'X':
                    self.rand_y = self.rand_y + 4
                    self.Ydown = False

        for t in range(10):
            for r in range(10):
                print(self.GameTableView.playerField[t][r], end='')
            print('')
        print('\n')

        if self.compcounter_ships == 0:
            won = MessageBox(self.game)
            won.win()
            for a in range(10):
                for b in range(10):
                    self.buttons[a][b].config(state='disabled')
            self.reset_button = tkinter.Button(self.formframe,
                                               height=3,
                                               width=10,
                                               text='Zagraj ponownie',
                                               command=self.reset_game)
            self.reset_button.grid(pady=6)
            self.endgame_button = tkinter.Button(self.formframe,
                                                 height=3,
                                                 width=10,
                                                 text='Zakoncz',
                                                 command=self.end_game)
            self.endgame_button.grid(pady=6)
        elif self.usercounter_ships == 0:
            lose = MessageBox(self.game)
            lose.lose()
            for a in range(10):
                for b in range(10):
                    self.buttons[a][b].config(state='disabled')
            for c in range(10):
                for d in range(10):
                    if (self.playerField[d][c] != 'W'
                            and self.playerField[d][c] != 'X'
                            and self.playerField[d][c] != '0'):
                        self.buttons[c][d].config(bg='dim gray')
            self.reset_button = tkinter.Button(self.formframe,
                                               height=3,
                                               width=10,
                                               text='Zagraj ponownie',
                                               command=self.reset_game)
            self.reset_button.grid(pady=6)
            self.endgame_button = tkinter.Button(self.formframe,
                                                 height=3,
                                                 width=10,
                                                 text='Zakoncz',
                                                 command=self.end_game)
            self.endgame_button.grid(pady=6)
Ejemplo n.º 21
0
 def showMessage(self, type, message):
     if (self.message):
         self.message.hide()
     self.message = MessageBox(type, message)
     self.message.show()
Ejemplo n.º 22
0
class GUI_Window(QtWidgets.QMainWindow, ui_interface.Ui_MainWindow):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.action_2.triggered.connect(self.openFile)
        self.action_3.triggered.connect(self.saveFile)
        self.actionGithub.triggered.connect(self.openGithub)
        self.button_convert.clicked.connect(self.convert)
        self.input_file_name = None
        self.message = None
        self.movie_cutter = None

    def openFile(self, test=False):
        if (not test):
            self.input_file_name, _ = QFileDialog.getOpenFileName(
                self, "Открыть файл", QDir.homePath(),
                "MP4 (*.mp4);;MKV (*.mkv);;TS (*.ts)", "",
                QFileDialog.DontUseNativeDialog)
        if self.input_file_name != '':
            self.movie_cutter = MovieCutterAPI(
                source_file=self.input_file_name,
                min_silence_len=self.input_min_length.value(),
                silence_thresh=self.input_thresh.value())
            if (self.movie_cutter.convert_required()):
                self.showMessage(
                    "info",
                    'Необходима конвертация исходного файла, это может занять несколько минут'
                )
            self.movie_cutter.convert()
            self.video_player_original.openFile(self.input_file_name)

    def saveFile(self):
        if (self.movie_cutter):
            result_filename, _ = QFileDialog.getSaveFileName(
                self, "Экспортировать файл", QDir.homePath(),
                "Видео-файл (*." + self.movie_cutter.format + ")", "",
                QFileDialog.DontUseNativeDialog)
            QFile.copy(self.movie_cutter.output_file,
                       result_filename + "." + self.movie_cutter.format)

    def openGithub(self):
        QDesktopServices.openUrl(
            QUrl(
                "https://github.com/moevm/mse_automatic_pause_cutter_from_video"
            ))

    def convert(self):
        if (self.input_file_name is None):
            self.showMessage("error", "Не указан исходный файл")
        else:
            self.movie_cutter.min_silence_len = self.input_min_length.value()
            self.movie_cutter.silence_thresh = self.input_thresh.value()
            try:
                self.showMessage(
                    "info",
                    'Преобразование исходного файла может занять несколько минут'
                )
                self.movie_cutter.cut()
                output_file_name = self.movie_cutter.save_clip()
                self.video_player_result.openFile(output_file_name)
            except Exception as ex:
                self.showMessage("error", str(ex))

    def showMessage(self, type, message):
        if (self.message):
            self.message.hide()
        self.message = MessageBox(type, message)
        self.message.show()

    def hideMessage(self):
        if (self.message):
            self.message.hide()
            self.message = None
Ejemplo n.º 23
0
	def __init__(self, xspecio=False):
		super().__init__()
		self.xspecio = xspecio

		#----------- External data ---------------------------------
		# save a fits copy in the main window
		self.fitsobj = FitsObj([],None,None)
		self.linelist = []
		self.newlinelist = []
		self.z_est = [] #pd.DataFrame(columns=['Name', 'RA', 'DEC', 'Z', 'Z_err', 'Confidence', 'Flag'])

		# --------- Menus and Toolbars -----------------------------
		self.setStatusBar(QStatusBar(self))
		self.toolbar = Custom_ToolBar(self)
		self.addToolBar(self.toolbar)

		#menubar = Custom_MenuBar(self)
		#self.setMenuBar(menubar)		

		# --------- Define all necessary widgets ------------------- 
		#placeholder to hold the central widget in main window
		widget = QWidget()
		#widget.setMinimumSize(1000, 800)
		#widget.setFixedSize(1600, 900)

		widget_z = LineListWidget()
		#widget_z.setFixedSize(1000,80)
		table_z = CustomZTable()
		mbox = MessageBox()
		sublayout = QHBoxLayout()
		sublayout.addWidget(mbox)
		sublayout.addWidget(table_z)
		sublayout.setContentsMargins(0,0,0,0)

		layout = QVBoxLayout()
		layout.setAlignment(QtCore.Qt.AlignLeft) #QtCore.Qt.AlignTop | 

		self.sc = MplCanvas(width=15, height=9, dpi=100)
		self.sc.setMinimumSize(1000,500)
		sc_layout = QVBoxLayout()
		sc_layout.setContentsMargins(0,0,0,0)
		mpl_toolbar = NavigationToolbar(self.sc, self)
		sc_layout.addWidget(mpl_toolbar)
		sc_layout.addWidget(self.sc)
		
		layout.addLayout(sc_layout)
		layout.addWidget(widget_z)
		#layout.addWidget(table_z)
		#layout.addWidget(mbox)
		layout.addLayout(sublayout)
		layout.setContentsMargins(0,0,0,0)
		widget.setLayout(layout)

		# MainWindow parameters
		self.setCentralWidget(widget)
		self.setWindowTitle('Spectrum Analysis GUI')
		#self.setMinimumSize(1000, 900)
		


		# ----------------- Signal connections ---------------
		# 1. menubar signal exports
		#menubar.send_fitsobj.connect(self.on_fitsobj_slot)
		#menubar.send_linelist.connect(self.on_linelist_slot)
		#menubar.send_z_est.connect(self.on_z_est_slot)
		#menubar.send_filename.connect(widget_z.on_linelist_name_slot)
		#menubar.send_linelist.connect(widget_z.on_linelist_slot)
		#menubar.send_linelist.connect(self.sc.on_linelist_slot)
		#menubar.send_z_est.connect(table_z._on_sent_estZ)

		# 2. toolbar signal exports
		self.toolbar.send_filename.connect(widget_z._on_sent_filename)
		self.toolbar.send_fitsobj.connect(widget_z._on_sent_fitsobj)
		self.toolbar.send_filename.connect(table_z._move_current_filename_top)
		self.toolbar.send_filename.connect(self.sc._update_lines_for_newfile)
		self.toolbar.send_fitsobj.connect(self.on_fitsobj_slot)
		self.toolbar.send_message.connect(lambda s,c='#ff0000': mbox.on_sent_message(s, c))

		# 3. widget_z signal exports
		widget_z.send_linelist.connect(self.sc.on_linelist_slot)
		widget_z.send_lineindex.connect(self.sc.on_lineindex_slot)
		widget_z.send_gauss_num.connect(self.sc._on_sent_gauss_num)
		widget_z.send_z_returnPressed.connect(self.sc._on_estZ_return_pressed)
		widget_z.send_more_linelist.connect(self.sc.on_additional_linelist_slot)
		widget_z.send_more_linelist_z.connect(self.sc.on_additional_linelist_slot_z)
		widget_z.send_linelists2multiG.connect(self.sc._on_sent_linelists2multiG)
		widget_z.send_message.connect(mbox.on_sent_message)
		widget_z.send_data.connect(table_z._on_sent_data)

		# 4. sc (SpecCanvas) signal exports
		self.sc.send_message.connect(mbox.on_sent_message)
		self.sc.send_z_est.connect(widget_z._on_estZ_changed)
		self.sc.send_z_manual.connect(widget_z._on_estZ_manual)
		self.sc.send_scale_limits.connect(self.toolbar._on_scale_limits_slot)
		self.sc.send_extract1d.connect(self.toolbar._on_sent_extract1d)
		#self.sc.gauss2d.send_gcenter
		
		# 5. table_z ==> widget_z
		table_z.send_dictdata.connect(widget_z._on_sent_dictdata)
Ejemplo n.º 24
0
 def ask_shutdown(self):
     # are you sure?
     mb = MessageBox(text='Shutdown - Are you Sure?',
                     cb=lambda b: self._do_shutdown(b))
     mb.open()
Ejemplo n.º 25
0
    def _check_dragged(self, e):
        fnames = [s.toLocalFile() for s in e.mimeData().urls()]
        exts = [os.path.splitext(s)[1][1:].upper() for s in fnames]
        exts = np.array(exts)
        ext = exts[0]

        #check that all file extensions are the same
        self._assert(np.all(exts == ext),
                     'All dragged files must have the same extension')

        #check that all file extensions are supported
        self._assert(
            exts[0] in self.ftypes,
            '%s files unsupported.\nFile type must be one of:\n%s' %
            (exts[0], self.ftypes))

        #check extension-specific maximum number of files
        self._assert(
            len(fnames) <= self.maxnumfiledict[ext],
            'Maximum number of %s files is: %d' %
            (ext, self.maxnumfiledict[ext]))

        #######
        # check file readability (result of each check should be a single variable "y" which will be subject to further common checks)
        #######

        y = np.array([])

        #check NPY file:
        if self._checknext and ext == 'NPY':
            try:
                y = np.load(fnames[0])
            except:
                self._checknext = False
                MessageBox(
                    'NPY file unreadable.\nMust be readble using:\n  np.load')

        #check MAT file:
        if self._checknext and ext == 'MAT':
            try:
                mfile = loadmat(fnames[0])
            except:
                self._checknext = False
                MessageBox(
                    'MAT file unreadable.\nMust be readble using:\n  scipy.io.loadmat'
                )

            if self._checknext:
                keys = [s for s in mfile.keys() if not s.startswith('__')]
                b0 = 'Y' in mfile.keys()
                b1 = len(keys) == 1
                self._assert(
                    b0,
                    'MAT file must contain only a single variable called "Y".\nNo variable named "Y" found.'
                )
                self._assert(
                    b1,
                    'MAT file must contain only a single variable called "Y".\nOther variables found.'
                )
                if b0 and b1:
                    y = mfile['Y']

        #check CSV file(s):
        if self._checknext and ext == 'CSV':
            if len(fnames) == 1:
                try:
                    y = np.loadtxt(fnames[0], delimiter=',')
                except:
                    self._checknext = False
                    MessageBox(
                        'CSV file unreadable.\nMust be readble using:\n  np.loadtxt(filename, delimiter=",")'
                    )

            else:
                yy = []
                for fname in fnames:
                    try:
                        yy.append(np.loadtxt(fname, delimiter=','))
                    except:
                        self._checknext = False
                        MessageBox(
                            'CSV file (%s) unreadable.\nMust be readble using:\nnp.loadtxt(filename, delimiter=",")'
                            % fname)
                if self._checknext:
                    shapes = [yyy.shape for yyy in yy]
                    sa = np.array(shapes)
                    self._assert(
                        np.all(sa == sa[0]),
                        'All CSV files must contain the same number of columns and rows.\nArray sizes:\n%s'
                        % shapes)
                if self._checknext:
                    y = np.dstack(yy)

        #check that data are numeric:
        if self._checknext:
            try:
                y = np.asarray(y, dtype=float)
            except:
                self._checknext = False
                MessageBox('Data not convertable to float.')

        self._y = y if self._checknext else np.array([])
        self._checknext = True
        return self._accept
Ejemplo n.º 26
0
 def reprint(self):
     # are you sure?
     mb = MessageBox(text='ReRun {}?'.format(self.app.gcode_file),
                     cb=self._reprint)
     mb.open()
Ejemplo n.º 27
0
 def ask_exit(self):
     # are you sure?
     mb = MessageBox(text='Exit - Are you Sure?',
                     cb=lambda b: self._do_exit(b))
     mb.open()
Ejemplo n.º 28
0
 def m0_dlg(self):
     MessageBox(text='M0 Pause, click OK to continue',
                cb=self._m0_dlg).open()
Ejemplo n.º 29
0
 def abort_print(self):
     # are you sure?
     mb = MessageBox(text='Abort - Are you Sure?',
                     cb=lambda b: self._abort_print(b))
     mb.open()
Ejemplo n.º 30
0
 def config_editor(self):
     if self.app.is_v2:
         MessageBox(text='Implemented for V1 config only').open()
         return
     self.app.config_editor.populate()
     self.app.sm.current = 'config_editor'