1

I want to have abutton like this in tkinter (Modern window 10 buttons):
button_i_want

However, I get this button:
my_button

The code for my button is:

from tkinter import Tk,Button
root=Tk()
Button(root,text='OK').pack()
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Arman_Ahmadi
  • 11
  • 1
  • 2
  • Does this answer your question? [How do I change the overall theme of a tkinter application?](https://stackoverflow.com/questions/24367710/how-do-i-change-the-overall-theme-of-a-tkinter-application) – frankenapps Aug 11 '20 at 17:37
  • try `from tkinter import ttk as ttk` and use this `butt = ttk.Button(root)` – Thingamabobs Aug 11 '20 at 17:49
  • You can use themes like said [here](https://stackoverflow.com/questions/63325559/how-to-set-a-style-to-my-whole-tkinter-app/63326642#63326642) and make a button with the theme. – Delrius Euphoria Aug 11 '20 at 18:20

3 Answers3

1

The themed widgets are in 'themed Tk' aka ttk.

import tkinter as tk
import tkinter.ttk as ttk

root = tk.Tk()
ok = ttk.Button(root, text='OK')
ok.pack()
root.mainloop()

Avoid from tkinter import * as both tkinter and tkinter.ttk define Button and many other widgets.

If you use this on Windows you should get something looking like a native button. But this is a theme and can be changed. On Linux or MacOS you will get a button style that is appropriate to that platform.

patthoyts
  • 32,320
  • 3
  • 62
  • 93
0

Another alternative to create button is to create a label and bind it to the action functions. In the below example .bind() is used to connect the label with respective function. You can design according to your requirements.

from tkinter import *

def OnPressed(event):
    print('Hello')
def OnHover(event):
    But.config(bg='red', fg='white')
def OnLeave(event):
    But.config(bg='white', fg='black')

root = Tk()

But = Label(root, text='Hi', bg='white', relief='groove')
But.place(x=10, y=10, width=100)
But.bind('<Button-1>', OnPressed)
But.bind('<Enter>', OnHover)
But.bind('<Leave>', OnLeave)

root.mainloop()
0
vol_up = Button(root, text="+",activebackground='orange',bg='yellow')
vol_up.pack(side='top')
Delrius Euphoria
  • 14,910
  • 3
  • 15
  • 46