Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

button images in tkinter

img = PhotoImage(file='not_not.jpg')

main_button = Button(root, image=img, command=open_level_menu, fg="white", bg="black",)
Comment

Python Tkinter button Image

from Tkinter import *

root = Tk()

class PokemonClass(object):
    def __init__(self, master):
        frame = Frame(master)
        frame.pack()

        self.WelcomeLabel = Label(root, text="Welcome! Pick your Pokemon!",
                                  bg="Black", fg="White")
        self.WelcomeLabel.pack(fill=X)

        self.CharButton = Button(root, text="Charmander", bg="RED", fg="White",
                                 command=self.CharClick)
        self.CharButton.pack(side=LEFT, fill=X)

        self.SquirtButton = Button(root, text="Squirtle", bg="Blue", fg="White")
        self.SquirtButton.pack(side=LEFT, fill=X)

        self.BulbButton = Button(root, text="Bulbasaur", bg="Dark Green",
                                 fg="White")
        self.BulbButton.pack(side=LEFT, fill=X)

    def CharClick(self):
        print "You like Charmander!"
        global CharSwitch
        CharSwitch = 'Yes'

CharSwitch = 'No'

if CharSwitch == 'Yes':
    CharPhoto = PhotoImage(file="Charmander.gif")
    ChLabel = Label(root, image=CharPhoto)
    ChLabel.pack()

k = PokemonClass(root)
root.mainloop()
Comment

PREVIOUS NEXT
Code Example
Python :: Kivy FileChooser 
Python :: python find if strings are anagrams 
Python :: permission denied when converting dataframe to csv 
Python :: python tkinter button dynamic button command 
Python :: **kwargs in python 
Python :: repr() in python 
Python :: urllib.error.HTTPError: HTTP Error 404: Not Found 
Python :: how to write a comment in python 
Python :: python list all columns in dataframe 
Python :: how to union value without the same value in numpy 
Python :: decimal to binary python 
Python :: identity matrix python 
Python :: make gif from images in python 
Python :: how to convert string to datetime 
Python :: confusion matrix 
Python :: Normalize columns in pandas dataframe 
Python :: google assistant in windows 10 
Python :: close a file python 
Python :: python combinations 
Python :: make value of two tables unique django 
Python :: check if any letter in string python 
Python :: if else pandas dataframe 
Python :: ip address finder script python 
Python :: list to dic 
Python :: django sessions for beginners 
Python :: python only decimal part 
Python :: Python __mul__ 
Python :: python discord know message from bot 
Python :: empty array python 
Python :: django form field add attrs 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =