当前位置: 首页>>代码示例>>Python>>正文


Python MameWahIni.get方法代码示例

本文整理汇总了Python中mamewah_ini.MameWahIni.get方法的典型用法代码示例。如果您正苦于以下问题:Python MameWahIni.get方法的具体用法?Python MameWahIni.get怎么用?Python MameWahIni.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mamewah_ini.MameWahIni的用法示例。


在下文中一共展示了MameWahIni.get方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from mamewah_ini import MameWahIni [as 别名]
# 或者: from mamewah_ini.MameWahIni import get [as 别名]
 def __init__(self, glade_filename, window_name, WinSetup):
     """build the dialog"""
     GladeSupport.__init__(self, glade_filename, window_name, APP_NAME)
     self.dlgAddEmu.set_transient_for(WinSetup.winSetup)
     self.dlgAddEmu.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
     #winsetup class
     self.WinSetup = WinSetup
     #create new emulator list
     self.tvw, self.ls, self.tvws = self.setup_treeview(
         columns = [_('Select an Emulator Template...')],
         column_types = [gobject.TYPE_STRING, gobject.TYPE_STRING,
             gobject.TYPE_STRING],
         container = self.scw,
         resizeable_cols = False)
     #get list of available templates
     emu_ini_files = glob.glob(os.path.join(APP_PATH, 'templates', '*.ini'))
     for emu_ini in emu_ini_files:
         ini = MameWahIni(emu_ini)
         if not ini.has_option('list_title'):
             basename = os.path.splitext(os.path.basename(emu_ini))[0]
             self.ls.append(
                 ('%s (%s)' % (ini.get('emulator_title'), basename),
                 basename,
                 emu_ini))
     #set dialog size
     num = len(self.ls)
     if num > 10:
         num = 10
     self.dlgAddEmu.set_size_request(320, 120 + (num * 15))
     #sort
     self.ls.set_sort_column_id(0, gtk.SORT_ASCENDING)
开发者ID:gglass,项目名称:blinkywah,代码行数:33,代码来源:wc_setup.py

示例2: __init__

# 需要导入模块: from mamewah_ini import MameWahIni [as 别名]
# 或者: from mamewah_ini.MameWahIni import get [as 别名]
 def __init__(self, glade_filename, window_name, emu_name, emu_list_idx):
     """build the window"""
     WahCade.__init__(self)
     GladeSupport.__init__(self, glade_filename, window_name, APP_NAME)
     self.config_dir = CONFIG_DIR
     self.emu_name = emu_name
     self.emu_list_idx = emu_list_idx
     #games list
     self.tvwList, self.lsList, self.tvwsList = self.setup_treeview(
         columns = [
             'Game Name',
             'ROM Name',
             'Year',
             'Manufacturer',
             'Clone Of',
             'Rom Of',
             'Display Type',
             'Screen Type',
             'Controller Type',
             'Driver Status',
             'Colour Status',
             'Sound Status',
             'Category'],
         column_types = [gobject.TYPE_STRING] * self.NUM_COLS,
         container = self.scwList,
         edit_cell_cb = self.on_tvwList_edited,
         resizeable_cols = True,
         highlight_rows = False)
     #self.tvwList.connect('row-activated', self.on_tvwList_activated)
     self.tvwList.connect('key-release-event', self.on_tvwList_key_event)
     #activate multiple selection mode on tvwsList
     self.tvwsList.set_mode(gtk.SELECTION_MULTIPLE)
     #load lists
     i = 0
     emu_game_lists = []
     while True:
         ini_file = os.path.join(self.config_dir, 'ini', '%s-%s.ini' % (self.emu_name, i))
         if os.path.isfile(ini_file):
             list_ini = MameWahIni(ini_file)
             emu_game_lists.append(list_ini.get('list_title'))
             i += 1
         else:
             break
     l = ['%s: %s' % (i, r) for i, r in enumerate(emu_game_lists)]
     self.setup_combo_box(self.cboList, l)
     #setup filters & emu ini
     emu_ini_filename = os.path.join(self.config_dir, 'ini', '%s.ini' % (self.emu_name))
     if os.path.isfile(emu_ini_filename):
         self.emu_ini = MameWahIni(emu_ini_filename)
         #filters._mameinfo_file = os.path.join(self.emu_ini.get('dat_file'))
         filters._catver_ini = os.path.join(self.emu_ini.get('catver_ini_file'))
     else:
         print _("Error: Emulator Ini file: [%s] doesn't exist" % (emu_ini_filename))
     #load filter
     self.new_iter = None
     self.new_path = None
     self.new_col = 0
     self.list_altered = False
     self.cboList.set_active(self.emu_list_idx)
开发者ID:FruitieX,项目名称:wahcade,代码行数:61,代码来源:win_list.py

示例3: buildemulist

# 需要导入模块: from mamewah_ini import MameWahIni [as 别名]
# 或者: from mamewah_ini.MameWahIni import get [as 别名]
 def buildemulist(self):
     emu_lists = []
     emu_ini_files = self.build_filelist("", "ini", "(.*(?<!=-))")
     for emu_ini in emu_ini_files:
         ini = MameWahIni(emu_ini)
         if not ini.has_option('list_title'):
             emu_lists.append(
                 [ini.get('emulator_title'),
                  os.path.splitext(os.path.basename(emu_ini))[0],ini])
     return emu_lists
开发者ID:FruitieX,项目名称:wahcade,代码行数:12,代码来源:wc_common.py

示例4: load_emulator_settings

