Exemplo n.º 1
0
    def create_locations_menu(self, arg=None, menuw=None):
        locations = []
        autoselect = 0
        # create menu items
        for location in config.PLUGIN_WEATHER_LOCATIONS:
            weather_item = WeatherItem(self, location)
            # Only display this entry if no errors were found
            if weather_item.isValid():
                locations.append(weather_item)

        # if only 1 valid location, autoselect it and go right to the detail screen
        if locations.__len__() == 1:
            autoselect = 1
            menuw.hide(clear=False)

        # if no locations were found, add a menu entry indicating that
        if not locations:
            nolocation = menu.MenuItem(_('No locations specified'),
                                       menuw.goto_prev_page, 0)
            locations.append(nolocation)

        # if only 1 valid menu entry present, autoselect it
        if autoselect:
            locations[0](menuw=menuw)
        else:
            # create menu
            weather_site_menu = menu.Menu(_('Locations'), locations)
            menuw.pushmenu(weather_site_menu)
            menuw.refresh()
Exemplo n.º 2
0
 def handle_event(self, pygame_event):
     """
     Käsittelee pygamen puolelta tulevat tapahtumat.
     """
     if pygame_event.type == pygame.QUIT:
         self.game_state = self.State.EXITING
     elif pygame_event.type == pygame.MOUSEBUTTONDOWN:
         self.input_handler.mouse_pressed(pygame.mouse.get_pressed())
     elif pygame_event.type == pygame.MOUSEBUTTONUP:
         self.input_handler.mouse_released(pygame.mouse.get_pressed())
     elif pygame_event.type == pygame.KEYDOWN and self.game_state == self.State.PLAYING:
         if pygame_event.key == pygame.K_r:
             self.game_screen = game.Game(self.settings["GridWidth"],
                                          self.settings["GridHeight"],
                                          self.settings["MineCount"],
                                          self.frame_timer)
             self.game_screen.add_listener(self)
         if pygame_event.key == pygame.K_ESCAPE:
             self.game_state = self.State.AT_MENU
             self.main_menu = menu.Menu()
             self.main_menu.add_listener(self)
         if pygame_event.key == pygame.K_w:
             self.game_screen.win_game()
         if pygame_event.key == pygame.K_e:
             self.game_screen.lose_game()
Exemplo n.º 3
0
    def __init__(self, *args, **kwargs):
        super(win, self).__init__(*args, **kwargs)
        self.Show()
        self.SetIcon(wx.Icon("icons/icon.ico"))
        self.Center()
        # self.SetSize(1000,600)
        self.Maximize(True)

        self.cfg = configparser.RawConfigParser()
        self.cfg.read('style.cfg')
        self.par = dict(self.cfg.items("settings"))
        for p in self.par:
            self.par[p] = self.par[p].split("#", 1)[0].strip()

        globals().update(self.par)

        self.statusbar = self.CreateStatusBar(3)
        self.statusbar.SetStatusWidths([-1, -4, -1])
        self.statusbar.SetBackgroundColour('#BDBDBD')
        self.statusbar.SetForegroundColour('#FFFFFF')
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.statlineinfo)
        self.timer.Start(40)
        self.Bind(wx.EVT_CLOSE, self.close)
        menu.Menu(self)
        style.style(self)
        self.init()
Exemplo n.º 4
0
 def select_profile(self, arg=None, menuw=None):
     logger.log(9, 'select_profile(self, arg=None, menuw=None)')
     menu_items = []
     menu_items += [
         menu.MenuItem(_('Xvid Low Quality'),
                       action=self.select_encoding_profile,
                       arg='xvid_low')
     ]
     menu_items += [
         menu.MenuItem(_('Xvid High Quality'),
                       action=self.select_encoding_profile,
                       arg='xvid_high')
     ]
     menu_items += [
         menu.MenuItem(_('iPod'),
                       action=self.select_encoding_profile,
                       arg='ipod')
     ]
     menu_items += [
         menu.MenuItem(_('DVD'),
                       action=self.select_encoding_profile,
                       arg='MPEG 2 (lavc)')
     ]
     encoding_menu = menu.Menu(_('Select Profile'),
                               menu_items,
                               item_types='video encoding menu')
     encoding_menu.infoitem = self
     menuw.pushmenu(encoding_menu)
     menuw.refresh()
Exemplo n.º 5
0
 def encoding_profile_menu(self, menuw=None, arg=None):
     logger.debug('encoding_profile_menu(self, menuw=None, arg=None)')
     #create a menu with a few encoding options (1cd, 2cd, xvid, mpeg4)
     #args : tuple, (videocodec, size, multipass
     menu_items = [
         menu.MenuItem("XviD, 800bps", self.create_job,
                       (0, 0, 1, None, 700, False, 800))
     ]
     menu_items.append(
         menu.MenuItem("XviD, 800bps, High Quality", self.create_job,
                       (0, 0, 1, None, 700, True, 800)))
     menu_items.append(
         menu.MenuItem("XviD, 1200bps", self.create_job,
                       (0, 0, 1, None, 1400, False, 1200)))
     menu_items.append(
         menu.MenuItem("XviD, 1200bps, High Quality", self.create_job,
                       (0, 0, 1, None, 1400, True, 1200)))
     menu_items.append(
         menu.MenuItem("DivX, 800bps", self.create_job,
                       (0, 0, 0, None, 700, False, 800)))
     menu_items.append(
         menu.MenuItem("DivX, 800bps, High Quality", self.create_job,
                       (0, 0, 0, None, 700, True, 800)))
     menu_items.append(
         menu.MenuItem("DivX, 1200bps", self.create_job,
                       (0, 0, 0, None, 1400, False, 1200)))
     menu_items.append(
         menu.MenuItem("DivX, 1200bps, High Quality", self.create_job,
                       (0, 0, 0, None, 1400, True, 1200)))
     menu_items.append(
         menu.MenuItem("iPod", self.create_job,
                       (2, 2, 2, None, None, False, 1200)))
     encoding_menu = menu.Menu(_('Choose your encoding profile'),
                               menu_items)
     menuw.pushmenu(encoding_menu)
Exemplo n.º 6
0
    def onchoose_node(self, arg=None, menuw=None):
        """
        browse through a tree specification
        """
        tree = arg[0]
        data = arg[1]
        title = '-'.join(data)

        mylistofitems = []

        if len(tree.spec) - 1 <> len(data):  #non-tracks
            for tree_item, count in tree.execute(data):
                mylistofitems.append(
                    menu.MenuItem("%s(%i)" % (tree_item, count),
                                  action=self.onchoose_node,
                                  arg=[tree, data + [tree_item]]))
        else:  #tracks
            self.onchoose_last_node(tree, data, menuw)
            return

        #should be impossible?
        if (len(mylistofitems) == 0):
            mylistofitems += [
                menu.MenuItem(_('No Objects found'), menuw.back_one_menu, 0)
            ]

        myobjectmenu = menu.Menu(title, mylistofitems)
        #reload_func=menuw.back_one_menu )
        rc.app(None)
        menuw.pushmenu(myobjectmenu)
        menuw.refresh()
Exemplo n.º 7
0
    def find_more(self, arg=None, menuw=None):
        """
        Find more of this program
        """

        _debug_(String('searching for: %s' % self.prog.title))

        pop = AlertBox(text=_('Searching, please wait...'))
        pop.show()

        items = []
        (result, matches) = record_client.findMatches(self.prog.title)

        pop.destroy()
        if result:
            _debug_('search found %s matches' % len(matches))

            f = lambda a, b: cmp(a.start, b.start)
            matches.sort(f)
            for prog in matches:
                items.append(ProgramItem(self, prog, context='search'))
        else:
            if matches == 'no matches':
                msgtext = _('No matches found for %s') % self.prog.title
                AlertBox(text=msgtext).show()
                return
            AlertBox(text=_('findMatches failed: %s') % matches).show()
            return

        search_menu = menu.Menu(_('Search Results'),
                                items,
                                item_types='tv program menu')

        menuw.pushmenu(search_menu)
        menuw.refresh()
