enneenne
enneenne

Reputation: 219

Python canvas bigger size than screen

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.

Upvotes: 2

Views: 1356

Answers (2)

Teerth jain
Teerth jain

Reputation: 85

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.

Upvotes: 0

Bryan Oakley
Bryan Oakley

Reputation: 386342

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)

Upvotes: 2

Related Questions