本文整理汇总了Python中scc.tools._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_profile_modified
def set_profile_modified(self, has_changes, is_template=False):
"""
Called to signalize that profile has changes to save in UI
by displaying "changed" next to profile name and showing Save button.
Returns giofile for currently selected profile. If profile is set as
changed, giofile is automatically changed to 'original/filename.mod',
so application can save changes without overwriting original wile.
"""
if has_changes:
if not self._savebutton:
# Save button has to be created
self._savebutton = ButtonInRevealer(
"gtk-save", _("Save changes"),
self.on_savebutton_clicked)
self._box.pack_start(self._savebutton, False, True, 0)
self.show_all()
self._savebutton.set_reveal_child(True)
iter = self._combo.get_active_iter()
if is_template:
self._model.set_value(iter, 2, _("(changed template)"))
else:
self._model.set_value(iter, 2, _("(changed)"))
else:
if self._savebutton:
# Nothing to hide if there is no revealer
self._savebutton.set_reveal_child(False)
for i in self._model:
i[2] = None
if is_template:
iter = self._combo.get_active_iter()
self._model.set_value(iter, 2, _("(template)"))
示例2: on_mnuMenuDelete_activate
def on_mnuMenuDelete_activate(self, *a):
id = self.get_selected_menu()
if MenuEditor.menu_is_global(id):
text = _("Really delete selected global menu?")
else:
text = _("Really delete selected menu?")
d = Gtk.MessageDialog(parent=self.editor.window,
flags = Gtk.DialogFlags.MODAL,
type = Gtk.MessageType.WARNING,
buttons = Gtk.ButtonsType.OK_CANCEL,
message_format = text,
)
if MenuEditor.menu_is_global(id):
d.format_secondary_text(_("This action is not undoable!"))
if d.run() == -5: # OK button, no idea where is this defined...
if MenuEditor.menu_is_global(id):
fname = os.path.join(get_menus_path(), id)
try:
os.unlink(fname)
except Exception, e:
log.error("Failed to remove %s: %s", fname, e)
else:
del self.app.current.menus[id]
self.app.on_profile_modified()
self.load_menu_list()
示例3: describe
def describe(self, context):
if self.name: return self.name
axis, neg, pos = self._get_axis_description()
if context in (Action.AC_STICK, Action.AC_PAD):
xy = "X" if self.parameters[0] in AxisAction.X else "Y"
return _("%s %s (reversed)") % (axis, xy)
return _("Reverse %s Axis") % (axis,)
示例4: select_gyro_button
def select_gyro_button(self, item):
""" Just sets combobox value """
cb = self.builder.get_object("cbGyroButton")
rvSoftLevel = self.builder.get_object("rvSoftLevel")
sclSoftLevel = self.builder.get_object("sclSoftLevel")
lblSoftLevel = self.builder.get_object("lblSoftLevel")
model = cb.get_model()
self._recursing = True
button = None
if isinstance(item, RangeOP):
button = nameof(item.what)
sclSoftLevel.set_value(item.value)
rvSoftLevel.set_reveal_child(True)
if item.what == STICK:
lblSoftLevel.set_label(_("Stick deadzone"))
else:
lblSoftLevel.set_label(_("Trigger Pull Level"))
elif item is not None:
button = nameof(item.name)
for row in model:
if button == row[0] and row[1] != None:
cb.set_active_iter(row.iter)
self._recursing = False
return
self._recursing = False
示例5: on_txName2_changed
def on_txName2_changed(self, *a):
txName2 = self.builder.get_object("txName2")
btNext = self.enable_next(True, self.on_scc_import_confirmed)
files = self.builder.get_object("lstImportPackage")
cbImportHidden = self.builder.get_object("cbImportPackageHidden")
cbImportVisible = self.builder.get_object("cbImportPackageVisible")
cbImportNone = self.builder.get_object("cbImportPackageNone")
rvAdvanced = self.builder.get_object("rvImportPackageAdvanced")
btNext.set_label('Apply')
btNext.set_use_stock(True)
main_name = txName2.get_text().decode("utf-8")
if self.check_name(main_name):
btNext.set_sensitive(True)
else:
btNext.set_sensitive(False)
cbImportHidden.set_label(_("Import as hidden menus and profiles named \".%s:name\"") % (main_name,))
cbImportVisible.set_label(_("Import normaly, with names formated as \"%s:name\"") % (main_name,))
for i in xrange(0, len(files)):
enabled, name, importas, type, obj = files[i]
if enabled == 2:
importas = main_name
elif cbImportHidden.get_active():
importas = ".%s:%s" % (main_name, name)
enabled = 1
elif cbImportVisible.get_active():
importas = "%s:%s" % (main_name, name)
enabled = 1
elif cbImportNone.get_active():
enabled = 0
files[i] = enabled, name, importas, type, obj
示例6: _add_refereced_menu
def _add_refereced_menu(self, model, menu_id, used):
"""
As _add_refereced_profile, but reads and parses menu file.
"""
if "." in menu_id and menu_id not in used:
# Dot in id means filename
used.add(menu_id)
filename = find_menu(menu_id)
name = ".".join(menu_id.split(".")[0:-1])
if name.startswith(".") and menu_is_default(menu_id):
# Default and hidden, don't bother user with it
return
if filename:
model.append((not menu_is_default(menu_id), _("Menu"), name,
filename, True, self.TP_MENU))
try:
menu = MenuData.from_file(filename, ActionParser())
except Exception, e:
# Menu that cannot be parsed shouldn't be exported
log.error(e)
return
for item in menu:
if isinstance(item, Submenu):
self._add_refereced_menu(model, os.path.split(item.filename)[-1], used)
if hasattr(item, "action"):
self._parse_action(model, item.action, used)
else:
model.append((False, _("Menu"), _("%s (not found)") % (name,),
"", False, self.TP_MENU))
示例7: on_menus_loaded
def on_menus_loaded(self, menus):
cb = self.builder.get_object("cbMenus")
cb.set_row_separator_func( lambda model, iter : model.get_value(iter, 1) is None )
model = cb.get_model()
model.clear()
i, current_index = 0, 0
if self.allow_in_profile:
# Add menus from profile
for key in sorted(self.app.current.menus):
model.append((key, key))
if self._current_menu == key:
current_index = i
i += 1
if i > 0:
model.append((None, None)) # Separator
i += 1
if self.allow_globals:
for f in menus:
key = f.get_basename()
name = key
if "." in name:
name = _("%s (global)" % (name.split(".")[0]))
model.append((name, key))
if self._current_menu == key:
current_index = i
i += 1
if i > 0:
model.append((None, None)) # Separator
model.append(( _("New Menu..."), "" ))
self._recursing = True
cb.set_active(current_index)
self._recursing = False
self.on_cbMenus_changed()
示例8: choose_editor
def choose_editor(self, action, title, id=None):
""" Chooses apropripate Editor instance for edited action """
if isinstance(action, SensitivityModifier):
action = action.action
if isinstance(action, FeedbackModifier):
action = action.action
if id in GYROS:
e = ActionEditor(self.app, self.on_action_chosen)
e.set_title(title)
elif isinstance(action, (ModeModifier, DoubleclickModifier, HoldModifier)) and not is_gyro_enable(action):
e = ModeshiftEditor(self.app, self.on_action_chosen)
e.set_title(_("Mode Shift for %s") % (title,))
elif RingEditor.is_ring_action(action):
e = RingEditor(self.app, self.on_action_chosen)
e.set_title(title)
elif isinstance(action, Type):
# Type is subclass of Macro
e = ActionEditor(self.app, self.on_action_chosen)
e.set_title(title)
elif isinstance(action, Macro) and not (is_button_togle(action) or is_button_repeat(action)):
e = MacroEditor(self.app, self.on_action_chosen)
e.set_title(_("Macro for %s") % (title,))
else:
e = ActionEditor(self.app, self.on_action_chosen)
e.set_title(title)
return e
示例9: on_button
def on_button(self, keycode, pressed):
#if len(self.grabbed) == 2 and self.grabbed[X] != None:
# # Already grabbed one axis, don't grab buttons
# return
if keycode in self.grabbed:
# Don't allow same button to be used twice
return
if not pressed:
if len(self.grabbed) < 4:
self.grabbed = [ None ] * 4
if self.grabbed[0] is None:
self.grabbed[0] = keycode
self.set_message(_("Move DPAD to right"))
elif self.grabbed[1] is None:
self.grabbed[1] = keycode
self.set_message(_("Move DPAD up"))
elif self.grabbed[2] is None:
self.grabbed[2] = keycode
self.set_message(_("Move DPAD down"))
elif self.grabbed[3] is None:
self.grabbed[3] = keycode
self.set_message(str(self.grabbed))
grabbed = [] + self.grabbed
for w in self.what:
for negative in (False, True):
keycode, grabbed = grabbed[0], grabbed[1:]
w.reset()
self.set_mapping(keycode, DPadEmuData(w, negative))
self.parent.generate_unassigned()
self.parent.generate_raw_data()
self.cancel()
示例10: on_cbInvertGyro_toggled
def on_cbInvertGyro_toggled(self, cb, *a):
lblGyroEnable = self.builder.get_object("lblGyroEnable")
if cb.get_active():
lblGyroEnable.set_label(_("Gyro Disable Button"))
else:
lblGyroEnable.set_label(_("Gyro Enable Button"))
if not self._recursing:
self.send()
示例11: describe_button
def describe_button(button):
if button in ButtonAction.SPECIAL_NAMES:
return _(ButtonAction.SPECIAL_NAMES[button])
elif button in MOUSE_BUTTONS:
return _("Mouse %s") % (button,)
elif button is None: # or isinstance(button, NoAction):
return "None"
return button.name.split("_", 1)[-1]
示例12: describe
def describe(self, context):
if self.name: return self.name
if self._mouse_axis == Rels.REL_WHEEL:
return _("Wheel")
elif self._mouse_axis == Rels.REL_HWHEEL:
return _("Horizontal Wheel")
elif self._mouse_axis in (PITCH, YAW, ROLL, None):
return _("Mouse")
else:
return _("Mouse %s") % (self._mouse_axis.name.split("_", 1)[-1],)
示例13: load
def load(self):
if AEComponent.load(self):
markup = ""
if self.editor.get_mode() == Action.AC_PAD:
markup = MARKUP_PAD
elif self.editor.get_mode() == Action.AC_STICK:
markup = MARKUP_STICK
elif self.editor.get_mode() == Action.AC_GYRO:
markup = MARKUP_GYRO
elif self.editor.get_mode() == Action.AC_TRIGGER:
markup = MARKUP_TRIGGER
else:
markup = MARKUP_BUTTON
long_names = {
'LPAD' : _("Left Pad"),
'RPAD' : _("Right Pad"),
'LGRIP' : _("Left Grip"),
'RGRIP' : _("Right Grip"),
'LB' : _("Left Bumper"),
'RB' : _("Right Bumper"),
'LEFT' : _("Left Trigger"),
'RIGHT' : _("Right Trigger"),
'STICK' : _("Stick"),
}
markup = markup % {
'what' : long_names.get(nameof(self.editor.get_id()),
nameof(self.editor.get_id()).title())
}
self.builder.get_object("lblMarkup").set_markup(markup.strip(" \r\n\t"))
return True
示例14: _choose_editor
def _choose_editor(self, action, cb):
if isinstance(action, Macro):
from scc.gui.macro_editor import MacroEditor # Cannot be imported @ top
e = MacroEditor(self.app, cb)
e.set_title(_("Edit Macro"))
else:
from scc.gui.action_editor import ActionEditor # Cannot be imported @ top
e = ActionEditor(self.app, cb)
e.set_title(_("Edit Action"))
e.hide_modeshift()
return e
示例15: _choose_editor
def _choose_editor(self, action, cb):
if isinstance(action, ModeModifier):
from scc.gui.modeshift_editor import ModeshiftEditor # Cannot be imported @ top
e = ModeshiftEditor(self.app, cb)
e.set_title(_("Edit Action"))
else:
from scc.gui.action_editor import ActionEditor # Cannot be imported @ top
e = ActionEditor(self.app, cb)
e.set_title(_("Edit Action"))
e.hide_macro()
e.hide_ring()
return e