Exemplo n.º 8
0
    def generate_station_list(self, arg=None, menuw=None):
        """
        Generates the Station List
        """
        stationlist = []
        pop = ProgressBox(text=_('Fetching station list for %s') % arg, full=2)
        pop.show()
        xmlfile = self.retrievexml(arg)
        pop.tick()

        if xmlfile == None:
            stationlist = [
                menu.MenuItem(_('Error retrieving stations'),
                              action=menuw.back_one_menu,
                              arg=None)
            ]
        else:
            try:
                parser = make_parser()
                parseStationXML = StationParser()
                parser.setContentHandler(parseStationXML)
                parser.parse(xmlfile)
                for station in parseStationXML.stationlist:
                    statid = urllib2.quote(station["id"])
                    statname = station["name"]
                    statbr = station["br"]
                    statct = station['ct']
                    if int(statbr) >= self.min_bitrate and (
                            self.max_bitrate == 0
                            or int(statbr) <= self.max_bitrate):
                        stationitem = AudioItem(
                            'http://www.shoutcast.com%s?id=%s' %
                            (parseStationXML.tunein, statid), self, statname,
                            False)
                        stationitem.player = 'mplayer'
                        stationitem.reconect = True
                        stationitem.network_play = True
                        stationitem.is_playlist = True
                        stationitem.bitrate = int(statbr)
                        stationitem.length = 0
                        stationitem.remain = 0
                        stationitem.info = {
                            'title':
                            statname,
                            'description':
                            '%s - %skbs' % (station['genre'], statbr)
                        }
                        stationlist.append(stationitem)
                    stationlist.sort(key=self.stationsortkey)
            except:
                stationlist = [
                    menu.MenuItem(_('Error retrieving stationlist'),
                                  action=menuw.back_one_menu,
                                  arg=None)
                ]

            stationmenu = menu.Menu(arg, stationlist, item_types='audio')
            menuw.pushmenu(stationmenu)
            menuw.refresh()
            pop.destroy()
Exemplo n.º 9
0
 def make_menu(self, arg=None, menuw=None):
     category = []
     keylist = self.categories_tv.keys()
     keylist.sort()
     for key in keylist:
         category.append(Nation(key, self.categories_tv[key], self))
     menuw.pushmenu(menu.Menu(_('Choose a Category'), category))
Exemplo n.º 10
0
 def show_choices(self, menuw, info):
     items = []
     soup = BeautifulStoneSoup(info, selfClosingTags=['feat'])
     results = soup.findAll('result')
     for result in results[:20]:
         # for performance reasons show the first possibilities only,
         # the more sensible hits are at the beginning of the list
         hid = result['hid']
         title = result.titleTag.string.replace('&amp;', '&')
         artist = result.artistTag.nameTag.string.replace('&amp;', '&')
         items.append(
             menu.MenuItem('%s - %s' % (title, artist),
                           action=self.fetch_lyric,
                           arg=hid))
     if len(items) > 0:
         msgtext = _('No exact match. ')
         msgtext += _('Here are some sugestions.')
         box = PopupBox(text=msgtext)
         box.show()
         time.sleep(2)
         box.destroy()
         choices_menu = menu.Menu(_('Choices'), items)
         menuw.pushmenu(choices_menu)
     else:
         box = PopupBox(text=_('Lyrics not found, sorry...'))
         box.show()
         time.sleep(3)
         box.destroy()
Exemplo n.º 11
0
    def configure(self, arg=None, menuw=None):
        """
        show the configure dialog for folder specific settings in folder.fxd
        """
        items = []
        for i, name, descr, type_list in self.all_variables:
            if name == '':
                continue
            name += '\t' + self.configure_set_name(i)
            mi = menu.MenuItem(name, self.configure_set_var, i)
            mi.description = descr
            items.append(mi)

        if self.parent and self.parent.display_type:
            if self.display_type:
                name = u'\tICON_RIGHT_OFF_' + _('off')
            else:
                name = u'\tICON_RIGHT_ON_' + _('on')

            mi = menu.MenuItem(
                _('Show all kinds of items') + name,
                self.configure_set_display_type)
            mi.description = _(
                'Show video, audio and image items in this directory')
            items.append(mi)

        m = menu.Menu(_('Configure'), items)
        m.table = (80, 20)
        m.back_one_menu = 2
        menuw.pushmenu(m)
Exemplo n.º 12
0
    def find_long_and_frequent(self):
        print(
            'Программа, которая принимает текст и выводит два слова: наиболее часто встречающееся и самое длинное.'
        )
        string = self.input_string()
        string = string.split(' ')
        longword = max(string, key=len)

        def counter(string):
            count = 0
            dict = {}
            for x in string:
                for j in string:
                    if x == j:
                        count += 1
                dict[count] = x
                count = 0
            return dict[max(dict)]

        print('Самое длинное слово: ', longword,
              '.Самое часто встречаемое слова: ', counter(string))

        menu.Menu().menu_after_task(
            repeat='task_strings.Tasks_string().find_long_and_frequent()',
            back='self.menu_string()')
Exemplo n.º 13
0
    def start(self):
        # 显示初始菜单
        self.__logger.somewhere_info("client start!")
        table = menu.Menu()
        table.login_menu()
        choose = input()
        if '1' == choose:
            nm_ps = table.login_input_message()
            id = user.User(nm_ps[0], nm_ps[1])
            # 给服务端发送用户名密码消息
            connect = sock.Sock()
            connect.load_message(message.Message(type='1', is_end='5', message_length='0',
                                                 user_name=id.username, pass_word=id.password))
            if connect.send_message():
                root = tk.Tk()
                root.title('somewhere')
                app = Application(master=root, username=id.username)
                app.mainloop()



        elif '2' == choose:
            print("bye ~ see you then")
        else:
            print("wrong choose")
            print("bye ~ see you then")
Exemplo n.º 14
0
    def display_recitem(self, arg=None, menuw=None):
        _debug_('display_recitem(self, arg=None, menuw=None)', 2)
        if not self.recordclient.pingNow():
            AlertBox(self.recordclient.recordserverdown).show()
            return

        self.make_newprog()

        items = []

        items.append(menu.MenuItem(_('Modify name'), action=self.mod_name))
        items.append(
            menu.MenuItem(_('Modify channel'), action=self.mod_channel))
        items.append(
            menu.MenuItem(_('Modify start month'),
                          action=self.mod_start_month))
        items.append(
            menu.MenuItem(_('Modify start day'), action=self.mod_start_day))
        items.append(
            menu.MenuItem(_('Modify start time'), action=self.mod_start_time))
        items.append(
            menu.MenuItem(_('Modify stop month'), action=self.mod_stop_month))
        items.append(
            menu.MenuItem(_('Modify stop day'), action=self.mod_stop_day))
        items.append(
            menu.MenuItem(_('Modify stop time'), action=self.mod_stop_time))
        items.append(menu.MenuItem(_('Save'), action=self.save_changes))

        manualrecord_menu = menu.Menu(_('Record Item Menu'),
                                      items,
                                      item_types='tv manual record menu')
        manualrecord_menu.infoitem = self
        menuw.pushmenu(manualrecord_menu)
        menuw.refresh()
Exemplo n.º 15
0
    def create_backup_items(self, arg, menuw):
        items = []

        if config.LAME_CMD:
            items.append(
                menu.MenuItem(_('Backup CD to hard drive in mp3 format'),
                              self.cd_backup,
                              arg=(arg, 'mp3')))
        if config.OGGENC_CMD:
            items.append(
                menu.MenuItem(_('Backup CD to hard drive in Ogg format'),
                              self.cd_backup,
                              arg=(arg, 'ogg')))
        if config.FLAC_CMD:
            items.append(
                menu.MenuItem(_('Backup CD to hard drive in FLAC format'),
                              self.cd_backup,
                              arg=(arg, 'flac')))
        items.append(
            menu.MenuItem(_('Backup CD to hard drive in wav format'),
                          self.cd_backup,
                          arg=(arg, 'wav')))

        backupmenu = menu.Menu(_('CD Backup'),
                               items,
                               reload_func=self.create_backup_menu)
        return backupmenu
Exemplo n.º 16
0
 def __init__(self, ui, state, opts, desc):
     self.ui = ui
     self.state = state
     self.items = self._create_menu(opts, desc)
     self.menu = menu.Menu(ui, self.items)
     self.in_menu = False
     self.last_level = ""
     self.last_level_ts = 0
     self.audio_state = "init"
     self.last_button_ts = None
     self.is_blanking = False
     self.last_backlight = self.ui.BACK_OFF
     self.allow_blank = True
     self.allow_chime = True
     self.ping_state = None
     self.ping_step = 0
     self.restart_ts = None
     # state
     self.is_connected = False
     self.is_audio_active = False
     self.is_audio_muted = False
     self.is_audio_playing = False
     self.is_audio_listen = False
     self._print_state()
     self._print_title()
     self._print_value()
