Python/wxPython/Graphics: Difference between revisions
Jump to navigation
Jump to search
| Line 8: | Line 8: | ||
C [label="wx.ClientDC"]; | C [label="wx.ClientDC"]; | ||
D [label="wx.PaintDC"]; | D [label="wx.PaintDC"]; | ||
E | E [label="wx.BufferedDC]; | ||
F [label="wx.BufferedPaintDC]; | |||
G [label="wx.AutoBufferedPaintDC]; | |||
D -> C; | D -> C; | ||
C -> B1; | C -> B1; | ||
{B1 B2} -> A; | {B1 B2} -> A; | ||
G -> F -> E -> B2; | |||
</quickgv> | </quickgv> | ||
Revision as of 01:30, 22 March 2019
wx.DC hierarchy
Error:
digraph DC {
// options
// theme = warm
// usage =
// default settings of graphs
graph [
rankdir = LR,
color = "#804000",
bgcolor = "#fffff7",
fontcolor = "#000000",
fontsize = 12,
style = dashed,
gradientangle = 65,
splines = ortho,
];
// default settings of nodes
node [
shape = box,
style = "filled,rounded",
height = 0.3,
fontsize = 10,
// theme
color = "#c07000",
fontcolor = "#000000",
fillcolor = "#ffffff:#ffffc0",
gradientangle = 295 // left, top -> right, bottom
];
// default settings of edges
edge [
color = "#704000",
fontcolor = "#704000",
fontsize = 10,
arrowsize = 0.6
];
// nodes, edges, and clusters
rankdir=BT;
A [label="wx.DC"];
B1 [label="wx.WindowDC"];
B2 [label="wx.MemoryDC"];
C [label="wx.ClientDC"];
D [label="wx.PaintDC"];
E [label="wx.BufferedDC];
F [label="wx.BufferedPaintDC];
G [label="wx.AutoBufferedPaintDC];
D -> C;
C -> B1;
{B1 B2} -> A;
G -> F -> E -> B2;
}
Draw line by PaintDC
#!/usr/bin/env python3
import wx
class MyApp(wx.App):
def OnInit(self):
frame = wx.Frame(None, -1, 'Hello World!')
frame.Bind(wx.EVT_PAINT, self.OnPaint)
frame.Show()
self.mainFrame = frame
return True
def OnPaint(self, evt):
dc = wx.PaintDC(self.mainFrame)
dc.DrawLine(10, 10, 200, 10)
if __name__ == '__main__':
app = MyApp()
app.MainLoop()
Draw line by Cairo
#!/usr/bin/env python3
import wx
import wx.lib.wxcairo
class MyApp(wx.App):
def OnInit(self):
frame = wx.Frame(None, -1, 'Hello World!')
frame.Bind(wx.EVT_PAINT, self.OnPaint)
frame.Show()
self.mainFrame = frame
return True
def OnPaint(self, evt):
dc = wx.PaintDC(self.mainFrame)
ctx = wx.lib.wxcairo.ContextFromDC(dc)
ctx.set_line_width(5)
ctx.move_to(10, 20)
ctx.line_to(200, 20)
ctx.stroke()
if __name__ == '__main__':
app = MyApp()
app.MainLoop()