Foros del Web » Programando para Internet » Python »

ayuda con EVT_ENTER

Estas en el tema de ayuda con EVT_ENTER en el foro de Python en Foros del Web. no me funciona esta funcion dice que no esta atribuido Código PHP: import wx ID_ABOUT  =  1 ID_OPEN  =  2 ID_SAVE  =  3 ID_QUIT  =  4 ...
  #1 (permalink)  
Antiguo 05/10/2008, 13:34
 
Fecha de Ingreso: mayo-2008
Mensajes: 499
Antigüedad: 15 años, 11 meses
Puntos: 1
ayuda con EVT_ENTER

no me funciona esta funcion dice que no esta atribuido

Código PHP:
import wx
ID_ABOUT 
1
ID_OPEN 
2
ID_SAVE 
3
ID_QUIT 
4
ID_COPY 
5
ID_TOOLS 
6
ID_HELP 
7

class MainWindow(wx.Frame):
    
def __init__(self,parent,id,title):
        
wx.Frame.__init__(selfparentid,title,size = (400,400),style wx.DEFAULT_FRAME_STYLE wx.NO_FULL_REPAINT_ON_RESIZE)
        
self.control wx.TextCtrl(self,1,style wx.TE_MULTILINE)
        
#---START NUEW CODE:--------------------------------------
        
self.CreateStatusBar()
        
#-------- Setting up the menu.
        
filemenu wx.Menu()
        
filemenu.Append(ID_ABOUT"&About","Informacion sobre la aplicacion")
        
filemenu.Append(ID_OPEN"&Open""Abrir archivo")
        
filemenu.Append(ID_SAVE"&Save""Grabar archivo")
        
filemenu.AppendSeparator()
        
quit wx.MenuItem(filemenuID_QUIT'&Quit\tCtrl+Q')
        
quit.SetBitmap(wx.Bitmap('wamp/exit.png'))
        
filemenu.AppendItem(quit)
        
        
editmenu wx.Menu()
        
editmenu.Append(ID_COPY,"&Copy""copiar texto")
        
toolmenu wx.Menu()
        
toolmenu.Append(ID_TOOLS"&Tool""Herramientas del programa")
        
helpmenu wx.Menu()
        
helpmenu.Append(ID_HELP"&Help""instruccion de aplicacion")
        
#-------- Creating the menu.
        
menubar wx.MenuBar()
        
menubar.Append(filemenu"&File")
        
menubar.Append(editmenu"&Edit")
        
menubar.Append(toolmenu"&Tool")
        
menubar.Append(helpmenu"&Help")
        
self.SetMenuBar(menubar)
        
#--- END NEW CODE --------------------------------------------------------
        
toolbar self.CreateToolBar(wx.TB_HORIZONTAL)
        
toolbar.AddLabelTool(wx.ID_ANY''wx.Bitmap('../wamp/exit.png'))
        
toolbar.AddLabelTool(wx.ID_ANY''wx.Bitmap('../wamp/exit.png'))
        
toolbar.AddLabelTool(wx.ID_ANY''wx.Bitmap('../wamp/exit.png'))
        
toolbar.AddLabelTool(wx.ID_ANY''wx.Bitmap('../wamp/exit.png'))
        
toolbar.AddLabelTool(wx.ID_ANY''wx.Bitmap('../wamp/exit.png'))
        
toolbar.AddLabelTool(wx.ID_ANY''wx.Bitmap('../wamp/exit.png'))
        
toolbar.AddLabelTool(wx.ID_ANY''wx.Bitmap('../wamp/exit.png'))
        
toolbar.AddLabelTool(wx.ID_ANY''wx.Bitmap('../wamp/exit.png'))
        

        
toolbar.Realize()
        [
B]panel wx.Panel(self1)
        
combo wx.ComboBox(panel1'EnterCombo', (11020))[/B]
        
    [
B]combo.Bind(wx.EVT_ENTER_WINDOWself.EnterComboid=1)[/B]
        
        
self.Centre()
        
self.Show(True)

        
def OnQuit(selfevent):
            
self.Close()
            
    
def EnterCombo(selfevent):
            
self.sb.SetStatusText('ComboBox widget')
            
event.Skip()
            
app wx.PySimpleApp()
frame MainWindow(None,-1,"iozk studio")
frame.Show(1)
app.MainLoop() 
  #2 (permalink)  
Antiguo 06/10/2008, 07:30
AlvaroG
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: ayuda con EVT_ENTER

Mostrá el error completo tal cual te aparece, por favor
  #3 (permalink)  
Antiguo 06/10/2008, 14:57
 
Fecha de Ingreso: mayo-2008
Mensajes: 499
Antigüedad: 15 años, 11 meses
Puntos: 1
Respuesta: ayuda con EVT_ENTER