# 需要导入模块: from mamewah_ini import MameWahIni [as 别名]
# 或者: from mamewah_ini.MameWahIni import get [as 别名]
 def load_emulator_settings(self, ini_name, emu_ini, default_list=0):
     """load emu settings"""
     self.txeEmuTitle.set_text(emu_ini.get('emulator_title'))
     self.txeEmuExe.set_text(emu_ini.get('emulator_executable'))
     self.txeEmuCmdLine.set_text(emu_ini.get('commandline_format'))
     self.txeEmuAltCmdLine1.set_text(emu_ini.get('alt_commandline_format_1'))
     self.txeEmuAltCmdLine2.set_text(emu_ini.get('alt_commandline_format_2'))
     self.txeEmuRomExt.set_text(emu_ini.get('rom_extension'))
     self.txeEmuRomDir.set_text(emu_ini.get('rom_path'))
     self.txeEmuNMSFile.set_text(emu_ini.get('nms_file'))
     #list gen type
     ini_lgen = emu_ini.get('list_generation_method')
     lgen_idx = [idx for idx, r in enumerate(self.emu_list_gen_types) if ini_lgen in r[0]][0]
     self.cboEmuListGen.set_active(lgen_idx)
     #artwork
     for idx, emu_art in enumerate(self.emu_artwork_txe):
         emu_art.set_text(emu_ini.get('artwork_%s_image_path' % (idx + 1)))
     self.txeEmuMovieDir.set_text(emu_ini.get('movie_preview_path'))
     self.spnEmuMovieNum.set_value(emu_ini.getint('movie_artwork_no'))
     self.cboeEmuExtApp1.child.set_text(emu_ini.get('app_1_executable'))
     self.txeEmuExtApp1.set_text(emu_ini.get('app_1_commandline_format'))
     self.cboeEmuExtApp2.child.set_text(emu_ini.get('app_2_executable'))
     self.txeEmuExtApp2.set_text(emu_ini.get('app_2_commandline_format'))
     self.cboeEmuExtApp3.child.set_text(emu_ini.get('app_3_executable'))
     self.txeEmuExtApp3.set_text(emu_ini.get('app_3_commandline_format'))
     self.txeEmuExtAuto.set_text(emu_ini.get('auto_launch_apps'))
     #screen saver
     ini_scr = emu_ini.get('saver_type')
     scr_idx = [idx for idx, r in enumerate(self.emu_scrsave_types) if r[0] == ini_scr][0]
     self.cboEmuScrSaver.set_active(scr_idx)
     self.txeEmuScrMovieDir.set_text(emu_ini.get('movie_path'))
     self.txeEmuScrExternal.set_text(emu_ini.get('scr_file'))
     #load lists
     i = 0
     self.emu_game_lists = []
     while True:
         ini_file = os.path.join(self.config_dir, 'ini', '%s-%s.ini' % (ini_name, i))
         if os.path.isfile(ini_file):
             list_ini = MameWahIni(ini_file)
             self.emu_game_lists.append([list_ini.get('list_title'), list_ini])
             i += 1
         else:
             break
     l = ['%s: %s' % (i, r[0]) for i, r in enumerate(self.emu_game_lists)]
     self.setup_combo_box(self.cboEmuLists, l)
     self.cboEmuLists.set_active(default_list)
     #mame only
     if ini_name in MAME_INI_FILES:
         self.vboxMame.set_sensitive(True)
         self.txeMameXMLFile.set_text(emu_ini.get('dat_file'))
         self.txeMameCatver.set_text(emu_ini.get('catver_ini_file'))
     else:
         self.vboxMame.set_sensitive(False)
         self.txeMameXMLFile.set_text('')
         self.txeMameCatver.set_text('')
开发者ID:vivanno,项目名称:myWah-cade,代码行数:57,代码来源:wc_setup.py

示例5: load_settings

# 需要导入模块: from mamewah_ini import MameWahIni [as 别名]
# 或者: from mamewah_ini.MameWahIni import get [as 别名]
 def load_settings(self, default_emu=None):
     """load wahcade settings"""
     #build list of emulators
     self.emu_lists = []
     self.emu_game_lists = []
     self.current_emu = None
     self.current_emu_list = None
     emu_ini_files = glob.glob(os.path.join(self.config_dir, 'ini', '*.ini'))
     for emu_ini in emu_ini_files:
         ini = MameWahIni(emu_ini)
         if not ini.has_option('list_title'):
             self.emu_lists.append(
                 [ini.get('emulator_title'),
                 os.path.splitext(os.path.basename(emu_ini))[0],
                 ini])
     self.emu_lists.sort()
     #load emu combo
     l = ['%s (%s.ini)' % (e[0], e[1]) for e in self.emu_lists]
     self.setup_combo_box(self.cboEmu, l)
     #wahcade
     self.txeWCLayoutDir.set_text(self.wahcade_ini.get('layout'))
     self.chkWCFullscreen.set_active((self.wahcade_ini.getint('fullscreen', 0) == 1))
     self.spnWCScrDelay.set_value(self.wahcade_ini.getint('delay'))
     self.spnWCScrSlide.set_value(self.wahcade_ini.getint('slide_duration'))
     self.spnWCMovieDelay.set_value(self.wahcade_ini.getint('delay_before_movie_preview'))
     self.hscWCMovieVolume.set_value(self.wahcade_ini.getint('movie_volume'))
     ini_mix = self.wahcade_ini.get('music_movie_mix')
     mix_idx = [idx for idx, r in enumerate(self.music_movie_mix) if r[0] == ini_mix][0]
     self.cboWCMovieMix.set_active(mix_idx)
     self.txeWCMovieIntro.set_text(self.wahcade_ini.get('intro_movie_file'))
     self.txeWCMovieExit.set_text(self.wahcade_ini.get('exit_movie_file'))
     self.txeWCMusicDir.set_text(self.wahcade_ini.get('music_path'))
     self.chkWCMusic.set_active((self.wahcade_ini.getint('enable_music', 0) == 1))
     self.hscWCMusicVolume.set_value(self.wahcade_ini.getint('music_volume'))
     self.chkWCMusicShuffle.set_active((self.wahcade_ini.getint('shuffle_music', 0) == 1))
     self.chkWCMouseCursor.set_active((self.wahcade_ini.getint('show_cursor') == 1))
     self.chkWCWrapLists.set_active((self.wahcade_ini.getint('wrap_list') == 1))
     self.chkWCScaleImages.set_active((self.wahcade_ini.getint('keep_image_aspect') == 1))
     self.chkWCListArrows.set_active((self.wahcade_ini.getint('show_list_arrows', 0) == 1))
     #set emu
     set_idx = 0
     if default_emu:
         set_idx = [idx for idx, e in enumerate(self.emu_lists) if e[1] == default_emu][0]
     self.cboEmu.set_active(set_idx)
     #mame history viewer
     self.txeHstDatFile.set_text(self.histview_ini.get('history_dat_file'))
     self.txeHstLayout.set_text(self.histview_ini.get('history_layout'))
     #mame cp viewer
     self.txeCPVIni.set_text(self.cpviewer_ini.get('controls_ini_file'))
     self.txeCPVLayout.set_text(self.cpviewer_ini.get('viewer_layout'))
     #load keys
     self.chkKeysUseKeyboard.set_active((self.ctrlr_ini.getint('keyboard') == 1))
     self.chkKeysUseMouse.set_active((self.ctrlr_ini.getint('mouse') == 1))
     self.chkKeysUseJoystick.set_active((self.ctrlr_ini.getint('joystick') == 1))
     self.populate_keys()
