plik nowy.py
def par(a,b,szer,wys,xyz): #xyz musi byc rozne 1 lub 2
    data=[]
    c=wys/szer  #obliczenie ile sztuk sie zmiesci
    x=z=y=0
    while b>=0: #b-szerokosc a-wysykosc
        if xyz==1:
            d=a       #d-zapasowa wysokosc
            print "1"
            while d>0:
                f=b+szer    #zapasowa szerokosc
                e=c    #e-zapasowa mnogosc
                while e>0 and (f-szer)>0 and d>0:   #plytki |||
                    print "1.1"
                    e=e-1
                    if (f-szer)>=szer and d>=wys:
                        print "1.1.1"
                        x=x+1
                        data.append((f+(c-2)*szer,d-(c-1)*szer,szer,wys))
                    elif d<wys and (f-szer)<szer:
                        print "1.1.2"
                        y=y+1
                        data.append((wys,szer,f-szer,d))
                    elif d<wys:
                        print "1.1.3"
                        y=y+1
                        data.append((f+(c-2)*szer,szer,szer,d))
                    elif (f-szer)<szer :
                        print "1.1.4"
                        y=y+1
                        data.append((wys,d-(c-1)*szer,f-szer,wys))
                    f=f-szer
                d=d-wys
                e=c
                while e>0 and d>0 and b>0:   #plytki poziome
                    print "1.2"
                    e=e-1
                    if d>=szer and b>=wys:
                        print "1.2.1"
                        x=x+1
                        data.append((b,d,wys,szer))
                    elif d<szer and b<wys:
                        print "1.2.2"
                        z=z+1
                        data.append((wys,szer,b,d))
                    elif d<szer:
                        print "1.2.3"
                        z=z+1
                        data.append((b,szer,wys,d))
                    elif b<wys:
                        print "1.2.4"
                        z=z+1
                        data.append((wys,d,b,szer))
                    d=d-szer
            xyz=2
            b=b-wys
        if xyz==2:
            d=a
            print "2"
            while d>0:
                e=c
                while e>0 and d>0 and b>0:   #plytki poziome
                    print "2.1"
                    e=e-1
                    if d>=szer and b>=wys:
                        print "2.1.1"
                        x=x+1
                        data.append((b,d,wys,szer))
                    elif d<szer and b<wys:
                        print "2.1.2"
                        z=z+1
                        data.append((wys,szer,b,d))
                    elif d<szer:
                        print "2.1.3"
                        z=z+1
                        data.append((b,szer,wys,d))
                    elif b<wys:
                        print "2.1.4"
                        z=z+1
                        data.append((wys,d,b,szer))
                    d=d-szer
                f=b+szer    #zapasowa szerokosc
                e=c    #e-zapasowa mnogosc
                while e>0 and (f-szer)>0 and d>0:   #plytki |||
                    print "2.2"
                    e=e-1
                    if (f-szer)>=szer and d>=wys:
                        print "2.2.1"
                        x=x+1
                        data.append((f+(c-2)*szer,d-(c-1)*szer,szer,wys))
                    elif d<wys and (f-szer)<szer:
                        print "2.2.2"
                        y=y+1
                        data.append((wys,szer,f-szer,d))
                    elif d<wys:
                        print "2.2.3"
                        y=y+1
                        data.append((f+(c-2)*szer,szer,szer,d))
                    elif (f-szer)<szer :
                        print "2.2.4"
                        y=y+1
                        data.append((wys,d-(c-1)*szer,f-szer,wys))
                    f=f-szer
                d=d-wys
            xyz=1
            b=b-wys
    return data
#-------------------------------------------------------------------------------------
from wxPython.wx import *
data=[(34,34,34,34)]
Width=410
Height=365
#-------------------------------------------------------------------------------------
class Blok(wxWindow):
    def __init__(self, parent, id,
                pos =(40,40),           #wxDefaultPosition,
                size =(Width,Height), #wxDefaultSize,  
                ):
        wxWindow.__init__(self, parent, id, pos,size)
        EVT_PAINT(self, self.OnPaint)
        EVT_SIZE(self, self.OnSize)
        self.OnSize(None)
    def Draw(self,dc):   #predefiniowanie funkcji
        pass
    def OnPaint(self, event):  #no ze tak sie wyraze pole do rysowania
        dc = wxBufferedPaintDC(self, self._Buffer)
    def OnSize(self, event):  #odswierzenie rysunku po zmianie rozmiaru
        global Width,Height
        Width, Height = self.GetClientSizeTuple()
        self._Buffer = wxEmptyBitmap(Width, Height)
        self.SetClientSizeWH(Width, Height)
        self.Updatek()
    def Updatek(self):   #funkcja pomocnicza
        dc = wxBufferedDC(wxClientDC(self), self._Buffer)
        self.Draw(dc)
    def SaveToFile(self,FileName,FileType):
        self._Buffer.SaveFile(FileName,FileType)
