hello I've this python code:
import wx
class MyFrame(wx.Frame):
def __init__(self, parent=None, id=-1, title=None):
wx.Frame.__init__(self, parent, id, title)
self.panel_1 = wx.Panel(self, -1)
self.panel_1.Bind(wx.EVT_PAINT, self.on_paint)
self.image = wx.Image('foto.jpg')
# Menu Bar
self.frame_1_menubar = wx.MenuBar()
self.File = wx.Menu()
self.Test = wx.MenuItem(self.File, wx.NewId(), "Test", "", wx.ITEM_NORMAL)
self.File.AppendItem(self.Test)
self.frame_1_menubar.Append(self.File, "File")
self.SetMenuBar(self.frame_1_menubar)
# Menu Bar end
self.frame_1_statusbar = self.CreateStatusBar(1, 0)
self.panel_1.Bind(wx.EVT_LEFT_UP, self.OnMove)
self.__set_properties()
self.__do_layout()
# end wxGlade
def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
#self.SetTitle("frame_1")
self.panel_1.SetMinSize((480, 272))
self.panel_1.SetMaxSize((480, 272))
self.panel_1.SetBackgroundColour(wx.Colour(0, 0, 0))
self.frame_1_statusbar.SetStatusWidths([-1])
# statusbar fields
frame_1_statusbar_fields = ["frame_1_statusbar"]
for i in range(len(frame_1_statusbar_fields)):
self.frame_1_statusbar.SetStatusText(frame_1_statusbar_fields[i], i)
# end wxGlade
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
sizer_3 = wx.BoxSizer(wx.VERTICAL)
sizer_2.Add(self.panel_1, 1, wx.ALIGN_CENTER_VERTICAL, 0)
sizer_2.Add(sizer_3, 1, wx.EXPAND, 0)
sizer_1.Add(sizer_2, 1, 0, 0)
#self.linea = wx.StaticLine(self.panel_1, pos=(0, 5), size=(0,wx.EXPAND))
#self.panel_1.Add(self.static_line_1, 0, wx.EXPAND, 0)
#self.linea.SetBackgroundColour(wx.Colour(255, 0, 0))
self.SetSizer(sizer_1)
sizer_1.Fit(self)
self.Layout()
# end wxGlade
def on_paint(self, event):
self.dc = wx.PaintDC(self.panel_1)
self.dc.SetBackground(wx.Brush('black'))
self.lineaorizzontale(34)
self.lineaverticale(34)
bitmap = wx.BitmapFromImage(self.image)
self.dc.DrawBitmap(bitmap, 0,0)
event.Skip()
def lineaorizzontale(self, y):
self.dc.SetPen(wx.Pen('blue', 1))
self.dc.DrawLine(0, y, 200, y)
def lineaverticale(self, x):
self.dc.SetPen(wx.Pen('blue', 1))
self.dc.DrawLine(x, 0, x, 200)
def OnMove(self, event):
self.dc.Clear()
bitmap = wx.BitmapFromImage(self.image)
self.dc.DrawBitmap(bitmap, 0,0)
pos = event.GetPosition()
self.lineaorizzontale(pos.y)
self.lineaverticale(pos.x)
print "%s, %s" % (pos.x, pos.y)
event.Skip()
# test it ...
app = wx.PySimpleApp()
frame1 = MyFrame(title='rounded-rectangle & circle')
frame1.Center()
frame1.Show()
app.MainLoop()
but I don't know why it doesn't not work properly.
Can you help me?
sorry for my english