Exemplo n.º 17
0
    def event(self, e):
        if e.type is MOUSEMOTION:
            for n, r in self.rects:
                if r.collidepoint(e.pos):
                    self.cur = n
                    #self.repaint()

        elif e.type == JOYAXISMOTION:
            if e.axis == 1:
                if round(e.value) < 0:
                    self.cur = (self.cur - 1 + len(self.menu)) % len(self.menu)
                elif round(e.value) > 0:
                    self.cur = (self.cur + 1 + len(self.menu)) % len(self.menu)

        elif e.type is KEYDOWN:
            if e.key == K_UP:
                self.cur = (self.cur - 1 + len(self.menu)) % len(self.menu)
                #self.repaint()
            if e.key == K_DOWN:
                self.cur = (self.cur + 1 + len(self.menu)) % len(self.menu)
                #self.repaint()
        if (e.type is KEYDOWN and e.key == K_RETURN) or e.type in [
                MOUSEBUTTONDOWN, JOYBUTTONDOWN
        ]:
            text, action = self.menu[self.cur]
            if action == 'start':
                if pygame.mixer:
                    pygame.mixer.music.stop()
                g = self.game
                g.data_reset()
                import menu
                return menu.Menu(self.game)
            else:
                return action(self.game)
Exemplo n.º 18
0
 def draw(self):
     pygame.init()
     pygame.display.set_caption("Records")
     while True:
         self.timer.tick(200)
         self.screen.blit(self.bg, (0, 0))
         font = pygame.font.Font(None, 25)
         text = font.render("Name", True, (255, 255, 255))
         self.screen.blit(text, [10, 15])
         text = font.render("Levels", True, (255, 255, 255))
         self.screen.blit(text, [150, 15])
         text = font.render("Score", True, (255, 255, 255))
         self.screen.blit(text, [250, 15])
         x = 50
         for i in range(0, min(10, len(self.players))):
             color = (255, 255, 255)
             if i == self.player_index:
                 color = (0, 255, 0)
             text = font.render(self.players[i].name, True, color)
             self.screen.blit(text, [10, x])
             text = font.render(self.players[i].levels, True, color)
             self.screen.blit(text, [150, x])
             text = font.render(str(self.players[i].score), True, color)
             self.screen.blit(text, [250, x])
             x += 25
         for e in pygame.event.get():
             if e.type == pygame.QUIT:
                 sys.exit()
             if e.type == pygame.KEYDOWN and e.key == pygame.K_ESCAPE:
                 menu.Menu()
         pygame.display.update()
Exemplo n.º 19
0
    def handle_server_coms(self):
        if (not self.is_socket_connected_to_server):
            self.logger.add_message("Connecting to server...")

            self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            try:
                self.socket.connect((HOST, PORT))
            except ConnectionRefusedError:
                menu.Menu(self.client, "Connection to server failed")
            self.logger.add_message("Connection successful.")
            self.is_socket_connected_to_server = True

        if (self.session_state == "nosession"):
            self.logger.add_message("Trying to join a session...")
            self.session_state = "request"
            send_serveur.connect(self.socket, self.username)
        elif (self.session_state == "jeu"):
            # send_serveur.newpos(self.socket, self.main_player.pos)

            if (time.time() - self.last_newcom > 1 / SERVER_TICKRATE):
                send_serveur.newcom(self.socket,
                                    self.main_player.command_angle,
                                    self.main_player.command_thrust,
                                    self.main_player.hasShoot)
                self.main_player.hasShoot = False
                self.last_newcom = time.time()

                # Commands sent, reset
                self.main_player.command_angle = 0
                self.main_player.command_thrust = 0

        self.handle_server_responses()
Exemplo n.º 20
0
def start_module(selfURL):
    menu.cfg.title = "SystemInfo"
    menu.Menu()

    SystemInfo()

    menu.print_footer()
