Open lozardo opened 5 months ago
self.bottom_toolbar_height = 40
self.download_button = Button(self.screen, self.width - 300, self.height - self.bottom_toolbar_height + 10, 100, 20, text='Download', fontSize=15, margin=20, inactiveColour=(255, 255, 255), activeColour=(240, 240, 240), onClick=self.save_picture)
self.save_button = Button(self.screen, self.width - 180, self.height - self.bottom_toolbar_height + 10, 100, 20, text='Save', fontSize=15, margin=20, inactiveColour=(255, 255, 255), activeColour=(240, 240, 240), onClick=self.send_save_action)
self.exit_button = Button(self.screen, self.width - 60, self.height - self.bottom_toolbar_height + 10, 100, 20, text='Exit', fontSize=15, margin=20, inactiveColour=(255, 255, 255), activeColour=(240, 240, 240), onClick=self.exit_whiteboard)
self.ID_button = Button(self.screen, self.width - 785, self.height - self.bottom_toolbar_height + 10, 100, 20, text=f"{self.id}", fontSize=15, margin=20, inactiveColour=(255, 255, 255), activeColour=(240, 240, 240), onClick=lambda: pyperclip.copy(f"{self.id}"))
pygame.draw.circle(self.screen, (255, 255, 255), (600, 500), 1000)
def send_save_action(self): """ Sends a save action to the server. """ message = ("save", '')
def exit_whiteboard(self): """ Exits the current whiteboard and returns to the whiteboard selection screen. """
# You may need to close the current whiteboard window and open a new dialog/window
while True: events = pygame.event.get() pygame_widgets.update(events) pygame.display.update() for event in events: if event.type == pygame.QUIT: recv_thread.join(1) pygame.quit() sys.exit() elif event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1:
for i, color_button in enumerate(self.color_buttons): color_button.listen(event) # Use listen method if color_button.clicked: self.change_color(i) break else: self.drawing = True elif event.type == pygame.MOUSEBUTTONUP: self.drawing = False self.points = [] elif event.type == pygame.MOUSEMOTION: if self.drawing and event.pos[1] > self.toolbar_height: if len(self.points) > 1: self.points = [self.points[-1], event.pos] else: self.points = [event.pos] # Handle slider events if self.line_width != int(self.width_slider.getValue()): self.line_width = int(self.width_slider.getValue()) # Handle button events self.download_button.listen(event) self.save_button.listen(event) self.exit_button.listen(event) self.draw_toolbar() self.draw_bottom_toolbar() # ... (the rest of the code remains the same)
Bottom toolbar
self.bottom_toolbar_height = 40
Calculate space for ID and adjust button positions
self.download_button = Button(self.screen, self.width - 300, self.height - self.bottom_toolbar_height + 10, 100, 20, text='Download', fontSize=15, margin=20, inactiveColour=(255, 255, 255), activeColour=(240, 240, 240), onClick=self.save_picture)
self.save_button = Button(self.screen, self.width - 180, self.height - self.bottom_toolbar_height + 10, 100, 20, text='Save', fontSize=15, margin=20, inactiveColour=(255, 255, 255), activeColour=(240, 240, 240), onClick=self.send_save_action)
self.exit_button = Button(self.screen, self.width - 60, self.height - self.bottom_toolbar_height + 10, 100, 20, text='Exit', fontSize=15, margin=20, inactiveColour=(255, 255, 255), activeColour=(240, 240, 240), onClick=self.exit_whiteboard)
self.ID_button = Button(self.screen, self.width - 785, self.height - self.bottom_toolbar_height + 10, 100, 20, text=f"{self.id}", fontSize=15, margin=20, inactiveColour=(255, 255, 255), activeColour=(240, 240, 240), onClick=lambda: pyperclip.copy(f"{self.id}"))
pygame.draw.circle(self.screen, (255, 255, 255), (600, 500), 1000)
def send_save_action(self): """ Sends a save action to the server. """ message = ("save", '')
Add your code to send the message to the server using socket_help.send_message()
def exit_whiteboard(self): """ Exits the current whiteboard and returns to the whiteboard selection screen. """
Add your code to return to the whiteboard selection screen
while True: events = pygame.event.get() pygame_widgets.update(events) pygame.display.update() for event in events: if event.type == pygame.QUIT: recv_thread.join(1) pygame.quit() sys.exit() elif event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1:
Check if clicked on a color button