I have been trying to replicate Matlab's patch() function
(reference url: http://www.mathworks.com/help/techdoc/ref/patch.html) with numpy and wxpython.

The ultimate goal is to replicate the functionality of following line in python:

patch(vertices(i,[1,5,9]),vertices(i,[2,6,10]),(ctotal/3))

It is a 2D patch function which draws triangular polygons.

I am familiar with using wxPython for simple GUI and rectangle and circles, but this is my first time trying to work with polygons and create 3D to 2D transformations from a raw file in python (without using OpenGL libraries)

Please let me know if you can show me an example of how to utilize the drawpolygon() in wxpython.

Thanks.

I've found a nice explanation with an animated polygon here http://users.info.unicaen.fr/~karczma/TEACH/ProgSci/Wxgra.html. It's in french, but you should be able to translate it roughly with google translate :)

I figured it out myself afterward ('cause I can't go to sleep without solving it) but thanks for the site. I was confused about how to create wx.point object and the list but with some trial and error, I got it working.

I have another question, I realize that there are different forms of the wxpython code. One with classes, another kind without. Like

import wx 

"""The start of our wxPython GUI tutorial"""

app = wx.App(redirect=False)

window = wx.Frame(None, title = 'Sample GUI App')
btn = wx.Button(window) 

window.Show()
app.MainLoop()

I tried to do something like

import wx 

app = wx.App(redirect=False)

window = wx.Frame(None, title = 'Sample GUI App')
dc = wx.PaintDC(window) 
dc.SetPen(wx.Pen('red', 1))
rect = wx.Rect(50, 50, 100, 100) 
dc.DrawRoundedRectangleRect(rect, 8)

window.Show()
app.MainLoop()

But the code will crash Python. I don't really understand why. Do you have any idea about this?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.