Equivalent of Qt.setGeometry () in tkinter

What is the equal function of PyQt setGeometry() in tkinter? Or Is there any function works like that? I searched a bit but couldn't find, all of examples looks like tkinter works on a specific widget and we just can set width-height. EDIT: The setGe

Understand the 'self' classes

This question already has an answer here: What is the purpose of self? 17 answers In the following example employee is not used in the __init__ function, but we used it in the add_employee function calling self.employee.append(). Why is that? Why did

How to print non-ascii characters like \ uXXXX

# what I currently have print('你好') # 你好 # this is what I want print('你好') # \uXXXX \uXXXX How do I do this? I want to print all non-ascii characters in strings as unicode escape literalsYou can convert strings to a debug representation with non-ASCI

Iterate through a string with different characters

I just signed up here because I am taking an online course in Python and have been using this site to help me through the course. I am; however, stuck. I am not posting my actual homework assignment, but rather just an element of my code I am having

Python - manage big data

I'm working on an application using Python (3.4) and PyQt. The goal of the program is to manage and analyze large amount of data - up to ~50 binary files, which might be of total size up to 2-3 GB. When I tried to load a couple files into the program

PyGame: Can not open file

I'm trying some basic examples from the Making Games with Python & Pygame book, but I'm facing a weird problem. Here is the example source: import pygame, time soundObj = pygame.mixer.Sound('beep.wav') soundObj.play() time.sleep(1) # wait and let the

\ ufeff Invalid character in identifier

I have the following code : import urllib.request try: url = "https://www.google.com/search?q=test" headers = {} usag = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:25.0) Gecko/20100101 Firefox/25.0' headers['User-Agent'] = usag.encode('utf-

Custom exit prompt dialog box in PyQt

I'm trying to create custom exit prompt dialog, which should do the following: It has Yes, No buttons along with "Save new settings" checkbox item When I click Yes, the dialog should shutdown the main program When I click No, the dialog should c

print binary tree level by level in python

I want to print my binary tree in the following manner: 10 6 12 5 7 11 13 I have written code for insertion of nodes but can't able to write for printing the tree. so please help on this . My code is : class Node: def __init__(self,data): self.data=d

How to analyze this streaming Json Python3.4

How to parse this API JSON streaming from PHP server with Python3.4? import requests import json url = 'http://api.example.com' parameters = {'code':1, 'user': 'default', 'password': 'default'} headers = {'content-type': 'application/json'} response

How do you structure a recursive function?

I'm trying to create a recursive function that checks if a grade can be converted to a float, then checks to make sure the grade is between 0 and 100. My logic as to why this would work is: Checks to see if the grade can be converted to a float. If i

Create a zip file object from bytestring to Python?

I have a bytestring. It's guaranteed that it's a representation of a zip file in bytes. How can I create a zip file object in Python, knowing this bytestring?Use io.BytesIO to construct a file-like object, and then pass that object to the ZipFile con

Python map exception Continue execution

The following example is very simple. I want to execute map() with a function which can raise Exception. It will be more clearly with an example : number_list = range(-2,8) def one_divide_by(n): return 1/n try: for number, divide in zip(number_list,

Show Pandas grouped results for defined groups only

I have a pandas dataframe of the following basic format: tempDF = pd.DataFrame({ 'id': [12,12,12,12,45,45,45,51,51,51,51,51,51,76,76,76,91,91,91,91], 'measure': [3.2,4.2,6.8,5.6,3.1,4.8,8.8,3.0,1.9,2.1,2.4,3.5,4.2,5.2,4.3,3.6,5.2,7.1,6.5,7.3], 'statu

to write a variable to a text file and encrypt it?

i know how to save a users input to a text file but how do i encrypt it? here is what i have for saving a users input to text file. i tried f.encrypt("Passwords_log.txt" but had no results import time password1 = input("Please type a passwo

Python list: remove brackets []

I'm trying to take away the brackets when creating a list. Here's my code: nums = [ 1,2 3,4,5] print (nums) output: [1,2,3,4,5] I want the single row and I want commas ... I can't figure out the rest. >>> lst = [1,2,3,4] >>> print(*lst,

Return two values ​​with arguments in the function

### The formulas for the area and perimeter. def area(a, b, c): # calculate the sides s = (a + b + c) / 2 # calculate the area areaValue = (s*(s-a)*(s-b)*(s-c)) ** 0.5 # returning the output # Calculate the perimeter perimValue = a + b + c # returnin

Understand Python logic

Using Python 3.4, wondering how does this loop processing? while SyntaxError: print ("Hi") It's an infinite loop, how does this while loop running? It's an exception but..?Boolean value of SyntaxError is True. >>> bool(SyntaxError) True