-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmenuItemsStore.py
More file actions
35 lines (26 loc) · 1.04 KB
/
menuItemsStore.py
File metadata and controls
35 lines (26 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- coding: utf-8 -*-
# Filer menu items store
# Copyright (C) 2019 Yukio Nozawa <personal@nyanchangames.com>
# Note: All comments except these top lines will be written in Japanese.
# wx のメニューのrefを一括管理してくれる便利な人
import win32file
import wx
class _MenuItemsStore(object):
"""このクラスは、外からインスタンス化してはいけません。"""
def __init__(self):
self.refs = {}
self.nextID = 5000
def _getRef(self, identifier):
identifier = identifier.upper()
try:
return self.refs[identifier]
except KeyError: # なかったら作る
ref = self.nextID
self.nextID += 1
self.refs[identifier] = ref
# end なかったから作った
return ref
_store = _MenuItemsStore()
def getRef(identifier):
"""文字列から、対応するメニューのrefを取得する。なかったら、作ってから帰す。"""
return _store._getRef(identifier)