Found 310 Articles for GUI-Programming

How to compile a Python 3 app to an .exe using Tkinter?

Dev Prakash Sharma
Updated on 25-May-2021 08:50:13

3K+ Views

Python is well-known for its rich library of extensions and packages. We can import and install the necessary packages from the library. However, if we require to run a Tkinter application with an executable file in Windows Operating System, then we can use the Pyinstaller package in Python. It converts a Python-based application to a native executable file (or.exe).Follow the steps to compile a Tkinter-based application into an executable file, Install Pyinstaller using 'pip install pyinstaller'.Open the Command or Shell in the same directory where the application file is located and run the file using the command, pyinstaller --onefile app.py. It ... Read More

Tkinter dropdown Menu with keyboard shortcuts

Dev Prakash Sharma
Updated on 25-May-2021 08:49:46

858 Views

A Dropdown Menu is nothing but a list of vertically stacked menu items that can be visible at the top Menu Bar of an application. We can create a Menu bar in a Tkinter application by creating an object of Menu() in which all the Menu items are present.There might be a case when we want to select the menu and perform some basic operations using Keyboard shortcuts. In order to bind the key to all the Menu, we use the bind_all(, callback) method.ExampleIn this example, the application window contains a Menu of items. When we press the combination of , it ... Read More

How to bind events to Tkinter Canvas items?

Dev Prakash Sharma
Updated on 25-May-2021 08:49:19

1K+ Views

Tkinter events can be bound with the widgets to perform a set of operations on the widgets. To be more specific, we can also bind an event handler to Canvas Items by using bind(, callback) method. Binding the event with the canvas item makes a canvas item dynamic which can be customized by event handlers.Example#Import the required Libraries from tkinter import * import random #Create an instance of Tkinter frame win = Tk() #Set the geometry of the window win.geometry("700x350") #Crate a canvas canvas=Canvas(win, width=700, height=350, bg='white') def draw_shapes(e):    canvas.delete(ALL) canvas.create_oval(random.randint(5, 300), random.randint(1, 300), 25, 25, ... Read More

How to specify where a Tkinter window should open?

Dev Prakash Sharma
Updated on 25-May-2021 08:47:17

6K+ Views

Tkinter window can be configured using the Geometry Manager. When we specify the main window using the geometry(width x height + position_right + position_left) method, then we generally enable the window to open in a particular position.Example#Import the required libraries from tkinter import * #Create an instance of Tkinter Frame win = Tk() #Set the geometry win.geometry("700x350+300+300") #Create a Label Label(win, text="This Window Opens at (300,300)", font=('Helvetica 15 bold')).pack(pady=30) win.mainloop()OutputRunning the above code will display a window at the specified position with a label text.

Word Dictionary using Python Tkinter

Dev Prakash Sharma
Updated on 06-Mar-2021 09:14:21

2K+ Views

In this article, we will create a GUI-based dictionary using PyDictionary and Tkinter Module.PyDictionary is a Python Module that helps to get meaning translations, antonyms and synonyms of words. It uses WordNet for getting meanings, Google for translations, and synonym.com for getting synonyms and antonyms. PyDictionary uses BeautifulSoup, Requests module as the dependencies.In order to create the application, we will first install these modules in our environment using pip install PyDictionaryAfter installing, we will create a tkinter frame and some other element.Example# Import Required Librares from tkinter import * from PyDictionary import PyDictionary # Create instances and objests dictionary ... Read More

Window Resizer Control Panel in Tkinter

Dev Prakash Sharma
Updated on 06-Mar-2021 09:08:53

251 Views

In this article, we will create a GUI-based window resizer control panel that will have a pane to resize the window by its height or width.In order to create the application, we will first create a slider that will help to resize the window size. The sliders are available in the ttk library of tkinter. We will import “ttk” first. Then, we will launch a new window which needs to be resized.Let us first import all the required libraries in the notebook and design the control bars using sliders.Example# Import the required Libraries from tkinter import * from tkinter import ... Read More

What does the 'tearoff' attribute do in a Tkinter Menu?

Dev Prakash Sharma
Updated on 06-Mar-2021 09:04:56

639 Views

Using Tkinter.Menu, we can create menus and submenus. Also, there are some other properties which are used with tkinter menus.Tearoff property makes the menus in the window as tearable. tearoff attribute accepts a Boolean value to separate the menu from the main window or the parent window. With tearoff attribute, we have two options, If tearoff=0, make the menu stick to the Window.If tearoff=1, it display a “----” empty dotted lines on the menus through which we can separate our menu from the window.Example#Importing the tkinter library from tkinter import * win= Tk() win.title("Tearoff Example") win.geometry("600x500") #Define a Function ... Read More

Tkinter bell() method

Dev Prakash Sharma
Updated on 06-Mar-2021 09:02:27

394 Views

Tkinter bell() method produces the default event or dialogue sound of the system. This method can be invoked in the default window or frame. We can change the sound of the window by going to the system configuration.In this example, we will create a button that will make the default sound.Example#Import the library from tkinter import * #Create an instance of tkinter frame win= Tk() #Define the size of the window win.geometry("700x150") win.resizable(0, 0) #Define the Bell function def click():    win.bell() Button(win, text= "Click Me", command= click).pack(pady=20) win.mainloop()OutputRunning the above code will create ... Read More

Ratio Calculator GUI using Tkinter

Dev Prakash Sharma
Updated on 06-Mar-2021 09:01:23

329 Views

In this article, we will see how to create a functional application that calculates the ratio. In order to make it fully functional, we will use SpinBox method that generally creates an ideal spinner for a value. This value can be modified using the spinner widget in the frame. Thus, a SpinBox object takes values in the range from minimum to maximum.First, we will create a tkinter frame inside which we will define some widgets.Examplefrom tkinter import * win = Tk() win.title("Ratio Calculator") win.geometry("600x500") win.resizable(0, 0) #Create text Label for Ratio Calculator label= Label(win, text="Ratio Calculator", font=('Times New ... Read More

Python program to find the sum of sine series

Dev Prakash Sharma
Updated on 06-Mar-2021 08:59:33

2K+ Views

Let us consider that we have a value x and we have to calculate the sum of sine(x) series. In a sine(x) series, there are multiple terms such that, sine(x) = x− x^3/fact(3) + x^5/fact(5) −x^7/fact(7)....In order to solve the particular series-based problem, we will first take the degree as the input and convert it into radian. To find out the sum of the total number of terms in this series, we will first iterate over all the given terms and find out the sum by operations.Approach to solve this ProblemTake input of Limit and degree.Iterate over the terms and ... Read More

Advertisements