change the Python GUI
This commit is contained in:
parent
0320267919
commit
e04bc556cc
|
@ -6,10 +6,10 @@ import csv
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from PyQt6.QtWidgets import QApplication, QMainWindow, QPushButton, QComboBox, QCheckBox, QLineEdit, QLabel, QVBoxLayout, QWidget, QTabWidget, QGridLayout, QMessageBox, QFileDialog, QProgressBar
|
from functools import partial
|
||||||
from PyQt6.QtCore import Qt, QThread, QTimer, QObject, pyqtSignal
|
from PyQt6.QtWidgets import QApplication, QMainWindow, QGridLayout, QPushButton, QComboBox, QWidget, QMenu, QTextEdit, QFileDialog
|
||||||
#from functools import partial
|
from PyQt6.QtCore import Qt, QPoint
|
||||||
from PyQt6.QtWidgets import QApplication, QMainWindow, QTableWidget, QTableWidgetItem, QPushButton, QVBoxLayout, QWidget
|
from PyQt6.QtGui import QFont
|
||||||
|
|
||||||
|
|
||||||
class MyWindow(QMainWindow):
|
class MyWindow(QMainWindow):
|
||||||
|
@ -17,45 +17,42 @@ class MyWindow(QMainWindow):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.setWindowTitle("Ptolemy GUI")
|
self.setWindowTitle("Ptolemy GUI")
|
||||||
self.setGeometry(100, 100, 1000, 200)
|
self.setGeometry(100, 100, 1000, 700)
|
||||||
|
self.setMinimumSize(400, 600)
|
||||||
|
|
||||||
# Create a table with 0 row and 8 columns
|
self.text_edit = QTextEdit()
|
||||||
self.table = QTableWidget(0, 9)
|
self.text_edit.setLineWrapMode(QTextEdit.LineWrapMode.NoWrap)
|
||||||
self.table.setHorizontalHeaderLabels(["Reaction", "gs-spin", "orbital", "spin-pi(Ex)", "Ex", "ELab [MeV/u]", "Entrance Pot.", "Exist Pot.", "Aux"])
|
font = QFont("Courier New", 8) # You can adjust the size as needed
|
||||||
|
self.text_edit.setFont(font)
|
||||||
# Set up button to add new rows
|
|
||||||
self.add_button = QPushButton("Add Row")
|
# self.text_edit.setFixedHeight(500)
|
||||||
self.add_button.clicked.connect(self.add_row)
|
try:
|
||||||
|
with open("../DWBA", 'r') as file:
|
||||||
|
content = file.read()
|
||||||
|
self.text_edit.setText(content)
|
||||||
|
except Exception as e:
|
||||||
|
self.text_edit.setText(f"Failed to load file:\n{e}")
|
||||||
|
|
||||||
|
# self.view_file_button = QPushButton("Help")
|
||||||
|
# self.view_file_button.clicked.connect(self.open_file_viewer)
|
||||||
|
|
||||||
self.cal_button = QPushButton("Calculate DWBA")
|
self.cal_button = QPushButton("Calculate DWBA")
|
||||||
|
self.cal_button.clicked.connect(self.CalDWBA)
|
||||||
|
|
||||||
|
|
||||||
# Set up the layout
|
# Set up the layout
|
||||||
layout = QVBoxLayout()
|
layout = QGridLayout()
|
||||||
layout.addWidget(self.add_button)
|
layout.addWidget(self.cal_button, 0, 0)
|
||||||
layout.addWidget(self.table)
|
layout.addWidget(self.text_edit, 0, 1, 5, 5)
|
||||||
layout.addWidget(self.cal_button)
|
|
||||||
|
|
||||||
# Set up the container and layout
|
# Set up the container and layout
|
||||||
container = QWidget()
|
container = QWidget()
|
||||||
container.setLayout(layout)
|
container.setLayout(layout)
|
||||||
self.setCentralWidget(container)
|
self.setCentralWidget(container)
|
||||||
|
|
||||||
self.add_row()
|
|
||||||
|
|
||||||
def add_row(self):
|
def CalDWBA(self):
|
||||||
# Add a new row to the table
|
print("Number of Row ")
|
||||||
row_position = self.table.rowCount()
|
|
||||||
self.table.insertRow(row_position)
|
|
||||||
# Optionally populate the new row with empty items
|
|
||||||
for column in range(5):
|
|
||||||
self.table.setItem(row_position, column, QTableWidgetItem(""))
|
|
||||||
|
|
||||||
combo_box1 = QComboBox()
|
|
||||||
combo_box1.addItems(["Option 1", "Option 2", "Option 3"])
|
|
||||||
combo_box2 = QComboBox()
|
|
||||||
combo_box2.addItems(["Option 1", "Option 2", "Option 3"])
|
|
||||||
self.table.setCellWidget(row_position, 6, combo_box1)
|
|
||||||
self.table.setCellWidget(row_position, 7, combo_box2)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user