本文整理汇总了Python中BEE2_config.GEN_OPTS.get_bool方法的典型用法代码示例。如果您正苦于以下问题:Python GEN_OPTS.get_bool方法的具体用法?Python GEN_OPTS.get_bool怎么用?Python GEN_OPTS.get_bool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BEE2_config.GEN_OPTS
的用法示例。
在下文中一共展示了GEN_OPTS.get_bool方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_opt
# 需要导入模块: from BEE2_config import GEN_OPTS [as 别名]
# 或者: from BEE2_config.GEN_OPTS import get_bool [as 别名]
def load_opt():
"""Load the checkbox's values."""
var.set(GEN_OPTS.get_bool(
section,
item,
default,
))
示例2: add_vars
# 需要导入模块: from BEE2_config import GEN_OPTS [as 别名]
# 或者: from BEE2_config.GEN_OPTS import get_bool [as 别名]
def add_vars(data):
"""
Add the given stylevars to our list.
"""
global var_list
var_list = sorted(data, key=operator.attrgetter('id'))
for var in var_list:
var.default = GEN_OPTS.get_bool('StyleVar', var.id, var.default)
示例3: add_vars
# 需要导入模块: from BEE2_config import GEN_OPTS [as 别名]
# 或者: from BEE2_config.GEN_OPTS import get_bool [as 别名]
def add_vars(style_vars, styles):
"""
Add the given stylevars to our list.
"""
VAR_LIST.clear()
VAR_LIST.extend(
sorted(style_vars, key=operator.attrgetter('id'))
)
for var in VAR_LIST: # type: packageLoader.StyleVar
var.enabled = GEN_OPTS.get_bool('StyleVar', var.id, var.default)
for style in styles:
STYLES[style.id] = style
示例4: make_pane
# 需要导入模块: from BEE2_config import GEN_OPTS [as 别名]
# 或者: from BEE2_config.GEN_OPTS import get_bool [as 别名]
def make_pane(tool_frame):
"""Create the styleVar pane.
"""
global window
window = SubPane(
TK_ROOT,
options=GEN_OPTS,
title='Style Properties',
name='style',
resize_y=True,
tool_frame=tool_frame,
tool_img=png.png('icons/win_stylevar'),
tool_col=2,
)
UI['style_can'] = Canvas(window, highlightthickness=0)
# need to use a canvas to allow scrolling
UI['style_can'].grid(sticky='NSEW')
window.rowconfigure(0, weight=1)
UI['style_scroll'] = ttk.Scrollbar(
window,
orient=VERTICAL,
command=UI['style_can'].yview,
)
UI['style_scroll'].grid(column=1, row=0, rowspan=2, sticky="NS")
UI['style_can']['yscrollcommand'] = UI['style_scroll'].set
canvas_frame = ttk.Frame(UI['style_can'])
frame_all = ttk.Labelframe(canvas_frame, text="All:")
frame_all.grid(row=0, sticky='EW')
frm_chosen = ttk.Labelframe(canvas_frame, text="Selected Style:")
frm_chosen.grid(row=1, sticky='EW')
ttk.Separator(
canvas_frame,
orient=HORIZONTAL,
).grid(row=2, sticky='EW', pady=(10, 5))
frm_other = ttk.Labelframe(canvas_frame, text="Other Styles:")
frm_other.grid(row=3, sticky='EW')
UI['stylevar_chosen_none'] = ttk.Label(
frm_chosen,
text='No Options!',
font='TkMenuFont',
justify='center',
)
UI['stylevar_other_none'] = ttk.Label(
frm_other,
text='None!',
font='TkMenuFont',
justify='center',
)
for pos, (var_id, name, default) in enumerate(styleOptions):
# Add the special stylevars which apply to all styles
tk_vars[var_id] = IntVar(
value=GEN_OPTS.get_bool('StyleVar', var_id, default)
)
checkbox_special[var_id] = ttk.Checkbutton(
frame_all,
variable=tk_vars[var_id],
text=name,
command=functools.partial(set_stylevar, var_id)
)
checkbox_special[var_id].grid(row=pos, column=0, sticky="W", padx=3)
for var in var_list:
tk_vars[var.id] = IntVar(value=var.default)
args = {
'variable': tk_vars[var.id],
'text': var.name,
'command': functools.partial(set_stylevar, var.id)
}
checkbox_chosen[var.id] = ttk.Checkbutton(frm_chosen, **args)
checkbox_other[var.id] = ttk.Checkbutton(frm_other, **args)
UI['style_can'].create_window(0, 0, window=canvas_frame, anchor="nw")
UI['style_can'].update_idletasks()
UI['style_can'].config(
scrollregion=UI['style_can'].bbox(ALL),
width=canvas_frame.winfo_reqwidth(),
)
ttk.Sizegrip(
window,
cursor="sb_v_double_arrow",
).grid(row=1, column=0)
UI['style_can'].bind('<Configure>', flow_stylevar)
# Scroll globally even if canvas is not selected.
window.bind(
"<MouseWheel>",
lambda e: scroll(int(-1*(e.delta/120))),
)
window.bind(
"<Button-4>",
#.........这里部分代码省略.........
示例5: init_backup_settings
# 需要导入模块: from BEE2_config import GEN_OPTS [as 别名]
# 或者: from BEE2_config.GEN_OPTS import get_bool [as 别名]
def init_backup_settings():
"""Initialise the auto-backup settings widget."""
from BEE2_config import GEN_OPTS
check_var = tk.IntVar(
value=GEN_OPTS.get_bool('General', 'enable_auto_backup')
)
count_value = GEN_OPTS.get_int('General', 'auto_backup_count', 0)
back_dir = GEN_OPTS.get_val('Directories', 'backup_loc', 'backups/')
def check_callback():
GEN_OPTS['General']['enable_auto_backup'] = utils.bool_as_int(
check_var.get()
)
def count_callback():
GEN_OPTS['General']['auto_backup_count'] = str(count.value)
def directory_callback(path):
GEN_OPTS['Directories']['backup_loc'] = path
UI['auto_frame'] = frame = ttk.LabelFrame(
window,
)
UI['auto_enable'] = enable_check = ttk.Checkbutton(
frame,
text='Automatic Backup After Export',
variable=check_var,
command=check_callback,
)
frame['labelwidget'] = enable_check
frame.grid(row=2, column=0, columnspan=3)
dir_frame = ttk.Frame(
frame,
)
dir_frame.grid(row=0, column=0)
ttk.Label(
dir_frame,
text='Directory',
).grid(row=0, column=0)
UI['auto_dir'] = tk_tools.FileField(
dir_frame,
loc=back_dir,
is_dir=True,
callback=directory_callback,
)
UI['auto_dir'].grid(row=1, column=0)
count_frame = ttk.Frame(
frame,
)
count_frame.grid(row=0, column=1)
ttk.Label(
count_frame,
text='Keep (Per Game):'
).grid(row=0, column=0)
count = tk_tools.ttk_Spinbox(
count_frame,
range=range(50),
command=count_callback,
)
count.grid(row=1, column=0)
count.value = count_value
示例6: auto_backup
# 需要导入模块: from BEE2_config import GEN_OPTS [as 别名]
# 或者: from BEE2_config.GEN_OPTS import get_bool [as 别名]
def auto_backup(game: 'gameMan.Game', loader: LoadScreen):
"""Perform an automatic backup for the given game.
We do this seperately since we don't need to read the property files.
"""
from BEE2_config import GEN_OPTS
if not GEN_OPTS.get_bool('General', 'enable_auto_backup'):
# Don't backup!
loader.skip_stage(AUTO_BACKUP_STAGE)
return
folder = find_puzzles(game)
if not folder:
loader.skip_stage(AUTO_BACKUP_STAGE)
return
# Keep this many previous
extra_back_count = GEN_OPTS.get_int('General', 'auto_backup_count', 0)
to_backup = os.listdir(folder)
backup_dir = GEN_OPTS.get_val('Directories', 'backup_loc', 'backups/')
os.makedirs(backup_dir, exist_ok=True)
# A version of the name stripped of special characters
# Allowed: a-z, A-Z, 0-9, '_-.'
safe_name = utils.whitelist(
game.name,
valid_chars=BACKUP_CHARS,
)
loader.set_length(AUTO_BACKUP_STAGE, len(to_backup))
if extra_back_count:
back_files = [
AUTO_BACKUP_FILE.format(game=safe_name, ind='')
] + [
AUTO_BACKUP_FILE.format(game=safe_name, ind='_'+str(i+1))
for i in range(extra_back_count)
]
# Move each file over by 1 index, ignoring missing ones
# We need to reverse to ensure we don't overwrite any zips
for old_name, new_name in reversed(
list(zip(back_files, back_files[1:]))
):
LOGGER.info(
'Moving: {old} -> {new}',
old=old_name,
new=new_name,
)
old_name = os.path.join(backup_dir, old_name)
new_name = os.path.join(backup_dir, new_name)
try:
os.remove(new_name)
except FileNotFoundError:
pass # We're overwriting this anyway
try:
os.rename(old_name, new_name)
except FileNotFoundError:
pass
final_backup = os.path.join(
backup_dir,
AUTO_BACKUP_FILE.format(game=safe_name, ind=''),
)
LOGGER.info('Writing backup to "{}"', final_backup)
with open(final_backup, 'wb') as f:
with ZipFile(f, mode='w', compression=ZIP_LZMA) as zip_file:
for file in to_backup:
zip_file.write(
os.path.join(folder, file),
file,
ZIP_LZMA,
)
loader.step(AUTO_BACKUP_STAGE)
示例7:
# 需要导入模块: from BEE2_config import GEN_OPTS [as 别名]
# 或者: from BEE2_config.GEN_OPTS import get_bool [as 别名]
'log_missing_ent_count': '0',
# Warn if a file is missing that a packfile refers to
'log_incorrect_packfile': '0',
# Show the log window on startup
'show_log_win': '0',
# The lowest level which will be shown.
'window_log_level': 'INFO',
},
}
GEN_OPTS.load()
GEN_OPTS.set_defaults(DEFAULT_SETTINGS)
loadScreen.main_loader.set_length('UI', 14)
loadScreen.show_main_loader(GEN_OPTS.get_bool('General', 'compact_splash'))
# OS X starts behind other windows, fix that.
if utils.MAC:
TK_ROOT.lift()
logWindow.init(
GEN_OPTS.get_bool('Debug', 'show_log_win'),
GEN_OPTS['Debug']['window_log_level']
)
UI.load_settings()
gameMan.load()
gameMan.set_game_by_name(
GEN_OPTS.get_val('Last_Selected', 'Game', ''),
示例8: make_pane
# 需要导入模块: from BEE2_config import GEN_OPTS [as 别名]
# 或者: from BEE2_config.GEN_OPTS import get_bool [as 别名]
def make_pane(tool_frame):
"""Create the styleVar pane.
"""
global window
window = SubPane(
TK_ROOT,
options=GEN_OPTS,
title='Style Properties',
name='style',
resize_y=True,
tool_frame=tool_frame,
tool_img=png.png('icons/win_stylevar'),
tool_col=3,
)
UI['style_can'] = Canvas(window, highlightthickness=0)
# need to use a canvas to allow scrolling
UI['style_can'].grid(sticky='NSEW')
window.rowconfigure(0, weight=1)
UI['style_scroll'] = ttk.Scrollbar(
window,
orient=VERTICAL,
command=UI['style_can'].yview,
)
UI['style_scroll'].grid(column=1, row=0, rowspan=2, sticky="NS")
UI['style_can']['yscrollcommand'] = UI['style_scroll'].set
utils.add_mousewheel(UI['style_can'], window)
canvas_frame = ttk.Frame(UI['style_can'])
frame_all = ttk.Labelframe(canvas_frame, text="All:")
frame_all.grid(row=0, sticky='EW')
frm_chosen = ttk.Labelframe(canvas_frame, text="Selected Style:")
frm_chosen.grid(row=1, sticky='EW')
ttk.Separator(
canvas_frame,
orient=HORIZONTAL,
).grid(row=2, sticky='EW', pady=(10, 5))
frm_other = ttk.Labelframe(canvas_frame, text="Other Styles:")
frm_other.grid(row=3, sticky='EW')
UI['stylevar_chosen_none'] = ttk.Label(
frm_chosen,
text='No Options!',
font='TkMenuFont',
justify='center',
)
UI['stylevar_other_none'] = ttk.Label(
frm_other,
text='None!',
font='TkMenuFont',
justify='center',
)
for pos, var in enumerate(styleOptions):
# Add the special stylevars which apply to all styles
tk_vars[var.id] = IntVar(
value=GEN_OPTS.get_bool('StyleVar', var.id, var.default)
)
checkbox_special[var.id] = ttk.Checkbutton(
frame_all,
variable=tk_vars[var.id],
text=var.name,
command=functools.partial(set_stylevar, var.id)
)
checkbox_special[var.id].grid(row=pos, column=0, sticky="W", padx=3)
tooltip.add_tooltip(
checkbox_special[var.id],
make_desc(var, is_hardcoded=True),
)
for var in VAR_LIST:
tk_vars[var.id] = IntVar(value=var.enabled)
args = {
'variable': tk_vars[var.id],
'text': var.name,
'command': functools.partial(set_stylevar, var.id)
}
checkbox_chosen[var.id] = ttk.Checkbutton(frm_chosen, **args)
checkbox_other[var.id] = ttk.Checkbutton(frm_other, **args)
desc = make_desc(var)
tooltip.add_tooltip(
checkbox_chosen[var.id],
desc,
)
tooltip.add_tooltip(
checkbox_other[var.id],
desc,
)
UI['style_can'].create_window(0, 0, window=canvas_frame, anchor="nw")
UI['style_can'].update_idletasks()
UI['style_can'].config(
#.........这里部分代码省略.........
示例9: make_pane
# 需要导入模块: from BEE2_config import GEN_OPTS [as 别名]
# 或者: from BEE2_config.GEN_OPTS import get_bool [as 别名]
def make_pane(tool_frame):
"""Create the styleVar pane.
"""
global window
window = SubPane(
TK_ROOT,
options=GEN_OPTS,
title="Style Properties",
name="style",
resize_y=True,
tool_frame=tool_frame,
tool_img=png.png("icons/win_stylevar"),
tool_col=3,
)
UI["style_can"] = Canvas(window, highlightthickness=0)
# need to use a canvas to allow scrolling
UI["style_can"].grid(sticky="NSEW")
window.rowconfigure(0, weight=1)
UI["style_scroll"] = ttk.Scrollbar(window, orient=VERTICAL, command=UI["style_can"].yview)
UI["style_scroll"].grid(column=1, row=0, rowspan=2, sticky="NS")
UI["style_can"]["yscrollcommand"] = UI["style_scroll"].set
canvas_frame = ttk.Frame(UI["style_can"])
frame_all = ttk.Labelframe(canvas_frame, text="All:")
frame_all.grid(row=0, sticky="EW")
frm_chosen = ttk.Labelframe(canvas_frame, text="Selected Style:")
frm_chosen.grid(row=1, sticky="EW")
ttk.Separator(canvas_frame, orient=HORIZONTAL).grid(row=2, sticky="EW", pady=(10, 5))
frm_other = ttk.Labelframe(canvas_frame, text="Other Styles:")
frm_other.grid(row=3, sticky="EW")
UI["stylevar_chosen_none"] = ttk.Label(frm_chosen, text="No Options!", font="TkMenuFont", justify="center")
UI["stylevar_other_none"] = ttk.Label(frm_other, text="None!", font="TkMenuFont", justify="center")
for pos, var in enumerate(styleOptions):
# Add the special stylevars which apply to all styles
tk_vars[var.id] = IntVar(value=GEN_OPTS.get_bool("StyleVar", var.id, var.enabled))
checkbox_special[var.id] = ttk.Checkbutton(
frame_all, variable=tk_vars[var.id], text=var.name, command=functools.partial(set_stylevar, var.id)
)
checkbox_special[var.id].grid(row=pos, column=0, sticky="W", padx=3)
if var.desc:
tooltip.add_tooltip(checkbox_special[var.id], var.desc)
for var in var_list:
tk_vars[var.id] = IntVar(value=var.default)
args = {"variable": tk_vars[var.id], "text": var.name, "command": functools.partial(set_stylevar, var.id)}
checkbox_chosen[var.id] = ttk.Checkbutton(frm_chosen, **args)
checkbox_other[var.id] = ttk.Checkbutton(frm_other, **args)
if var.desc:
tooltip.add_tooltip(checkbox_chosen[var.id], var.desc)
tooltip.add_tooltip(checkbox_other[var.id], var.desc)
UI["style_can"].create_window(0, 0, window=canvas_frame, anchor="nw")
UI["style_can"].update_idletasks()
UI["style_can"].config(scrollregion=UI["style_can"].bbox(ALL), width=canvas_frame.winfo_reqwidth())
ttk.Sizegrip(window, cursor=utils.CURSORS["stretch_vert"]).grid(row=1, column=0)
UI["style_can"].bind("<Configure>", flow_stylevar)
# Scroll globally even if canvas is not selected.
if utils.WIN:
window.bind("<MouseWheel>", lambda e: scroll(int(-1 * (e.delta / 120))))
elif utils.MAC:
window.bind("<Button-4>", lambda e: scroll(1))
window.bind("<Button-5>", lambda e: scroll(-1))
示例10: make_widgets
# 需要导入模块: from BEE2_config import GEN_OPTS [as 别名]
# 或者: from BEE2_config.GEN_OPTS import get_bool [as 别名]
#.........这里部分代码省略.........
desc=_('Select the music played when players jump on Repulsion Gel.'),
has_none=True,
sound_sys=filesystem,
none_desc=_('Add no music when jumping on Repulsion Gel.'),
callback=selwin_callback,
callback_params=[MusicChannel.BOUNCE],
)
WINDOWS[MusicChannel.SPEED] = SelectorWin(
TK_ROOT,
for_channel(MusicChannel.SPEED),
title=_('Select Propulsion Gel Music'),
desc=_('Select music played when players have large amounts of horizontal velocity.'),
has_none=True,
sound_sys=filesystem,
none_desc=_('Add no music while running fast.'),
callback=selwin_callback,
callback_params=[MusicChannel.SPEED],
)
assert set(WINDOWS.keys()) == set(MusicChannel), "Extra channels?"
# Widgets we want to remove when collapsing.
exp_widgets = [] # type: List[tkinter.Widget]
def toggle_btn_enter(event=None):
toggle_btn['text'] = BTN_EXPAND_HOVER if is_collapsed else BTN_CONTRACT_HOVER
def toggle_btn_exit(event=None):
toggle_btn['text'] = BTN_EXPAND if is_collapsed else BTN_CONTRACT
def set_collapsed():
"""Configure for the collapsed state."""
global is_collapsed
is_collapsed = True
GEN_OPTS['Last_Selected']['music_collapsed'] = '1'
base_lbl['text'] = _('Music: ')
toggle_btn_exit()
# Set all music to the children - so those are used.
set_suggested(WINDOWS[MusicChannel.BASE].chosen_id, sel_item=True)
for wid in exp_widgets:
wid.grid_remove()
def set_expanded():
"""Configure for the expanded state."""
global is_collapsed
is_collapsed = False
GEN_OPTS['Last_Selected']['music_collapsed'] = '0'
base_lbl['text'] = _('Base: ')
toggle_btn_exit()
for wid in exp_widgets:
wid.grid()
pane.update_idletasks()
pane.move()
def toggle(event=None):
if is_collapsed:
set_expanded()
else:
set_collapsed()
pane.update_idletasks()
pane.move()
frame.columnconfigure(2, weight=1)
base_lbl = ttk.Label(frame)
base_lbl.grid(row=0, column=1)
toggle_btn = ttk.Label(frame, text=' ')
toggle_btn.bind('<Enter>', toggle_btn_enter)
toggle_btn.bind('<Leave>', toggle_btn_exit)
toggle_btn.bind('<ButtonPress-1>', toggle)
toggle_btn.grid(row=0, column=0)
for row, channel in enumerate(MusicChannel):
btn = WINDOWS[channel].widget(frame)
if row:
exp_widgets.append(btn)
btn.grid(row=row, column=2, sticky='EW')
for row, text in enumerate([
_('Funnel:'),
_('Bounce:'),
_('Speed:'),
], start=1):
label = ttk.Label(frame, text=text)
exp_widgets.append(label)
label.grid(row=row, column=1, sticky='EW')
if GEN_OPTS.get_bool('Last_Selected', 'music_collapsed', True):
set_collapsed()
else:
set_expanded()
for channel, win in WINDOWS.items():
win.sel_item_id(last_selected[channel])
return base_win