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 :: python codes for counting the occurrence of a letters in dictionary excluding digits 
Python :: pandas heading 
Python :: swap two lists without using third variable python 
Python :: closures in python 
Python :: python string lenght 
Python :: extract directory python 
Python :: unicode error python 
Python :: assignment operators in python 
Python :: a function to create a null matrix in python 
Python :: numpy array [-1] 
Python :: check package is installed by conda or pip environment 
Python :: smooth interpolation python 
Python :: python re.sub() 
Python :: deleting key from dictionary 
Python :: get the last item in a python list 
Python :: how to get a list of all variables in memory python 
Python :: add vertical line in plot python 
Python :: check if boolean is true python 
Python :: lambda 
Python :: django make new application folder 
Python :: linkedlist python 
Python :: stemming words python 
Python :: python while loop 
Python :: kaspersky 
Python :: List Get a Element 
Python :: python get value from list 
Python :: python class getters and setters 
Python :: simple bmi calculator using python 
Python :: How to split a string into a dictionary in Python 
Python :: get nth character of string python 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =