Accelerator Table doesn't work

I test the next code using

wx.version()

Out[4]: ‘3.0.1.1 msw (classic)’

sys.version

Out[7]: ‘2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]’

I put the complete version on the attached file.

-- coding: utf-8 --

import wx

from wx.lib.embeddedimage import PyEmbeddedImage

class viewMain ( wx.Frame ):

def __init__( self, parent ):

    wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 711,488 ), style = wx.DEFAULT_FRAME_STYLE|wx.MAXIMIZE|wx.TAB_TRAVERSAL )

    self.toolbar()

def toolbar(self):

    def cat(nombre):

        return AA16.getBitmap()

    tools={1001:{'label':u'Control','icon':'control32','func':self.toolControl,'key':(wx.ACCEL_NORMAL,wx.WXK_F9)},

        1002:{'label':u'Tareas','icon':'tarea32','func':self.toolListaTareas,'key':(wx.ACCEL_NORMAL,wx.WXK_F10)},

        1100:{'label':u'Cédula','icon':'cedula32','func':self.toolCedula,'key':(wx.ACCEL_CTRL, ord('C'))},

        1103:{'label':u'Oficio','icon':'oficio32','func':self.toolOficio,'key':(wx.ACCEL_CTRL, ord('O'))},

        1104:{'label':u'Tramite','icon':'tramite32','func':self.toolTramite,'key':(wx.ACCEL_CTRL, ord('T'))},

        1105:{'label':u'Paz','icon':'paz32','func':self.toolPaz,'key':(wx.ACCEL_CTRL, ord('P'))},

        1106:{'label':u'Reincidencias','icon':'uer32','func':self.toolReincidencias,'key':(wx.ACCEL_CTRL, ord('R'))},

        1107:{'label':u'Int.Criminal','icon':'intcrim32','func':self.toolIntCriminal,'key':(wx.ACCEL_CTRL, ord('I'))},

        1201:{'label':u'Generar','icon':'generar32','func':self.toolGenerar,'key':(wx.ACCEL_NORMAL,wx.WXK_F11)},

        1202:{'label':u'Expediente','icon':'expediente32','func':self.toolExpediente,'key':(wx.ACCEL_NORMAL,wx.WXK_F12)},

        }

    ids=[k for k in tools.keys()]

    ids.sort()

    self.m_toolBar1 = self.CreateToolBar( wx.TB_HORIZONTAL|wx.TB_HORZ_TEXT, wx.ID_ANY )

    for id in ids:

        tool=tools[id]

        id_widg=wx.NewId()

        widg=self.m_toolBar1.AddLabelTool(id_widg, tool['label'], cat(tool['icon']),

            wx.NullBitmap, wx.ITEM_NORMAL,

            wx.EmptyString, wx.EmptyString, None )

        tool['id']=id_widg

    self.m_toolBar1.Realize()

    list_accel=[]

    for id in ids:

        tool_key=tools[id]['key']

        list_accel.append((tool_key[0],tool_key[1],tools[id]['id']))

    aTable=wx.AcceleratorTable(list_accel)

    for id in ids:

        tool=tools[id]

        self.m_toolBar1.Bind(wx.EVT_TOOL, tool['func'],id=tool['id'])

    self.SetAcceleratorTable(aTable)

def toolControl(self,evt):

    ...

AA16 = PyEmbeddedImage(…)

basu.py (4.7 KB)

Hi,

its not complete:

mario@mario:~/Escritorio$ python basu.py
Traceback (most recent call last):
File “basu.py”, line 7, in
import gui.views, gui.catalog
ImportError: No module named gui.views

···

2015-09-04 8:29 GMT-05:00 Marian mavignau@gmail.com:

I test the next code using

wx.version()

Out[4]: ‘3.0.1.1 msw (classic)’

sys.version

Out[7]: ‘2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]’

I put the complete version on the attached file.

-- coding: utf-8 --

import wx

from wx.lib.embeddedimage import PyEmbeddedImage

class viewMain ( wx.Frame ):

def __init__( self, parent ):
    wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 711,488 ), style = wx.DEFAULT_FRAME_STYLE|wx.MAXIMIZE|wx.TAB_TRAVERSAL )
    self.toolbar()
def toolbar(self):
    def cat(nombre):
        return AA16.getBitmap()
    tools={1001:{'label':u'Control','icon':'control32','func':self.toolControl,'key':(wx.ACCEL_NORMAL,wx.WXK_F9)},
        1002:{'label':u'Tareas','icon':'tarea32','func':self.toolListaTareas,'key':(wx.ACCEL_NORMAL,wx.WXK_F10)},
        1100:{'label':u'Cédula','icon':'cedula32','func':self.toolCedula,'key':(wx.ACCEL_CTRL, ord('C'))},
        1103:{'label':u'Oficio','icon':'oficio32','func':self.toolOficio,'key':(wx.ACCEL_CTRL, ord('O'))},
        1104:{'label':u'Tramite','icon':'tramite32','func':self.toolTramite,'key':(wx.ACCEL_CTRL, ord('T'))},
        1105:{'label':u'Paz','icon':'paz32','func':self.toolPaz,'key':(wx.ACCEL_CTRL, ord('P'))},
        1106:{'label':u'Reincidencias','icon':'uer32','func':self.toolReincidencias,'key':(wx.ACCEL_CTRL, ord('R'))},
        1107:{'label':u'Int.Criminal','icon':'intcrim32','func':self.toolIntCriminal,'key':(wx.ACCEL_CTRL, ord('I'))},
        1201:{'label':u'Generar','icon':'generar32','func':self.toolGenerar,'key':(wx.ACCEL_NORMAL,wx.WXK_F11)},
        1202:{'label':u'Expediente','icon':'expediente32','func':self.toolExpediente,'key':(wx.ACCEL_NORMAL,wx.WXK_F12)},
        }
    ids=[k for k in tools.keys()]
    ids.sort()
    self.m_toolBar1 = self.CreateToolBar( wx.TB_HORIZONTAL|wx.TB_HORZ_TEXT, wx.ID_ANY )
    for id in ids:
        tool=tools[id]
        id_widg=wx.NewId()
        widg=self.m_toolBar1.AddLabelTool(id_widg, tool['label'], cat(tool['icon']),
            wx.NullBitmap, wx.ITEM_NORMAL,
            wx.EmptyString, wx.EmptyString, None )
        tool['id']=id_widg
    self.m_toolBar1.Realize()
    list_accel=[]
    for id in ids:
        tool_key=tools[id]['key']
        list_accel.append((tool_key[0],tool_key[1],tools[id]['id']))
    aTable=wx.AcceleratorTable(list_accel)
    for id in ids:
        tool=tools[id]
        self.m_toolBar1.Bind(wx.EVT_TOOL, tool['func'],id=tool['id'])
    self.SetAcceleratorTable(aTable)
