本文整理汇总了Python中mamewah_ini.MameWahIni.reverse_get方法的典型用法代码示例。如果您正苦于以下问题:Python MameWahIni.reverse_get方法的具体用法?Python MameWahIni.reverse_get怎么用?Python MameWahIni.reverse_get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mamewah_ini.MameWahIni
的用法示例。
在下文中一共展示了MameWahIni.reverse_get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WinSetup
# 需要导入模块: from mamewah_ini import MameWahIni [as 别名]
# 或者: from mamewah_ini.MameWahIni import reverse_get [as 别名]
#.........这里部分代码省略.........
self.copy_user_config()
#reload settings
#self.load_settings()
#self.setup_altered = False
dlg.destroy()
def on_mnuFQuit_activate(self, *args):
"""quit"""
self.on_winSetup_delete_event()
def on_mnuHAbout_activate(self, *args):
"""about dialog"""
self.show_about_dialog('Wah!Cade Setup', self.config_dir)
def on_tvwKeys_row_activated(self, widget, path, column):
"""keys list double-clicked"""
#show key press dialog
dlg = DlgKeyPress(
SETUP_GLADE_FILE,
'dlgKeyPress',
path,
self.on_tvwKeys_change,
self.joystick)
def on_tvwKeys_change(self, path, mw_keys, keyname):
"""update key list with new keyname"""
#print "on_tvwKeys_change=",path, mw_keys, keyname
#clear
if mw_keys == [] and keyname == '':
self.ctrlr_ini.set(self.lsKeys[path][0], '')
self.lsKeys[path][1] = ''
return
#get existing actions for key
mw_functions = self.ctrlr_ini.reverse_get(mw_keys[0])
if mw_functions != []:
#re-assign?
key_actions = ''
for f in mw_functions:
key_actions += '\t%s\n' % f
msg = _('"%s" is already assigned to the following actions:\n%s\n' % (
keyname.upper(),
key_actions))
msg += _('Keep existing assignments?')
dlg = gtk.MessageDialog(
self.winSetup,
gtk.DIALOG_MODAL,
gtk.MESSAGE_QUESTION,
gtk.BUTTONS_YES_NO,
msg)
resp = dlg.run()
dlg.destroy()
if resp == gtk.RESPONSE_NO:
#remove from each old assignment
for mrf in mw_functions:
v = self.ctrlr_ini.get(mrf)
lv = v.strip(' "').split(' | ')
lv.remove(mw_keys[0])
s = ''
for v in lv:
s = '%s | ' % v
if lv != []:
s = '"%s"' % s[:-3]
self.ctrlr_ini.set(mrf, s)
#update keys for selected action
existing_keys = self.ctrlr_ini.get(self.lsKeys[path][0])
if existing_keys == '':
示例2: __init__
# 需要导入模块: from mamewah_ini import MameWahIni [as 别名]
# 或者: from mamewah_ini.MameWahIni import reverse_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
#.........这里部分代码省略.........
示例3: __init__
# 需要导入模块: from mamewah_ini import MameWahIni [as 别名]
# 或者: from mamewah_ini.MameWahIni import reverse_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'))
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, ...]
"""
#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 != '':
for ff in file_formats:
basename = '%s.%s' % (fp, ff)
#build list of possible filenames
fnl = [os.path.join(dirname, basename),
os.path.join(dirname, basename.lower()),
os.path.join(dirname, basename.upper())]
#return first valid match
for filename in fnl:
if os.path.isfile(filename):
return filename
else:
filename = os.path.join(dirname, fp)
if os.path.isfile(filename):
return filename
#done - nothing found
return ''
def get_artwork_image(self, img_path, layout_path, game_info, emu_name, artwork_num):
#.........这里部分代码省略.........