Posts by tomasantunes • 1,579 points
123 posts
-
0
votes1
answer41
viewsA: Use modified value within IF in another variable
In python we use Elif to add conditions. With three options it would look like this: if acao == 0: ... ... elif acao == 1: ... ... elif acao == 2: ... ...…
-
0
votes1
answer34
viewsA: SDL is always generating transparent screen. c++
To draw in the window we have to use Sdl_renderer. Sdl_renderclear fills the background. #include <SDL.h> int main(int argc, char* argv[]) { SDL_Window* window; SDL_Surface* screenSurface;…
-
0
votes1
answer27
viewsA: Format <td> table with CSS
We can remove the margin and align the text on the left. Also pay attention to colspan. table { margin-top: 60px; text-align: left; }
-
0
votes1
answer77
viewsA: Update label automatically with Tkinter
We can call a function in each key pressed to make the calculation. from tkinter import * root = Tk() root.geometry("200x300") valor1_content = DoubleVar() resultado_content = DoubleVar() resultado…
-
1
votes1
answer25
viewsA: Error Serpent Game in Javascript
Missing a key in the fruit if statement. if (frutax == cabecax && frutay == cabecay) {
javascriptanswered tomasantunes 1,579 -
0
votes1
answer32
viewsA: how to solve matrix vector code problems?
We can create the struct and call the encryption() function. To invert a string we have the _strrev method(). #include<stdio.h> #include<stdlib.h> #include<conio.h>…
c++answered tomasantunes 1,579 -
1
votes1
answer125
viewsA: Why in Opengl do we need to transform all objects to render them?
In clip space the coordinates have to be between -1 and 1 but we set a range type 0 to 100 and Opengl automatically converts to clip space. Z-Buffer is generated in window space. Object space is the…
openglanswered tomasantunes 1,579 -
0
votes2
answers137
viewsA: A proposed infinity loop PYTHON exercise
We can create a function with the calculation parameters and create a condition to exit the program at the end. def media(num1, num2, num3, med): if med in 'Aa': med_arit=((num1 + num2 + num3) / 3)…
-
0
votes1
answer35
viewsA: Store values obtained by calculating the distance of points in a matrix
the np.Matrix() method allows creating the matrix, then we can filter by condition within the defined limit. m = [] for i in range(0,n): m.append([]) for j in range(0,n): dist =…
pythonanswered tomasantunes 1,579 -
1
votes1
answer31
viewsA: Slick carousel
Slick has a method for filtering slides by class. function updateSlides() { if($(document).width() < 480) { $('.carousel').slick('slickFilter',':not(.divbranca)'); } if($(document).width() >…
-
0
votes1
answer95
viewsA: Function that copies chained list in another chained list (excluding repeated elements) does not work
You need to use a while cycle, do a search to see if it is repeated and insert into the new list. /* Copia uma lista passada como parametro para outra lista (excluindo os repetidos) */ bool…
-
0
votes1
answer27
viewsA: How do you make a login button that opens a new window?
Button command missing on line 27. bt = Button(jnl, text="Confirmar", command=janela_do_hub)
pythonanswered tomasantunes 1,579 -
0
votes1
answer53
viewsA: Pick up value of a $.get()
$.get() does not return the value of the callback function and the operation is asynchronous. Maybe it is a key inside the object. $.get("./core/consulta-unidades.php", function(data){…
-
0
votes1
answer29
viewsA: How to plot graphics and images . png in the same window with openGL and SDL
When Opengl is activated we have to move the image to a texture. Then we need to call the Sdl_gl_swapbuffers() function to update the screen. #include </usr/include/SDL/SDL.h> //compilar com…
-
-1
votes2
answers74
viewsA: When to use new and delete in c++?
With the operator new we can initialize the value or allocate memory in Runtime. int *a = new int(25); int *b = new int[10]; The variable stays in memory until do delete. delete a; delete[] b;…
-
0
votes1
answer30
viewsA: Dataframe input
The input() function allows entering data. Creating a CSV file is possible to read with Pandas. import csv from datetime import datetime ano = int(input("Ano: ")) mes = int(input("Mês: ")) dia =…
-
0
votes1
answer48
viewsA: Can someone help me with the slide show?
You need to create two buttons to change slide and with javascript you can show and hide the slides. <ul class="slider"> <li class="slide"> <input type="radio" id="slide1"…
-
1
votes1
answer59
viewsA: Fill graph line in Python and change axis numbers to strings
We have to define the ytick Labels and add the 3D shape polygons to fill. labels = [item.get_text() for item in ax.get_yticklabels()] labels[1] = 'Label1' labels[2] = 'Label2' labels[3] = 'Label3'…
-
1
votes1
answer105
viewsA: Adjusting axis values on a Python chart
It is necessary to define the limits of the axes. plt.xlim([0, 1.3]) plt.ylim([-0.8, 1.2])
-
3
votes2
answers77
viewsA: When to use constexpr in C++?
The functions constexpr allow to return only one constant and run to build time. When we declare a variable const the function is evaluated directly for the same type and improves readability.…
-
0
votes1
answer56
viewsA: Printing a permanent array in html
To save the data would need a database. There is also the client-side localStorage that persists even after reloading. localStorage only lets you write strings so you need to convert the array to…
-
-2
votes1
answer24
viewsA: Perform the next step without going through a previous one
def caractere(resposta): # false if resposta == 'N': return 'Encerrando programa...' # true elif resposta == 'S': return 'Ok, vamos continuar...' #…
pythonanswered tomasantunes 1,579 -
0
votes1
answer21
viewsA: sync slide of scrollbars of different sizes
With the scrollHeight attribute we can get the scroll percentage and use this value to set the position in the other div. $("#div1").scroll(function () { var scrollPercentage = Math.round(100 *…
-
0
votes1
answer16
viewsA: Pyside2 // How to change frame without hiding buttons?
In the list of frames put the buttons instead of the frames. self.meus_frames = (self.frm_cadastrar,self.frm_pesquisar, self.frm_relatorio, self.frm_editar)…
-
-1
votes2
answers191
viewsA: What are the main differences between prototype-oriented programming and class-oriented programming?
Prototypical heritage is a fairly simple model of code reuse, code can be reused directly and helps us reduce redundancy. Disadvantages are the lack of private and protected variables and unsafe…
-
1
votes1
answer182
viewsA: How to download ALL files from a folder with requests?
In an HTTP folder we only receive HTML with the list of files. We have to use Beautifulsoup to get the links. from bs4 import BeautifulSoup import requests from pathlib import Path url =…
pythonanswered tomasantunes 1,579 -
2
votes1
answer60
viewsA: How to login with SELECT in a table? Login system Pyside2 sqlite3
When using the fetchall() method we receive a list of results. Just check whether it is empty or not. if len(ver) > 0: return 'Operador conectado'
-
2
votes1
answer45
viewsA: How to detect functions in the browser
Beautifulsoup does not allow you to read javascript. If you can extract text from the script you are looking for, you would have to use regex to get the desired value. To read javascript code there…
-
-2
votes1
answer91
viewsA: Javascript - Given an array cedulas = [200, 100, 50, 20, 10, 2]
const newArrCedulas = cedulas.map(function(cedula) { cedulas = Math.floor(amount / cedula) if ((amount == 6 || amount == 8) && cedula == 5) { return 0; } amount -=…
javascriptanswered tomasantunes 1,579 -
1
votes1
answer55
viewsA: How to add a header to a captured image with html2canvas?
We can add the header before converting and place the encoded image in Base64. function gerarImagem() { var telaPrint = document.getElementById('telaPrint'); var header =…
-
0
votes1
answer862
viewsA: Open modal via a HREF with parameters
Data-toggle attribute missing from link. <a href='#edit-escolaridade?nome=".$cont['nome']."' data-toggle="modal" title='Editar'>
-
0
votes2
answers207
viewsA: Use of multiple keys in Tkinter
You can create a set with all the keys pressed. from tkinter import Tk, Canvas, Frame Tela_principal = Tk() Tela_principal.geometry('1024x720+10+10') keys = set() def keyPressHandler(event):…
-
0
votes1
answer526
viewsA: Make image appear stay a while and then disappear - JS
The drawImage() method must be inside the draw() function and just set a flag for the image to be visible. function draw() { // ... if (mouseVisible == true) { var img3 = new Image(); img3.src =…
-
0
votes1
answer90
viewsA: Indexerror: list index out of range with csv data?
The loadtxt() method also requires the delimiter. lat, lon, temp = np.loadtxt('teste.csv', delimiter=',', usecols=(0,1,2), unpack=True, skiprows=1)
pythonanswered tomasantunes 1,579 -
0
votes1
answer126
viewsA: kivy recycleview with line with multiple items
Here is an example table with 4 columns. from kivy.app import App from kivy.lang import Builder from kivy.uix.recycleview import RecycleView from kivy.uix.boxlayout import BoxLayout items = [ {'1':…
-
0
votes1
answer61
viewsA: 3d graph with dimension error
Arrays of x, y and z must have the same. import matplotlib.pyplot as plt import numpy as np from mpl_toolkits import mplot3d xx = np.arange(-5,5,0.25) xx,yy = np.meshgrid(xx,xx) zz =…
-
0
votes1
answer18
viewsA: How to "rebuild" a file from the buffer stored in the database?
Fs module lets you save files from a Buffer. fs.writeFile(filename, Buffer.from(data));
-
0
votes1
answer81
viewsA: How do I make a circle jump up and down when I press into space?
GLUT has glutKeyboardFunc() function to detect keyboard events. #include <math.h> #include <GL/glut.h> #ifndef M_PI #define M_PI 3.1415926 #endif #define CIRCLE_STEPS 50 float jump_y =…
-
1
votes1
answer395
viewsA: PYTHON DELIMITER
The read_csv() method supports a parameter with the delimiter. df_bonus = pd.read_csv('bonus.txt', delimiter=';')
-
1
votes2
answers179
viewsA: Javascript function for color exchange
Check the cycle startup. for (var i2 = 0; i2 < tds2.length; i2++)
-
0
votes1
answer73
viewsA: How to add lines from one matrix into another?
The numpy module has a method for concatenating matrices. np.concatenate((new_output, new_output_test), axis=0)
-
0
votes2
answers91
viewsA: how can I take a value of a variable in javascript and 'concatenate' in a <p> text in html?
You can set the textContent property of the span element. var valor = document.getElementById("valor"); valor.textContent = jogadorScore;
-
2
votes2
answers74
viewsA: How do I know if a Shader is working?
Coordinates are too high. After testing a triangle of the defined color appears. shader = ps.from_string(v,f) shader.use() @t.event def on_draw(): glClearColor(0.5,0.5,0.5,1)…
-
1
votes1
answer390
viewsA: Take information from the API and display in the HTML element
The jquery text() method allows you to fill in the values. $("#data").text(json["cidade"]["previsao"][0]["dia"]); $("#tempo").text(json["cidade"]["previsao"][0]["tempo"]);…
-
0
votes1
answer83
viewsA: Update data from two worksheets without overwriting in the source file
Excelwriter supports append mode: with pd.ExcelWriter("meus_dados.xlsx", mode='a') as writer:
-
0
votes1
answer37
viewsA: How do I identify if the scale of the div being animated increased using javascript
The condition has to be called in a loop to check the Transform value. setInterval(function() { var pegar = document.getElementById("dv"); var transform = window.getComputedStyle(pegar).transform;…
-
1
votes1
answer59
viewsA: Create address bar from a string
With the split method you can split the string and then create the buttons dynamically. <div class="address_bar"> </div> <script…
-
1
votes1
answer96
viewsA: What is the logic for discovering all possible numbers that add up to the requested number?
These are numerical partitions. One possible solution is to find the combinations and remove duplicates. def sum_to_n(n): b, mid, e = [0], list(range(1, n)), [n] splits = [d for i in range(n) for d…
logicanswered tomasantunes 1,579 -
1
votes2
answers501
viewsA: Create array/list with indexes
1. To define the indexes would need a dictionary instead of a list: dict1 = {1: "Jan", 2: "Fev", ..., 12: "Dez"} 2. What happens in the code is a list comprehension, separate would look like this:…
-
1
votes1
answer42
viewsA: Wxpython: Getfocuseditem() returning item even with nothing focused
This code removes all selections: for x in xrange(0, self.lstDisciplinasPadroes.GetItemCount(), 1): self.lstDisciplinasPadroes.Select(x, on=0)