开发者ID:vivanno,项目名称:myWah-cade,代码行数:57,代码来源:wc_setup.py

示例6: on_cboLists_changed

# 需要导入模块: from mamewah_ini import MameWahIni [as 别名]
# 或者: from mamewah_ini.MameWahIni import get [as 别名]
 def on_cboLists_changed(self, *args):
     """emulator list combo"""
     #get settings for current emu list
     self.emu_list_idx = self.cboLists.get_active()
     emu_list_ini = MameWahIni(os.path.join(self.config_dir, 'ini', '%s-%s.ini' % (self.emu_name, self.emu_list_idx)))
     if self.emu_list_idx >= 1:
         if emu_list_ini.get('list_type') != 'normal':
             self.show_msg_dialog(msg=_('List Type must be "normal" to generate filters'))
             self.cboLists.set_active(0)
             return
     if self.emu_list_idx >= 0:
         self.load_filter()
开发者ID:gglass,项目名称:blinkywah,代码行数:14,代码来源:win_filter.py

示例7: build_filelist

# 需要导入模块: from mamewah_ini import MameWahIni [as 别名]
# 或者: from mamewah_ini.MameWahIni import get [as 别名]
 def build_filelist(self, type, ext="ini", regex="(?<=-)\d+", emu="", sep=""):
     """return array of files numbers matching regex value"""
     filelist = []
     fileset = glob.glob(os.path.join(CONFIG_DIR, ext, emu + sep + '*.' + ext))
     for file in fileset:
         m = re.search(regex,file)
         if m is not None:
             if type == "int":
                 filelist.append(self.return_listnum(file))
             elif type == "glist":
                 if os.path.isfile(file):
                     list_ini = MameWahIni(file)
                     filelist.append('%s: %s' % (self.return_listnum(file),list_ini.get('list_title')))
             else:
                 filelist.append(file)
     filelist.sort()
     return filelist
开发者ID:FruitieX,项目名称:wahcade,代码行数:19,代码来源:wc_common.py

示例8: WinHistory

# 需要导入模块: from mamewah_ini import MameWahIni [as 别名]
# 或者: from mamewah_ini.MameWahIni import get [as 别名]
class WinHistory(WahCade):
    """History Window"""

    def __init__(self, WinMain):
        # set main window
        self.WinMain = WinMain
        self.layout_filename = ""
        self.histview_ok = True
        # open history viewer ini
        self.histview_ini = MameWahIni(os.path.join(CONFIG_DIR, "histview.ini"), "default", "0.16")
        if not os.path.isfile(self.histview_ini.get("history_dat_file")):
            self.WinMain.log_msg(
                "Warning: history file: [%s] does not exist" % (self.histview_ini.get("history_dat_file"))
            )
            self.histview_ok = False
        self.layout_filename = self.histview_ini.get("history_layout")
        if not os.path.isfile(self.layout_filename):
            self.WinMain.log_msg("Warning: history layout: [%s] does not exist" % (self.layout_filename))
            self.histview_ok = False
        # build the window
        self.winHistory = gtk.Fixed()
        self.winHistory.set_has_window(True)
        self.imgBackground = gtk.Image()
        self.lblHeading = gtk.Label()
        self.sclHistory = ScrollList(self.WinMain)
        self.winHistory.add(self.imgBackground)
        self.winHistory.add(self.make_evb_widget(self.lblHeading))
        self.winHistory.add(self.sclHistory.fixd)
        WinMain.fixd.add(self.winHistory)
        self.imgBackground.show()
        self.lblHeading.show()
        self.winHistory.show()
        # build list
        self.lsHistory = []
        self.sclHistory.auto_update = True
        # widgets
        self._histview_items = [(8, self.lblHeading), (21, self.sclHistory)]
        # get history
        self.history = self.read_history(self.histview_ini.get("history_dat_file"))
        # app number
        self.app_number = 0

    def set_history(self, rom_name, game_name):
        """display history for rom_name"""
        if not self.histview_ok:
            return
        rom_name = rom_name.upper()
        # display
        self.lsHistory = []
        if rom_name not in self.history:
            self.lblHeading.set_text("no history found")
            self.WinMain.show_window("history")
            return
        tw = textwrap.TextWrapper(width=self.line_length, replace_whitespace=False)
        for line in self.history[rom_name]:
            if line == " ":
                wrapped_lines = [""]
            else:
                wrapped_lines = tw.wrap(line)
            for wl in wrapped_lines:
                self.lsHistory.append(wl)
        self.sclHistory.ls = self.lsHistory
        self.lblHeading.set_text(game_name)
        self.sclHistory.set_selected(0)
        self.WinMain.show_window("history")

    def read_history(self, dat_filename):
        """read history into dictionary"""
        if not os.path.isfile(dat_filename):
            # self.histview_ok = False
            return
        f = open(dat_filename, "r")
        d = {}
        while True:
            try:
                line = f.next().strip()
            except StopIteration:
                break
            # start of a game history
            if line[:5] == "$info":
                # history can be for more than one rom
                rom_names = line[6:-1].split(",")
                hist_txt = []
                # read file until end of current game history
                while line != "$end":
                    try:
                        line = f.next().strip()
                    except StopIteration:
                        line = "$end"
                    # add blank lines
                    if line == "":
                        line = " "
                    if line[0] != "$":
                        hist_txt.append(line)
                if hist_txt != []:
                    for rom_name in rom_names:
                        d[rom_name.upper()] = hist_txt
        # done
        return d

