- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use the "native" GUI look with Tkinter?
We generally use Tkinter to develop standard GUI-based applications with default style and theme applied to all the widgets in it. To change the overall style of the application GUI, we use the ttk package. The Tkinter ttk is a themed widget which is used to style the tkinter widgets. It provides a native GUI look to the widget.
The themed widget has many inbuilt functions and features which are accessible and can be used thoroughly in the application. ttk works in the same way as CSS does for an HTML page. You can use ttk either by importing directly or by instantiating an object of ttk. Once the object is created, you can define all the styling properties that works globally for all the widgets.
# Import the tkinter library from tkinter import * from tkinter import ttk # Create an instance of tkinter frame win = Tk() # Set the size of the Tkinter window win.geometry("700x350") # Create an instance of ttk s = ttk.Style() # Use the window native theme s.theme_use('winnative') # Add a label text label= Label(win, text="Eat-sleep,Code Repeat", font= ('Aerial 16'), background= "green3") label.pack(pady = 30) # Create a ttk styled Button ttk.Button(win, text = "Button-1").pack() win.mainloop()
Running the above code will display a window with a label widget and a button.
- How to create a simple "star rating" look with CSS?
- How to code the tkinter "scrolledtext" module?
- How to bind multiple events with one "bind" in Tkinter?
- A closer look at Java "Hello World" program
- How to use the "defined?" keyword in Ruby?
- How to use the "or" keyword in Ruby?
- How to use the "not" keyword in Ruby?
- What's the difference between "update" and "update_idletasks" in Tkinter?
- Write a program to display "Hello World" in react native?
- Difference between "grid" and "pack" geometry managers in Tkinter
- How to create "next" and "previous" buttons with CSS?
- Difference between "fill" and "expand" options for tkinter pack method
- Create multiple buttons with "different" command function in Tkinter
- What does the "wait_window" method do in Tkinter?