#-------------------------------------------------------------------------------------
class DrawWindow(Blok):
    def __init__(self, parent, id = -1):
        Blok.__init__(self, parent, id)
    def Draw(self,dc):  #funkcja rysujaca
        dc.BeginDrawing()
        dc.SetBackground(wxBrush("Yellow"))
        dc.Clear()  #czyszczenie ekranu
        dc.SetBrush(wxBrush(wxWHITE, wxSOLID))
        dc.SetPen(wxPen(wxCYAN, 1, wxSOLID))
        for r in data:
            dc.DrawRectangle(*r)
        dc.EndDrawing()
#-------------------------------------------------------------------------------------
class Zonk(wxFrame):
    def __init__(self):
        wxFrame.__init__(self, NULL, -1, "Test",
                         wxDefaultPosition,
                         size=(500,500),
                         style=wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
        self.drawingarea = DrawWindow(self, -1)
        self.SetAutoLayout(True)
        gap = 40 #in pixels
        lc = wxLayoutConstraints()
        lc.top.SameAs(self, wxTop, gap)   #rozm gora
        lc.left.SameAs(self, wxLeft, gap)   #rozm lewo
        lc.right.SameAs(self, wxWidth, gap)   #rozm prawo
        lc.bottom.SameAs(self, wxBottom, gap)  #rozm dol
        self.drawingarea.SetConstraints(lc)  #nadawanie wymiarow dla pola
        #pola do wprowadzania danych
        width1= wxStaticText(self, -1, "szerokosc", wxPoint(10,0))
        self.x=wxTextCtrl(self, 20, "235", wxPoint(10, 12), wxSize(50,-1))
        height1 = wxStaticText(self, -1, "wysokosc", wxPoint(70,0))
        self.y=wxTextCtrl(self, 20, "235", wxPoint(70, 12), wxSize(50,-1))
        width2 = wxStaticText(self, -1, "szerkosc", wxPoint(130,0))
        self.w=wxTextCtrl(self, 20, "10", wxPoint(130, 12), wxSize(50,-1))
        height2 = wxStaticText(self, -1, "wysokosc", wxPoint(190,0))
        self.s=wxTextCtrl(self, 20, "30", wxPoint(190, 12), wxSize(50,-1))
        self.guzior =wxButton(self, 10, "rysuj", wxPoint(300, 10))
        EVT_BUTTON(self,10,self.rys)
        self.Show(true)
        self.Window = DrawWindow(self)
        #menu
        MenuBar = wxMenuBar()
        draw_menu = wxMenu()
        ID_DRAW_MENU = wxNewId()
        BMP_ID = wxNewId()
        draw_menu.Append(BMP_ID,'&Save Drawing\tAlt-I','')
        EVT_MENU(self,BMP_ID, self.SaveToFile)
        MenuBar.Append(draw_menu, "&Draw")
        self.SetMenuBar(MenuBar)
    def rys(self, event): #funkcja wyciagajaca dane z pol
        global data
        a=int(self.x.GetValue())
        b=int(self.y.GetValue())
        c=int(self.w.GetValue())
        d=int(self.s.GetValue())
        data=par(a,b,c,d,1)
        self.Window.OnSize(self)
    def wah(self,event):
        self.Window.Updatek()
    def SaveToFile(self,event):
        dlg = wxFileDialog(self, "Choose a file name to save the image as a PNG to",
                           defaultDir = "",
                           defaultFile = "",
                           wildcard = "*.png",
                           style = wxSAVE)
        if dlg.ShowModal() == wxID_OK:
            self.Window.SaveToFile(dlg.GetPath(),wxBITMAP_TYPE_PNG)
        dlg.Destroy()
class Demo(wxApp):
    def OnInit(self):
        frame = Zonk()
        frame.Show(True)
        frame.wah(None)
        self.SetTopWindow(frame)
        return true
app = Demo(0)
app.MainLoop()