furas

Python - tkinter, ttk, change style

Jun 25th, 2018
117
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×