Questions tagged as 'python'

1
answer

How to add methods to a QuerySet?

I have a model defined in Django. I would like to add to this model a method that returns me part of a mounted query (a QuerySet ). That is, a method I want to define a method that affects the results of the query when calling Model.objects...
asked by 09.02.2018 / 13:15
1
answer

How to load only one line and modify it

I want to modify only one line of a file, something like this with open('arquivo.txt', 'r+') as f: for line in f.readlines(): if line == algumacoisa: line.write('textoaqui'); break f.close() I sa...
asked by 10.02.2018 / 18:28
1
answer

PYTHON - How do I know if there is an object on the screen from a reference?

Basically I was wondering if there is a possibility of knowing if there is an object on the screen from a reference Example: There is a generic program on the screen that displays a closed padlock, and when you do an action the padlock is dis...
asked by 08.02.2018 / 19:26
1
answer

Request Get in Python terminates the program when there is no connection

I'm developing a Python application to check the external IP and save to a database, the problem is the following function: def pega_ip(): ip = get('https://api.ipify.org').text return ip Because it uses the get method to receive con...
asked by 31.01.2018 / 15:05
1
answer

Importing classes in Python 3

I have three .py files in my directory: Banco.py , app.py , Usuarios.py . My app.py contains the Tkinder import I am using in the code and here I start all my view and import the Usuarios.py class as follows:...
asked by 02.02.2018 / 02:07
1
answer

Add column to a dataframe based on sorting done in another dataframe

Greetings! I have two dataframes. Both have columns that determine ranges, with maximum and minimum numbers. In each dataframe the ranking of each range is done one way. I wanted to make a new column in the second dataframe with the rating accor...
asked by 31.01.2018 / 01:52
1
answer

Error installing psycopg2 in a virtualenv environment with pypy

I installed the pypy of the following form: wget https://bitbucket.org/pypy/pypy/downloads/pypy3-v5.10.1-linux64.tar.bz2 tar xf pypy3-v5.10.1-linux64.tar.bz2 virtualenv -p ~/pypy3-v5.10.1-linux64/bin/pypy my-pypy-env...
asked by 21.02.2018 / 14:54
1
answer

Change colors in program using tkinter

Hello, I need to create a function or maybe two to change the background color of the main window without interfering with subsequent events. I wanted to add in the menu> Environment: Light color pattern; Night: dark color, and I want to bind...
asked by 19.01.2018 / 19:57
1
answer

What signal to use to trigger methods from a thread in pyGtk?

I have a Tree View that I need popular with data obtained in a thread, but if I do it apart from it the program has several random problems and errors. Searching I found that the ideal is to trigger a signal from within the thread to be called a...
asked by 10.01.2018 / 22:40
1
answer

Shortcut by the initial letter OptionMenu in TKinter in Python

I have an OptionMenu in TKinter in Python which is a big list, when I press the letter G for example it does not direct me to the elements with the letter G and also does not allow the use of pageUp and pageDown. Is there a way to make it work l...
asked by 09.01.2018 / 21:26