1 / 21

Python Essential 세미나

Python Essential 세미나. 2001. 5. 22( 화 ). GUI Programming - Part 2 ( GUI for Python - wxPython ). 발표자 : 최용준. Python’s GUI Binding (1). Tkinter “TK interface” TK GUI toolkit / Python standard module Unix, Windows, Mac 등에서 사용 PyGTK Gtk+(Gimp Tool Kit) widget 을 위한 Python binding.

abby
Télécharger la présentation

Python Essential 세미나

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Python Essential 세미나 2001. 5. 22(화) GUI Programming - Part 2 ( GUI for Python - wxPython ) 발표자 : 최용준

  2. Python’s GUI Binding (1) • Tkinter • “TK interface” • TK GUI toolkit / Python standard module • Unix, Windows, Mac 등에서 사용 • PyGTK • Gtk+(Gimp Tool Kit) widget을 위한 Python binding

  3. Python’s GUI Binding (2) • Gnome-python • GNOME의 Python binding • PyQt • Python의 Qt 확장모듈 • PyKDE • Python의 KDE 확장모듈 • Etc… • WPY(MFC, Tk), Pmw(Tkinter), FXPY(FOX GUI lib. Interface)

  4. wxPython Module • wxWindows GUI lib.를 Python에서 사용하기 위한 Python 확장 모듈 • C와 C++, SWIG(Simplified Wrapper and Interface Generator), Python으로 작성

  5. wxWindows, native API

  6. wxPython, wxWindows

  7. wxWindows • C++로 작성된 Cross-platform GUI library • MS-Windows(w)와 X-Window(x)에서 사용 가능하다는 뜻의 wx • 현재 Windows, X-Window, Mac에서 사용가능

  8. wxWindows 특징 (1) • 최소한의 코드 수정으로 cross platform C++ 응용프로그램 작성 • Native API에 대해 각각의 wxWindows버전이 존재, native GUI의 ‘look and feel’을 갖음 • 파일복사, 삭제, 소켓, 쓰레드등 운영체제간 공통적인 기능을 제공 • 스트링, 배열, 링크드리스트, 해시테이블등의 데이터 구조

  9. wxWindows 특징 (2) • Qt, BeOS, OS/2, Windows CE, QNX/Photon, FLT로의 포팅도 고려하고 있고 일부 개발중

  10. wxPython 특징 • Python과 wxWindows의 특징을 모두 가짐 • 현재는 Gtk+, Windows 버전만 지원 • 대부분의 wxWindows클래스를 구현 • Python과 C++언어상의 특징 때문에 차이점 존재 • Argument pointer로 결과값을 반환하는 경우 • 오버로딩된 함수를 사용하는 경우

  11. wxPython 예제1 (1) from wxPython.wx import * class MyApp(wxApp): def OnInit(self): frame = wxFrame(NULL, -1, "Hello from wxPython") frame.Show(true) self.SetTopWindow(frame) return true app = MyApp(0) app.MainLoop()

  12. wxPython 예제1 (2)

  13. wxPython 클래스 구조 • Application Class • 화면에 보이지 않는 부분 • OS로부터 이벤트를 받아 처리 • 무한루프(이벤트 드리븐 방식) • Main Frame Class • 화면에 보이는 부분 • 버튼, 컨크롤등의 배치

  14. wxPython 예제2 (1) from wxPython.wx import * ID_ABOUT = 101 ID_EXIT = 102 class MyFrame(wxFrame): def __init__(self, parent, ID, title): wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, wxSize(200, 150)) self.CreateStatusBar() self.SetStatusText("This is the statusbar") menu = wxMenu() menu.Append(ID_ABOUT, "&About", "More information about this program") menu.AppendSeparator() menu.Append(ID_EXIT, "E&xit", "Terminate the program") menuBar = wxMenuBar() menuBar.Append(menu, "&File"); self.SetMenuBar(menuBar) class MyApp(wxApp): def OnInit(self): frame = MyFrame(NULL, -1, "Hello from wxPython") frame.Show(true) self.SetTopWindow(frame) return true app = MyApp(0) app.MainLoop()

  15. wxPython 예제2 (2)

  16. wxPython EVENT

  17. from wxPython.wx import * ID_ABOUT = 101 ID_EXIT = 102 class MyFrame(wxFrame): def __init__(self, parent, ID, title): wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, wxSize(200, 150)) self.CreateStatusBar() self.SetStatusText("This is the statusbar") menu = wxMenu() menu.Append(ID_ABOUT, "&About", "More information about this program") menu.AppendSeparator() menu.Append(ID_EXIT, "E&xit", "Terminate the program") menuBar = wxMenuBar() menuBar.Append(menu, "&File"); self.SetMenuBar(menuBar) EVT_MENU(self, ID_ABOUT, self.OnAbout) EVT_MENU(self, ID_EXIT, self.TimeToQuit) def OnAbout(self, event): dlg = wxMessageDialog(self, "This sample program shows off\n" "frames, menus, statusbars, and this\n" "message dialog.", "About Me", wxOK | wxICON_INFORMATION) dlg.ShowModal() dlg.Destroy() def TimeToQuit(self, event): self.Close(true) class MyApp(wxApp): def OnInit(self): frame = MyFrame(NULL, -1, "Hello from wxPython") frame.Show(true) self.SetTopWindow(frame) return true app = MyApp(0) app.MainLoop() wxPython 예제3 (1)

  18. wxPython 예제3 (2)

  19. wxPython Programming Style • 객체(컨트롤)를 생성 • 객체에 해당하는 속성을 세팅 • 적절한 이벤트를 객체와 연결시킴 • 만들어진 객체가 화면에 보이도록 함 • 사용자의 입력(반응)을 기다림

  20. 작은 프로그램 예제 • 주소록(address.py) • by 홍성두 • 계산기(calculator.py) • by 최용준

  21. 참고 • 제2회 파이썬 오픈 세미나 • GUI for Python – wxPython (이한승) • 해맑은 일기장 for Linux (홍성두) • 제1회 파이썬 작은 세미나 • wxPython 프로그래밍하기 (홍성두) • www.wxpython.org • www.wxwindows.org • wxWindows User Guide

More Related