python-3.x

access element from .ui

扶醉桌前 提交于 2021-02-10 20:25:52
问题 I have problem to access my button and label from my dialog.ui. I am using Python 3.x and QT Designer 5.x. from PyQt5 import uic, QtWidgets from PyQt5.QtWidgets import QApplication Form, Window = uic.loadUiType("dialog.ui") #load ui (GUI) file app = QApplication([]) #create a QApplication window = Window() form = Form() form.setupUi(window) def on_click(): # self.qlFreeText.text("hello") alert = QMessageBox() alert.setText("You clicked the button!") alert.exec_() class Ui(QtWidgets

Defining TkInter StringVars in a loop

自古美人都是妖i 提交于 2021-02-10 20:22:29
问题 My program iterates through a list of values and creates a new frame with relevant information. I want to add a button to refresh the values in just one of the frames. The following image is a mockup of what I'm trying to achieve, where the "reload" button grabs new data for just one printer. I'm running into an issue where only the last values get updated. The following code is an approximation of what I was trying: import tkinter as tk from tkinter import ttk def buttonupdate(x): return int

Defining TkInter StringVars in a loop

≡放荡痞女 提交于 2021-02-10 20:20:35
问题 My program iterates through a list of values and creates a new frame with relevant information. I want to add a button to refresh the values in just one of the frames. The following image is a mockup of what I'm trying to achieve, where the "reload" button grabs new data for just one printer. I'm running into an issue where only the last values get updated. The following code is an approximation of what I was trying: import tkinter as tk from tkinter import ttk def buttonupdate(x): return int

Not able to add Text Clip in Moviepy. Getting error related to Imagemagic

亡梦爱人 提交于 2021-02-10 20:17:25
问题 I am using the moviepy module for python from here https://github.com/Zulko/moviepy I had successfully installed moviepy and necessary modules with it. But when I am trying to run the first example of adding Text clip in the video, I am getting error. Here is my code and my output. Code: from moviepy.editor import * clip = VideoFileClip("video1.mp4").subclip(50, 60) txt_clip = TextClip("My Holidays 2013", fontsize=70, color='white') txt_clip = txt_clip.set_pos('center').set_duration(10) video

Drawing a line using centroid point in opencv

送分小仙女□ 提交于 2021-02-10 20:15:26
问题 How do I pass a line through the center of a contour? I have the center coordinates of my contour. 回答1: This is how you solve this question - Original image - Result image - You first need to do basic filtering and find the contour. Then - 1) Find out the area of contour (minAreaRect) 2) Extract points from the contour (BoxPoints) 3) Convert it to a numpy array (np.array) 4) Order the points (perspective.order_points) 5) Take out Top-left, Top-right, Bottom-right and Bottom-left(tl, tr, br,

Difference Between Running Python File as Executable vs. Running from Command Line?

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-10 20:14:21
问题 Background Below, I detail two different ways of running Python files - I am confused about the difference between them. Running the Python file as an executable. To run a Python file as an executable, I must first set a shebang in my file ( # /usr/bin/env python3 ), then run $ chmod +x filename.py at the command line, then run $ ./filename.py at the command line to execute the file. Running the Python file through the python3 command line command. To run a Python file through the python3

Regression line using Relplot in seaborn

老子叫甜甜 提交于 2021-02-10 20:00:35
问题 Below is a working example where I need to draw regression line. I have searched online but I see another function like regplot, implot to draw regression lines but here I am using replot. How I can draw regression line using relplot? from matplotlib import pyplot as plt import pandas as pd import seaborn as sns d = {'x-axis':[100,915,298,299], 'y-axis': [1515,1450,1313,1315], 'text':['point1','point2','point3','point4']} df = pd.DataFrame(d) p1 = sns.relplot(x='x-axis', y='y-axis',data=df )

How to retrieve the list of values from a drop down list

半腔热情 提交于 2021-02-10 19:55:32
问题 I am trying to retrieve the list of available option expiries for a given ticker on yahoo finance. For instance using SPY as ticker on https://finance.yahoo.com/quote/SPY/options The list of expiries are in the drop down list: <div class="Fl(start) Pend(18px) option-contract-control drop-down-selector" data-reactid="4"> <select class="Fz(s)" data-reactid="5"> <option selected="" value="1576627200" data-reactid="6">December 18, 2019</option> <option value="1576800000" data-reactid="7">December

How to retrieve the list of values from a drop down list

拜拜、爱过 提交于 2021-02-10 19:54:41
问题 I am trying to retrieve the list of available option expiries for a given ticker on yahoo finance. For instance using SPY as ticker on https://finance.yahoo.com/quote/SPY/options The list of expiries are in the drop down list: <div class="Fl(start) Pend(18px) option-contract-control drop-down-selector" data-reactid="4"> <select class="Fz(s)" data-reactid="5"> <option selected="" value="1576627200" data-reactid="6">December 18, 2019</option> <option value="1576800000" data-reactid="7">December

Python :get possibilities of lists and change the number of loops

情到浓时终转凉″ 提交于 2021-02-10 19:53:28
问题 I'd like to be able to change the number of loops and store all possibilities in a (list of lists). Let me explain by an example: You have the following list: initial_list=[1,2] Then you have a parameter n, which is the number of loops For example if n=2, I'd like my programm to return this list: final_list=[[x,x,1,2],[x,1,x,2],[x,1,2,x],[1,x,x,2],[1,x,2,x][1,2,x,x]] So for n=3, the program would do the same with 3 'x', etc Also, i'd like my initial_list could have different length, like [1,2