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
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
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
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.
While and do-while loops are also present in Dart's arsenal. They are quite similar in terms of syntax and functionality to the C's while and do-while loops.While loopA while loop is an indefinite loop that can be modified to run for a finite number of iterations based on the condition we provide.Syntaxwhile(condition){ // do this }ExampleConsider the example shown below − Live Demovoid main() { var age = 6; while(age < 10){ print("age is now $age"); age++; } }Outputage is now 6 age is now 7 age is now 8 age ... Read More
Dart being a statically typed language demands that we declare the type of variable that we going to use. In simpler terms, it is necessary that we define what kind of data we are going to store in the variable before making use of it.ExampleConsider the example shown below − Live Demovoid main(){ int collegeId = 1234; // declaring and assigning a variable print(collegeId); // printing the variable's value String myName = "mukul"; print(myName); }In the above example, we declared two variables named 'collegeId' and 'myName' and assigned 1234 and "mukul" as ... Read More
In Dart, we make use of Typedef when we want to create an alias for a function type that we can use as type annotations for declaring variables and return types of that function type.A typedef holds type information when a function type is assigned to a variable.Syntaxtypedef functionName(parameters)We make use of the above syntax when we want to create a Typedef in Dart.Now, let's take a look at an example when we want to assign a typedef variable to a function in a program.typdef varName = functionNameOnce we have assigned the functionName to a typedef variable, we can later invoke the original ... Read More
This keyword in dart is used to remove the ambiguity that can be caused if the class attributes and the parameters have the same name. This keyword basically represents an implicit object pointing to the current class object.We usually prefix the class attribute with this keyword whenever we want to remove the ambiguity between the class attributes and the parameters.ExampleLet's take two examples of the case where the name of the class attribute and the parameters are the same.Consider the example shown below − Live Demovoid main() { Employee emp = new Employee('001'); emp.empCode = '111'; } class ... Read More
There are certain cases where we want to check if a variable is of a certain data type or not. Dart provides two test type operators that we can make use of.These two test type operators are −is - return true if that variable of the type we are checking againstis! - return true if that variable is not of the type that we are checking against.SyntaxThe syntax of is operator looks something like this −x is intIn the above example, x is the name of the variable and we are checking whether x is of data type int.The syntax ... Read More
The ternary operator is a shorthand version of an if-else condition. There are two types of ternary operator syntax in Dart, one with a null safety check and the other is the same old one we encounter normally.Syntax 1condition ? expressionOne : expressionTwo;The above syntax implies that if a certain condition evaluates to true then we evaluate the expressionOne first and then the expressionTwo.ExampleLet's explore a Dart example where we make use of the above syntax of the ternary operator.Consider the example shown below − Live Demovoid main(){ var ans = 10; ans == 10 ? print("Answer is 10") ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP