Advertisement
axl456

Untitled

Apr 16th, 2011
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.00 KB | None | 0 0
  1. import wx
  2. import random
  3.  
  4. class Panel(wx.Panel):
  5.     def __init__(self, parent):
  6.         super(Panel, self).__init__(parent, -1)
  7.         self.Bind(wx.EVT_PAINT, self.on_paint)
  8.         self.points = [[0, 0], [10, 25]]
  9.         self.lines = [[random.randint(0, 500) for i in range(4)] for j in range(100)]
  10.         self.x= 1
  11.         self.y = 1
  12.         self.Bind(wx.EVT_LEFT_UP, self.OnLeftDown)
  13.         self.Bind(wx.EVT_RIGHT_UP, self.OnRightDown)
  14.  
  15.     def OnLeftDown(self, event):
  16.         self.x += 0.1
  17.         self.y += 0.1
  18.         self.Refresh()
  19.  
  20.     def OnRightDown(self, event):
  21.         self.x -= 0.1
  22.         self.y -= 0.1
  23.         self.Refresh()
  24.         self.foo(self.a)
  25.        
  26.     def on_paint(self, event):
  27. #        print event
  28.         dc = wx.PaintDC(self)
  29.         gcdc = wx.GCDC(dc)
  30. #        gc = gcdc.GetGraphicsContext()
  31.         gc = wx.GraphicsContext.Create(dc)
  32.         self.Draw(gcdc)
  33.         self.a = dir(gc)
  34.        
  35.  
  36.     def Draw(self, dc):
  37. #        pass
  38.         dc.Clear()
  39.         dc.SetUserScale(self.x, self.y)
  40. #        dc.DrawPointList(self.points)
  41. #        print dc.GetMapMode()
  42. #        for points in self.points:
  43. #            print "for X: device = %s, logical %s" % (points[0], dc.DeviceToLogicalX(points[0]))
  44. #            print "for Y: device = %s, logical %s" % (points[1], dc.DeviceToLogicalY(points[1]))
  45.         for line in self.lines:
  46.             dc.DrawLine(*line)
  47.  
  48.     def foo(self, dicty):
  49.         print len(dicty)
  50.         to_print = []
  51.         count = 0
  52.         for x in dicty:
  53. #            count += 1
  54.             if count < 5:
  55.                 to_print.append(x)
  56.                 count += 1
  57.             else:
  58.                 print to_print
  59.                 count = 0
  60.                 to_print = []
  61.  
  62.  
  63. class Frame(wx.Frame):
  64.     def __init__(self):
  65.         super(Frame, self).__init__(None, -1, 'Test', size=(550, 600))
  66.         Panel(self)
  67.  
  68. if __name__ == "__main__":
  69.     app = wx.PySimpleApp()
  70.     frame = Frame()
  71.     frame.Show()
  72.     app.MainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement