My image is too large for the turtle window. I had to enlarge the image because the text I need at each spot overlaps.
How do I Resize the window in python?
It sounds like you have drawn an image, but it has gone outside the borders of the window, so therefore you need to make the window larger to see the entire image.
To resize the window:
setup( width = 200, height = 200, startx = None, starty = None)
This will make your output window 200X200 (which may be too small for you so you'll need to make those numbers larger.)
Here is the URL where I found this information.
TurtleDocs
Related
I want to set default tkinter screen and not full screen in tkinter.Thank you
root.geometry("500x100") #Width x Height
Use this code to change your Tkinter screen size. Here root is the main window, geometry() is the function used to change screen size. 500 is the width and 100 is the height
its very easy you just need to set the with and heigth of the window by
root.geometry("400x900") # this .geometry() takes a string in the form of width x heigth
You have various arguments for your Tkinter window :
window.attributes("-fullscreen", True)
Changing it to False will disable fullscreen mode, True will activate it
window.geometry("1400x700")
You can set the default size of your GUI with this, but the user will be able to resize it classically
window.minsize(200, 200)
This one will set the minimum size of your GUI, past it, the user will not be able to reduce the window any further. If you set it to the size of your window, you disable the resizing.
Apologies for not being very clear the first time round.
I am looking for a way to specify the size of "fullscreen" for a window. Is there a way for me to do this?
I have a window that opens off fullscreen mode. When I put the window in full screen mode, the bottom of the window goes behind the taskbar. Is there a way that I can avoid this.
Note that I don't know the size of the screen or taskbar beforehand.
you can simply write:
from tkinter import *
root = Tk()
height = root.winfo_screenheight()
width = 400 #or whatever you want the width to be
root.resizable(height = height, width = width)
I´m trying to figure out how to set the size of my tkinter canvas to bigger then actually my screen is. My screen is 1920x1280, if I set in the following code any higher numbers, the size never gets above this (and I want to do it due to huge drawing there).
Code:
from tkinter import *
class Draw:
def __init__(self, min, max):
self.min = min
self.max = max
def draw(self):
master = Tk()
w = Canvas(master, width=2500, height=2500)
#...
I also tried master.geometry("2500x2500") but that didn´t work either.
You can't make windows larger than the physical screen. However, if your goal is to create a large drawing, you can do that without making the canvas physically large. The canvas widget is just a viewport into a much larger virtual drawing area.
For example, you can create a canvas that is only 400x400 pixels, yet draw an image that is 4000x4000. You can define the size of the virtual window by setting the scrollregion attribute to whatever size you want (up to a limit which I think is maybe around 64000x64000)
This happens because of your screen constraint, you cannot run 2500px * 2500px window on your 1920px * 1280px screen, if you try to run a window 1920px * 1280px on your screen, it would work.
This happens because your limits (2500px * 2500px) is too big for your monitor. The window tries to make 7250000 pixel on you 2457600 pixel screen!
So you would have to get a better screen possibly a 3k or 4k screen to run this.
I am working on making a background for my video game but I can't figure out or find out how to make the image larger.
My code is:
from tkinter import *
Master = Tk()
Can = Canvas(Master, width=1325, height=400)
img = PhotoImage(file="G.E.N.E.S\Textures\Ppm's\G.E.N.E.S.-1.ppm")
Background = Can.create_image(0,160,anchor=NW,image=img)
Blob = Can.create_oval(650,385,675,360,fil="black")
Can.config(bg="white")
Can.pack()
How can I make the image larger on the Canvas?
I'd really appreciate anyone's help.
Note: I cant install any modules because I'm working at school.
P.S. I'm sorry but I can't figure out how to put a screen shot in.
You can use the .zoom method.
img = PhotoImage(file="G.E.N.E.S\Textures\Ppm's\G.E.N.E.S.-1.ppm")
img.zoom(2,2) # x, y
This will make the image larger by 2x both height and width. If x or y is not specified, x or y will stay the same.
This is supposed to just load a sprite onto the screen, but the background of the image is this black box, and i don't want to see that. How do I make the background of the image transparent?
from Tkinter import *
import pygame
from livewires import games
#Creating screen window
games.init(screen_width = 700, screen_height = 650, fps = 50)
#creating background image for the screen
screen_background = games.load_image('resized_stars background.png', transparent = False)
games.screen.background = screen_background
#Creating a sprite
spaceship_image = games.load_image('pixel_spaceship.png')
spaceship = games.Sprite(image = spaceship_image, x=350, y=235)
games.screen.add(spaceship)
#main loop at the end of the program just as in tkinter
games.screen.mainloop()
Your image needs to be a png. Open Preview, for example, and use the alpha tool to remove the background, thus adding transparency.
Before png:
After png:
Look here for a tool on making your picture transparent.
When loading the png image, you have to convert it:
image = pygame.image.load("yourImage.png").convert_alpha()
This should get rid of that black box that should be the transparent alpha.