#.........这里部分代码省略.........
开发者ID:thevoiceless,项目名称:wc-testing,代码行数:103,代码来源:win_history.py

示例9: __init__

# 需要导入模块: from mamewah_ini import MameWahIni [as 别名]
# 或者: from mamewah_ini.MameWahIni import get [as 别名]
class WahCade:
    """Common functions for Wah!Cade"""

    def __init__(self):
        """initialise common wahcade class"""
        #set default icon for windows
        gtk.window_set_default_icon_from_file(
            os.path.join(APP_PATH, 'pixmaps', 'wahcade.png'))
        ### LOGFILE
        if os.path.exists(CONFIG_DIR):
            self.log_filename = os.path.join(CONFIG_DIR, 'wahcade.log')
            try:
                f = open(self.log_filename, 'w')
                self.log_msg("//======================= NEW LOG RUN =======================//")
                f.close
            except:
                print "ERROR opening LOG FILE, %s, check for orphaned processes" % self.log_filename

    def hide_mouse_cursor(self, win):
        """hide mouse cursor"""
        gtk_col = gtk.gdk.Color()
        pixmap = gtk.gdk.Pixmap(None, 1, 1, 1)
        invisible_cursor = gtk.gdk.Cursor(
            pixmap, pixmap, gtk_col, gtk_col, 0, 0)
        win.window.set_cursor(invisible_cursor)

    def get_layout_item_properties(self, lines, offset):
        """get properties for item in layout"""
        d={}
        d['visible'] = (lines[offset].lower() == 'true')
        d['transparent'] = (lines[offset + 1] == '1')
        d['background-col'] = self.get_colour(int(lines[offset + 2]))
        d['text-col'] = self.get_colour(int(lines[offset + 3]))
        d['font'] = lines[offset + 4]
        d['font-bold'] = (lines[offset + 5].lower() == 'true')
        d['font-italic'] = (lines[offset + 6].lower() == 'true')
        d['font-size'] = float(lines[offset + 7])
        align_rot = lines[offset + 8].split(';')
        d['text-align'] = int(align_rot[0])
        d['text-rotation'] = 0
        if len(align_rot) > 1:
            d['text-rotation'] = int(align_rot[1])
        d['x'] = int(lines[offset + 9])
        d['y'] = int(lines[offset + 10])
        d['width'] = int(lines[offset + 11])
        d['height'] = int(lines[offset + 12])
        #done
        return d

    def get_colorbutton_info(self, clr_widget):
        """get gtk.ColorButton widgets current colour in gdk and hex format"""
        clr = clr_widget.get_color()
        hex_clr = '#%s%s%s' % (
            hex(clr.red/256)[2:].rjust(2, '0'),
            hex(clr.green/256)[2:].rjust(2, '0'),
            hex(clr.blue/256)[2:].rjust(2, '0'))
        return clr, hex_clr

    def get_colour(self, col):
        """convert decimal colour into format suitable for gtk colour"""
        hex_col = hex(col)[2:].rjust(6, '0').upper()
        #re-arrange
        hex_col = '#%s%s%s' % (hex_col[4:6], hex_col[2:4], hex_col[0:2])
        return hex_col

    def reverse_get_colour(self, hex_col):
        """reverse get_colour method - convert hex colour (#RRGGBB) into
           wahcade's decimal format"""
        r = int(hex_col[1:3], 16)
        g = int(hex_col[3:5], 16)
        b = int(hex_col[5:7], 16)
        col = (b * 256 * 256) + (g * 256) + r
        return col

    def get_matching_filename(self, file_prefixes, file_formats):
        """return the filename if it exists from given formats & path
              file_prefixes = [(dir_name, filename), ...]
              file_formats = [file_ext1, file_ext2, ...]
        """
        p = re.compile('(\.[^\.]+$)|(\s(\(|\[).+(?<=(\)|\]|\s))\.[^\.]+$)')
        self.wahcade_ini = MameWahIni(os.path.join(CONFIG_DIR, 'wahcade.ini'))
        l = self.wahcade_ini.get('layout')
        fz = self.wahcade_ini.getint('fuzzy_artwork_search')
        #check lower & upper case filenames for each given prefix & format
        for dirname, fp in file_prefixes:
            if fp == '##random##':
                for ff in file_formats:
                    fnl = walk_dir(dirname, False, '*.%s' % ff.lower(), False) + \
                        walk_dir(dirname, False, '*.%s' % ff.upper(), False)
                    #return first valid match
                    for filename in fnl:
                        if os.path.isfile(filename):
                            return filename
            elif fp != '':
                if file_formats != '':
                    # Check if this is a layout
                    if l not in dirname:
                        if fz:
                            # NB: we append a fake extension here to support the regex currently - sairuk
                            #     handles . appearing in filename being treated as an ext
