Ciao a tutti.
<div>Sto iniziando ad utilizzare WxPython seguendo le "wiki" .. </div><div> </div><div><codice></div><div><div>class MainWindow(wx.Frame):</div><div> def __init__(self, parent, title):</div><div> wx.Frame.__init__(self, parent, title=title, size=(600,300))</div>
<div> #self.control = wx.TextCtrl(self, size=(200, 100), style=wx.TE_MULTILINE)</div><div> self.pulsante = wx.Button(self, -1, "Prova", pos=(50, 100))</div><div> self.CreateStatusBar() # A Statusbar in the bottom of the window</div>
<div> </div><div> # Setting up the menu.</div><div> filemenu= wx.Menu()</div><div><br></div><div> # wx.ID_ABOUT and wx.ID_EXIT are standard IDs provided by wxWidgets.</div><div> about=filemenu.Append(wx.ID_ABOUT, "&About"," Information about this program")</div>
<div> open_=filemenu.Append(-1 , "&Open"," Open file")</div><div> filemenu.AppendSeparator()</div><div> esci = filemenu.Append(wx.ID_EXIT,"E&xit"," Terminate the program")</div>
<div> </div><div> self.Bind(wx.EVT_MENU,self.OnAbout,about)</div><div> self.Bind(wx.EVT_MENU,self.OnOpen,open_)</div><div> self.Bind(wx.EVT_MENU,self.OnExit,esci)</div><div> # Creating the menubar.</div>
<div> menuBar = wx.MenuBar()</div><div> menuBar.Append(filemenu,"&File") # Adding the "filemenu" to the MenuBar</div><div> self.SetMenuBar(menuBar) # Adding the MenuBar to the Frame content.</div>
<div> self.Show(True)</div><div><br></div><div> def OnAbout(self,event):</div><div> dlg = wx.MessageDialog( self, "A small text editor", "About Sample Editor")</div><div> dlg.ShowModal()</div>
<div> #dlg.Destroy()</div><div><br></div><div> def OnExit(self,event):</div><div> self.Close(True)</div><div><br></div><div> def OnOpen(self,e):</div><div> #""" Open a file"""</div>
<div> self.dirname = ''</div><div> dlg = wx.FileDialog(self, "Choose a file", self.dirname, "", "*.py*")</div><div> if dlg.ShowModal() == wx.ID_OK:</div><div> self.filename = dlg.GetFilename()</div>
<div> self.dirname = dlg.GetDirectory()</div><div> f = open(os.path.join(self.dirname, self.filename), 'r')</div><div> self.control.SetValue(f.read())</div><div> f.close()</div>
<div> dlg.Destroy()</div><div> </div><div>app = wx.App(False)</div><div>frame = MainWindow(None, "Sample editor")</div><div>app.MainLoop()</div><div><br></div></div><div><fine_codice></div><div>
<br></div><div>Il pulsante "Prova" che cerco di inserire, mi occupa tutto lo schermo..anche se provo a settare il size del pulsante.</div><div>Dove sbaglio? </div>