13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Advanced widgetshttp://www.zetcode.com/wxpython/advanced/Python IDEHome ContentsFaster, Easier Python Development Editor,Debugger, Browser, and moreeXtreme ProgrammingAssistance Technique Java/J2ee, .Net/C#,Python, RubyAdvanced widgets in <strong>wxPython</strong>In the following chapters we will talk about advanced widgets. A bigadvantage of <strong>wxPython</strong> over a competing PyGTK is the availability of a hugeamount of advanced widgets. PyGTK is a layer over a C based GKT+ toolkit.It does not provide new widgets. In contrast, <strong>wxPython</strong> is a layer overwxWidgets a C++ based toolkit. wxWidgets consists of a large group ofwidgets. All this widgets are created in C++. <strong>wxPython</strong> is a glue thatcombines python language with this toolkit. If we want to have a grid widgetin our application using PyGTK, we have to create it ourselves. Such awidget is quite complicated. Not to mention the speed penalty. Dynamiclanguages like Python, PERL or Ruby are not suitable for such tasks.Dynamic languages are great in various areas. <strong>The</strong>y are simple to use. <strong>The</strong>yare great for prototyping, in house developing or for studying computerprogramming. If we need a quick solution or we need an application, thatwill change rapidly over a short period of time, dynamic languages aresuperior to compiled languages. On the other hand, if we develop resourceintensive applications, games, high quality multimedia applications, there isno competition to C++.<strong>wxPython</strong> has several well known advanced widgets. For example a treewidget, an html window, a grid widget, a listbox widget, a list widget or aneditor with advanced styling capabilities. <strong>wxPython</strong> and wxWidgets are beingdeveloped all the time. New widgets and features emerge with every majorrelease. At the time when I write these words a <strong>wxPython</strong> 2.8.3.0 has beenreleased just two days ago. (22-Mar-2007).A W X . L I S T B O X W I D G E TA wx.ListBox widget is used for displaying and working with a list of items.As it's name indicates, it is a rectangle that has a list of strings inside. Wecould use it for displaying a list of mp3 files, book names, module names ofa larger project or names of our friends. A wx.ListBox can be created in twodifferent states. In a single selection state or a multiple selection state. <strong>The</strong>single selection state is the default state. <strong>The</strong>re are two significant events inwx.ListBox. <strong>The</strong> first one is the wx.EVT_COMMAND_LISTBOX_SELECTEDevent. This event is generated when we select a string in a wx.ListBox. <strong>The</strong>second one is the wx.EVT_COMMAND_LISTBOX_DOUBLE_CLICKED event. Itis generated when we double click an item in a wx.ListBox. <strong>The</strong> number ofelements inside a wx.ListBox is limited on GTK platform. According to thedocumentation, it is currently around 2000 elements. Quite enough, I think.<strong>The</strong> elements are numbered from zero. Scrollbars are displayedautomatically if needed.1 de 21 27/04/2008 1:05

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!