Articles on Trending Technologies

Technical articles with clear explanations and examples

Tkinter dropdown Menu with keyboard shortcuts

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-May-2021 1K+ 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
Dev Prakash Sharma
Updated on 25-May-2021 2K+ 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
Dev Prakash Sharma
Updated on 25-May-2021 11K+ 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.

Read More

This keyword in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 24-May-2021 904 Views

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

Ternary Operator in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 24-May-2021 9K+ Views

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

Super keyword in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 24-May-2021 780 Views

Super keyword in dart is used to refer to the parent's class object's methods or variables. In simple terms, it is used to refer to the superclass properties and methods.The most important use of the super keyword is to remove the ambiguity between superclass and subclass that have methods and variables with the same name.The super keyword is able to invoke the parent's objects method and fields, as when we create an instance of the subclass in Dart, an instance of the parent class is also created implicitly.Syntaxsuper.varName or super.methodNameAs we can access both the variables and methods of the parent's ...

Read More

Super constructor in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 24-May-2021 752 Views

The subclass can inherit the superclass methods and variables, but it cannot inherit the superclass constructor. The superclass constructor can only be invoked with the use of the super() constructor.The super() constructor allows a subclass constructor to explicitly call the no arguments and parametrized constructor of superclass.SyntaxSubclassconstructor():super(){ }Though, it is not even necessary to use the super() keyword as the compiler automatically or implicitly does the same for us.When an object of a new class is created by making use of the new keyword, it invokes the subclass constructor which implicitly invokes the parent class's default constructor.Let's make use of an example where ...

Read More

String Interpolation in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 24-May-2021 2K+ Views

There are times when we want to make use of variables inside the statement that is made up of string values.We know that we can add two strings together in Dart with the help of the + symbol operator. But to make use of a variable in between the strings that we are concatenating, we need to add one more + symbol and then type the name of the variable, which works okay when it comes to small statements.ExampleConsider the example shown below − Live Demovoid main(){    String name = "Tutorials";    var collegeName = "DTU";    print("Name is " ...

Read More

Return statement in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 24-May-2021 1K+ Views

There are certain cases where we want to return a value from a given function so that we can use it later. These return values make use of a return keyword which in turn allows a function to return values.It should be noted that the return statement is optional, if not specified the function returns null.Also, only one return statement is allowed in a function.Syntaxreturn ;Syntax of a Dart function with a return value −returnType funcName(){    // statement(s)    return value; }In the above syntax, the funcName is replaced with the name of our function. The returnType represents the type of data/expression ...

Read More

Read and Write Input in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 24-May-2021 2K+ Views

Dart provides us with a standard library named 'io' which contains different classes and in turn, these classes contains different methods that we can use to read or write input from the terminal.We import the library in our program by making use of the import command.ExampleConsider the example shown below −Import 'dart:io';Writing something to the terminalWe can write something to the terminal by making use of the standard out class (stdout) that is available to us in the 'dart:io' library.ExampleConsider the example shown below − Live Demoimport 'dart:io'; void main(List arguments) {    stdout.write('What is your name?\r'); }OutputWhat is your ...

Read More
Showing 31301–31310 of 61,248 articles
Advertisements