Posts by tomasantunes • 1,579 points
123 posts
-
0
votes3
answers227
viewsA: Add a string before a given word using Regex
With regex you can save the occurrence with parentheses and use the OR symbol (the character |) for more than one word. line = re.sub('(a|b|c)', "L1_structure." + r'\1', line.rstrip())…
-
1
votes1
answer535
viewsA: Access functions within classes in kivy + python
With the app prefix you can access the main class methods. prg.Kv <Tela>: Button: on_release: app.teste.chama() Prg.py class Tela(Widget): pass class teste(): def chama(self): print("chama")…
-
0
votes1
answer294
viewsA: Take folder and file path (at the same time) with Electron
In the documentation mentions that it is not possible to select files and directories at the same time. Note: On Windows and Linux an open dialog can not be Both a file selector and a directory…
-
0
votes1
answer45
viewsA: Turn dataframe column into hours, minutes and seconds
You can use the to_timedelta method() df["A"] = pd.to_timedelta(df["A"], unit="S")
pythonanswered tomasantunes 1,579 -
0
votes1
answer43
viewsA: How to rescue specific parts of a txt?
Check whether the line contains the field to add to the list. folha = open("xxxxx.txt") linhas = folha.readlines() list_func = [] for i in range(0, len(linhas)): linha = linhas[i] if "Cod:" in linha…
pythonanswered tomasantunes 1,579 -
1
votes1
answer51
viewsA: Add "loading" animation to the canvas element while generating the image
You can create a div with a previous Loader. function thumbnailList() { var link = document.querySelectorAll(".selecao.video"); var loaders = document.querySelectorAll(".loader"); for (let x = 0; x…
-
0
votes1
answer257
viewsA: Update Fullcalendar on onChange from a select
You would have to remove the events and render again. Example: $('#calendar').fullCalendar('removeEvents'); $('#calendar').fullCalendar('addEventSource', data);…
-
0
votes1
answer303
viewsA: Black background python image
The map has to be converted into a list. images = list(map(Image.open, list_jpg))
-
0
votes1
answer130
viewsA: How to know if a file exists through its url without needing to download it?
Using Webrequest instead of Webclient can check the file size. Example: WebRequest request = WebRequest.Create(new Uri("http://www.example.com/")); request.Method = "HEAD"; using(WebResponse…
c#answered tomasantunes 1,579 -
1
votes1
answer217
viewsA: Help with kivy (error: Attributeerror: 'weakref' Object has no attribute 'cline_in_traceback')
You need to import the Kv file. from kivy.lang import Builder Builder.load_file('test.kv')
-
0
votes2
answers390
viewsA: Open file with 2 clicks in a Python program
In the context menu go to Open With->Python and use a script like this: file = open("text1.txt", "r") print(file.read()) input("Press Enter to quit: ")
-
1
votes1
answer417
viewsA: Change a user’s password in Django, and check that the data provided is correct
To check if the user exists you can use Try: try: user = User.objects.get(username=username) except user.DoesNotExist: messages.success(request, 'Dados errados') return…
-
0
votes1
answer132
viewsA: Tkinter Entry always captures empty string
The code that is in main has to be in the __handler_entry function(). def __handler_entry(self): word = self.get_word() word_meaning = self.dictionary.get_meaning(word) if type(word_meaning) ==…
-
0
votes2
answers245
viewsA: How to remove a character-specific string from a Python string
The method strip() removes blanks. new_poetry = "" for line in poetry[0].splitlines(): new_poetry += line.strip() + " "
-
1
votes1
answer87
viewsA: Code takes time to execute, points error but then displays the result
This algorithm finds the lowest common multiple of the first n natural numbers. #include <stdio.h> #include <stdlib.h> int main( int argc, char** argv ) { int n = 20; int res = 1; int…
-
1
votes1
answer395
viewsA: How to add Datetime.Time in Pandas by group by?
You can convert to datetime and timedelta and then groupby() and sum(). For Plot you need to convert in seconds. import pandas as pd import matplotlib.pyplot as plt data = { 'Total Cpu Time':…
-
-1
votes1
answer394
viewsA: How to consume an authenticated service with Oauth2 on Nodejs?
You can create Clientid and Clientsecret in the control panel. Then you have to redirect the user to a URL to get an Authorization code. More information: Google Cloud - Authenticate Users…
-
1
votes3
answers92
viewsA: Argument error in python 3.7
The print function returns None. The ideal would be to use string formatting. desconto = float(preco * 0.90) print("O valor a vista com desconto é de {:.2f}".format(desconto))…
pythonanswered tomasantunes 1,579 -
0
votes1
answer177
viewsA: How to dynamically change an image in a kivy label
You can create a new Imagelabel class with the image property. file . py: class StackLayout(StackLayout): pass class ImageLabel(Label): image = StringProperty() class StackApp(App): def build(self):…
-
1
votes1
answer1361
viewsA: Error "Valueerror: Length of value does not match length of index"
You can convert the array to pd. Series and the missing values will be filled with null values. dEnd[sChave] = pd.Series([])
-
0
votes1
answer110
viewsA: How to add to each value of a list, a number that depends on another random?
It is possible to cycle and subtract the inserted value in each iteration. from random import randint pat = int(input("Inserir número: ")) lista = [] valor_parcial = pat for i in range(0,21): x =…
-
0
votes1
answer34
viewsA: How to create a function that inserts at the bottom of the list (PYTHON ) using the signature : def inserts Fim(self, item)
def insereFim(self, item): temp = Noh(item) if self.inicio is None: self.inicio = temp return fim = self.inicio while(fim.getProx()): fim = fim.getProx() fim.setProx(temp)…
pythonanswered tomasantunes 1,579 -
0
votes1
answer80
viewsA: Connect microphone to Analyser to get hertz with javascript
Can connect an Analyser and a Scriptprocessor. var display = document.getElementById("display"); navigator.mediaDevices.getUserMedia({audio: true}) .then(function(stream) { var ctx = new…
-
0
votes1
answer349
viewsA: How to change the month of a datetime object in pandas?
It is possible to use the lambda apply method that filters the dates of the month of August and then replace. import pandas as pd df = pd.DataFrame({'year': [2018, 2018, 2018, 2018, 2018, 2018],…
-
0
votes1
answer178
viewsA: The code does not work as expected. (python and kivy)
You have to use the same sign instead of the two dots. import kivy kivy.require("1.9.1") from kivy.app import App from kivy.uix.boxlayout import BoxLayout class MinhaTela(BoxLayout): def…
-
0
votes1
answer316
viewsA: Classes vs Constructor Functions / Factory Functions
In Javascript everything is done from objects. The most common method of creating and instantiating objects is using a function. For example: function Carro (marca, cor) { this.marca = marca;…
javascriptanswered tomasantunes 1,579 -
0
votes1
answer35
viewsA: Cut an image and display the two parts that have been cut
You can get the original size before cutting. int width = ImagemOriginalCopiada.Size.Width; int height = ImagemOriginalCopiada.Size.Height; Lobj_ImagemcortadaEsquerda =…
c#answered tomasantunes 1,579 -
0
votes1
answer62
viewsA: I can’t do the "web scraping" properly from a Python comic strip site
Images are a list, so you can download all: # coding=utf-8 from bs4 import BeautifulSoup import requests import datetime import os os.chdir('./') def get_img(): r =…
-
0
votes1
answer634
viewsA: Buttons with dynamic images with kivy
We can set the width with size_hint and the height is equal. size_hint: 0.1, None height: self.width
-
1
votes2
answers154
viewsA: Flask and its contexts
What are the differences between Flask. g and Flask.current_app? There has been a change in Flask 0.10. Flask. g exists within the application context. The application context is available during…
-
1
votes1
answer364
viewsA: How to filter tweets (status) with tweepy (Cursor)
this code converts the string to a date: from dateutil.parser import parse date = parse(date)
-
0
votes1
answer76
viewsA: do not delete the image on canvas
"Destination-out" mode has the intended effect. draw: function(action) { var event, previous, _i, _len, _ref; this.context.lineJoin = "round"; this.context.lineCap = "round";…
-
3
votes2
answers51
viewsA: How to clone an object in Fabricjs?
There is a method to clone objects. document.querySelector('#clonar-objeto').addEventListener('click', function () { var obj = fabric.util.object.clone(canvas.getActiveObject()); obj.set("top", 0);…
-
1
votes1
answer596
viewsA: How do I turn my results into txt, excel or word file?
To create a file there is a function open(): file = open("file.txt","w") file.write(RegressionBBAS3.summary()) file.close()…
-
1
votes1
answer930
viewsA: For Python, what is the difference between Pip x Conda x anaconda
Pip is a package manager for the Python language. Conda is a package manager for several languages. Anaconda is a set of modules for data science with python.
-
6
votes3
answers502
viewsA: Python - Cycle for as an alternative to the while cycle
soma = 0 i = 20 for i in range(20, 0, -2): soma += -i print('soma =', soma)
-
1
votes1
answer79
viewsA: Javascript array showing duplicate values
no need to repeat the push() <script> function Livro () { this.codigo; this.nome; this.autor; this.editora; this.ano; this.ediçao; this.getCodigo = function () { return this.codigo; }…
-
0
votes1
answer143
viewsA: Numpy Array Error With dtype=numpy.uint8
works if the vectors have the same number of elements M = numpy.array([[1, 2, 3], [1, 2, 3], [1, 2, 3]], dtype=numpy.uint8)
-
0
votes1
answer90
viewsA: Set time (minute:second) on Flot chart
The Flot.time plugin has to be after Flot. <script src="https://cdnjs.cloudflare.com/ajax/libs/flot/0.8.3/jquery.flot.js"></script> <script…
-
-1
votes1
answer42
viewsA: Eletron overlay other screens
mainWindow = new BrowserWindow(); mainWindow.show();
node.jsanswered tomasantunes 1,579 -
1
votes1
answer69
viewsA: Perform 3 tasks with setInterval
You can create an array with queries and increment a counter. var c = 0; setInterval(function () { var queries = ["select * from weather.forecast where woeid = '429100' and u = 'c'", "select * from…
javascriptanswered tomasantunes 1,579 -
-1
votes1
answer48
viewsA: test filter scenario
var array = [ { id: 1, city: "Washington" }, { id: 2, city: "Chicago" }, { id: 3, city: "New York" }]; var city = { id: 1, city: "Washington" }; console.log(districtFilter(city, array));…
-
2
votes1
answer799
viewsA: Replace in list
just put the aux2 variable inside the cycle: def corrigePalavra(str): palavra = [str[-1:], str[-2:], str[-3:], str[-4:]] result = str palavra_modificada = False for w in palavra: if result.count(w)…
pythonanswered tomasantunes 1,579 -
0
votes1
answer254
viewsA: Get dynamically created Checkbox values
can get the form data like this: if request.method == "POST": valor = request.form["id"]
-
1
votes1
answer137
viewsA: Vertical table Flask template
{% for i in range(4) %} <tr> <td align= middle width=150>{{data[i] ["id"]}}</td> <td align= middle width=150>{{data[i]["title"]}}</td> </tr> {% endfor %}…
-
1
votes1
answer200
viewsA: photo with distorted webcam using Html5 + javascript
webcam only supports Landscape so you need to make a Crop <video id="video" width="630" height="472" autoplay></video> <button id="snap">Snap Photo</button> <canvas…
-
0
votes2
answers218
viewsA: for in range no flask template
respis not defined, is data {% for i in range(3) %} <td align= middle width=150>{{data[i] ["id"]}}</td> <td align= middle width=150>{{data[i]["title"]}}</td> {% endfor %}…
-
0
votes1
answer75
viewsA: Information from an API in your web application - Flask Python
You have to pass the dice as argument. return render_template('index.html', data=game()) Another alternative is to use AJAX.
-
0
votes1
answer225
viewsA: Sprites Phaser JS
To change the initial frame you need to change this line in the update function: player.frame = 4;
-
-1
votes2
answers286
viewsA: Debug with Flask/Python
perhaps so: print(object) return