mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-21 23:06:38 +00:00
libgui/GuiFrame.py:loadAccels(): obtain from {menu,Toolbar}s[].
libroar/RoarCanvasCommands{,Edit,File,Help,Tools}.py: remove self.accels[]. libroar/RoarClient.py: updated.
This commit is contained in:
parent
309e8cf089
commit
bb23efac56
@ -53,18 +53,22 @@ class GuiFrame(wx.Frame):
|
||||
self.SetIcon(icon)
|
||||
# }}}
|
||||
|
||||
# {{{ loadAccels(self, accels)
|
||||
def loadAccels(self, accels):
|
||||
# {{{ loadAccels(self, menus, toolBars)
|
||||
def loadAccels(self, menus, toolBars):
|
||||
def loadAccels_(accels):
|
||||
nonlocal accelTableEntries
|
||||
for accel in accels:
|
||||
if (not accel in [NID_MENU_SEP, NID_TOOLBAR_HSEP]) \
|
||||
and (accel.attrDict["accel"] != None):
|
||||
accelTableEntries += [wx.AcceleratorEntry()]
|
||||
if accel.attrDict["id"] == None:
|
||||
accel.attrDict["id"] = self.lastId; self.lastId += 1;
|
||||
accelTableEntries[-1].Set(*accel.attrDict["accel"], accel.attrDict["id"])
|
||||
accel.attrDict["accelEntry"] = accelTableEntries[-1]
|
||||
self.itemsById[accel.attrDict["id"]] = accel
|
||||
self.Bind(wx.EVT_MENU, self.onMenu, id=accel.attrDict["id"])
|
||||
accelTableEntries = []
|
||||
for accel in accels:
|
||||
if accel.attrDict["accel"] != None:
|
||||
accelTableEntries += [wx.AcceleratorEntry()]
|
||||
if accel.attrDict["id"] == None:
|
||||
accel.attrDict["id"] = self.lastId; self.lastId += 1;
|
||||
accelTableEntries[-1].Set(*accel.attrDict["accel"], accel.attrDict["id"])
|
||||
accel.attrDict["accelEntry"] = accelTableEntries[-1]
|
||||
self.itemsById[accel.attrDict["id"]] = accel
|
||||
self.Bind(wx.EVT_MENU, self.onMenu, id=accel.attrDict["id"])
|
||||
[loadAccels_(menu[1:]) for menu in menus]; [loadAccels_(toolBar) for toolBar in toolBars];
|
||||
self.SetAcceleratorTable(wx.AcceleratorTable(accelTableEntries))
|
||||
# }}}
|
||||
# {{{ loadBitmap(self, basePathName, descr, size=(16, 16))
|
||||
|
@ -87,12 +87,10 @@ class RoarCanvasCommands(RoarCanvasCommandsFile, RoarCanvasCommandsEdit, RoarCan
|
||||
#
|
||||
# __init__(self, parentCanvas, parentFrame):
|
||||
def __init__(self, parentCanvas, parentFrame):
|
||||
accels, menus, toolBars = [], [], []
|
||||
menus, toolBars = [], []
|
||||
self.canvasPathName, self.lastPanelState, self.parentCanvas, self.parentFrame = None, {}, parentCanvas, parentFrame
|
||||
for classObject in self.__class__.__bases__:
|
||||
classObject.__init__(self)
|
||||
if len(self.accels):
|
||||
accels += self.accels
|
||||
if len(self.menus):
|
||||
menus += self.menus
|
||||
if len(self.toolBars):
|
||||
@ -118,6 +116,6 @@ class RoarCanvasCommands(RoarCanvasCommandsFile, RoarCanvasCommandsEdit, RoarCan
|
||||
self.canvasBrushSize(self.canvasBrushSize, 1, True), self.canvasBrushSize(self.canvasBrushSize, 0, False), self.canvasBrushSize(self.canvasBrushSize, 1, True), self.canvasBrushSize(self.canvasBrushSize, 1, False), NID_TOOLBAR_HSEP,
|
||||
self.canvasBrushSize(self.canvasBrushSize, 2, True), self.canvasBrushSize(self.canvasBrushSize, 2, False),
|
||||
])
|
||||
self.accels, self.menus, self.toolBars = accels, menus, toolBars
|
||||
self.menus, self.toolBars = menus, toolBars
|
||||
|
||||
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=0
|
||||
|
@ -141,7 +141,6 @@ class RoarCanvasCommandsEdit():
|
||||
#
|
||||
# __init__(self)
|
||||
def __init__(self):
|
||||
self.accels = (self.canvasUndo, self.canvasRedo)
|
||||
self.menus = (
|
||||
("&Edit",
|
||||
self.canvasUndo, self.canvasRedo, NID_MENU_SEP,
|
||||
|
@ -220,7 +220,6 @@ class RoarCanvasCommandsFile():
|
||||
# __init__(self)
|
||||
def __init__(self):
|
||||
self.imgurApiKey = ImgurApiKey.imgurApiKey if haveImgurApiKey else None
|
||||
self.accels = (self.canvasExit, self.canvasNew, self.canvasOpen, self.canvasSave)
|
||||
self.menus = (
|
||||
("&File",
|
||||
self.canvasNew, self.canvasOpen, self.canvasSave, self.canvasSaveAs, NID_MENU_SEP,
|
||||
|
@ -17,6 +17,6 @@ class RoarCanvasCommandsHelp():
|
||||
#
|
||||
# __init__(self)
|
||||
def __init__(self):
|
||||
self.accels, self.menus, self.toolBars = (), (("&Help", self.canvasAbout,),), ()
|
||||
self.menus, self.toolBars = (("&Help", self.canvasAbout,),), ()
|
||||
|
||||
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=0
|
||||
|
@ -41,7 +41,6 @@ class RoarCanvasCommandsTools():
|
||||
#
|
||||
# __init__(self)
|
||||
def __init__(self):
|
||||
self.accels = (self.canvasTool(self.canvasTool, 5), self.canvasTool(self.canvasTool, 0), self.canvasTool(self.canvasTool, 2), self.canvasTool(self.canvasTool, 3), self.canvasTool(self.canvasTool, 6), self.canvasTool(self.canvasTool, 1), self.canvasTool(self.canvasTool, 4),)
|
||||
self.menus = (
|
||||
("&Tools",
|
||||
self.canvasTool(self.canvasTool, 5), self.canvasTool(self.canvasTool, 0), self.canvasTool(self.canvasTool, 2), self.canvasTool(self.canvasTool, 3), self.canvasTool(self.canvasTool, 6), self.canvasTool(self.canvasTool, 1), self.canvasTool(self.canvasTool, 4),
|
||||
|
@ -42,7 +42,7 @@ class RoarClient(GuiFrame):
|
||||
super().__init__(self._getIconPathName(), size, parent, title)
|
||||
self.canvas = Canvas(defaultCanvasSize)
|
||||
self.canvasPanel = RoarCanvasWindow(GuiCanvasWxBackend, self.canvas, defaultCellSize, RoarCanvasCommands, self.panelSkin, self, defaultCanvasPos, defaultCellSize, defaultCanvasSize)
|
||||
self.loadAccels(self.canvasPanel.commands.accels)
|
||||
self.loadAccels(self.canvasPanel.commands.menus, self.canvasPanel.commands.toolBars)
|
||||
self.loadMenus(self.canvasPanel.commands.menus)
|
||||
self._initToolBitmaps(self.canvasPanel.commands.toolBars)
|
||||
self.loadToolBars(self.canvasPanel.commands.toolBars)
|
||||
|
Loading…
Reference in New Issue
Block a user