'How to update progressbar in during processing of function
attached my script with form design I want to change the value of the progress bar at the same time with the function of find proximity so when the process over the progress bar get the maximal value 100% https://www.dropbox.com/sh/b7g9wbeacl2qpxb/AABhJcQ4kFJRyXQEEYKm_2MMa?dl=0
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import sys
import design
import numpy as np
import pandas as pd
import scipy.spatial as spatial
class main(QMainWindow, design.Ui_MainWindow):
def __init__(self):
super(self.__class__, self).__init__()
self.setupUi(self)
self.btn_start.clicked.connect(self.find_proximity)
def find_proximity(self):
df = pd.read_csv("Myfile.txt", names=["code", "point", "x", "y", "z"], sep=" ", header=None)
point_tree = spatial.cKDTree(df[["x", "y"]])
rayon_pro = 5
df['a'] = ""
for i, row in df.iterrows():
a = (point_tree.query_ball_point([df["x"].iloc[i], df["y"].iloc[i]], rayon_pro))
df.at[i, 'a'] = a
df = df.rename_axis('id').reset_index()
df = df.explode('a')
df = df[df['id'] != df['a']]
df2 = df[["id", "a"]]
df2.rename(columns={'id': 'id1', 'a': 'id2'}, inplace=True)
df2[["id1", "id2"]] = np.sort(df2[["id1", "id2"]].values, axis=1)
df2 = df2.drop_duplicates(subset=["id1", "id2"])
for i in range(df2.shape[0]):
self.list_view.addItem(str(df2["id1"].iloc[i])+" & "+str(df2["id2"].iloc[i]))
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
MainWindow = QMainWindow()
ui = design.Ui_MainWindow()
Form = main()
Form.show()
sys.exit(app.exec_())
app.exec_()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