#.........这里部分代码省略.........
开发者ID:FruitieX,项目名称:wahcade,代码行数:103,代码来源:wc_common.py

示例10: __init__

# 需要导入模块: from mamewah_ini import MameWahIni [as 别名]
# 或者: from mamewah_ini.MameWahIni import get [as 别名]
    def __init__(self, glade_filename, window_name, emu_name):
        """build the window"""
        WahCade.__init__(self)
        GladeSupport.__init__(self, glade_filename, window_name, APP_NAME)
        self.config_dir = CONFIG_DIR
        #print "emu_name=",emu_name
        self.emu_name = emu_name
        self.emu_list_idx = 0
        #setup tree & lists
        self.tsFilter = gtk.TreeStore(str, gobject.TYPE_BOOLEAN, str)
        self.tvwFilter = gtk.TreeView(model = self.tsFilter)
        #text col
        cellrt = gtk.CellRendererText()
        tvcol = gtk.TreeViewColumn(_('Filter'))
        tvcol.pack_start(cellrt, True)
        tvcol.add_attribute(cellrt, 'text', 0)
        tvcol.set_resizable(True)
        #checkbox col
        crt = gtk.CellRendererToggle()
        crt.set_property('activatable', True)
        crt.connect('toggled', self.on_tvwFilter_toggled, self.tsFilter)
        tvcol2 = gtk.TreeViewColumn(_('Selected?'), crt)
        tvcol2.add_attribute(crt, 'active', 1)
        #add columns to treeview
        self.tvwFilter.append_column(tvcol)
        self.tvwFilter.append_column(tvcol2)
        #self.tvwFilter.set_rules_hint(True)
        self.tvwFilter.show()
        self.scwFilter.add(self.tvwFilter)
        #games list
        self.tvwGames, self.lsGames, self.tvwsGames = self.setup_treeview(
            columns = ['Games'],
            column_types = [gobject.TYPE_STRING],
            container = self.scwGameList,
            resizeable_cols = True,
            highlight_rows = False)

        #load lists
        i = 0
        emu_game_lists = []
        while True:
            ini_file = os.path.join(self.config_dir, 'ini', '%s-%s.ini' % (self.emu_name, i))
            if os.path.isfile(ini_file):
                list_ini = MameWahIni(ini_file)
                emu_game_lists.append(list_ini.get('list_title'))
                i += 1
            else:
                break
        l = ['%s: %s' % (i, r) for i, r in enumerate(emu_game_lists)]
        
        #setup filters & emu ini
        emu_ini_filename = os.path.join(self.config_dir, 'ini', '%s.ini' % (self.emu_name))
        if os.path.isfile(emu_ini_filename):
            self.emu_ini = MameWahIni(emu_ini_filename)
            #filters._mameinfo_file = os.path.join(self.emu_ini.get('dat_file'))
            filters._catver_ini = os.path.join(self.emu_ini.get('catver_ini_file'))
        else:
            print _("Error: Emulator Ini file: [%s] doesn't exist" % (emu_ini_filename))
       
        #filter values
        if os.path.isfile(self.emu_ini.get('dat_file')):
            self._display_clones = [
                [_('No'), 'no'],
                [_('Yes'), 'yes'],
                [_('Only if better than Parent'), 'better']]
            self._filter_sections = [
                ['filter_type', _('Display Clones')],
                ['year', _('Year Filters')],
                ['manufacturer', _('Manufacturer Filters')],
                ['driver', _('BIOS Filters')],
                ['display_type', _('Screen Type Filters')],
                ['screen_type', _('Screen Orientation Filters')],
                ['controller_type', _('Input Type Filters')],
                ['driver_status', _('General Status Filters')],
                ['colour_status', _('Colour Status Filters')],
                ['sound_status', _('Sound Status Filters')],
                ['category', _('Category Filters')]]
        elif os.path.isfile(self.emu_ini.get('catver_ini_file')):
            self._filter_sections = [['category', _('Category Filters')]]
        else:
            self._filter_sections = []         
        self.setup_combo_box(self.cboLists, l)
        #load filter
        self.cboLists.set_active(self.emu_list_idx)
        self.filter_altered = False
开发者ID:gglass,项目名称:blinkywah,代码行数:87,代码来源:win_filter.py

示例11: WinFilter

