Hi, it's me again and i have new question:
This is my code:
# -*- coding: cp1250 -*-
import string as _string
import time as _time
import wx
from math import*
class Canvas:
def __init__(self,parent):
self.okno=parent
self.okno.SetBackgroundColour("#FCFCFE")
self.radic = wx.FlexGridSizer(2,2,0,0)
self.canvas = wx.ScrolledWindow(self.okno, -1)
self.canvas.EnableScrolling(True, True)
self.P_WIDTH = 1000
self.P_HEIGHT = 1000
self.canvas.SetScrollbars(20, 20, self.P_WIDTH/20, self.P_HEIGHT/20)
self.radic.Add(self.canvas, 1, wx.EXPAND)
self.radic.Add((0,0))
sizer=wx.BoxSizer(wx.VERTICAL)
self.radic.Add(sizer, 1, wx.EXPAND)
self.radic.Add((0,0))
self.radic.AddGrowableRow(0, 1)
self.radic.AddGrowableCol(0, 1)
sizer2=wx.BoxSizer(wx.HORIZONTAL)
sizer2.Add(wx.StaticText(self.okno,label=" f(y)= "),0,wx.ALIGN_CENTER)
self.vstup=wx.TextCtrl(self.okno)
sizer2.Add(self.vstup,1,0,wx.ALL)
sizer.Add(sizer2,0,wx.EXPAND)
sizer3=wx.BoxSizer(wx.HORIZONTAL)
button1=wx.Button(self.okno,label="Show")
sizer3.Add(button1,0,wx.ALIGN_RIGHT)
sizer.Add(sizer3,0,wx.EXPAND)
##
self.canvas.SetCursor(wx.CROSS_CURSOR)
self.canvas.Bind(wx.EVT_PAINT, self.OnPaint)
self.okno.SetSizer(self.radic)
button1.Bind(wx.EVT_BUTTON,lambda e:self.vykresli())
self.body=[(0,0,0,0)]
self.pocet=0
self.dc=False
def vykresli(self):
l=[]
for prvek in self.vstup.GetValue().split(','):
l.append(int(prvek))
self.body=l
self.dc.BeginDrawing()
self.dc.DrawLineList([l])
self.dc.EndDrawing()
def OnPaint(self, evt):
self.dc=wx.PaintDC(self.canvas)
self.dc.BeginDrawing()
self.dc.DrawLineList(self.body)
self.dc.EndDrawing()
if __name__ == "__main__":
okno = wx.App(0)
parent=wx.MDIParentFrame(None,size=wx.Size(500,500))
child=wx.MDIChildFrame(parent,title="Graf",id=-1)
Canvas(child)
child.Maximize()
parent.Show()
okno.MainLoop()
if i write in entry for example 4,5,4,40 than will becreated line at this coordinates. But if i press button Show, the line is showed, but i get some error. Do you can tell me please what i am doing bad?