Skip to content

Commit dfdbee1

Browse files
jsut fixed a bug -- though it still doesn't lay out right :-)
1 parent 74bc519 commit dfdbee1

File tree

2 files changed

+88
-80
lines changed

2 files changed

+88
-80
lines changed

DrawLinesTest.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
#!/usr/bin/env python2.4
1+
#!/usr/bin/env pythonw
22

33
import wx
4-
import numarray
5-
from numarray import random_array
6-
import RandomArray # the Numeric version
4+
print wx.__version__
5+
import numpy as np
6+
from numpy import random
77
import time
88

99

10-
NumLinePoints = 5000
11-
NumPointPoints = 5000
10+
NumLinePoints = 1000
11+
NumPointPoints = 1000
1212

1313
## Make some random data to draw things with.
1414
MaxX = 500
15-
LinesPoints = random_array.randint(1, MaxX, (NumLinePoints,2) )
15+
# LinesPoints = random.randint(1, MaxX, (NumLinePoints,2) )
16+
LinesPoints = random.randint(1, MaxX, (NumLinePoints,2) )
1617
#PointsPoints = random_array.randint(1, MaxX, (NumPointPoints,2) )
17-
PointsPoints = RandomArray.randint(1, MaxX, (NumPointPoints,2) ) # Numeric
18+
PointsPoints = random.randint(1, MaxX, (NumPointPoints,2) ) # Numeric
1819

1920

2021

2122
class TestFrame(wx.Frame):
2223
def __init__(self):
2324
wx.Frame.__init__(self, None, -1, "DrawLines Test",
2425
wx.DefaultPosition,
25-
size=(500,500),
26+
size=(MaxX, MaxX),
2627
style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)
27-
2828
## Set up the MenuBar
2929
MenuBar = wx.MenuBar()
3030

@@ -42,9 +42,10 @@ def __init__(self):
4242

4343
self.SetMenuBar(MenuBar)
4444

45-
wx.EVT_PAINT(self, self.OnPaint)
45+
self.Bind(wx.EVT_PAINT, self.OnPaint)
4646

4747
def OnPaint(self,event):
48+
print "in OnPaint..."
4849
dc = wx.PaintDC(self)
4950
dc.SetBackground( wx.Brush("White") )
5051
dc.Clear()
@@ -62,9 +63,16 @@ def DrawLines(self, dc):
6263
dc.BeginDrawing()
6364
dc.SetPen(wx.Pen('Black', 2))
6465
start = time.clock()
65-
#dc.DrawLines(LinesPoints.tolist())
6666
dc.DrawLines(LinesPoints)
6767
print "DrawLines Call took %f seconds"%(time.clock() - start)
68+
start = time.clock()
69+
for i in range(len(LinesPoints)-1):
70+
dc.DrawLine(LinesPoints[i,0],
71+
LinesPoints[i,1],
72+
LinesPoints[i+1,0],
73+
LinesPoints[i+1,1],
74+
)
75+
print "DrawLine loop took %f seconds"%(time.clock() - start)
6876
dc.EndDrawing()
6977

7078
def DrawPoints(self, dc):
@@ -87,7 +95,7 @@ def OnInit(self):
8795
return True
8896

8997
if __name__ == "__main__":
90-
app = DemoApp(0)
98+
app = DemoApp(False)
9199
app.MainLoop()
92100

93101

SizerTest2.py

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3,78 +3,78 @@
33
import wx
44

55
class MyFrame(wx.Frame):
6-
def __init__(self, parent, id, name):
7-
wx.Frame.__init__ (self,
8-
parent,
9-
id,
10-
name,
11-
size = wx.DefaultSize,
12-
style = (wx.DEFAULT_DIALOG_STYLE |
13-
wx.MAXIMIZE_BOX |
14-
wx.THICK_FRAME |
15-
wx.RESIZE_BORDER)
16-
)
17-
self.status = self.CreateStatusBar()
18-
19-
btn1above = wx.Button(self, -1, "Create")
20-
btn2above = wx.Button(self, -1, "Ok")
21-
btn1right = wx.Button(self, -1, "Cancel")
22-
btnbrowser = wx.Button(self, -1, "Browse")
23-
btnmenu = wx.Button(self, -1, "Menu")
24-
lst = wx.ListCtrl(self, -1)
25-
self.chkMatchCase = wx.CheckBox(self, -1, "Match Case")
26-
self.chkRegularExpression = wx.CheckBox(self, -1,"RegularExpression")
27-
self.chkSubDirectories = wx.CheckBox(self, -1, "Subdirectories")
6+
def __init__(self, parent, id, name):
7+
wx.Frame.__init__ (self,
8+
parent,
9+
id,
10+
name,
11+
size = wx.DefaultSize,
12+
style = (wx.DEFAULT_DIALOG_STYLE |
13+
wx.MAXIMIZE_BOX |
14+
wx.THICK_FRAME |
15+
wx.RESIZE_BORDER)
16+
)
17+
self.status = self.CreateStatusBar()
2818

29-
# status = wx.StatusBar(self, -1)
30-
31-
helpsizer = wx.BoxSizer(wx.VERTICAL)
32-
helpsizer.Add((0, 5), 0, wx.ALL, 0)
33-
helpsizer.Add(btnbrowser, 0, wx.ALL, 0)
34-
helpsizer.Add((0, 30), 0, wx.ALL, 0)
35-
helpsizer.Add(btnmenu, 0, wx.ALL, 0)
36-
helpsizer.Add((0, 40), 0, wx.ALL, 0)
37-
helpsizer.Add(btn1above, 0, wx.ALL, 0)
38-
helpsizer.Add((0, 5), 0, wx.ALL, 0)
39-
helpsizer.Add(self.chkRegularExpression, 0, wx.ALL, 0)
40-
helpsizer.Add((0, 25), 0, wx.ALL, 0)
41-
helpsizer.Add(self.chkMatchCase, 0, wx.ALL, 0)
42-
helpsizer.Add((0, 5), 0, wx.ALL, 0)
43-
helpsizer.Add(self.chkSubDirectories, 0, wx.ALL, 0)
44-
helpsizer.Add((0, 30), 0, wx.ALL, 0)
45-
helpsizer.Add(btn2above, 0, wx.ALL, 0)
46-
helpsizer.Add((0, 10), 0, wx.ALL, 0)
47-
helpsizer.Add(btn1right, 0, wx.ALL, 0)
19+
btn1above = wx.Button(self, -1, "Create")
20+
btn2above = wx.Button(self, -1, "Ok")
21+
btn1right = wx.Button(self, -1, "Cancel")
22+
btnbrowser = wx.Button(self, -1, "Browse")
23+
btnmenu = wx.Button(self, -1, "Menu")
24+
lst = wx.ListCtrl(self, -1)
25+
self.chkMatchCase = wx.CheckBox(self, -1, "Match Case")
26+
self.chkRegularExpression = wx.CheckBox(self, -1,"RegularExpression")
27+
self.chkSubDirectories = wx.CheckBox(self, -1, "Subdirectories")
4828

49-
stat1 = wx.StaticText(self, -1, "Directory:")
50-
stat2 = wx.StaticText(self, -1, "File Pattern:")
51-
stat3 = wx.StaticText(self, -1, "Search For:")
52-
text1 = wx.ComboBox(self, -1, "", wx.DefaultPosition, (300,-1))
53-
text2 = wx.ComboBox(self, -1, "")
54-
text3 = wx.ComboBox(self, -1, "")
29+
# status = wx.StatusBar(self, -1)
5530

