size

Tkinter button size is not accurate

Tkinter button size is not accurate Question: I want to set the size of a button in Tkinter, but it won’t be as big as I want. It should be 100 pixels high and 100 pixels wide, but the button almost takes up the 800×600 window. enter image description here I am using this code …

Total answers: 1

How can i resize image in moviepy so that it perfectly fits in 1980×1080?

How can i resize image in moviepy so that it perfectly fits in 1980×1080? Question: So I’m trying to resize an image and maintain its ratio so that it perfectly fits in 1980×1080 in the moviepy library. Currently, I’m doing this with a function like this: def FitClip(size): #size is basicly clip.size clipRes = size …

Total answers: 1

problem with np.random.multinomial and size option in python

problem with np.random.multinomial and size option in python Question: My problem is the following: I have N people choosing between three objects [1,2,3] with probabilities [p_1,p_2,p_3] such that p_1+p_2+p_3=1. Let’s call X_1,X_2,X_3 the counts of the chosen objects in one sample among the N people (then, for example, X_1 is the number of people choosing …

Total answers: 1

Maximum and minimum value of C types integers from Python

Maximum and minimum value of C types integers from Python Question: I’m looking for a way to get (using Python) the maximum and minimum values of C types integers (ie uint8, int8, uint16, int16, uint32, int32, uint64, int64…) from Python. I was expecting to find this in ctypes module In [1]: import ctypes In [2]: …

Total answers: 1

Why is a False value (0) smaller in bytes than True (1)?

Why is a False value (0) smaller in bytes than True (1)? Question: I was playing around with sys‘s getsizeof() and found that False (or 0) consists of less bytes than True (or 1). Why is that? import sys print(“Zero: ” + str(sys.getsizeof(0))) print(“One: ” + str(sys.getsizeof(1))) print(“False: ” + str(sys.getsizeof(False))) print(“True: ” + str(sys.getsizeof(True))) …

Total answers: 1

Python: how to get size of all objects in current namespace?

Python: how to get size of all objects in current namespace? Question: I have some code that I am running from my own package and the program is using a lot more memory (60GB) than it should be. How can I print the size of all objects (in bytes) in the current namespace in order …

Total answers: 3

How to create a DataFrame of random integers with Pandas?

How to create a DataFrame of random integers with Pandas? Question: I know that if I use randn, the following code gives me what I am looking for, but with elements from a normal distribution. But what if I just wanted random integers? import pandas as pd import numpy as np df = pd.DataFrame(np.random.randn(100, 4), …

Total answers: 3

How to get matplotlib figure size

How to get matplotlib figure size Question: For a project, I need to know the current size (in pixels) of my matplotlib figure, but I can’t find how to do this. Does anyone know how to do this ? Asked By: Tristan || Source Answers: import matplotlib.plt fig = plt.figure() size = fig.get_size_inches()*fig.dpi # size …

Total answers: 3

Python Tkinter: Attempt to get widget size

Python Tkinter: Attempt to get widget size Question: I am trying to find the size of my window by using the winfo_geometry() function but it ends up returning 1×1+0+0 I have also tried winfo_height, winfo_width but i keep getting 1 CODE from tkinter import * root=Tk() root.geometry(‘400×600’) print (root.winfo_width()) print (root.winfo_height()) print (root.winfo_geometry()) root.mainloop() Asked …

Total answers: 2

Image size (Python, OpenCV)

Image size (Python, OpenCV) Question: I would like to get the Image size in python,as I do it with c++. int w = src->width; printf(“%d”, ‘w’); Asked By: Andrea Diaz || Source Answers: Use the function GetSize from the module cv with your image as parameter. It returns width, height as a tuple with 2 …

Total answers: 8