File: drShortcutsDialog.py

package info (click to toggle)
drpython 1%3A3.11.4-1.1
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 3,868 kB
  • ctags: 2,871
  • sloc: python: 16,653; makefile: 141; sh: 1
file content (592 lines) | stat: -rw-r--r-- 28,127 bytes parent folder | download
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
#   Programmer: Daniel Pozmanter
#   E-mail:     drpython@bluebottle.com
#   Note:       You must reply to the verification e-mail to get through.
#
#   Copyright 2003-2010 Daniel Pozmanter
#
#   Distributed under the terms of the GPL (GNU Public License)
#
#    DrPython is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#Shortcuts Dialog

import os.path, re
import wx, wx.lib.dialogs
import drScrolledMessageDialog
from drGetKeyDialog import drGetKeyDialog
import drShortcutsFile
import drShortcuts
from drShortcuts import MatchControl, MatchShift, MatchAlt, MatchMeta
from drListBox import *

def ShortcutIsAlreadyTaken(TargetShortcut, ShortcutArrays, CurrentShortcut = None):
    if drShortcuts.GetKeycodeStringFromShortcut(TargetShortcut) == "":
        return -1
    i = 0
    for ShortcutArray in ShortcutArrays:
        for Shortcut in ShortcutArray:
            if Shortcut == TargetShortcut:
                if CurrentShortcut is not None:
                    if not CurrentShortcut == TargetShortcut:
                        return i
                else:
                    return i
        i += 1
    return -1

#todo: comment out? the function don't seem to be used anywhere
def GetShortcuts(filename, frame):
    try:
        f = open(filename, 'r')
        text = f.read()
        f.close()
    except:
        drScrolledMessageDialog.ShowMessage(frame, "File error with: '" + filename + "'.", "ERROR")
        return ""

    reShortcuts = re.compile(r'^\s*?DrFrame\.AddPluginShortcutFunction\(.*\)', re.MULTILINE)

    allShortcuts = reShortcuts.findall(text)

    ShortcutsArray = []

    for s in allShortcuts:
        #From the Left most '('
        start = s.find('(')
        #To the Right most ')'
        end = s.rfind(')')

        if (start > -1) and (end > -1):
            s = s[start+1:end]
            i = s.find(',')
            e = i + 1 + s[i+1:].find(',')
            argfunctionname = s[i+1:e].strip().strip('"')

            ShortcutsArray.append(argfunctionname)

    return ShortcutsArray

class drShortcutPanel(wx.Panel):

    def __init__(self, parent, id, wxSize):

        wx.Panel.__init__(self, parent, id, size=wxSize)

        self.ID_GET_KEY = 403

        self.shortcutIndex = -1
        self.listIndex = 0

        self.theSizer = wx.FlexGridSizer(0, 3, 5, 10)

        self.txtKeyChar = wx.TextCtrl(self, id, size=(100, -1), style=wx.TE_READONLY)

        self.txtKeyCode = wx.TextCtrl(self, id, size=(100, -1), style=wx.TE_READONLY)

        self.chkAlt = wx.CheckBox(self, id, "")
        self.chkControl = wx.CheckBox(self, id, "")
        self.chkMeta = wx.CheckBox(self, id, "")
        self.chkShift = wx.CheckBox(self, id, "")

        self.chkAlt.Enable(False)
        self.chkControl.Enable(False)
        self.chkMeta.Enable(False)
        self.chkShift.Enable(False)

        self.btnGetKey = wx.Button(self, self.ID_GET_KEY, "Get Key")

        self.parent = parent

        self.theSizer.Add(wx.StaticText(self, -1, ""), 1, wx.ALIGN_LEFT | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, "Key Char:"), 1, wx.ALIGN_LEFT | wx.SHAPED)
        self.theSizer.Add(self.txtKeyChar, 1, wx.ALIGN_LEFT | wx.SHAPED)

        self.theSizer.Add(wx.StaticText(self, -1, ""), 1, wx.ALIGN_LEFT | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, "Key Code:"), 1, wx.ALIGN_LEFT | wx.SHAPED)
        self.theSizer.Add(self.txtKeyCode, 1, wx.ALIGN_LEFT | wx.SHAPED)

        self.theSizer.Add(wx.StaticText(self, -1, ""), 1, wx.ALIGN_LEFT | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, "Alt:"), 1, wx.ALIGN_LEFT | wx.SHAPED)
        self.theSizer.Add(self.chkAlt, 1, wx.ALIGN_LEFT | wx.SHAPED)

        self.theSizer.Add(wx.StaticText(self, -1, ""), 1, wx.ALIGN_LEFT | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, "Control"), 1, wx.ALIGN_LEFT | wx.SHAPED)
        self.theSizer.Add(self.chkControl, 1, wx.ALIGN_LEFT | wx.SHAPED)

        self.theSizer.Add(wx.StaticText(self, -1, ""), 1, wx.ALIGN_LEFT | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, "Meta:"), 1, wx.ALIGN_LEFT | wx.SHAPED)
        self.theSizer.Add(self.chkMeta, 1, wx.ALIGN_LEFT | wx.SHAPED)

        self.theSizer.Add(wx.StaticText(self, -1, ""), 1, wx.ALIGN_LEFT | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, "Shift:"), 1, wx.ALIGN_LEFT | wx.SHAPED)
        self.theSizer.Add(self.chkShift, 1, wx.ALIGN_LEFT | wx.SHAPED)

        self.theSizer.Add(wx.StaticText(self, -1, ""), 1, wx.ALIGN_LEFT | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, ""), 1, wx.ALIGN_LEFT | wx.SHAPED)
        self.theSizer.Add(self.btnGetKey, 1, wx.ALIGN_LEFT | wx.SHAPED)

        self.SetAutoLayout(True)
        self.SetSizer(self.theSizer)

        self.Bind(wx.EVT_BUTTON, self.OnbtnGetKey, id=self.ID_GET_KEY)

    def OnbtnGetKey(self, event):
        oldv = self.parent.ShortcutsArray[self.listIndex][self.shortcutIndex]
        d = drGetKeyDialog(self, self.parent.txtIgnore.GetValue(), self.parent)
        d.SetKeyString(oldv)
        d.ShowModal()
        newv = d.GetKeyString()
        d.Destroy()
        alreadytaken = ShortcutIsAlreadyTaken(newv, self.parent.ShortcutsArray, oldv)
        if alreadytaken > -1:
            if alreadytaken == 0:
                takenby = self.parent.parent.ShortcutNames[self.parent.ShortcutsArray[alreadytaken].index(newv)]
            elif alreadytaken == 1:
                takenby = self.parent.parent.STCShortcutNames[self.parent.ShortcutsArray[alreadytaken].index(newv)]
            elif alreadytaken == 2:
                takenby = self.parent.DrScriptShortcutNamesAlpha[self.parent.ShortcutsArray[alreadytaken].index(newv)]
            else:
                takenby = self.parent.PluginShortcutNameList[alreadytaken-3][self.parent.ShortcutsArray[alreadytaken].index(newv)]
            drScrolledMessageDialog.ShowMessage(self, "The Shortcut '" + newv + \
            "'\nis already being used by '" + takenby + "'.\nDrPython will politely ignore your request.",\
            "Shortcut Already Taken")
            return
        self.parent.ShortcutsArray[self.listIndex][self.shortcutIndex] = newv
        self.SetShortcut(self.parent.ShortcutsArray[self.listIndex][self.shortcutIndex], self.shortcutIndex, self.listIndex)

    def Reset(self):
        self.txtKeyChar.SetValue("")
        self.txtKeyCode.SetValue("")

        self.chkAlt.SetValue(False)
        self.chkControl.SetValue(False)
        self.chkMeta.SetValue(False)
        self.chkShift.SetValue(False)

    def SetShortcut(self, shortcut, shortcutIndex, listIndex):
        try:
            self.shortcutIndex = shortcutIndex
            self.listIndex = listIndex

            keycode = drShortcuts.GetKeycodeFromShortcut(shortcut)

            if keycode:
                found, text = drShortcuts.GetKeycodeText(keycode)
                if found:
                    self.txtKeyChar.SetValue(text)
                elif (keycode < 0) or (keycode > 256):
                    self.txtKeyChar.SetValue("UnKnown")
                else:
                    self.txtKeyChar.SetValue(chr(keycode))
            else:
                self.txtKeyChar.SetValue("None")

            self.txtKeyCode.SetValue(str(keycode))

            self.chkAlt.SetValue(drShortcuts.MatchAlt(shortcut))
            self.chkControl.SetValue(drShortcuts.MatchControl(shortcut))
            self.chkMeta.SetValue(drShortcuts.MatchMeta(shortcut))
            self.chkShift.SetValue(drShortcuts.MatchShift(shortcut))
        except:
            drScrolledMessageDialog.ShowMessage(self.parent, "Error Selecting Shortcut", "DrPython Error")
            return


class drShortcutsDialog(wx.Dialog):

    def __init__(self, parent):
        wx.Dialog.__init__(self, parent, -1, ("Customize Shortcuts"), wx.DefaultPosition, (-1, -1), wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        wx.Yield()

        self.ID_SHORTCUTS = 1001

        self.ID_LIST = 1300

        self.ID_RESET = 1004
        self.ID_UPDATE = 1005
        self.ID_SAVE = 1006

        self.ID_IGNORE = 1300

        self.parent = parent

        self.theSizer = wx.FlexGridSizer(0, 4, 5, 10)
        self.listSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.ignoreSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.shortcutsdirectory = parent.shortcutsdirectory

        self.ShortcutsArray = [[], [], []]

        #Shortcuts

        self.ShortcutsIgnoreString = parent.ShortcutsIgnoreString

        self.ShortcutsArray[0] = list(self.parent.Shortcuts)

        #Text Control

        self.ShortcutsArray[1] = list(self.parent.STCShortcuts)

        #DrScript
        #prepaire for alphabetical display
        drscripshortcutssorted = zip(*sorted(zip(self.parent.DrScriptShortcutNames, self.parent.DrScriptShortcuts), key=lambda x: x[0]))
        self.DrScriptShortcutNamesAlpha = list(drscripshortcutssorted[0])
        self.ShortcutsArray[2] = list(drscripshortcutssorted[1])
        #end prepaire for alphabetical display

        self.ShortcutsArrayPos = 0

        #Plugins

        self.LoadPluginShortcutList()

        self.ShortcutList = ["Standard", "Text Control", "DrScript"]
        self.ShortcutList.extend(self.PluginList)

        self.cboList = wx.ComboBox(self, self.ID_LIST, "Standard", wx.DefaultPosition, (200, -1), self.ShortcutList, wx.CB_DROPDOWN|wx.CB_READONLY)

        self.boxShortcuts = drListBox(self, self.ID_SHORTCUTS, wx.DefaultPosition, (200, 200), self.parent.ShortcutNames)

        self.pnlShortcut = drShortcutPanel(self, -1, (250, -1))

        self.btnGetIgnoreKeys = wx.Button(self, self.ID_IGNORE, "Ignore Key(s)...")

        self.txtIgnore = wx.TextCtrl(self, -1, self.ShortcutsIgnoreString, size=(100, -1), style=wx.TE_READONLY)

        self.theSizer.Add(wx.StaticText(self, -1, ""), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, "   "), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, "   "), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, "   "), 0, wx.ALIGN_CENTER | wx.SHAPED)

        self.listSizer.Add(wx.StaticText(self, -1, "List: "), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.listSizer.Add(self.cboList, 0, wx.ALIGN_CENTER | wx.SHAPED)

        self.ignoreSizer.Add(wx.StaticText(self, -1, "Ignore: "), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.ignoreSizer.Add(self.txtIgnore, 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.ignoreSizer.Add(self.btnGetIgnoreKeys, 0, wx.ALIGN_CENTER | wx.SHAPED)

        self.theSizer.Add(wx.StaticText(self, -1, ""), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.theSizer.Add(self.listSizer, 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, "   "), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.theSizer.Add(self.ignoreSizer, 0, wx.ALIGN_CENTER | wx.SHAPED)

        self.theSizer.Add(wx.StaticText(self, -1, ""), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, "Shortcuts List:"), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, "   "), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, "Shortcut:"), 0, wx.ALIGN_CENTER | wx.SHAPED)

        self.theSizer.Add(wx.StaticText(self, -1, ""), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.theSizer.Add(self.boxShortcuts, 0, wx.SHAPED | wx.ALIGN_CENTER)
        self.theSizer.Add(wx.StaticText(self, -1, ""), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.theSizer.Add(self.pnlShortcut, 1,  wx.EXPAND | wx.ALIGN_CENTER)

        self.theSizer.Add(wx.StaticText(self, -1, ""), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, ""), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, ""), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, ""), 0, wx.ALIGN_CENTER | wx.SHAPED)

        self.btnReset = wx.Button(self, self.ID_RESET, "&Reset")
        self.btnUpdate = wx.Button(self, self.ID_UPDATE, "&Update")
        self.btnSave = wx.Button(self, self.ID_SAVE, "&Save")

        self.btnClose = wx.Button(self, 101, "&Close")

        self.theSizer.Add(wx.StaticText(self, -1, ""), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.theSizer.Add(self.btnReset, 0,  wx.SHAPED | wx.ALIGN_CENTER)
        self.theSizer.Add(self.btnUpdate, 0,  wx.SHAPED | wx.ALIGN_CENTER)
        self.theSizer.Add(self.btnSave, 0,  wx.SHAPED | wx.ALIGN_CENTER)

        self.theSizer.Add(wx.StaticText(self, -1, ""), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.theSizer.Add(wx.StaticText(self, -1, ""), 0, wx.ALIGN_CENTER | wx.SHAPED)
        self.theSizer.Add(self.btnClose, 0,  wx.SHAPED | wx.ALIGN_CENTER)
        self.theSizer.Add(wx.StaticText(self, -1, ""), 0, wx.ALIGN_CENTER | wx.SHAPED)

        self.btnClose.SetDefault()

        self.SetAutoLayout(True)
        self.SetSizerAndFit(self.theSizer)

        self.Bind(wx.EVT_BUTTON, self.OnbtnReset, id=self.ID_RESET)
        self.Bind(wx.EVT_BUTTON, self.OnbtnUpdate, id=self.ID_UPDATE)
        self.Bind(wx.EVT_BUTTON, self.OnbtnSave, id=self.ID_SAVE)
        self.Bind(wx.EVT_BUTTON, self.OnbtnClose, id=101)

        self.Bind(wx.EVT_BUTTON, self.OnbtnGetIgnoreKeys, id=self.ID_IGNORE)

        self.Bind(wx.EVT_COMBOBOX, self.OnList, id=self.ID_LIST)
        self.Bind(wx.EVT_LISTBOX, self.OnSelect, id=self.ID_SHORTCUTS)

        self.parent.LoadDialogSizeAndPosition(self, "shortcutsdialog.sizeandposition.dat")
        if parent.PLATFORM_IS_GTK: #does not get initially the focus (bug tracker #1903778, "Open Imported Module: focus problem", 29.02.2008: from Jon White, thanks.
            self.SetFocus()

    def LoadPluginShortcutList(self):
        plist = os.listdir(self.parent.pluginsdirectory)

        self.PluginShortcutNameList = []

        self.PluginList = []
        for p in plist:
            i = p.find(".py")
            l = len(p)
            if i > -1 and (i + 3 == l):
                self.PluginList.append("<Plugin>:" + p[:i])

        self.PluginList.sort()

        poplist = []
        #Load shortcuts from plugins.
        for plugin in self.PluginList:
            list = []
            if plugin.find("<Plugin>") > -1:
                pluginfile = os.path.join(self.parent.pluginsdirectory, plugin[plugin.find(':')+1:] + ".py")
                shortcutfile = os.path.join(self.parent.pluginsshortcutsdirectory, plugin[plugin.find(':')+1:] + ".shortcuts.dat")
                #todo: comment out? the function don't seem to be used anywhere
                list = GetShortcuts(pluginfile, self)
                plist = self.parent.GetPluginLabels(pluginfile, True)
                for p in plist:
                    if not (p in list):
                        list.append(p)
                shortcuts = []
                if list:
                    needtomakefile = 0
                    #If the file does not exist, or is out of date, create it.
                    if not os.path.exists(shortcutfile):
                        needtomakefile = 1
                    else:
                        shortcuts, names, ignorestring = drShortcutsFile.ReadShortcuts(shortcutfile, 0)
                        if len(shortcuts) != len(list):
                            needtomakefile = 2

                    if needtomakefile:
                        try:
                            if list:
                                f = open(shortcutfile, 'w')
                                if needtomakefile == 2:
                                    for s in list:
                                        if s in names:
                                            ix = names.index(s)
                                            f.write("<" + s + "><mod>")
                                            if MatchControl(shortcuts[ix]):
                                                f.write("Control,")
                                            if MatchShift(shortcuts[ix]):
                                                f.write("Shift,")
                                            if MatchAlt(shortcuts[ix]):
                                                f.write("Alt,")
                                            if MatchMeta(shortcuts[ix]):
                                                f.write("Meta")
                                            f.write("</mod><keycode>" + drShortcuts.GetKeycodeStringFromShortcut(shortcuts[ix]) +
                                            "</keycode></" + s + ">\n")
                                        else:
                                            f.write("<" + s + "><mod></mod><keycode></keycode></" + s + ">\n")
                                else:
                                    for s in list:
                                        f.write("<" + s + "><mod></mod><keycode></keycode></" + s + ">\n")
                                f.close()
                                shortcuts, names, ignorestring = drShortcutsFile.ReadShortcuts(shortcutfile, 0)
                            else:
                                shortcuts, names, ignorestring = [], [], ""

                            if plugin.find(':') > -1:
                                plugin = plugin[plugin.find(':')+1:]

                            x = 0
                            for shortcut in shortcuts:
                                try:
                                    i = self.parent.PluginShortcutFunctionNames.index(plugin + ":" + names[x])
                                    self.parent.PluginAction.append(self.parent.PluginShortcutFunctions[i])
                                    self.parent.PluginShortcuts.append(shortcut)
                                except:
                                    pass
                                x += 1
                            if os.path.exists(shortcutfile):
                                shortcuts, names, ignorestring = drShortcutsFile.ReadShortcuts(shortcutfile, 0)
                        except:
                            drScrolledMessageDialog.ShowMessage(self, ("Error Creating Shortcuts For Plugin"), "Plugin Shortcuts Error")
                            return

                if shortcuts:
                    self.ShortcutsArray.append(shortcuts)
                    self.PluginShortcutNameList.append(names)
                else:
                    poplist.append(plugin)

        for popl in poplist:
            try:
                i = self.PluginList.index(popl)
                self.PluginList.pop(i)
            except:
                pass

    def OnCloseW(self, event):
        self.parent.SaveDialogSizeAndPosition(self, "shortcutsdialog.sizeandposition.dat")
        if event is not None:
            event.Skip()

    def OnbtnClose(self, event):
        self.Close(1)

    def OnbtnGetIgnoreKeys(self, event):
        addstring = '\n\n'
        if self.parent.PLATFORM_IS_WIN:
            addstring = '\n\n\n\n\n\n'
        d = wx.lib.dialogs.MultipleChoiceDialog(self, "Select the Modifier Keys you wish to ignore:" + addstring,
            "Ignore Modifier Keys", ["Control", "Meta", "Shift", "Alt"])
        answer = d.ShowModal()
        if answer == wx.ID_OK:
            tuply = d.GetValueString()
            leString = ""
            for selection in tuply:
                leString = leString + selection + ","
            self.txtIgnore.SetValue(leString)
        d.Destroy()

    def OnbtnReset(self, event):
        answer = wx.MessageBox("This will reset all standard shortcuts to the program default.\n(You still need to click update and/or save)\nAre you sure you want to do this?",
            "Reset Shortcuts", wx.YES_NO | wx.ICON_QUESTION)
        if answer == wx.YES:
            self.ShortcutsArray[0], self.ShortcutsIgnoreString = drShortcutsFile.GetDefaultShortcuts()
            self.ShortcutsArray[0], saa, sarg = drShortcuts.SetShortcuts(self.parent, self.ShortcutsArray[0], self.parent.ShortcutNames, 1)
            sel = self.boxShortcuts.GetSelection()
            self.ShortcutsArray[1] = drShortcuts.SetSTCShortcuts(self.parent.txtDocument, self.ShortcutsArray[1], True)
            drShortcuts.SetSTCShortcuts(self.parent.txtPrompt, self.ShortcutsArray[1], True)
            self.pnlShortcut.SetShortcut(self.ShortcutsArray[self.ShortcutsArrayPos][sel], sel, self.ShortcutsArrayPos)

    def OnbtnSave(self, event):
        self.update()
        #STC
        shortcutsfile = os.path.join(self.shortcutsdirectory, "stcshortcuts.dat")
        try:
            drShortcutsFile.WriteShortcuts(shortcutsfile, self.ShortcutsArray[1], self.parent.STCShortcutNames, "", False)
        except:
            drScrolledMessageDialog.ShowMessage(self, ("There were some problems writing to:\n"  + shortcutsfile + "\nEither the file is having metaphysical issues, or you do not have permission to write.\nFor metaphysical issues, consult the documentation.\nFor permission issues, change the permissions on the directory to allow yourself write access.\nDrPython will now politely ignore your request to save.\nTry again when you have fixed the problem."), "Write Error")
            return

        #STCDefault
        if self.parent.STCUseDefault:
            self.parent.STCUseDefault = 0

        #Main
        shortcutsfile = os.path.join(self.shortcutsdirectory, "shortcuts.dat")
        try:
            drShortcutsFile.WriteShortcuts(shortcutsfile, self.ShortcutsArray[0], self.parent.ShortcutNames, self.txtIgnore.GetValue())
        except:
            drScrolledMessageDialog.ShowMessage(self, ("There were some problems writing to:\n"  + shortcutsfile + "\nEither the file is having metaphysical issues, or you do not have permission to write.\nFor metaphysical issues, consult the documentation.\nFor permission issues, change the permissions on the directory to allow yourself write access.\nDrPython will now politely ignore your request to save.\nTry again when you have fixed the problem."), "Write Error")
            return

        #DrScripts
        shortcutsfile = os.path.join(self.shortcutsdirectory, "drscript.shortcuts.dat")
        try:
            drShortcutsFile.WriteShortcuts(shortcutsfile, self.ShortcutsArray[2], self.parent.DrScriptShortcutNames, "", False)
        except:
            drScrolledMessageDialog.ShowMessage(self, ("There were some problems writing to:\n"  + shortcutsfile + "\nEither the file is having metaphysical issues, or you do not have permission to write.\nFor metaphysical issues, consult the documentation.\nFor permission issues, change the permissions on the directory to allow yourself write access.\nDrPython will now politely ignore your request to save.\nTry again when you have fixed the problem."), "Write Error")
            return

        #Plugins
        x = 3
        l = len(self.ShortcutsArray)
        while x < l:
            plugin = self.ShortcutList[x]
            if plugin.find("<Plugin>") > -1:
                shortcutsfile = os.path.join(self.parent.pluginsshortcutsdirectory, plugin[plugin.find(':')+1:] + ".shortcuts.dat")
                try:
                    drShortcutsFile.WriteShortcuts(shortcutsfile, self.ShortcutsArray[x], self.PluginShortcutNameList[x-3], "", False)
                except:
                    drScrolledMessageDialog.ShowMessage(self, ("There were some problems writing to:\n"  + shortcutsfile + "\nEither the file is having metaphysical issues, or you do not have permission to write.\nFor metaphysical issues, consult the documentation.\nFor permission issues, change the permissions on the directory to allow yourself write access.\nDrPython will now politely ignore your request to save.\nTry again when you have fixed the problem."), "Write Error")
                    return

            x = x + 1

        if self.parent.prefs.enablefeedback:
            drScrolledMessageDialog.ShowMessage(self, ("Succesfully saved shortcuts\nand updated the current instance of DrPython."), "Saved Shortcuts")

        wx.MessageBox("To update the menu shortcuts, please restart DrPython", "Info")

    def OnbtnUpdate(self, event):

        self.update()

        if self.parent.prefs.enablefeedback:
            drScrolledMessageDialog.ShowMessage(self, ("Succesfully updated the current instance of DrPython.\nClick Save to make it permanent."), "Updated Shortcuts")

    def OnList(self, event):
        sel = self.cboList.GetSelection()
        self.ShortcutsArrayPos = sel

        self.pnlShortcut.Reset()

        if sel == 0:
            names = self.parent.ShortcutNames

        elif sel == 1:
            names = self.parent.STCShortcutNames

        elif sel == 2:
            names = self.DrScriptShortcutNamesAlpha

        else:
            names = self.PluginShortcutNameList[sel-3]

        self.boxShortcuts.Set(names)

    def OnSelect(self, event):
        sel = self.boxShortcuts.GetSelection()
        self.pnlShortcut.SetShortcut(self.ShortcutsArray[self.ShortcutsArrayPos][sel], sel, self.ShortcutsArrayPos)

    def update(self):
        self.parent.ShortcutsIgnoreString = self.txtIgnore.GetValue()

        self.parent.Shortcuts = self.ShortcutsArray[0]
        self.parent.STCShortcuts = self.ShortcutsArray[1]

        #restore from alphabetical display
        i = 0
        for scriptname in self.DrScriptShortcutNamesAlpha:
            ind = self.parent.DrScriptShortcutNames.index(scriptname)
            self.parent.DrScriptShortcuts[ind] = self.ShortcutsArray[2][i]
            i += 1
        self.ShortcutsArray[2] = self.parent.DrScriptShortcuts
        #end restore from alphabetical display

        self.parent.ShortcutsActionArray = []
        self.parent.ShortcutsArgumentsArray = []

        drShortcuts.SetSTCShortcuts(self.parent.txtPrompt, self.parent.STCShortcuts)
        self.parent.STCShortcuts = drShortcuts.SetSTCShortcuts(self.parent.txtDocument, self.parent.STCShortcuts)
        self.parent.Shortcuts, self.parent.ShortcutsActionArray, self.parent.ShortcutsArgumentsArray = drShortcuts.SetShortcuts(self.parent, self.ShortcutsArray[0], self.parent.ShortcutNames)

        #Plugins:

        l = len(self.ShortcutsArray)
        if l > 3:
            x = 3
            while x < l:
                sArray = self.ShortcutsArray[x]
                a = x - 3
                ly = len(sArray)
                y = 0
                while y < ly:
                    yName = self.ShortcutList[x] + ":" + self.PluginShortcutNameList[a][y]
                    yName = yName[yName.find(':')+1:]
                    if yName in self.parent.PluginShortcutFunctionNames:
                        i = self.parent.PluginShortcutFunctionNames.index(yName)
                        try:
                            self.parent.PluginShortcuts[i] = sArray[y]
                        except:
                            pass
                    y = y + 1
                x = x + 1