Questions tagged as 'python'

1
answer

Access variable through exec

I was trying to create a shell to be able to communicate with a program in python during its execution, so far I have the following (this code is just an example): import sys, pygame from threading import Thread import math pygame.init() # I...
asked by 12.02.2018 / 13:12
1
answer

Python - Access a function above outside a class

Hello everyone! A question about Python. I have a structure something like this: class Tela(FloatLayout): def exemplo(self): print("teste") class botao(Button): ????? Explaining: It is a screen that has a function and...
asked by 13.02.2018 / 14:50
1
answer

Why is the text label unchanged?

I have the class of a screen, which contains a text label, the code loads an xml containing the objects. tela.py: #!/usr/bin/python3 import gi import modulo_arquivos import os gi.require_version("Gtk", "3.0") from gi.repository import Gt...
asked by 26.02.2018 / 21:00
1
answer

How to retrieve the return of a function that was executed inside a Thread in Python3?

I need to run a function through a Thread only so I'm not sure how to retrieve the return from this function. Here's an example of how I want to do it: from threading import Thread import time def teste_thread(): for k in range(5): prin...
asked by 26.02.2018 / 22:21
4
answers

Comparison between random number and typed number never says you got it right, even the numbers being equal

I'm trying to make a program where I can type a number n and then I would like to generate a random number between 1 and 2. If this random number is the same as n , it would show "You won!" and if not, "You have lost." But even when...
asked by 15.02.2018 / 04:22
1
answer

Is it worth doing exercises that teach not very optimized ways to make a program? [closed]

Well, I'm learning python and sometimes I come across some relatively difficult exercises, for example, an exercise where the program had to read a cash value and say how many 1, 5, 10, 20, 50 , 100 that money could be represented. The proble...
asked by 23.02.2018 / 02:46
2
answers

Python 3 and Tkinter: progress bar does not update during script execution

Hello. I'm creating a layout converter using Python 3.6.4 and Tkinter. Among other things, the GUI should have a progress bar that updates its value with each interaction of the conversion process, for example, every processed line of the fil...
asked by 12.03.2018 / 19:01
1
answer

Problem with PySerial library (PYTHON)

I'm trying to control the arduino by a Python script through the "pyserial" and "serial" library. But every time I run the code it gives an error in the first few lines: import serial ser = serial.Serial('COM7', 9600) error returned: Tra...
asked by 04.03.2018 / 19:48
2
answers

How to display if I was able to ping a machine without displaying the textual pollution of the ping itself?

My code is printing out the ping (that polluted screen), but I wanted to print only the "{ip} ta on" pattern. How do you currently print:    PING 192.168.2.1 (192.168.2.1) 56 (84) bytes of data.   64 bytes from 192.168.2.1: icmp_seq = 1 tt...
asked by 03.03.2018 / 03:13
2
answers

Strings in python [closed]

I know the basic encoding of strings in Python, but I still can not move forward and complete the whole requirement of the statement. I do not know how to code the quantities you require in the question. Follow the sentence: Read keyboar...
asked by 06.03.2018 / 15:11