Python GUI프레임워크가운데 한가지. wxPython

http://wxpython.org

관련자료

통합개발환경(IDE)

가장 간단한 GUI예제

   1 from wxPython.wx import *
   2 
   3 ID_ABOUT = 101
   4 ID_EXIT = 102
   5 
   6 class MyFrame(wxFrame):
   7     def __init__(self, parent, ID, title):
   8         wxFrame.__init__(self, parent, ID, title, wxDefaultPosition,
   9                 wxSize(200,150))
  10         self.CreateStatusBar()
  11         self.SetStatusText("This is the statusbar")
  12 
  13         menu = wxMenu()
  14         menu.Append(ID_ABOUT, "&About",
  15                 "More information about this program")
  16         menu.AppendSeparator()
  17         menu.Append(ID_EXIT, "E&xit", "Terminate the program")
  18 
  19         menuBar = wxMenuBar()
  20         menuBar.Append(menu, "&File")
  21         self.SetMenuBar(menuBar)
  22 
  23         EVT_MENU(self, ID_ABOUT, self.OnAbout)
  24         EVT_MENU(self, ID_EXIT, self.TimeToQuit)
  25 
  26     def OnAbout(self, event):
  27         dlg = wxMessageDialog(self,
  28                 "This sample program shows off\n"
  29                 "frames, menus, statusbars, and this\n"
  30                 "message dialog.",
  31                 "About Me", wxOK | wxICON_INFORMATION)
  32         dlg.ShowModal()
  33         dlg.Destroy()
  34 
  35     def TimeToQuit(self, event):
  36         self.Close(true)
  37 
  38 class MyApp(wxApp):
  39     def OnInit(self):
  40         frame = MyFrame(NULL, -1, "Hello from wxPython")
  41         frame.Show(true)
  42         self.SetTopWindow(frame)
  43         return true
  44 
  45 app = MyApp(0)
  46 app.MainLoop()


CategoryProgramLibrary

WxPython (last edited 2012-04-07 12:13:07 by 116)

web biohackers.net