Gestire il testo proveniente da wx.TextCtrl
Von: LaGuNa (scozzaro@gmail.com) [Profil]
Datum: 03.07.2008 13:19
Message-ID: <3bedcc10-699c-408b-bfe1-587c23849df0@d77g2000hsb.googlegroups.com>
Newsgroup: it.comp.lang.python
Datum: 03.07.2008 13:19
Message-ID: <3bedcc10-699c-408b-bfe1-587c23849df0@d77g2000hsb.googlegroups.com>
Newsgroup: it.comp.lang.python
In questo piccolo programma che allego mi sto scontrando con la gestione delle stringhe di desto provenienti da wx.TextCtrl, in particoloare ho questa riga, credo che sia giusta text1 = wx.TextCtrl(self, wx.NewId(), "", size=(100, -1), pos=(80, 50)) e ho gestilo l'evento di un pulsante per stampare il contenuto con il comando print con print text1 ma non ottengo nulla, mi fate capire do ho sbagliato. Grazie a Tutti by Enzo import wx import string # Assegnamento id FILE_NEW_ID = wx.NewId() FILE_OPEN_ID = wx.NewId() FILE_RECENT_ID = wx.NewId() FILE_QUIT_ID = wx.NewId() text1 ="" class StaticBox(wx.Dialog): def __init__(self, parent, id, title): global text1 wx.Dialog.__init__(self, parent, id, title, size=(250, 230)) #wx.StaticBox(self, -1, 'Cognome', (5, 5), size=(240, 170)) wx.CheckBox(self, -1 ,'Male', (15, 30)) wx.CheckBox(self, -1 ,'Married', (15, 55)) wx.StaticText(self, -1, 'Age', (15, 95)) text1 = wx.TextCtrl(self, wx.NewId(), "", size=(100, -1), pos=(80, 50)) text2 = wx.TextCtrl(self, wx.NewId(), "", size=(110, -1), pos=(80, 80)) textbox = wx.TextCtrl(self, -1, "", (55, 90), (190, 50), wx.TE_MULTILINE) wx.SpinCtrl(self, -1, '1', (55, 90), (60, -1), min=1, max0) wx.Button(self, 1, 'Ok', (90, 185), (60, -1)) self.Bind(wx.EVT_BUTTON, self.OnPrint, id=1) self.Centre() self.ShowModal() self.Destroy() def OnPrint(self, event): print text1 class MyMenu(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(800, 600)) panel = wx.Panel(self, -1) # Creazione sotto-frame # # Creazione barra del menu menubar = wx.MenuBar() # Creazione menu File file = wx.Menu() # Inserimento elementi nel menu File nuovo = wx.MenuItem(file, FILE_NEW_ID, '&Nuovo\tCtrl+N', 'Nuova storia') file.AppendItem(nuovo) file.AppendSeparator() open = wx.MenuItem(file, FILE_OPEN_ID, '&Apri...\tCtrl+O', 'Apri File') file.AppendItem(open) quit = wx.MenuItem(file, FILE_QUIT_ID, '&Quit\tCtrl+Q', 'Quit the Application') file.AppendItem(quit) menubar.Append(file, '&File') self.SetMenuBar(menubar) self.Centre() # wx.PyEventBinder # Bind(self, target, id1, id2, function) self.Bind(wx.EVT_MENU, self.OnNew, id = FILE_NEW_ID) self.Bind(wx.EVT_MENU, self.OnQuit, id = FILE_QUIT_ID) def OnNew(self, event): StaticBox(None, -1, 'Converter') def OnQuit(self, event): self.Close() class MyApp(wx.App): def OnInit(self): frame = MyMenu(None, -1, 'menu1.py') frame.Show(True) return True app = MyApp(0) app.MainLoop()[ Auf dieses Posting antworten ]
