Skip to main content

Posts

Showing posts with the label wxPython

A Simple wxPython Stopwatch

This is a very short wxPython script that helps to measure time interval during various testing. Initial screen shows a stock wxPython clock control. When clicked on the clock face, a list appears on the right, on which time stamp, lap time, and cumulative time are displayed. This list disappears when clicked on it. And all data is cleared. Finally, the transparency of the program can be adjusted with the mouse wheel button. <<source code>>

Data Plotting in wxPython

wx.lib.plot wxPython has its own plotting library, which provides simple way of drawing large number of data on a canvas. It is convenient to use and it is fast. However you have only one axis per canvas and you can plot 2D graphs only. To plot a line graph like above, you create line objects using numpy Source file 214 x = np . linspace ( 0 , 10 , 500 ) 215 y = np . sin ( x ) 216 217 # create lines 218 line1 = wxplot . PolyLine ( list ( zip ( x , np . sin ( x ))), 219 colour = 'red' , width = 3 , style = wx . PENSTYLE_DOT_DASH ) 220 line2 = wxplot . PolyLine ( list ( zip ( x , - np . sin ( x ))), 221 colour = 'blue' , width = 3 , style = wx . PENSTYLE_LONG_DASH ) Then generate a graphics object and render it on the canvas Source file 223 # create a graphics 224 ...

wxPython Highlight Frontend

Highlight is a source code syntax highlighter that convert source code into HTML and other formats with syntax highlighting. It comes with a nice GUI as well as a command-line executable. The program implemented here utilizes the command-line version of Highlight as its backend. It exposes only limited number of features of the original program. However you may find it convenient in certain situations. The program has three main windows: one for the source code, one for the HTML view and one for the HTML code. In the HTML view you can check the result rendered by the HTML engine. In the HTML code page, you can see its actual HTML code. The HTML view window and the HTML code window are embedded in the notebook window as separate pages under the source code window. The upper window (a text control) and the lower window (a notebook) are two client areas of a wx.SplitterWindow. So you can resize them by moving the sash in the middle. On the right, you have several options to choo...

wxPython COM Terminal

PySerial provides a convenient way to handle data transfer over COM ports. It works on most of the platforms. The program is written using wxPython to create a simple terminal emulator. It is pretty much similar to the example presented by PySerial itself.  However in this case, the UI is built on wx.Panel instead of wx.Frame, thus it is easy to embed the terminal emulator into any wxPython GUI. All GUI components are populated on a single panel inherited from the wx.Panel. On the left a wx.TextCtrl is located as a terminal window. On the right, handful controls are added for for basic setup and control of the terminal window and the COM port. The controls on the right side can be hidden or shown at any time.This terminal supports ASCII mode and Hexadecimal mode. You can also save data to a disk file. Since all the features are implemented on a wx.Panel (TermPanel), it can be embedded into any window including main frame window simply by creating an instance and passing a P...