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 :: load saved model pyspark 
Python :: python is letter or number functin 
Python :: upgrade python to 3.8 
Python :: remove base from terminal anaconda 
Python :: sns seaborn set theme 
Python :: matplotlib set dpi 
Python :: save dataframe to csv without index 
Python :: how to make text bold in tkinter 
Python :: argument sequence in python function 
Python :: count words python 
Python :: add self role with discord bot python 
Python :: qspinbox value changed 
Python :: how to get a list of followers on instagram python 
Python :: django auto increment field 
Python :: area of a circle in python 
Python :: write custom query odoo 
Python :: read image python 
Python :: link python3 to python3.7 
Python :: How to extract numbers from a string in Python? 
Python :: Sin , Cos Graph using python turtle. 
Python :: python datetime minus 1 day 
Python :: numpy softmax 
Python :: how to check if a network port is open using python 
Python :: python plot_confusion_matrix 
Python :: format numbers in dataframe pandas 
Python :: min max scaler on one column 
Python :: convert c_ubyte_Array_ to opencv 
Python :: Set up and run a two-sample independent t-test 
Python :: pickle save 
Python :: Python create a digital clock 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =