Python Articles - Page 328 of 1048

Creating a LabelFrame inside a Tkinter Canvas

Dev Prakash Sharma
Updated on 16-Dec-2021 10:54:10

2K+ Views

Tkinter provides many built-in widgets which can be used to create highlevel desktop applications. The LabelFrame widget is one of them, which allows the users to add a labelled frame. The Label is another widget in the LabelFrame, which is used to add text or images in a frame or any container.There are two main components of the LabelFrame widget, The Title Bar (also known as the text of the LabelFrame widget).The content (the content of the LabelFrame widget. You can add an image, or text as the content inside the LabelFrame widget.)To define a LabelFrame widget, you’ll need to ... Read More

How to get a new API response in a Tkinter textbox?

Dev Prakash Sharma
Updated on 16-Dec-2021 10:52:25

1K+ Views

APIs are extremely useful in implementing a service or feature in an application. APIs help to establish the connection between the server and a client, so whenever a client sends a request using one of the API methods to the server, the server responds with a status code (201 as a successful response) to the client.You can make a request to any API you want using one of the methods (GET, POST, PUT or DELETE). However, if you want to create an application where you need a request to the server using one of the publicly available API (for example, ... Read More

Adding coloured text to selected text in Tkinter

Dev Prakash Sharma
Updated on 16-Dec-2021 10:42:46

1K+ Views

If we want to implement a text editor in an application that can accept multiline user input, then we can use the Tkinter Text widget. The Text widget in Tkinter is generally used to create a text editor for an application, where we can write text and perform operations like selecting, editing and creating a specific text in the application.If you want to highlight a text and provide a color to the highlighted text, then you can use the tag_add("start", "first", "second") method. The tag_add() method takes two arguments for selecting the specified text from the text widget. You can ... Read More

How to set a certain number of rows and columns of a Tkinter grid?

Dev Prakash Sharma
Updated on 16-Dec-2021 10:41:34

4K+ Views

In Tkinter, you can set the GUI of the application by using a different geometry manager. The grid geometry manager is one of the most useful geometry managers in tkinter that is used to set the widgets location in the application using the 2D geometry form.With a grid geometry manager, you can set a certain number of rows and columns and place the widget in any location of the application. To set a certain number of rows and columns, you’ll need to specify the size value of the row and column configuration that helps to set the location of a ... Read More

Python - Ranking Rows of Pandas DataFrame

Prateek Jangid
Updated on 26-Nov-2021 06:03:47

1K+ Views

To add a column that contains the ranking of each row in the provided data frame that will help us to sort a data frame and determine the rank of a particular element, for example −Our DataframeName Play Time (in hours)Rate0Call Of Duty45Better than Average1Total Overdose46Good2GTA352Best3Bully22AverageOutputName Play Time (in hours)Rate ranking0Call Of Duty45Better than Average3.01Total Overdose46Good2.02GTA352Best1.03Bully22Average4.0Now, as you can see in the above example, our rankings are the whole numbers but have a decimal beside it, so that means we can have ranking in real numbers also, and that happens when more and one element have the same rank in ... Read More

How do I install Python SciPy?

Gaurav Kumar
Updated on 14-Dec-2021 11:35:14

671 Views

We can install Python SciPy with the help of following methods −Scientific Python Distributions − There are various scientific Python distributions that provide the language itself along with the most used packages. The advantage of using these distributions is that they require little configuration and work on almost all the setups. Here we will be discussing three most useful distributions −Anaconda − Anaconda, a free Python distribution, works well on MS Windows, Mac OS, and Linux. It provides us over 1500 Python and R packages along with a large collection of libraries. This Python distribution is best suited for beginners.WinPython − It ... Read More

How to trigger headless test execution in Selenium with Python?

Debomita Bhattacharjee
Updated on 19-Nov-2021 10:58:05

935 Views

Selenium supports headless execution. In the Chrome browser, the headless execution can be implemented with the help of the ChromeOptions class. We have to create an object of this class and apply the add_arguments method to it. Finally, pass the parameter --headless to this method.Let us obtain the title - About Careers at Tutorials Point - Tutorialspoint of the page launched in a headless mode −ExampleCode Implementationfrom selenium import webdriver from selenium.webdriver.chrome.options import Options #object of Options class c = Options() #passing headless parameter c.add_argument("--headless") #adding headless parameter to webdriver object driver = webdriver.Chrome(executable_path='../drivers/chromedriver', options=c) # implicit wait time driver.implicitly_wait(5) ... Read More

How to compute the Logarithm of elements of a tensor in PyTorch?

Shahid Akhtar Khan
Updated on 06-Nov-2021 10:08:01

1K+ Views

To compute the logarithm of elements of a tensor in PyTorch, we use the torch.log() method. It returns a new tensor with the natural logarithm values of the elements of the original input tensor. It takes a tensor as the input parameter and outputs a tensor.StepsImport the required library. In all the following Python examples, the required Python library is torch. Make sure you have already installed it.Create a tensor and print it.Compute torch.log(input). It takes input, a tensor, as the input parameter and returns a new tensor with the natural logarithm values of elements of the input.Print the tensor ... Read More

How to get the data type of a tensor in PyTorch?

Shahid Akhtar Khan
Updated on 06-Nov-2021 10:06:20

14K+ Views

A PyTorch tensor is homogenous, i.e., all the elements of a tensor are of the same data type. We can access the data type of a tensor using the ".dtype" attribute of the tensor. It returns the data type of the tensor.StepsImport the required library. In all the following Python examples, the required Python library is torch. Make sure you have already installed it.Create a tensor and print it.Compute T.dtype. Here T is the tensor of which we want to get the data type.Print the data type of the tensor.Example 1The following Python program shows how to get the data ... Read More

How to compute the sine of elements of a tensor in PyTorch?

Shahid Akhtar Khan
Updated on 06-Nov-2021 10:15:17

546 Views

To compute the sine of elements of a tensor, we use the torch.sin() method. It returns a new tensor with the sine values of the elements of the original input tensor. It takes a tensor as the input parameter and outputs a tensor.StepsImport the required library. In all the following Python examples, the required Python library is torch. Make sure you have already installed it.Create a tensor and print it.Compute torch.sin(input). It takes input, a tensor as input parameter, and returns a new tensor with the sine values of elements of the input.Print the tensor with the sine values of ... Read More

Advertisements