def toolControl(self,evt):
    ...

AA16 = PyEmbeddedImage(…)

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Saludos / Best regards

Mario Lacunza
Email:: mlacunza@gmail.com
Personal Website:: http://www.lacunza.biz/
Hosting:: http://mlv-host.com/
Mascotas Perdidas:: http://mascotas-perdidas.com/
Skype: mlacunzav

Lima - Peru

Pls, just comment this line

···

2015-09-04 13:57 GMT-03:00 Mario Lacunza mlacunza@gmail.com:

Hi,

its not complete:

mario@mario:~/Escritorio$ python basu.py
Traceback (most recent call last):
File “basu.py”, line 7, in
import gui.views, gui.catalog
ImportError: No module named gui.views

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Saludos / Best regards

Mario Lacunza
Email:: mlacunza@gmail.com
Personal Website:: http://www.lacunza.biz/
Hosting:: http://mlv-host.com/
Mascotas Perdidas:: http://mascotas-perdidas.com/
Skype: mlacunzav

Lima - Peru

2015-09-04 8:29 GMT-05:00 Marian mavignau@gmail.com:

I test the next code using

wx.version()

Out[4]: ‘3.0.1.1 msw (classic)’

sys.version

Out[7]: ‘2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]’

I put the complete version on the attached file.

-- coding: utf-8 --

import wx

from wx.lib.embeddedimage import PyEmbeddedImage

class viewMain ( wx.Frame ):

def __init__( self, parent ):
    wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 711,488 ), style = wx.DEFAULT_FRAME_STYLE|wx.MAXIMIZE|wx.TAB_TRAVERSAL )
    self.toolbar()
def toolbar(self):
    def cat(nombre):
        return AA16.getBitmap()
    tools={1001:{'label':u'Control','icon':'control32','func':self.toolControl,'key':(wx.ACCEL_NORMAL,wx.WXK_F9)},
        1002:{'label':u'Tareas','icon':'tarea32','func':self.toolListaTareas,'key':(wx.ACCEL_NORMAL,wx.WXK_F10)},
        1100:{'label':u'Cédula','icon':'cedula32','func':self.toolCedula,'key':(wx.ACCEL_CTRL, ord('C'))},
        1103:{'label':u'Oficio','icon':'oficio32','func':self.toolOficio,'key':(wx.ACCEL_CTRL, ord('O'))},
        1104:{'label':u'Tramite','icon':'tramite32','func':self.toolTramite,'key':(wx.ACCEL_CTRL, ord('T'))},
        1105:{'label':u'Paz','icon':'paz32','func':self.toolPaz,'key':(wx.ACCEL_CTRL, ord('P'))},
        1106:{'label':u'Reincidencias','icon':'uer32','func':self.toolReincidencias,'key':(wx.ACCEL_CTRL, ord('R'))},
        1107:{'label':u'Int.Criminal','icon':'intcrim32','func':self.toolIntCriminal,'key':(wx.ACCEL_CTRL, ord('I'))},
        1201:{'label':u'Generar','icon':'generar32','func':self.toolGenerar,'key':(wx.ACCEL_NORMAL,wx.WXK_F11)},
        1202:{'label':u'Expediente','icon':'expediente32','func':self.toolExpediente,'key':(wx.ACCEL_NORMAL,wx.WXK_F12)},
        }
    ids=[k for k in tools.keys()]
    ids.sort()
    self.m_toolBar1 = self.CreateToolBar( wx.TB_HORIZONTAL|wx.TB_HORZ_TEXT, wx.ID_ANY )
    for id in ids:
        tool=tools[id]
        id_widg=wx.NewId()
        widg=self.m_toolBar1.AddLabelTool(id_widg, tool['label'], cat(tool['icon']),
            wx.NullBitmap, wx.ITEM_NORMAL,
            wx.EmptyString, wx.EmptyString, None )
        tool['id']=id_widg
    self.m_toolBar1.Realize()
    list_accel=[]
    for id in ids:
        tool_key=tools[id]['key']
        list_accel.append((tool_key[0],tool_key[1],tools[id]['id']))
    aTable=wx.AcceleratorTable(list_accel)
    for id in ids:
        tool=tools[id]
        self.m_toolBar1.Bind(wx.EVT_TOOL, tool['func'],id=tool['id'])
    self.SetAcceleratorTable(aTable)
def toolControl(self,evt):
    ...

AA16 = PyEmbeddedImage(…)

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Marian
"La función de un buen software es hacer que lo complejo aparente ser simple " Grady Booch