Skip to main content

Posts

How to remove an image with PyGame? [duplicate]

I want to remove an image but i don't know really how to do it. I think we have to create a function ? import pygame pygame.init() pygame.display.set_caption("Képomon") screen = pygame.display.set_mode((284*2,472*2)) BattleStartImage = pygame.image.load('assets/BattleStart.png') buttonRondAImage = pygame.image.load('assets/buttonRondA.png') class Button(): def __init__(self, x, y, image, scale): width = image.get_width() height = image.get_height() self.image = pygame.transform.scale(image, (int(width * scale), int(height * scale))) self.rect = self.image.get_rect() self.rect.topleft = (x,y) self.clicked = False def draw(self): action = False #get mouse position pos = pygame.mouse.get_pos() #check mouseover and clicked conditions if self.rect.collidepoint(pos): if pygame.mouse.get_pressed()[0]==1 and self.clicked == False: self.cl

Tkinter layout doesn’t place buttons in the right place

I am trying to make an image viewer using Python Tkinter as a part of the course I am participating in and I am having some trouble with my code. My problem is in the positioning of the forward and the exit button in the first image, The picture explains this Look at the exit and forward(>>) button under the screen By the way, this problem is only appears in the first image but in the others, the positioning is perfect as shown in the picture the back(<<) and the forward and the exit buttons are in the correct position I have tried to read and debug the code multiple times, and I have even looked at the source code from the course, but I still can't seem to find the issue. Do you have any suggestions or recognize any bugs that I may have missed? Any help would be greatly appreciated. Thank you! Here is all code: #importing files from tkinter import * from PIL import ImageTk,Image #the start of the program root = Tk() root.title("Image Viewer") root.

How to properly declare optional dependencies both as extras and in dedicated groups in Poetry?

From Poetry documentation about the difference between groups and extras: Dependency groups, other than the implicit main group, must only contain dependencies you need in your development process. Installing them is only possible by using Poetry. To declare a set of dependencies, which add additional functionality to the project during runtime, use extras instead. Extras can be installed by the end user using pip. This perfectly makes sense and works fine most of the time. However, during development one usually wants to install all the extras dependencies in order to test all the functionalities of the package. However, extras are not installed by default contrary to groups. Moreover, the Poetry documentation states that: The dependencies specified for each extra must already be defined as project dependencies. Dependencies listed in dependency groups cannot be specified as extras. Thus, because it is not possible to define extras in a Poetry project that are defined in dep

Where to find the code for ESRK1 and RSwM1 in the Julia library source code?

I'm trying to implement the SDE solver called ESRK1 and the adaptive stepsize algorithm called RSwM1 from Rackauckas & Nie (2017). I'm writing a python implementation, mainly to confirm to myself that I've understood the algorithm correctly. However, I'm running into a problem already at the implementation of ESRK1: When I test my implementation with shorter and shorter timesteps on a simple SDE describing geometric Brownian motion, the solution does not converge as dt becomes smaller, indicating that I have a mistake in my code. I believe this algorithm is implemented as part of the library DifferentialEquations.jl in Julia, so I thought perhaps I could find some help by looking at the Julia code. However, I have had some trouble locating the relevant code. If someone could point me to the implementation of ESRK1 and RSwM1 in the relevant Julia librar(y/ies) (or indeed any other readable and correct implementation) of these algorithms, I would be most grateful.

How to input Multiple Image for one output and fit ImageDataGenerator data Tensorflow

I am using ImageDataGenerator to load data. My code is below, When I try to fit, I'm getting error this error: ValueError: Failed to find data adapter that can handle input: (<class 'list'> containing values of types {"<class 'keras.src.preprocessing.image.DirectoryIterator'>"}), <class 'NoneType'> from tensorflow.keras.preprocessing.image import ImageDataGenerator from tensorflow.keras.layers import Input, Conv2D, MaxPooling2D, Flatten, Dense # Loading Data train_a = ImageDataGenerator(rescale=1/255) train_a_gen = train_a.flow_from_directory(path+'/a/', target_size=(500, 500), batch_size=32, class_mode='binary') train_b = ImageDataGenerator(rescale=1/255) train_b_gen = train_b.flow_from_directory(path+'/b/', target_size=(500, 500), batch_size=32, class_mode='binary') # Layers conv1 = Conv2D(32, (3, 3), activation='relu') pool1 = MaxPool2D(pool_size=(2, 2)) conv2 = Conv2D(64, (3, 3), ac

How to increase timeout limit on Vercel Serverless functions

I have an API endpoint on a NextJS project that needs longer than 60s to run. I'm on a pro Vercel plan but for some reason cannot get the timeout limit to increase. At the endpoint itself I've tried export const maxDuration = 300 export const dynamic = 'force-dynamic' which doesn't seem to do anything, I also tried adding a vercel.json file at the top level (above /src ) like so: { "functions": { "pages/api/**": { "memory": 3008, "maxDuration": 300 }, } } Which again isn't working. I've combed through the documentation (mostly here ) and also a handful of threads ( one example ), none of which have helped. I'm running NextJs version 13.5.6 , am definitely on a pro plan, and Node v18, what am I doing wrong? Am really unsure of what else to try. Via Active questions tagged javascript - Stack Overflow https://ift.tt/Agu1h8b

Naming New Tab with Image

I am trying to rename a new tab I am opening up. This new tab contains an iframe with an image as the source. This is how I am opening the tab, but can't seem to get document.title to work. var customTab = window.open(); customTab && customTab.document.title = 'My new tab';//this doesn't work customTab && customTab.document.write( '<iframe src="' + myImage + '" style="border: none;"></iframe>' ); Any ideas would be much appreciated. Via Active questions tagged javascript - Stack Overflow https://ift.tt/Agu1h8b