Commit 1471d461 authored by Doerr, Kevin's avatar Doerr, Kevin
Browse files

Added table widget feature and minor visual changes

parent 90fbbd52
......@@ -16,10 +16,12 @@ Show the available templates:
import sys
from PyQt5 import QtWidgets
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import QMainWindow
from PyQt5.QtWidgets import QMessageBox
from PyQt5.QtWidgets import QDialog, QApplication
from phantasy import MachinePortal
from phantasy_ui import BaseAppForm
......@@ -43,7 +45,6 @@ TWISS_KEYS_Y = [
'gamma_{u}', 'total_intensity')
]
class MyAppWindow(BaseAppForm, Ui_MainWindow):
def __init__(self, version, **kws):
super(self.__class__, self).__init__()
......@@ -53,7 +54,7 @@ class MyAppWindow(BaseAppForm, Ui_MainWindow):
self.setAppTitle("My App")
# app info in about dialog
# self.app_about_info = "About info of My App."
self.app_about_info = "This application will display the X/Y beam ellipse, beam envelope, and associated values of the virtual accelerator. A figure describing the beam ellipse is included here."
# UI
self.setupUi(self)
......@@ -172,6 +173,26 @@ class MyAppWindow(BaseAppForm, Ui_MainWindow):
params_x = dict(zip(TWISS_KEYS_X, vals_x))
params_y = dict(zip(TWISS_KEYS_Y, vals_y))
#Fill table widget with constant values
#table is coded as one column even though two exist in QTDesigner GUI
#Only accepts String type (Table View widget could fix this)
self.tableWidget.setItem(0,0,QtWidgets.QTableWidgetItem(str(s.xcen)))#x_c
self.tableWidget.setItem(0,1,QtWidgets.QTableWidgetItem(str(s.ycen)))#y_c
self.tableWidget.setItem(0,2,QtWidgets.QTableWidgetItem(str(s.xpcen)))#a_c
self.tableWidget.setItem(0,3,QtWidgets.QTableWidgetItem(str(s.ypcen)))#b_c
self.tableWidget.setItem(0,4,QtWidgets.QTableWidgetItem(str(s.xrms)))#xm
self.tableWidget.setItem(0,5,QtWidgets.QTableWidgetItem(str(s.yrms)))#ym
self.tableWidget.setItem(0,6,QtWidgets.QTableWidgetItem(str(s.xprms)))#am
self.tableWidget.setItem(0,7,QtWidgets.QTableWidgetItem(str(s.yprms)))#bm
self.tableWidget.setItem(0,8,QtWidgets.QTableWidgetItem(str(s.xemittance)))#eps_x
self.tableWidget.setItem(0,9,QtWidgets.QTableWidgetItem(str(s.yemittance)))#eps_y
self.tableWidget.setItem(0,10,QtWidgets.QTableWidgetItem(str(s.xtwiss_alpha)))#x-alpha
self.tableWidget.setItem(0,11,QtWidgets.QTableWidgetItem(str(s.ytwiss_alpha)))#y-alpha
self.tableWidget.setItem(0,12,QtWidgets.QTableWidgetItem(str(s.xtwiss_beta)))#x-beta
self.tableWidget.setItem(0,13,QtWidgets.QTableWidgetItem(str(s.ytwiss_beta)))#y-beta
self.tableWidget.setItem(0,14,QtWidgets.QTableWidgetItem(str((s.xtwiss_alpha**2 + 1) / s.xtwiss_beta)))#x-gamma
self.tableWidget.setItem(0,15,QtWidgets.QTableWidgetItem(str((s.ytwiss_alpha**2 + 1) / s.ytwiss_beta))) #y-gamma
self._plot_ellipse(self.x_ellipse_plot,
params_x,
color='b',
......
......@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'ui_app.ui'
#
# Created by: PyQt5 UI code generator 5.14.1
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!
......@@ -12,15 +12,53 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1381, 641)
MainWindow.resize(1627, 611)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
MainWindow.sizePolicy().hasHeightForWidth())
MainWindow.setSizePolicy(sizePolicy)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icons/default.png"),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon.addPixmap(
QtGui.QPixmap("../../../../default.png"), QtGui.QIcon.Normal,
QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.label = QtWidgets.QLabel(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
self.label.sizePolicy().hasHeightForWidth())
self.label.setSizePolicy(sizePolicy)
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
self.quad1_name_cbb = QtWidgets.QComboBox(self.centralwidget)
self.quad1_name_cbb.setObjectName("quad1_name_cbb")
self.horizontalLayout.addWidget(self.quad1_name_cbb)
self.label_2 = QtWidgets.QLabel(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
self.label_2.sizePolicy().hasHeightForWidth())
self.label_2.setSizePolicy(sizePolicy)
self.label_2.setObjectName("label_2")
self.horizontalLayout.addWidget(self.label_2)
self.quad1_grad_dsbox = QtWidgets.QDoubleSpinBox(self.centralwidget)
self.quad1_grad_dsbox.setDecimals(3)
self.quad1_grad_dsbox.setObjectName("quad1_grad_dsbox")
self.horizontalLayout.addWidget(self.quad1_grad_dsbox)
self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 1)
self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
self.tabWidget.setObjectName("tabWidget")
self.tab = QtWidgets.QWidget()
......@@ -92,6 +130,41 @@ class Ui_MainWindow(object):
self.y_ellipse_plot.setProperty("figureToolbarToggle", False)
self.y_ellipse_plot.setObjectName("y_ellipse_plot")
self.horizontalLayout_2.addWidget(self.y_ellipse_plot)
self.tableWidget = QtWidgets.QTableWidget(self.tab)
sizePolicy = QtWidgets.QSizePolicy(
QtWidgets.QSizePolicy.MinimumExpanding,
QtWidgets.QSizePolicy.MinimumExpanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
self.tableWidget.sizePolicy().hasHeightForWidth())
self.tableWidget.setSizePolicy(sizePolicy)
self.tableWidget.setAutoFillBackground(False)
self.tableWidget.setShowGrid(True)
self.tableWidget.setObjectName("tableWidget")
self.tableWidget.setColumnCount(2)
self.tableWidget.setRowCount(8)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(3, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(4, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(5, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(6, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(7, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(1, item)
self.horizontalLayout_2.addWidget(self.tableWidget)
self.tabWidget.addTab(self.tab, "")
self.tab_2 = QtWidgets.QWidget()
self.tab_2.setObjectName("tab_2")
......@@ -110,39 +183,9 @@ class Ui_MainWindow(object):
self.horizontalLayout_3.addWidget(self.envelope_plot)
self.tabWidget.addTab(self.tab_2, "")
self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.label = QtWidgets.QLabel(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
self.label.sizePolicy().hasHeightForWidth())
self.label.setSizePolicy(sizePolicy)
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
self.quad1_name_cbb = QtWidgets.QComboBox(self.centralwidget)
self.quad1_name_cbb.setObjectName("quad1_name_cbb")
self.horizontalLayout.addWidget(self.quad1_name_cbb)
self.label_2 = QtWidgets.QLabel(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
self.label_2.sizePolicy().hasHeightForWidth())
self.label_2.setSizePolicy(sizePolicy)
self.label_2.setObjectName("label_2")
self.horizontalLayout.addWidget(self.label_2)
self.quad1_grad_dsbox = QtWidgets.QDoubleSpinBox(self.centralwidget)
self.quad1_grad_dsbox.setDecimals(3)
self.quad1_grad_dsbox.setObjectName("quad1_grad_dsbox")
self.horizontalLayout.addWidget(self.quad1_grad_dsbox)
self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1381, 30))
self.menubar.setGeometry(QtCore.QRect(0, 0, 1627, 24))
self.menubar.setObjectName("menubar")
self.menu_File = QtWidgets.QMenu(self.menubar)
self.menu_File.setObjectName("menu_File")
......@@ -175,22 +218,45 @@ class Ui_MainWindow(object):
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.label.setText(_translate("MainWindow", "Select quadrupole"))
self.label_2.setText(_translate("MainWindow", "Gradient Setting"))
self.quad1_grad_dsbox.setSuffix(_translate("MainWindow", " T/m"))
self.x_ellipse_plot.setFigureXlabel(_translate("MainWindow", "X (mm)"))
self.x_ellipse_plot.setFigureYlabel(
_translate("MainWindow", "X\' (mrad)"))
self.y_ellipse_plot.setFigureXlabel(_translate("MainWindow", "Y (mm)"))
self.y_ellipse_plot.setFigureYlabel(
_translate("MainWindow", "Y\' (mrad)"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab),
_translate("MainWindow", "Beam Ellipse"))
self.tableWidget.setSortingEnabled(False)
item = self.tableWidget.verticalHeaderItem(0)
item.setText(_translate("MainWindow", "x(y)_c [mm]"))
item = self.tableWidget.verticalHeaderItem(1)
item.setText(_translate("MainWindow", "a(b)_c [mm]"))
item = self.tableWidget.verticalHeaderItem(2)
item.setText(_translate("MainWindow", "x(y)m [mm]"))
item = self.tableWidget.verticalHeaderItem(3)
item.setText(_translate("MainWindow", "a(b)m [mm]"))
item = self.tableWidget.verticalHeaderItem(4)
item.setText(_translate("MainWindow", "eps_x(y)"))
item = self.tableWidget.verticalHeaderItem(5)
item.setText(_translate("MainWindow", "alpha_x(y)"))
item = self.tableWidget.verticalHeaderItem(6)
item.setText(_translate("MainWindow", "beta_x(y)"))
item = self.tableWidget.verticalHeaderItem(7)
item.setText(_translate("MainWindow", "gamma_x(y)"))
item = self.tableWidget.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "X"))
item = self.tableWidget.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Y"))
self.tabWidget.setTabText(
self.tabWidget.indexOf(self.tab),
_translate("MainWindow", "Beam Ellipse"))
self.envelope_plot.setFigureXlabel(_translate("MainWindow", "s [m]"))
self.envelope_plot.setFigureYlabel(
_translate("MainWindow", "Envelop [mm]"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2),
_translate("MainWindow", "Beam Envelope"))
self.label.setText(_translate("MainWindow", "Select quadrupole"))
self.label_2.setText(_translate("MainWindow", "Gradient Setting"))
self.quad1_grad_dsbox.setSuffix(_translate("MainWindow", " T/m"))
self.tabWidget.setTabText(
self.tabWidget.indexOf(self.tab_2),
_translate("MainWindow", "Beam Envelope"))
self.menu_File.setTitle(_translate("MainWindow", "&File"))
self.menu_Help.setTitle(_translate("MainWindow", "&Help"))
self.action_About.setText(_translate("MainWindow", "&About"))
......
......@@ -6,19 +6,68 @@
<rect>
<x>0</x>
<y>0</y>
<width>1381</width>
<height>641</height>
<width>1627</width>
<height>611</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="windowIcon">
<iconset resource="resources.qrc">
<normaloff>:/icons/default.png</normaloff>:/icons/default.png</iconset>
<iconset>
<normaloff>../../../../default.png</normaloff>../../../../default.png</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Select quadrupole</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="quad1_name_cbb"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Gradient Setting</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="quad1_grad_dsbox">
<property name="suffix">
<string> T/m</string>
</property>
<property name="decimals">
<number>3</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
......@@ -124,6 +173,75 @@
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="showGrid">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
<row>
<property name="text">
<string>x(y)_c [mm]</string>
</property>
</row>
<row>
<property name="text">
<string>a(b)_c [mm]</string>
</property>
</row>
<row>
<property name="text">
<string>x(y)m [mm]</string>
</property>
</row>
<row>
<property name="text">
<string>a(b)m [mm]</string>
</property>
</row>
<row>
<property name="text">
<string>eps_x(y)</string>
</property>
</row>
<row>
<property name="text">
<string>alpha_x(y)</string>
</property>
</row>
<row>
<property name="text">
<string>beta_x(y)</string>
</property>
</row>
<row>
<property name="text">
<string>gamma_x(y)</string>
</property>
</row>
<column>
<property name="text">
<string>X</string>
</property>
</column>
<column>
<property name="text">
<string>Y</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
......@@ -157,49 +275,6 @@
</widget>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Select quadrupole</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="quad1_name_cbb"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Gradient Setting</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="quad1_grad_dsbox">
<property name="suffix">
<string> T/m</string>
</property>
<property name="decimals">
<number>3</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
......@@ -207,8 +282,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1381</width>
<height>30</height>
<width>1627</width>
<height>24</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment