Mar-21-2018, 11:46 AM
Mar-21-2018, 03:45 PM
What do you have so far?
Have you tried this? https://wiki.wxpython.org/VerySimpleDrawing
Have you tried this? https://wiki.wxpython.org/VerySimpleDrawing
Quote:import wx class DrawPanel(wx.Frame): """Draw a line to a panel.""" def __init__(self): wx.Frame.__init__(self, title="Draw on Panel") self.Bind(wx.EVT_PAINT, self.OnPaint) def OnPaint(self, event=None): dc = wx.PaintDC(self) dc.Clear() dc.SetPen(wx.Pen(wx.BLACK, 4)) dc.DrawLine(0, 0, 50, 50) app = wx.App(False) frame = DrawPanel() frame.Show() app.MainLoop()
Mar-21-2018, 05:17 PM
Before I was working with Tkinter and most of my examples was in functional style so I am not so good with classes and I don't want to build a class for only testing a widget
Mar-21-2018, 06:06 PM
Luckily, that link includes another example that doesn't use a class :)
Mar-22-2018, 01:14 PM
I wasn't able to reprodure the second example with wx.ClientDC
Mar-22-2018, 06:22 PM
I just tried it (had to install wx first, since I didn't have it), and it worked for me as written. So if it isn't working, please share your code, and the error message.
Mar-22-2018, 08:34 PM
You really should get yourself comfortable with classes.
GUI programming involves so many layers that It's very difficult to do without.
So many methods rely of inheriting from other methods and classes that it is very difficult to
do all but the simplest of code without using classes.
One way to improve your understanding of this is to load the python demo program, which is very complete
and backed by source code, available with a single click of a notebook tab allowing you to flip between demo
and source code while trying to understand a concept.
To get this demo:
GUI programming involves so many layers that It's very difficult to do without.
So many methods rely of inheriting from other methods and classes that it is very difficult to
do all but the simplest of code without using classes.
One way to improve your understanding of this is to load the python demo program, which is very complete
and backed by source code, available with a single click of a notebook tab allowing you to flip between demo
and source code while trying to understand a concept.
To get this demo:
- Download the source here: https://github.com/wxWidgets/Phoenix
- Open a command window and:
- Unzip in a directory of your choice
- cd to Phoenix-master/Demo/
- run the denmo
python demo.py