Cita:
Traceback (most recent call last):
File "C:\pruave.py", line 67, in ?
frame = MainWindow(None,-1,"iozk studio")
File "C:\pruave.py", line 54, in __init__
combo.Bind(wx.EVT_ENTER_WINDOW, self.EnterCombo, id=1)
AttributeError: 'MainWindow' object has no attribute 'EnterCombo'
  #4 (permalink)  
Antiguo 06/10/2008, 15:26
 
Fecha de Ingreso: mayo-2008
Mensajes: 499
Antigüedad: 15 años, 11 meses
Puntos: 1
Respuesta: ayuda con EVT_ENTER

como poner este ComboBox en la toolbar()
combo = wx.ComboBox(toolbar, 4, '', (110, 20))
????
  #5 (permalink)  
Antiguo 06/10/2008, 20:03
AlvaroG
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: ayuda con EVT_ENTER

Antes de eso, ¿solucionaste el problema anterior? porque yo probé el código que pegaste y me anda sin problemas, ¿en qué momento te muestra el error que pegaste?

En cuanto a tu último mensaje, en principio te aconsejaría probar con

toolbar.AddControl(combo)


Saludos.
  #6 (permalink)  
Antiguo 06/10/2008, 20:52
 
Fecha de Ingreso: mayo-2008
Mensajes: 499
Antigüedad: 15 años, 11 meses
Puntos: 1
Respuesta: ayuda con EVT_ENTER

cuando le pongo el self.Bind(wx.EVT_ETC..) lo pongo y sale error y lo quito y ya no sale


ya puse el combo pero no sale dice error


mejor voy a bajarme todo el python e unstalarlo denuevo por que creeo que no se quizo instalar una libreria quiza ese es el problema y si no me equivoco quiza funcione
gracias denuevo saludos!
  #7 (permalink)  
Antiguo 07/10/2008, 16:13
 
Fecha de Ingreso: mayo-2008
Mensajes: 499
Antigüedad: 15 años, 11 meses
Puntos: 1
Respuesta: ayuda con EVT_ENTER

como ponerle un undo y el redo funcionen

Código python:
Ver original
  1. import wx
  2.  
  3. ID_STAT = 2
  4. ID_TOOL = 3
  5.  
  6.  
  7. class Apple(wx.Frame):
  8.     def __init__(self, parent, id, title):
  9.         wx.Frame.__init__(self, parent, id, title, size=(550, 580))
  10.        
  11.        
  12.         menubar = wx.MenuBar()
  13.         file = wx.Menu()
  14.         new = wx.MenuItem(file, 101, '&New\tCtrl+N', 'Creates a new document')
  15.         file.AppendItem(new)
  16.        
  17.         open = wx.MenuItem(file, 102, '&Open\tCtrl+O', 'Open an existing file')
  18.         file.AppendItem(open)
  19.         save = wx.MenuItem(file, 103, '&Save\tCtrl+S', 'Save the file')
  20.         file.AppendItem(save)
  21.         saveas = wx.MenuItem(file, 104, 'Save &As...\tShift+Ctrl+S', 'Save the file with a different name')
  22.         file.AppendItem(saveas)
  23.         file.AppendSeparator()
  24.         quit = wx.MenuItem(file, 1, '&Quit\tCtrl+Q', 'Exit program')
  25.         file.AppendItem(quit)
  26.  
  27.         edit = wx.Menu()
  28.         cut = wx.MenuItem(edit, 106, '&Cut\tCtrl+X', 'Cut the Selection')
  29.         edit.AppendItem(cut)
  30.         copy = wx.MenuItem(edit, 107,  '&Copy\tCtrl+C', 'Copy the Selection')
  31.         edit.AppendItem(copy)
  32.         paste = wx.MenuItem(edit, 108, '&Paste\tCtrl+V', 'Paste text from clipboard')
  33.         edit.AppendItem(paste)
  34.         delete = wx.MenuItem(edit, 109, '&Delete', 'Delete the selected text')
  35.         edit.AppendItem(delete)
  36.         view = wx.Menu()
  37.         self.shst = view.Append(ID_STAT, 'Show statusbar', 'Show Statusbar', kind=wx.ITEM_CHECK)
  38.         self.shtl = view.Append(ID_TOOL, 'Show toolbar', 'Show Toolbar', kind=wx.ITEM_CHECK)
  39.         view.Check(ID_STAT, True)
  40.         view.Check(ID_TOOL, True)
  41.  
  42.         self.Bind(wx.EVT_MENU, self.NewApplication, id=101)
  43.         self.Bind(wx.EVT_MENU, self.OnOpenFile, id=102)
  44.         self.Bind(wx.EVT_MENU, self.OnSaveFile, id=103)
  45.         self.Bind(wx.EVT_MENU, self.OnSaveAsFile, id=104)
  46.         self.Bind(wx.EVT_MENU, self.OnCut, id=106)
  47.         self.Bind(wx.EVT_MENU, self.OnCopy, id=107)
  48.         self.Bind(wx.EVT_MENU, self.OnPaste, id=108)
  49.         self.Bind(wx.EVT_MENU, self.OnDelete, id=109)
  50.         self.Bind(wx.EVT_MENU, self.OnSelectAll, id=110)
  51.        
  52.  
  53.         self.Bind(wx.EVT_MENU, self.ToggleStatusBar, id=ID_STAT)
  54.         self.Bind(wx.EVT_MENU, self.ToggleToolBar, id=ID_TOOL)
  55.         self.Bind(wx.EVT_MENU, self.OnQuit, id=1)
  56.  
  57.         menubar.Append(file, '&File')
  58.         menubar.Append(edit, '&Edit')
  59.         menubar.Append(view, '&View')
  60.         self.SetMenuBar(menubar)
  61.  
  62.         self.count = 5
  63.        
  64.  
  65.         self.toolbar = self.CreateToolBar(wx.TB_HORIZONTAL)
  66.         self.toolbar.AddLabelTool(wx.ID_EXIT, '', wx.Bitmap('Lamp/exit.png'))
  67.         self.toolbar.AddLabelTool(3, 'que', wx.Bitmap('Lamp/pluma.png'))
  68.         self.toolbar.AddLabelTool(3, '', wx.Bitmap('Lamp/lapiz.png'))
  69.         self.toolbar.AddLabelTool(wx.ID_UNDO, '', wx.Bitmap('Lamp/exit.png'))
  70.         self.toolbar.AddLabelTool(wx.ID_REDO, '', wx.Bitmap('Lamp/exit.png'))
  71.         self.toolbar.EnableTool(wx.ID_REDO, False)
  72.         self.toolbar.Realize()
  73.  
  74.         self.Bind(wx.EVT_TOOL, self.OnExit, id=wx.ID_EXIT)
  75.         self.Bind(wx.EVT_TOOL, self.OnUndo, id=wx.ID_UNDO)
  76.         self.Bind(wx.EVT_TOOL, self.OnRedo, id=wx.ID_REDO)
  77.  
  78.         wx.TextCtrl(self, -1)
  79.        
  80.  
  81.         self.statusbar = self.CreateStatusBar()
  82.         self.Centre()
  83.         self.Show(True)
  84.         #aqui
  85.     def NewApplication(self, event):
  86.         editor = Editor(None, -1, 'Editor')
  87.         editor.Centre()
  88.         editor.Show()
  89.  
  90.     def OnOpenFile(self, event):
  91.         file_name = os.path.basename(self.last_name_saved)
  92.         if self.modify:
  93.             dlg = wx.MessageDialog(self, 'Save changes?', '', wx.YES_NO | wx.YES_DEFAULT |
  94.      wx.CANCEL | wx.ICON_QUESTION)
  95.             val = dlg.ShowModal()
  96.             if val == wx.ID_YES:
  97.                 self.OnSaveFile(event)
  98.                 self.DoOpenFile()
  99.             elif val == wx.ID_CANCEL:
  100.                 dlg.Destroy()
  101.             else:
  102.                 self.DoOpenFile()
  103.         else:
  104.             self.DoOpenFile()
  105.  
  106.     def DoOpenFile(self):
  107.         wcd = 'All files (*)|*|Editor files (*.ef)|*.ef|'
  108.         dir = os.getcwd()
  109.         open_dlg = wx.FileDialog(self, message='Choose a file', defaultDir=dir, defaultFile='',
  110.             wildcard=wcd, style=wx.OPEN|wx.CHANGE_DIR)
  111.         if open_dlg.ShowModal() == wx.ID_OK:
  112.             path = open_dlg.GetPath()
  113.  
  114.             try:
  115.                 file = open(path, 'r')
  116.                 text = file.read()
  117.                 file.close()
  118.                 if self.text.GetLastPosition():
  119.                     self.text.Clear()
  120.                 self.text.WriteText(text)
  121.                 self.last_name_saved = path
  122.                 self.statusbar.SetStatusText('', 1)
  123.                 self.modify = False
  124.  
  125.             except IOError, error:
  126.                 dlg = wx.MessageDialog(self, 'Error opening file\n' + str(error))
  127.                 dlg.ShowModal()
  128.  
  129.             except UnicodeDecodeError, error:
  130.                 dlg = wx.MessageDialog(self, 'Error opening file\n' + str(error))
  131.                 dlg.ShowModal()
  132.  
  133.         open_dlg.Destroy()
  134.  
  135.     def OnSaveFile(self, event):
  136.         if self.last_name_saved:
  137.  
  138.             try:
  139.                 file = open(self.last_name_saved, 'w')
  140.                 text = self.text.GetValue()
  141.                 file.write(text)
  142.                 file.close()
  143.                 self.statusbar.SetStatusText(os.path.basename(self.last_name_saved) + ' saved', 0)
  144.                 self.modify = False
  145.                 self.statusbar.SetStatusText('', 1)
  146.  
  147.             except IOError, error:
  148.                 dlg = wx.MessageDialog(self, 'Error saving file\n' + str(error))
  149.                 dlg.ShowModal()
  150.         else:
  151.             self.OnSaveAsFile(event)
  152.  
  153.     def OnSaveAsFile(self, event):
  154.         wcd='All files(*)|*|Editor files (*.ef)|*.ef|'
  155.         dir = os.getcwd()
  156.         save_dlg = wx.FileDialog(self, message='Save file as...', defaultDir=dir, defaultFile='',
  157.             wildcard=wcd, style=wx.SAVE | wx.OVERWRITE_PROMPT)
  158.         if save_dlg.ShowModal() == wx.ID_OK:
  159.             path = save_dlg.GetPath()
  160.  
  161.             try:
  162.                 file = open(path, 'w')
  163.                 text = self.text.GetValue()
  164.                 file.write(text)
  165.                 file.close()
  166.                 self.last_name_saved = os.path.basename(path)
  167.                 self.statusbar.SetStatusText(self.last_name_saved + ' saved', 0)
  168.                 self.modify = False
  169.                 self.statusbar.SetStatusText('', 1)
  170.  
  171.             except IOError, error:
  172.                 dlg = wx.MessageDialog(self, 'Error saving file\n' + str(error))
  173.                 dlg.ShowModal()
  174.         save_dlg.Destroy()
  175.  
  176.     def OnCut(self, event):
  177.         self.text.Cut()
  178.  
  179.     def OnCopy(self, event):
  180.         self.text.Copy()
  181.  
  182.     def OnPaste(self, event):
  183.         self.text.Paste()
  184.  
  185.     def OnDelete(self, event):
  186.         frm, to = self.text.GetSelection()
  187.         self.text.Remove(frm, to)
  188.  
  189.     def OnSelectAll(self, event):
  190.         self.text.SelectAll()
  191.  
  192.     def OnTextChanged(self, event):
  193.         self.modify = True
  194.         self.statusbar.SetStatusText(' modified', 1)
  195.         event.Skip()
  196.  
  197.     def OnKeyDown(self, event):
  198.         keycode = event.GetKeyCode()
  199.         if keycode == wx.WXK_INSERT:
  200.             if not self.replace:
  201.                 self.statusbar.SetStatusText('INS', 2)
  202.                 self.replace = True
  203.             else:
  204.                 self.statusbar.SetStatusText('', 2)
  205.                 self.replace = False
  206.         event.Skip()
  207.  
  208.     def OnAbout(self, event):
  209.         dlg = wx.MessageDialog(self, '\tEditor\t\n Another Tutorial\njan bodnar 2005-2006',
  210.                                 'About Editor', wx.OK | wx.ICON_INFORMATION)
  211.         dlg.ShowModal()
  212.         dlg.Destroy()
  213.  
  214.  
  215.         #termina
  216.  
  217.     def OnQuit(self, event):
  218.         self.Close()
  219.  
  220.     def OnUndo (self, event):
  221.         if self.count > 1 and self.count <=5:
  222.             self.count = self.count - 1
  223.             if self.count == 1:
  224.                 self.toolbar.EnableTool(wx.ID_UNDO, False)
  225.  
  226.         if self.count == 4:
  227.             self.toolbar.EnableTool(wx.ID_REDO, True)
  228.  
  229.     def OnRedo(self, event):
  230.         if self.count < 5 and self.count >= 1:
  231.             self.count = self.count + 1
  232.  
  233.         if self.count == 5:
  234.             self.toolbar.EnableTool(wx.ID_REDO, False)
  235.  
  236.         if self.count == 2:
  237.             self.toolbar.EnableTool(wx.ID_UNDO, True)
  238.  
  239.     def OnExit(self, event):
  240.         self.Close()
  241.  
  242.  
  243.     def ToggleStatusBar(self, event):
  244.         if self.shst.IsChecked():
  245.             self.statusbar.Show()
  246.         else:
  247.             self.statusbar.Hide()
  248.  
  249.     def ToggleToolBar(self, event):
  250.         if self.shtl.IsChecked():
  251.             self.toolbar.Show()
  252.         else:
  253.             self.toolbar.Hide()
  254.  
  255. app = wx.App()
  256. Apple(None, 1, 'Editor de texto')
  257. app.MainLoop()

Última edición por AlvaroG; 07/10/2008 a las 17:06 Razón: resaltado de sintaxis
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:52.