SHARE
TWEET

Python - tkinter, ttk, change style

furas Jun 25th, 2018 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import tkinter as tk
  2. from tkinter import ttk
  3.  
  4.  
  5. class Salman:
  6.    
  7.     def __init__(self):
  8.         self.mainwin = tk.Tk()
  9.        
  10.         self.label = ttk.Label(self.mainwin, text="simple practice", font="italic")
  11.         self.label.grid(row=0, column=0)
  12.  
  13.         self.button = ttk.Button(self.mainwin, text="button", command=self.clickme)
  14.         self.button.grid(row=1, column=3)
  15.  
  16.         self.textvar = tk.StringVar()
  17.         self.entry = ttk.Entry(self.mainwin, width=12, textvariable=self.textvar)
  18.         self.entry.grid(row=1, column=2)
  19.  
  20.         tk.mainloop()
  21.        
  22.     def clickme(self):
  23.         self.label.configure(text=self.textvar.get())
  24.         self.button.config(text="ihave been clicked")
  25.  
  26.         style = ttk.Style()
  27.         style.configure("TButton", foreground="blue")
  28.         style.configure("TLabel", background="yellow")
  29.        
  30.          
  31. nomi = Salman()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top