Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

create image tkinter set active background

import tkinter as tk
from PIL import ImageTk, Image

class CanvasButton:
    def __init__(self, canvas):
        self.canvas = canvas
        self.number = tk.IntVar()
        self.button = tk.Button(canvas, textvariable=self.number,
                                command=self.buttonclicked)
        self.id = canvas.create_window(50, 100, width=25, height=25,
                                       window=self.button)
    def buttonclicked(self):
        self.number.set(self.number.get()+1)  # auto updates Button

root = tk.Tk()
root.resizable(width=False, height=False)
root.wm_attributes("-topmost", 1)

imgpath = 'archipelago_big.gif'
img = Image.open(imgpath)
photo = ImageTk.PhotoImage(img)

canvas = tk.Canvas(root, bd=0, highlightthickness=0)
canvas.pack()
canvas.create_image(0, 0, image=photo)

CanvasButton(canvas)  # create a clickable button on the canvas

root.mainloop()
Comment

PREVIOUS NEXT
Code Example
Python :: import nifti to numpy 
Python :: SQLAlchemy Users to JSON code snippet 
Python :: How to make bot commands case insensitive in discord.py 
Python :: python loop invalid input 
Python :: check accessability of the file 
Python :: python time a code segment 
Python :: how to remove na values in r data frame 
Python :: wx.SingleInstanceCheckerindexmodules 
Python :: python keyboard monitoring 
Python :: xmlrpc get all posts 
Python :: matplotlib set dpi 300 
Python :: how to take multiple input python 
Python :: initialize boolean list of size python 
Python :: to check weather a dictionary is empty or not in python 
Python :: open tkinter and cli 
Python :: plot row vs column in dataframe python 
Python :: How to change the height of an input in python tkinter 
Python :: len range 
Python :: ternary operator using dictionary in Python 
Python :: running mean 
Python :: como escribir letras griegas en python 
Python :: python turtle documentation 
Python :: n largest python 
Python :: python wikipedia 
Python :: wikipedia api python 
Python :: convert date to integer python 
Python :: scikit decision tree regressor 
Python :: start and end index in python 
Python :: add an index column in range dataframe 
Python :: if statements python 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =