Create a Child Window and Communicate with Parents in Tkinter

Dev Prakash Sharma
Updated on 22-Apr-2021 07:13:17

3K+ Views

Unlike other Python libraries, Tkinter has many features that are used to create a full-fledged application. It supports multiple window operations and threading for processing the operation on Windows.Following the thread, we will create an application that will pull the data from root window and put it into a child window. The concept of child window can be referred to as Dialog Boxes which present some information to the user during the happening of an event. The child window in Tkinter is created very easily by using Toplevel(root) constructor.ExampleIn this example, we will create an entry widget along with a ... Read More

Create Borderless Fullscreen Application Using Python 3 Tkinter

Dev Prakash Sharma
Updated on 22-Apr-2021 07:12:56

3K+ Views

In order to make a Tkinter window borderless and full-screen, we can use the utility method attributes(‘-fullscreen’, True). Tkinter windows can be configured using functions and methods defined in the Tkinter library.Another similar method Tkinter provides to make the application window full-screen is, overrideredirect(True). This method can be invoked only if the application needs to resize in its defined width and height only.Example#Import the required Libraries from tkinter import * #Create an instance of Tkinter frame win= Tk() #Set the Geometry win.geometry("750x250") #Full Screen Window win.attributes('-fullscreen', True) def quit_win():    win.destroy() #Create a Quit Button button=Button(win, text="Quit", font=('Comic Sans', 13, ... Read More

Create a Dropdown Menu from a List in Tkinter

Dev Prakash Sharma
Updated on 22-Apr-2021 06:09:57

15K+ Views

Let us suppose we want to create a dropdown menu of a list in an application using tkinter. In this case, we can use the Tkinter OptionMenu(win, menu_to_set, options) function.First, we will instantiate an object of StringVar(), then we will set the initial value of the dropdown menu. We will create the dropdown menu by creating an object of OptionMenu and passing the value of window, menu object, and options which are to be displayed.Example#Import the required libraries from tkinter import * #Create an instance of tkinter frame win= Tk() #Define the size of window or frame win.geometry("715x250") ... Read More

Removing Comments from Array of Strings in JavaScript

AmitDiwan
Updated on 21-Apr-2021 13:17:35

345 Views

ProblemWe are required to write a JavaScript function that takes in array of strings, arr, as the first argument and an array of special characters, starters, as the second argument.The starter array contains characters that can start a comment. Our function should iterate through the array arr and remove all the comments contained in the strings.For example, if the input to the function is:const arr = [    'red, green !blue',    'jasmine, #pink, cyan' ]; const starters = ['!', '#'];Then the output should be −const output= [    'red, green',    'jasmine, ' ];ExampleFollowing is the code − Live Democonst ... Read More

Finding All Peaks and Their Positions in an Array in JavaScript

AmitDiwan
Updated on 21-Apr-2021 13:13:06

592 Views

Build UpSuppose we have the following array in JavaScript −const arr = [4, 3, 4, 7, 5, 2, 3, 4, 3, 2, 3, 4];If we plot the points of this array on y-axis with each adjacent point being unit distance away on x-axis, the graph will look like this −This graph clearly shows that there exist two local maxima (peaks) in this array at index 3 and 7 with values 7 and 4 respectively.ProblemWe are required to write a JavaScript function that takes in an array of integers, arr, as the first and the only argument.Our function is supposed to ... Read More

Find Just Bigger Number Formed by Same Digits in JavaScript

AmitDiwan
Updated on 21-Apr-2021 12:58:39

85 Views

ProblemWe are required to write a JavaScript function that takes in a number, num, as the first and the only argument.Our function should find and return a number such that it contains only and all the digits of the input number and is just bigger than the input numberIf there exists no such number, our function should return -1.For example, if the input to the function is −const num = 5656;Then the output should be −const output = 5665;Output ExplanationBecause 5665 contains only and all digits of 5656 and is just greater than 5656.ExampleFollowing is the code &mius; Live Democonst num ... Read More

Creating a Chained Operation Class in JavaScript

AmitDiwan
Updated on 21-Apr-2021 12:47:52

122 Views

ProblemWe are supposed to create a user defined data type Streak in JavaScript that can be chained to any extent with value and operations alternativelyThe value can be one of the following strings −→ one, two three, four, five, six, seven, eight, nineThe operation can be one of the following strings −→ plus, minusFor example, if we implement the following in context of our class −Streak.one.plus.five.minus.three;Then the output should be −const output = 3;Output ExplanationBecause the operations that took place are −1 + 5 - 3 = 3ExampleFollowing is the code − Live Democonst Streak = function() {    let value = 0; ... Read More

Finding Minimum Time Difference in an Array in JavaScript

AmitDiwan
Updated on 21-Apr-2021 12:41:47

420 Views

ProblemWe are required to write a JavaScript function that takes in an array of 24-hour clock time points in "Hour:Minutes" format. Our function should find the minimum minutes difference between any two time points in the array.For example, if the input to the function is −const arr = ["23:59", "00:00"];Then the output should be −const output = 1;Because the minimum difference between the times is 1 minuteExampleFollowing is the code − Live Democonst arr = ["23:59", "00:00"]; const findMinDifference = (arr = []) => {    const find = (str = '') => str.split(':').map(time => parseInt(time, 10))    const mapped = ... Read More

Reversing and Preserving Spaces in JavaScript

AmitDiwan
Updated on 21-Apr-2021 12:37:24

346 Views

ProblemWe are required to write a JavaScript function that takes in a sentence string, str, as the first and the only argument.Our function is supposed to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.For example, if the input to the function is −const str = 'this is some sample string';Then the output should be −const output = 'siht si emos elpmas gnirts';ExampleFollowing is the code − Live Democonst str = 'this is some sample string'; const reverseWords = (str = '') => {    return str.trim()       .split(/\s+/) ... Read More

Find and Return the Longest Length of Set in JavaScript

AmitDiwan
Updated on 21-Apr-2021 12:32:33

236 Views

ProblemWe are required to write a JavaScript function that takes in an array of numbers, arr, as the first and the only argument.The array, arr, of length N contains all integers from 0 to N-1. Our function is supposed to find and return the longest length of set S, where S[i] = {A[i], A[A[i]], A[A[A[i]]], ... } subjected to the rule below.Suppose the first element in S starts with the selection of element A[i] of index = i, the next element in S should be A[A[i]], and then A[A[A[i]]]… By that analogy, we stop adding right before a duplicate element ... Read More

Advertisements