56-
topsizer = wx.FlexGridSizer(2,2,5,5)
57-
topsizer.AddGrowableCol(1)
58-
topsizer.Add(stat1,0)
59-
topsizer.Add(text1,1,wx.GROW)
60-
topsizer.Add(stat2,0)
61-
topsizer.Add(text2,1,wx.GROW)
62-
topsizer.Add(stat3,0)
63-
topsizer.Add(text3,1,wx.GROW)
31+
helpsizer = wx.BoxSizer(wx.VERTICAL)
32+
helpsizer.Add((0, 5), 0, wx.ALL, 0)
33+
helpsizer.Add(btnbrowser, 0, wx.ALL, 0)
34+
helpsizer.Add((0, 30), 0, wx.ALL, 0)
35+
helpsizer.Add(btnmenu, 0, wx.ALL, 0)
36+
helpsizer.Add((0, 40), 0, wx.ALL, 0)
37+
helpsizer.Add(btn1above, 0, wx.ALL, 0)
38+
helpsizer.Add((0, 5), 0, wx.ALL, 0)
39+
helpsizer.Add(self.chkRegularExpression, 0, wx.ALL, 0)
40+
helpsizer.Add((0, 25), 0, wx.ALL, 0)
41+
helpsizer.Add(self.chkMatchCase, 0, wx.ALL, 0)
42+
helpsizer.Add((0, 5), 0, wx.ALL, 0)
43+
helpsizer.Add(self.chkSubDirectories, 0, wx.ALL, 0)
44+
helpsizer.Add((0, 30), 0, wx.ALL, 0)
45+
helpsizer.Add(btn2above, 0, wx.ALL, 0)
46+
helpsizer.Add((0, 10), 0, wx.ALL, 0)
47+
helpsizer.Add(btn1right, 0, wx.ALL, 0)
6448

65-
leftSizer = wx.BoxSizer(wx.VERTICAL)
66-
leftSizer.Add(topsizer,0, wx.EXPAND | wx.ALL, 5)
67-
leftSizer.Add(lst,1, wx.EXPAND | wx.ALL, 5)
68-
69-
newSizer = wx.BoxSizer(wx.HORIZONTAL)
70-
newSizer.Add(leftSizer,1, wx.EXPAND | wx.ALL, 10)
71-
newSizer.Add(helpsizer,0, wx.ALIGN_TOP | wx.ALL, 10)
72-
lastSizer = wx.BoxSizer(wx.VERTICAL)
73-
self.SetSizer(newSizer)
49+
stat1 = wx.StaticText(self, -1, "Directory:")
50+
stat2 = wx.StaticText(self, -1, "File Pattern:")
51+
stat3 = wx.StaticText(self, -1, "Search For:")
52+
text1 = wx.ComboBox(self, -1, "", wx.DefaultPosition, (300,-1))
53+
text2 = wx.ComboBox(self, -1, "")
54+
text3 = wx.ComboBox(self, -1, "")
55+
56+
topsizer = wx.FlexGridSizer(2,3,5,5)
57+
topsizer.AddGrowableCol(1)
58+
topsizer.Add(stat1,0)
59+
topsizer.Add(text1,1,wx.GROW)
60+
topsizer.Add(stat2,0)
61+
topsizer.Add(text2,1,wx.GROW)
62+
#topsizer.Add(stat3,0)
63+
#topsizer.Add(text3,1,wx.GROW)
64+
65+
leftSizer = wx.BoxSizer(wx.VERTICAL)
66+
leftSizer.Add(topsizer,0, wx.EXPAND | wx.ALL, 5)
67+
leftSizer.Add(lst,1, wx.EXPAND | wx.ALL, 5)
68+
69+
newSizer = wx.BoxSizer(wx.HORIZONTAL)
70+
newSizer.Add(leftSizer,1, wx.EXPAND | wx.ALL, 10)
71+
newSizer.Add(helpsizer,0, wx.ALIGN_TOP | wx.ALL, 10)
72+
lastSizer = wx.BoxSizer(wx.VERTICAL)
73+
self.SetSizer(newSizer)
74+
75+
self.Fit()
76+
self.Show()
7477

75-
self.Fit()
76-
self.Show()
77-
7878
app = wx.PySimpleApp()
7979
Panel = MyFrame(None, -1, "Find Files")
8080

0 commit comments

Comments
 (0)