Option list Tkinter Azure Dark theme

Let’s see an example of the beautiful Azure dark theme:

# Importing Tkinter and Ttk
import tkinter as tk
from tkinter import ttk

class Window:
	def __init__(self):
		# Create the window
		self.root = tk.Tk()
		self.root.title('Azure - Option Menu')

		# Place the window in the center of the screen
		self.windowWidth = 800
		self.windowHeight = 530
		self.screenWidth = self.root.winfo_screenwidth()
		self.screenHeight = self.root.winfo_screenheight()
		self.xCordinate = int((self.screenWidth/2) - (self.windowWidth/2))
		self.yCordinate = int((self.screenHeight/2) - (self.windowHeight/2))
		self.root.geometry("{}x{}+{}+{}".format(self.windowWidth, self.windowHeight, self.xCordinate, self.yCordinate))
		# Create a style
		self.style = ttk.Style(self.root)
		self.style.configure("Button", background="red")
		self.style.map('Button', background=[('active','red')])
		# Import the tcl file
		self.root.tk.call('source', 'azure dark/azure dark.tcl')
		# Set the theme with the theme_use method
		self.style.theme_use('azure')



	def create_option_list(self,x,y,lst):
		# Creating lists
		self.option_list = lst
		self.e = tk.StringVar(value=self.option_list[1])
		self.optionmenu = ttk.OptionMenu(self.root, self.e, *self.option_list)
		self.optionmenu.place(x=x, y=y)

w = Window()
w.create_option_list(10,10,
	['', 'OptionMenu', 'Value 1', 'Value 3'])
w.root.mainloop()

https://github.com/formazione/Azure-ttk-theme.git

[hoop name=”all”]

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.