Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save eros18123/ac92e06eb0c49571325c0ee7391d88d4 to your computer and use it in GitHub Desktop.

Select an option

Save eros18123/ac92e06eb0c49571325c0ee7391d88d4 to your computer and use it in GitHub Desktop.
modo foco, ativa e desativa botoes de barra de cima e de baixo ctrl+h
import os
import json
from aqt import mw
from aqt.qt import *
from aqt.gui_hooks import state_did_change, reviewer_did_show_question
config_file = os.path.join(os.path.dirname(__file__), "config.json")
config = {"hidden": False}
def load_config():
global config
if os.path.exists(config_file):
try:
with open(config_file, "r") as f:
config = json.load(f)
except:
pass
def save_config():
with open(config_file, "w") as f:
json.dump(config, f)
def update_ui():
should_show = not config["hidden"]
if mw.menuBar():
mw.menuBar().setVisible(should_show)
if mw.toolbar.web:
mw.toolbar.web.setVisible(should_show)
if mw.bottomWeb:
if not should_show:
mw.bottomWeb.setVisible(False)
elif mw.state == "review":
mw.bottomWeb.setVisible(True)
def toggle_interface():
config["hidden"] = not config["hidden"]
save_config()
update_ui()
def on_state_change(new_state, old_state):
update_ui()
load_config()
action = QAction("Toggle Interface", mw)
action.setShortcut(QKeySequence("Ctrl+H"))
action.setShortcutContext(Qt.ShortcutContext.ApplicationShortcut)
action.triggered.connect(toggle_interface)
mw.addAction(action)
state_did_change.append(on_state_change)
reviewer_did_show_question.append(lambda c: update_ui())
update_ui()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment