hytos / HYTOS / HYTOS / Export_To_PAP.py @ 9f5097ca
이력 | 보기 | 이력해설 | 다운로드 (2.88 KB)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
"""This is Equipment module"""
|
3 |
|
4 |
from PyQt5 import QtCore, QtGui, QtWidgets |
5 |
from PyQt5.QtWidgets import * |
6 |
from PyQt5.QtGui import QMovie |
7 |
import os |
8 |
|
9 |
import Export_To_PAP_UI |
10 |
import math |
11 |
import requests |
12 |
import json |
13 |
from AppDocData import AppDocData |
14 |
def is_float(s): |
15 |
try:
|
16 |
if s:
|
17 |
float(s)
|
18 |
return True |
19 |
else:
|
20 |
return False |
21 |
except ValueError: |
22 |
return False |
23 |
|
24 |
|
25 |
def is_blank(s): |
26 |
return not (s and s.strip()) |
27 |
|
28 |
|
29 |
def is_not_blank(s): |
30 |
return bool(s and s.strip()) |
31 |
|
32 |
|
33 |
def convert_to_fixed_point(value): |
34 |
if is_float(str(value)): |
35 |
tokens = f"{float(value):.10f}".split('.') |
36 |
if len(tokens) == 2: |
37 |
# 소수점 아래가 있을 경우 소수점 아래의 trailing zero를 제거한다.
|
38 |
if is_blank(tokens[1].rstrip('0')): |
39 |
return tokens[0] |
40 |
else:
|
41 |
tokens[1] = tokens[1].rstrip('0') |
42 |
return '.'.join(tokens) |
43 |
else:
|
44 |
return tokens[0] |
45 |
else:
|
46 |
return value
|
47 |
|
48 |
|
49 |
class QExport_To_PAP(QDialog): |
50 |
def __init__(self): |
51 |
QDialog.__init__(self)
|
52 |
self.ui = Export_To_PAP_UI.Ui_Dialog()
|
53 |
self.ui.setupUi(self) |
54 |
self.ui.buttonBox.button(QDialogButtonBox.Ok).setIcon(QtGui.QIcon(':/images/OK.svg')) |
55 |
self.ui.buttonBox.button(QDialogButtonBox.Cancel).setIcon(QtGui.QIcon(':/images/Cancel.svg')) |
56 |
self.load_movie = QMovie(":/images/loader.gif") |
57 |
self.close_movie = QMovie(":/images/close.png") |
58 |
self.done_movie = QMovie(":/images/done.png") |
59 |
self.send_api("/api/Projects", "GET") |
60 |
|
61 |
def startAnimation(self): |
62 |
self.close_movie.stop()
|
63 |
self.done_movie.stop()
|
64 |
self.ui.label_loading.setMovie(self.load_movie) |
65 |
self.load_movie.start()
|
66 |
# Stop Animation(According to need)
|
67 |
|
68 |
def doneAnimation(self): |
69 |
self.load_movie.stop()
|
70 |
self.close_movie.stop()
|
71 |
self.ui.label_loading.setMovie(self.done_movie) |
72 |
self.done_movie.start()
|
73 |
|
74 |
def closeAnimation(self): |
75 |
self.load_movie.stop()
|
76 |
self.done_movie.stop()
|
77 |
self.ui.label_loading.setMovie(self.close_movie) |
78 |
self.close_movie.start()
|
79 |
|
80 |
def send_api(self, path, method): |
81 |
app_doc_data = AppDocData.instance() |
82 |
url = app_doc_data.API_HOST + path |
83 |
headers = {'Content-Type': 'application/json', 'charset': 'UTF-8', 'Accept': '*/*'} |
84 |
try:
|
85 |
if method == 'GET': |
86 |
response = requests.get(url, headers=headers) |
87 |
if response.status_code == 200: |
88 |
json_objects = json.loads(response.text) |
89 |
for json_object in json_objects: |
90 |
self.ui.comboBox_select_PAP_Project.addItem(json_object['Name']) |
91 |
except Exception as ex: |
92 |
print(ex) |
93 |
|
94 |
def accept(self): |
95 |
QDialog.accept(self)
|
96 |
|
97 |
def reject(self): |
98 |
QDialog.reject(self)
|