1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 00:07:14 +03:00

Fix click_counter example to work & pass linting

* It was returning 'ClickCounter' for the name, mis-matching with the
  folder name of 'click_counter', which caused plain logging to be used.
  That in turn then complained about the lack of %(osthreadid).

* flake8 pass, including adding doc strings, with references to
  PLUGINS.md sections.

* mypy pass.
This commit is contained in:
Athanasius 2021-11-22 10:42:31 +00:00
parent 9f231cc57e
commit 71ed90fb3a
No known key found for this signature in database
GPG Key ID: AE3E527847057C7D

View File

@ -8,10 +8,11 @@ import logging
import tkinter as tk
from typing import Optional
import myNotebook as nb
import myNotebook as nb # noqa: N813
from config import appname, config
PLUGIN_NAME = "ClickCounter"
# This **MUST** match the name of the folder the plugin is in.
PLUGIN_NAME = "click_counter"
logger = logging.getLogger(f"{appname}.{PLUGIN_NAME}")
@ -76,7 +77,7 @@ class ClickCounter:
:param cmdr: The current ED Commander
:param is_beta: Whether or not EDMC is currently marked as in beta mode
"""
config.set('click_counter_count', self.click_count.get())
config.set('click_counter_count', self.click_count.get()) # type: ignore
def setup_main_ui(self, parent: tk.Frame) -> tk.Frame:
"""
@ -92,7 +93,7 @@ class ClickCounter:
button = tk.Button(
frame,
text="Count me",
command=lambda: self.click_count.set(str(int(self.click_count.get()) + 1))
command=lambda: self.click_count.set(str(int(self.click_count.get()) + 1)) # type: ignore
)
button.grid(row=current_row)
current_row += 1
@ -107,20 +108,45 @@ cc = ClickCounter()
# Note that all of these could be simply replaced with something like:
# plugin_start3 = cc.on_load
def plugin_start3(plugin_dir: str) -> str:
"""
Handle start up of the plugin.
See PLUGINS.md#startup
"""
return cc.on_load()
def plugin_stop() -> None:
"""
Handle shutdown of the plugin.
See PLUGINS.md#shutdown
"""
return cc.on_unload()
def plugin_prefs(parent: nb.Notebook, cmdr: str, is_beta: bool) -> Optional[tk.Frame]:
"""
Handle preferences tab for the plugin.
See PLUGINS.md#configuration
"""
return cc.setup_preferences(parent, cmdr, is_beta)
def prefs_changed(cmdr: str, is_beta: bool) -> None:
"""
Handle any changed preferences for the plugin.
See PLUGINS.md#configuration
"""
return cc.on_preferences_closed(cmdr, is_beta)
def plugin_app(parent: tk.Frame) -> Optional[tk.Frame]:
"""
Set up the UI of the plugin.
See PLUGINS.md#display
"""
return cc.setup_main_ui(parent)