# 需要导入模块: from mamewah_ini import MameWahIni [as 别名]
# 或者: from mamewah_ini.MameWahIni import get [as 别名]
class WinFilter(GladeSupport, WahCade):
    """wahcade setup - set filter window"""

    def __init__(self, glade_filename, window_name, emu_name):
        """build the window"""
        WahCade.__init__(self)
        GladeSupport.__init__(self, glade_filename, window_name, APP_NAME)
        self.config_dir = CONFIG_DIR
        #print "emu_name=",emu_name
        self.emu_name = emu_name
        self.emu_list_idx = 0
        #setup tree & lists
        self.tsFilter = gtk.TreeStore(str, gobject.TYPE_BOOLEAN, str)
        self.tvwFilter = gtk.TreeView(model = self.tsFilter)
        #text col
        cellrt = gtk.CellRendererText()
        tvcol = gtk.TreeViewColumn(_('Filter'))
        tvcol.pack_start(cellrt, True)
        tvcol.add_attribute(cellrt, 'text', 0)
        tvcol.set_resizable(True)
        #checkbox col
        crt = gtk.CellRendererToggle()
        crt.set_property('activatable', True)
        crt.connect('toggled', self.on_tvwFilter_toggled, self.tsFilter)
        tvcol2 = gtk.TreeViewColumn(_('Selected?'), crt)
        tvcol2.add_attribute(crt, 'active', 1)
        #add columns to treeview
        self.tvwFilter.append_column(tvcol)
        self.tvwFilter.append_column(tvcol2)
        #self.tvwFilter.set_rules_hint(True)
        self.tvwFilter.show()
        self.scwFilter.add(self.tvwFilter)
        #games list
        self.tvwGames, self.lsGames, self.tvwsGames = self.setup_treeview(
            columns = ['Games'],
            column_types = [gobject.TYPE_STRING],
            container = self.scwGameList,
            resizeable_cols = True,
            highlight_rows = False)

        #load lists
        i = 0
        emu_game_lists = []
        while True:
            ini_file = os.path.join(self.config_dir, 'ini', '%s-%s.ini' % (self.emu_name, i))
            if os.path.isfile(ini_file):
                list_ini = MameWahIni(ini_file)
                emu_game_lists.append(list_ini.get('list_title'))
                i += 1
            else:
                break
        l = ['%s: %s' % (i, r) for i, r in enumerate(emu_game_lists)]
        
        #setup filters & emu ini
        emu_ini_filename = os.path.join(self.config_dir, 'ini', '%s.ini' % (self.emu_name))
        if os.path.isfile(emu_ini_filename):
            self.emu_ini = MameWahIni(emu_ini_filename)
            #filters._mameinfo_file = os.path.join(self.emu_ini.get('dat_file'))
            filters._catver_ini = os.path.join(self.emu_ini.get('catver_ini_file'))
        else:
            print _("Error: Emulator Ini file: [%s] doesn't exist" % (emu_ini_filename))
       
        #filter values
        if os.path.isfile(self.emu_ini.get('dat_file')):
            self._display_clones = [
                [_('No'), 'no'],
                [_('Yes'), 'yes'],
                [_('Only if better than Parent'), 'better']]
            self._filter_sections = [
                ['filter_type', _('Display Clones')],
                ['year', _('Year Filters')],
                ['manufacturer', _('Manufacturer Filters')],
                ['driver', _('BIOS Filters')],
                ['display_type', _('Screen Type Filters')],
                ['screen_type', _('Screen Orientation Filters')],
                ['controller_type', _('Input Type Filters')],
                ['driver_status', _('General Status Filters')],
                ['colour_status', _('Colour Status Filters')],
                ['sound_status', _('Sound Status Filters')],
                ['category', _('Category Filters')]]
        elif os.path.isfile(self.emu_ini.get('catver_ini_file')):
            self._filter_sections = [['category', _('Category Filters')]]
        else:
            self._filter_sections = []         
        self.setup_combo_box(self.cboLists, l)
        #load filter
        self.cboLists.set_active(self.emu_list_idx)
        self.filter_altered = False

    def on_winFilter_delete_event(self, *args):
        """window closed"""
        if self.filter_altered:
            dlg = gtk.MessageDialog(
                self.winFilter,
                gtk.DIALOG_MODAL,
                gtk.MESSAGE_QUESTION,
                gtk.BUTTONS_YES_NO,
                _('Save filter changes?'))
            resp = dlg.run()
            if resp == gtk.RESPONSE_YES:
#.........这里部分代码省略.........
开发者ID:gglass,项目名称:blinkywah,代码行数:103,代码来源:win_filter.py

示例12: WinList

# 需要导入模块: from mamewah_ini import MameWahIni [as 别名]
# 或者: from mamewah_ini.MameWahIni import get [as 别名]
class WinList(GladeSupport, WahCade):
    """wahcade setup - edit list window"""
    NUM_COLS = 13

    def __init__(self, glade_filename, window_name, emu_name, emu_list_idx):
        """build the window"""
        WahCade.__init__(self)
        GladeSupport.__init__(self, glade_filename, window_name, APP_NAME)
        self.config_dir = CONFIG_DIR
        self.emu_name = emu_name
        self.emu_list_idx = emu_list_idx
        #games list
        self.tvwList, self.lsList, self.tvwsList = self.setup_treeview(
            columns = [
                'Game Name',
                'ROM Name',
                'Year',
                'Manufacturer',
                'Clone Of',
                'Rom Of',
                'Display Type',
                'Screen Type',
                'Controller Type',
                'Driver Status',
                'Colour Status',
                'Sound Status',
                'Category'],
            column_types = [gobject.TYPE_STRING] * self.NUM_COLS,
            container = self.scwList,
            edit_cell_cb = self.on_tvwList_edited,
            resizeable_cols = True,
            highlight_rows = False)
        #self.tvwList.connect('row-activated', self.on_tvwList_activated)
        self.tvwList.connect('key-release-event', self.on_tvwList_key_event)
        #activate multiple selection mode on tvwsList
        self.tvwsList.set_mode(gtk.SELECTION_MULTIPLE)
        #load lists
        i = 0
        emu_game_lists = []
        while True:
            ini_file = os.path.join(self.config_dir, 'ini', '%s-%s.ini' % (self.emu_name, i))
            if os.path.isfile(ini_file):
                list_ini = MameWahIni(ini_file)
                emu_game_lists.append(list_ini.get('list_title'))
                i += 1
            else:
                break
        l = ['%s: %s' % (i, r) for i, r in enumerate(emu_game_lists)]
        self.setup_combo_box(self.cboList, l)
        #setup filters & emu ini
        emu_ini_filename = os.path.join(self.config_dir, 'ini', '%s.ini' % (self.emu_name))
        if os.path.isfile(emu_ini_filename):
            self.emu_ini = MameWahIni(emu_ini_filename)
            #filters._mameinfo_file = os.path.join(self.emu_ini.get('dat_file'))
            filters._catver_ini = os.path.join(self.emu_ini.get('catver_ini_file'))
        else:
            print _("Error: Emulator Ini file: [%s] doesn't exist" % (emu_ini_filename))
        #get ini files
        self.wahcade_ini = MameWahIni(os.path.join(self.config_dir, 'wahcade.ini'))
        #window size
        self.do_events()
        w, h = self.wahcade_ini.get('setup_window_size', 'default', '400x400').split('x')
        self.winList.resize(width=int(w), height=int(h))
        #load filter
        self.new_iter = None
        self.new_path = None
        self.new_col = 0
        self.list_altered = False
        self.cboList.set_active(self.emu_list_idx)

    def on_winList_delete_event(self, *args):
        """window closed"""
        self.save_list_query()
        #close window
        self.winList.destroy()
        return False

    def on_btnAdd_clicked(self, *args):
        """add a new row"""
        self.new_iter = self.lsList.append(([''] * self.NUM_COLS))
        self.new_path = self.lsList.get_path(self.new_iter)
        self.new_col = 0
        tvc = self.tvwList.get_column(0)
        self.tvwList.set_cursor(self.new_path, tvc, True)

    def on_btnRemove_clicked(self, *args):
        """remove selected rows"""
        rows2remove = []
        self.tvwsList.selected_foreach(self.remove_selected, rows2remove)
        if len(rows2remove) > 0:
            for row in rows2remove:
               self.lsList.remove(row)
            self.update_total_games()
            self.list_altered = True

    def remove_selected(self, model, path, iter, data=None):
        """remove selected rows from list"""
        data.append(iter)

    def on_btnSave_clicked(self, *args):
#.........这里部分代码省略.........
开发者ID:dutchhome,项目名称:wahcade,代码行数:103,代码来源:win_list.py

示例13: WinCPViewer

# 需要导入模块: from mamewah_ini import MameWahIni [as 别名]
# 或者: from mamewah_ini.MameWahIni import get [as 别名]
class WinCPViewer(WahCade):
    """cpviewer based control panel viewer"""

    def __init__(self, WinMain):
        """setup cp viewer window"""
        #set main window
        self.WinMain = WinMain
        self.layout_filename = ''
        self.cpviewer_ok = True
        #open cpviewer viewer ini
        self.cpviewer_ini = MameWahIni(os.path.join(CONFIG_DIR, 'cpviewer.ini'), 'default')
        self.ctrls_ini_filename = self.cpviewer_ini.get('controls_ini_file')
        if not os.path.isfile(self.ctrls_ini_filename):
            self.WinMain.log_msg("Warning: controls file: [%s] does not exist" % (self.ctrls_ini_filename))
            self.cpviewer_ok = False
        self.layout_filename = self.cpviewer_ini.get('viewer_layout')
        if not os.path.exists(self.layout_filename):
            self.WinMain.log_msg("Warning: CPViewer layout file: [%s] does not exist" % (self.layout_filename))
            self.cpviewer_ok = False
        #build gui
        self.winCPViewer = gtk.Fixed()
        self.winCPViewer.set_has_window(True)
        self.imgBackground = gtk.Image()
        self.winCPViewer.add(self.imgBackground)
        self.WinMain.fixd.add(self.winCPViewer)
        self.imgBackground.show()
        self.winCPViewer.show()
        self.ctrls_ini = self.get_controls_ini(self.ctrls_ini_filename)
        if self.ctrls_ini is None:
            self.cpviewer_ok = False
        self.app_number = 0

    def on_winMain_delete_event(self, *args):
        """exit window"""
        #hide window
        self.WinMain.hide_window('cpviewer')
        return True

    def _make_label(self, widget_name):
        """create a label (inside an event box)"""
        evb = gtk.EventBox()
        evb.set_name(widget_name)
        lbl = gtk.Label(widget_name)
        lbl.show()
        #lbl.set_line_wrap(True)
        lbl.set_text('')
        evb.set_size_request(100, 25)
        evb.set_visible_window(True)
        evb.show()
        evb.add(lbl)
        evb.set_property('visible', False)
        return evb

    def load_layout(self, xml_filename):
        """parse cpviewer xml file and create & position labels"""
        if not os.path.isfile(xml_filename):
            return
        #init widgets
        cpv_widgets = {}
        for i, widget_name in enumerate(_items):
            evb = self._make_label(widget_name)
            cpv_widgets[widget_name] = evb
            self.winCPViewer.add(evb)
        #get category info
        for event, ctrl_element in ET.iterparse(xml_filename):
            if ctrl_element.tag in _items:
                #get label / event box
                evb = cpv_widgets[ctrl_element.tag]
                lbl = evb.child
                #font
                fd = ctrl_element.find('FontName').text
                if ctrl_element.find('FontBold').text == 'True':
                    fd += ' Bold'
                if ctrl_element.find('FontItalic').text == 'True':
                    fd += ' Italic'
                fd += ' %s' % (ctrl_element.find("FontSize").text)
                font_desc = pango.FontDescription(fd)
                #colours
                transparent = True
                if ctrl_element.find('Transparent') is not None:
                    transparent = (ctrl_element.find('Transparent').text == 'True')
                fg_col = gtk.gdk.color_parse(self.get_colour(abs(int(ctrl_element.find('ForeColor').text))))
                bg_col = gtk.gdk.color_parse(self.get_colour(abs(int(ctrl_element.find('BackColor').text))))
                lbl.modify_font(font_desc)
                lbl.modify_fg(gtk.STATE_NORMAL, fg_col)
                if transparent:
                    evb.set_visible_window(False)
                else:
                    evb.modify_bg(gtk.STATE_NORMAL, bg_col)
                #visible?
                evb.set_property('visible', ctrl_element.find('Visible').text == 'True')
                #alignment
                if ctrl_element.find('TextAlign').text == 'MiddleLeft':
                    align = 0.0
                    justify = gtk.JUSTIFY_LEFT
                elif ctrl_element.find('TextAlign').text == 'MiddleCenter':
                    align = 0.5
                    justify = gtk.JUSTIFY_CENTER
                elif ctrl_element.find('TextAlign').text == 'MiddleRight':
                    align = 1.0
#.........这里部分代码省略.........
开发者ID:kalymos,项目名称:wc-testing,代码行数:103,代码来源:win_cpviewer.py

示例14: WinSetup

# 需要导入模块: from mamewah_ini import MameWahIni [as 别名]
# 或者: from mamewah_ini.MameWahIni import get [as 别名]
class WinSetup(GladeSupport, WahCade):
    """wahcade setup - main window"""

    def __init__(self, glade_filename, window_name, config_opts, config_args):
        """build the window"""
        WahCade.__init__(self)
        GladeSupport.__init__(self, glade_filename, window_name, APP_NAME)
        #command-line options
        self.config_opts = config_opts
        #set default config location (create / update as necessary)
        self.config_dir = CONFIG_DIR
        if not os.path.exists(self.config_dir):
            self.copy_user_config('all')
        else:
            #update current config
            self.copy_user_config()
        #keys list
        self.tvwKeys, self.lsKeys, self.tvwsKeys = self.setup_treeview(
            columns = ['Function', 'Key'],
            column_types = [gobject.TYPE_STRING, gobject.TYPE_STRING],
            container = self.scwKeys,
            resizeable_cols = False)
        self.lsKeys.set_sort_column_id(0, gtk.SORT_ASCENDING)
        self.tvwKeys.connect('row-activated', self.on_tvwKeys_row_activated)
        self.tvwKeys.set_tooltip_text(_('Double-Click a row to change a Key...'))
        #set max width for keys column (stops window getting too wide)
        col = self.tvwKeys.get_column(1)
        col.set_max_width(200)
        #get ini files
        self.wahcade_ini = MameWahIni(os.path.join(self.config_dir, 'wahcade.ini'))
        self.histview_ini = MameWahIni(os.path.join(self.config_dir, 'histview.ini'))
        self.cpviewer_ini = MameWahIni(os.path.join(self.config_dir, 'cpviewer.ini'))
        self.ctrlr_ini = MameWahIni(os.path.join(self.config_dir, 'ctrlr', 'default.ini'), 'ctrlr')
        #emu stuff
        self.emu_list_gen_types = [
            [['rom_folder'], 'Rom Directory'],
            [['rom_folder_vs_listxml', 'list_xml'], 'XML File'],
            [['rom_folder_vs_dat_file', 'dat_file'], 'DAT File']]
        self.emu_scrsave_types = [
            ['blank_screen', 'Blank Screen'],
            ['slideshow', 'Slide Show'],
            ['movie', 'Movies'],
            ['launch_scr', 'Launch External Screen Saver']]
        self.emu_list_types = [
            ['normal', 'Normal'],
            ['most_played', 'Most Played'],
            ['longest_played', 'Longest Played']]
        self.music_movie_mix = [
            ['mute_movies', 'Mute Movies'],
            ['merge', 'Mix with Music']]
        self.emu_artwork_txe = [
            self.txeEmuArt1, self.txeEmuArt2, self.txeEmuArt3, self.txeEmuArt4,
            self.txeEmuArt5, self.txeEmuArt6, self.txeEmuArt7, self.txeEmuArt8,
            self.txeEmuArt9, self.txeEmuArt10]
        self.emu_artwork_btn = [
            self.btnEmuArt1, self.btnEmuArt2, self.btnEmuArt3, self.btnEmuArt4,
            self.btnEmuArt5, self.btnEmuArt6, self.btnEmuArt7, self.btnEmuArt8,
            self.btnEmuArt9, self.btnEmuArt10]
        #setup combo boxes
        self.setup_combo_box(self.cboEmuScrSaver, [r[1] for r in self.emu_scrsave_types])
        self.setup_combo_box(self.cboEmuListGen, [r[1] for r in self.emu_list_gen_types])
        self.setup_combo_box(self.cboEmuListType, [r[1] for r in self.emu_list_types])
        self.setup_combo_box(self.cboWCMovieMix, [r[1] for r in self.music_movie_mix])
        #global joy
        self.joystick = joystick.joystick()
        self.joystick.use_all_controls()
        #get default window size & pos
        self.do_events()
        w, h = self.wahcade_ini.get('setup_window_size', 'default', '400x400').split('x')
        self.winSetup.resize(width=int(w), height=int(h))
        #load settings
        self.load_settings()
        self.setup_altered = False
        #set icon sizes
        settings = gtk.settings_get_default()
        settings.set_string_property('gtk-icon-sizes', 'gtk-button=16,16', '')

    def on_winSetup_delete_event(self, *args):
        """done, quit the application"""
        #save settings
        self.save_setups()
        #save default window size & pos
        win_size = self.winSetup.get_size()
        self.wahcade_ini.set('setup_window_size', '%sx%s' % (win_size))
        self.wahcade_ini.write()
        #exit gtk loop
        gtk.main_quit()
        return False

    def on_Setup_changed(self, widget, *args):
        """widget has been modified, update altered flag"""
        self.setup_altered = True

    def on_mnuFSave_activate(self, *args):
        """save settings"""
        self.save_setups(False)

    def on_mnuFReset_activate(self, *args):
        """reset settings"""
        dlg = gtk.MessageDialog(
#.........这里部分代码省略.........
开发者ID:gglass,项目名称:blinkywah,代码行数:103,代码来源:wc_setup.py


注:本文中的mamewah_ini.MameWahIni.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。