Exemplo n.º 21
0
    def mod_time(self, arg=None, menuw=None):
        """ Modify time

        Opens a submenu where the time of a favorite can be configured.
        """
        items = []

        items.append(
            menu.MenuItem('ANY TIME',
                          action=self.alter_prop,
                          arg=('mod', 'ANY')))

        for i in range(48):
            mod = i * 30
            items.append(
                menu.MenuItem(strftime(config.TV_TIMEFORMAT,
                                       gmtime(float(mod * 60))),
                              action=self.alter_prop,
                              arg=('mod', mod)))

        favorite_menu = menu.Menu(_('Modify Time'),
                                  items,
                                  item_types='tv favorite menu')
        favorite_menu.infoitem = self
        menuw.pushmenu(favorite_menu)
        menuw.refresh()
Exemplo n.º 22
0
 def __init__(self):
     self.screen = pygame.display.set_mode((800, 600))
     pygame.display.set_caption("Painter")
     self.clock = pygame.time.Clock()
     self.brush = brush.Brush(self.screen)
     self.menu = menu.Menu(self.screen)
     self.menu.set_brush(self.brush)
Exemplo n.º 23
0
 def lose(self):
     if int(self.lives) <= 0:
         self.win.fill((0, 0, 0))
         self.win.blit(
             pygame.font.SysFont("arial", 35,
                                 "light").render(self.loss_text, True,
                                                 (255, 255, 255)),
             (300, 200))
         self.Texts = [
             f"score : {self.scoreNum}", f"wave : {self.waveNum}",
             f"lives : {self.lives}",
             f"prepare for wave number {self.waveNum}"
         ]
         for i in range(3):
             self.win.blit(
                 self.font.render(self.Texts[i], True, (255, 255, 255)),
                 (320, 240 + i * 40))
         self.refresh()
         time.sleep(5)
         m = menu.Menu()
         st = m.main()
         if st[0]:
             g = Game(st[1])
             g.gameLoop()
     for i, v in enumerate(self.details):
         if v[1] > 600:
             self.lives = str(int(self.lives) - 1)
             self.details.remove(v)
         self.Texts = [
             f"score : {self.scoreNum}", f"wave : {self.waveNum}",
             f"lives : {self.lives}"
         ]
Exemplo n.º 24
0
    def decTimer(self, gameDisplay):
        if not self._loseGame:
            self._timer -= 1

            if self._beginWaveTimer == 0 and not self._waveOn:
                self._wave.incWaveNumber()
                self._waveOn = True
            else:
                if not self._enemiesList and (self._spawnEnemieCount == 10
                                              or self._spawnEnemieCount == 0):
                    self._waveOn = False
                    self._spawnEnemieCount = 0
                    self._beginWaveTimer -= 1

            if self._waveOn:
                self._enemieTimer -= 1

            for towerAux in self.getTowers():
                towerAux.decReloadTime()

            for trapAux in self.getTraps():
                trapAux.decReloadTime()

            for enemieAux in self.getEnemies():
                enemieAux.executeEffects(self)
        else:
            self._endTimer -= 1
            self.paintLoseGameMessage(gameDisplay)
            if self._endTimer == 0:
                pygame.quit()
                menu = MENU.Menu()
                menu.start()
