diff --git a/ClassLajsna.py b/ClassLajsna.py new file mode 100644 index 0000000..22e6e97 --- /dev/null +++ b/ClassLajsna.py @@ -0,0 +1,33 @@ +import pygame +from Labela import * + +class Lajsna: + def __init__(self, x, y, width, height): + self.x = x + self.y = y + self.width = width + self.height = height + self.press = 2 + self.prevpress = [-1, -1] + self.labela = Label(x, y) + + def draw(self, screen): + pygame.draw.rect(screen, (0, 102, 255), pygame.Rect(self.x, self.y, self.width, self.height)) + pygame.draw.line(screen, (200, 20, 0), (self.x + self.width*14/15 - self.width/30, self.y + self.height/10), + (self.x + self.width*14/15 - self.width/30 + self.width/15, self.y + self.height*8/10), 3) + pygame.draw.line(screen, (200, 20, 0), (self.x + self.width*14/15 - self.width/30, self.y + self.height/10 + self.height*8/10), + (self.x + self.width*14/15 - self.width/30 + self.width/15, self.y + self.height/10), 3) + self.labela.draw(screen) + + def click(self, x, y): + if x > self.x + self.width*14/15 - self.width/30 and x < self.x + self.width*14/15 - self.width/30 + self.width/15: + self.press = 0 + else: + self.press = 1 + self.prevpress = [x, y] + + def drag(self, x, y, prevx, prevy): + self.x += x + self.y += y + self.prevpress = [prevx, prevy] + self.labela.change_pos(self.x, self.y) \ No newline at end of file diff --git a/ClassProzor.py b/ClassProzor.py new file mode 100644 index 0000000..54f8080 --- /dev/null +++ b/ClassProzor.py @@ -0,0 +1,21 @@ +from ClassLajsna import * +import pygame +class Prozor: + def __init__(self,x,y,width,height,labeltext): + self.x=x + self.y=y + self.width=width + self.height=height + self.label=labeltext + self.lajsna=Lajsna(self.x,self.y,self.width,30) + def draw(self,screen): + pygame.draw.rect(screen,(153, 153, 102),pygame.Rect(self.x,self.y,self.width,self.height)) + self.lajsna.draw(screen) + def click(self,x,y): + if(x>=self.lajsna.x and x<=self.lajsna.x+self.lajsna.width) and (y>self.lajsna.y and y=self.prozori[i].x and x<=self.prozori[i].x+self.prozori[i].width) and (y>self.prozori[i].y and yself.x+self.width*14/15-self.width/30 and x= lajsna.x and x <= lajsna.x + lajsna.width) and (y > lajsna.y and y < lajsna.y + lajsna.height): - lajsna.click(x, y) - if lajsna.press == 0: - laj.remove(lajsna) - if event.type == pygame.MOUSEBUTTONUP: - for lajsna in laj: - lajsna.press = 2 - if event.type == pygame.MOUSEMOTION: - for lajsna in laj: - if lajsna.press == 1: - lajsna.drag(x - lajsna.prevpress[0], y - lajsna.prevpress[1], x, y) +prozori=[] +window_menager=WindowMenager() +while running: x, y = pygame.mouse.get_pos() - screen.fill(background_colour) - for lajsna in laj: - lajsna.draw(screen) - pygame.draw.circle(screen, (254, 254, 254), [x, y], 7) - - # Draw the label - label.draw(screen) - + for event in pygame.event.get(): + if (event.type == pygame.KEYDOWN and event.key == pygame.K_u) or event.type==pygame.QUIT: + running = False + if event.type == pygame.KEYDOWN and event.key == pygame.K_w: + window_menager.add_prozor() + if event.type==pygame.MOUSEBUTTONDOWN: + window_menager.check_click(x,y) + # for prozor in prozori: + # if(x>=prozor.x and x<=prozor.x+prozor.width) and (y>prozor.y and y