Exemplo n.º 25
0
 def Action(self):
     time.sleep(5)
     new = menu.Menu()
     new.menuRun()
     mainFrame.MainFrame.check = False
     pygame.display.update()
     '''for event in pygame.event.get():
Exemplo n.º 26
0
    def info_showdata(self, arg=None, menuw=None):
        """
        show info for this item
        """
        actions = self.item.actions()
        plugins = plugin.get('item') + plugin.get('item_video')

        plugins.sort(lambda l, o: cmp(l._level, o._level))

        for p in plugins:
            if p != self:
                for a in p.actions(self.item):
                    if isinstance(a, menu.MenuItem):
                        actions.append(a)
                    else:
                        actions.append(a[:2])

        items = []
        for a in actions:
            if not isinstance(a, item.Item):
                a = menu.MenuItem(a[1], a[0])
            a.subtitle = self.item.name
            a.title    = self.item.name
            items.append(a)

        m = menu.Menu(_('Details'), items)
        m.infoitem   = self.item
        m.viewitem   = self.item
        m.item_types = 'video details'
        m.is_submenu = True
        menuw.pushmenu(m)
Exemplo n.º 27
0
 def create_stations_menu(self, arg=None, menuw=None):
     station_items = []
     for rstation in config.RADIO_STATIONS:
         radio_item = RadioItem()
         radio_item.name = rstation[0]
         radio_item.station = rstation[1]
         radio_item.url = 'radio://' + str(rstation[1])
         radio_item.type = 'radio'
         radio_item.station_index = config.RADIO_STATIONS.index(rstation)
         radio_item.length = 0
         radio_item.remain = 0
         radio_item.elapsed = 0
         radio_item.info = {
             'album': '',
             'artist': '',
             'trackno': '',
             'title': ''
         }
         station_items += [radio_item]
     if (len(station_items) == 0):
         station_items += [
             menu.MenuItem(_('No Radio Stations found'),
                           menwu.goto_prev_page, 0)
         ]
     station_menu = menu.Menu(_('Radio Stations'), station_items)
     rc.app(None)
     menuw.pushmenu(station_menu)
     menuw.refresh()
Exemplo n.º 28
0
    def create_commands_menu(self, arg=None, menuw=None):
        """
        create a list with commands
        """
        command_items = []
        for command in os.listdir(config.COMMANDS_DIR):
            if os.path.splitext(command)[1] in ('.jpg', '.png'):
                continue
            if os.path.splitext(command)[1] in ('.fxd', '.xml'):
                fxd_file = os.path.join(config.COMMANDS_DIR, command)

                # create a basic fxd parser
                parser = util.fxdparser.FXD(fxd_file)

                # create items to add
                parser.setattr(None, 'items', command_items)

                # set handler
                parser.set_handler('command', fxdparser)

                # start the parsing
                parser.parse()
            else:
                cmd_item = CommandItem(command, config.COMMANDS_DIR)
                command_items.append(cmd_item)

        command_items.sort(lambda l, o: cmp(l.name.upper(), o.name.upper()))
        command_menu = menu.Menu(_('Commands'), command_items)
        menuw.pushmenu(command_menu)
        menuw.refresh()
Exemplo n.º 29
0
    def create_podcast_menu(self, arg=None, menuw=None):
        popup = PopupBox(text=_('Fetching podcast...'))
        popup.show()
        podcast_menu_items = []

        for location in config.APODCAST_LOCATIONS:
            url = location[1]
            image_path = os.path.join(config.APODCAST_DIR, location[0],
                                      'cover.jpg')
            if self.check_logo(image_path):
                p = podcast()
                p.open_rss(url)
                p.rss_title()
                name = p.rss_title
                image_url = p.rss_image
                self.download(image_url, image_path)

            if (len(config.APODCAST_DIR) == 0):
                podcast_items += [
                    menu.MenuItem(_('Set APODCAST_DIR in local_conf.py'),
                                  menwu.back_one_menu, 0)
                ]
            podcast_menu_items += [
                menu.MenuItem(_(location[0]),
                              action=self.create_podcast_submenu,
                              arg=location,
                              image=image_path)
            ]

        popup.destroy()
        podcast_main_menu = menu.Menu(_('AUDIO PODCAST'), podcast_menu_items)
        menuw.pushmenu(podcast_main_menu)
        menuw.refresh()
Exemplo n.º 30
0
 def cwd(self, arg=None, menuw=None):
     """
     make a menu item for each file in the directory
     """
     items = []
     parentPath = self.path
     if len(parentPath) == 1:
         parentPath = ""
     print "cwd for" + parentPath
     # Append Folders
     folders = pygphoto.gp_getsubfolders(self.gCamera, self.path)
     number = pygphoto.gp_list_count(folders)
     while number > 0:
         number = number - 1
         name = pygphoto.gp_name(folders, number)
         subFolder = CameraFolder(self, self.gCamera,
                                  parentPath + "/" + name, name)
         items.append(subFolder)
     files = pygphoto.gp_getfiles(self.gCamera, self.path)
     number = pygphoto.gp_list_count(files)
     while number > 0:
         number = number - 1
         name = pygphoto.gp_name(files, number)
         subFile = CameraFile(self, self.gCamera, parentPath, name)
         items.append(subFile)
     item_menu = menu.Menu(self.name, items)
     menuw.pushmenu(item_menu)
     return items