Commit c21d3c92 authored by Tong Zhang's avatar Tong Zhang
Browse files

REF: Generated files with updated makeBasedPyQtApp tool.

parent 618e9b90
redeploy: clean build deploy clean
clean:
/bin/rm -rf dist build *.egg-info
build:
python3 setup.py bdist_wheel
deploy: build
python3 -m pip install dist/*.whl --upgrade --user
uninstall:
python3 -m pip uninstall aris
\ No newline at end of file
# ARIS-VA-Ellipse
This is a high-level physics application built upon ``phantasy`` framework.
This is a high-level physics application (HLA) built upon ``phantasy`` framework.
The EPICS controls environment is provided by ARIS virtual accelerator (VA)
(pre-separator), the UI skeleton is provided by ``phantasy-ui``, and
the device controls is provided by ``phantasy``.
This repository keeps the generated project files as the start point of the
development of a HLA to visualize the beam ellipse drawing with the simulation
results from FLAME model. This HLA also works with the real machine.
## Initialize App Skeleton
```shell
makeBasePyQtApp --app myApp --template AppWindow
# the working directory is /tmp
$ makeBasePyQtApp --app aris-va-ellipse --template AppWindow
What's the name of this package? (default: mypkg) aris
What's the name of the app, also the command to run it? (default: myApp) beam_ellipse
Generating aris-va-ellipse with template AppWindow...
Successfully made an base app at '/tmp/aris-va-ellipse'.
What to do next:
> Install package: cd /tmp/aris-va-ellipse; make deploy
> Run app by executing beam_ellipse
> Edit .ui file with 'frib_designer', and the .py files.
> Update the package: cd /tmp/aris-va-ellipse; make redeploy
> Happy Coding!
```
## Start ARIS VA
......@@ -43,5 +58,7 @@ quad0.B2 = 10
## Development Workflow
1. Edit .ui file in ``frib_designer``, which is a command tool from package ``phantasy_ui``;
2. Convert .ui file to .py file with ``pyuic5``: ``pyuic5 ui_app.ui -o ui_app.py -x``;
3. Run app by ``python3 app.py``.
2. Convert .ui files to .py files by executing `make` in the ui folder;
3. In the project root folder, type `make redeploy` to update the package and execute the command
(i.e. ``beam_ellipse``) to run the app;
4. Uninstall the package by: ``pip uninstall <pkg_name>`` (for this case, pkg_name is `aris`).
"""Template arguments:
- pkg_name: Python package name, default if mypkg
- exe_name: Executable name for the GUI app, default is myApp
"""
from setuptools import setup
PKG_NAME = "aris"
EXE_NAME = "beam_ellipse"
install_requires = []
def set_entry_points():
r = {}
r['gui_scripts'] = [
f'{EXE_NAME}={PKG_NAME}.myapp:run',
]
return r
def readme():
with open('README.md', 'r') as f:
return f.read()
def read_license():
with open('LICENSE') as f:
return f.read()
setup(
name=f'{PKG_NAME}',
version='0.1.0',
description='My app created with phantasy framework',
long_description=readme(),
license=read_license(),
packages=[f'{PKG_NAME}.myapp',
f'{PKG_NAME}.myapp.ui',
f'{PKG_NAME}'
],
package_dir={
f'{PKG_NAME}.myapp': 'src/myApp',
f'{PKG_NAME}.myapp.ui': 'src/myApp/ui',
f'{PKG_NAME}': 'src',
},
entry_points=set_entry_points(),
install_requires=install_requires,
)
\ No newline at end of file
# -*- coding: utf8 -*-
import sys
from phantasy_ui import QApp as QApplication
from .app import MyAppWindow
__version__ = '0.1'
__title__ = 'Beam Ellipse Drawing App'
def run(cli=False):
app = QApplication(sys.argv)
w = MyAppWindow(version=__version__)
w.setWindowTitle(__title__)
w.show()
if cli:
app.exec_()
else:
sys.exit(app.exec_())
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Template Python module generated based on 'app_template', 'phantasy-ui'
is required to make it executable as a PyQt5 app.
Created by: makeBasePyQtApp.
An example to create an app template:
>>> makeBasePyQtApp --app my_great_app --template AppWindow
Show the available templates:
>>> makeBasePyQtApp -l
"""
from PyQt5.QtWidgets import QMainWindow
from phantasy_ui import BaseAppForm
from .ui.ui_app import Ui_MainWindow
class MyAppWindow(BaseAppForm, Ui_MainWindow):
def __init__(self, version, **kws):
super(self.__class__, self).__init__()
# app version, title
self.setAppVersion(version)
self.setAppTitle("My App")
# app info in about dialog
# self.app_about_info = "About info of My App."
# UI
self.setupUi(self)
self.postInitUi()
if __name__ == "__main__":
from PyQt5.QtWidgets import QApplication
import sys
version = 0.1
app = QApplication(sys.argv)
w = MyAppWindow(version)
w.show()
w.setWindowTitle("This is an app from template")
sys.exit(app.exec_())
UIC_FLAGS := --from-imports -x
all: main rc
main: rc
pyuic5 ui_app.ui -o ui_app.py $(UIC_FLAGS)
yapf -i ui_app.py
rc:
pyrcc5 resources.qrc -o resources_rc.py
yapf -i resources_rc.py
<RCC>
<qresource prefix="icons">
<file>default.png</file>
</qresource>
</RCC>
This diff is collapsed.
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'ui_app.ui'
#
# Created by: PyQt5 UI code generator 5.14.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1600, 1200)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icons/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")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1600, 30))
self.menubar.setObjectName("menubar")
self.menu_File = QtWidgets.QMenu(self.menubar)
self.menu_File.setObjectName("menu_File")
self.menu_Help = QtWidgets.QMenu(self.menubar)
self.menu_Help.setObjectName("menu_Help")
MainWindow.setMenuBar(self.menubar)
self.action_About = QtWidgets.QAction(MainWindow)
self.action_About.setObjectName("action_About")
self.actionAbout_Qt = QtWidgets.QAction(MainWindow)
self.actionAbout_Qt.setObjectName("actionAbout_Qt")
self.actionE_xit = QtWidgets.QAction(MainWindow)
self.actionE_xit.setObjectName("actionE_xit")
self.actionContents = QtWidgets.QAction(MainWindow)
self.actionContents.setObjectName("actionContents")
self.menu_File.addAction(self.actionE_xit)
self.menu_Help.addAction(self.actionContents)
self.menu_Help.addSeparator()
self.menu_Help.addAction(self.action_About)
self.menu_Help.addAction(self.actionAbout_Qt)
self.menubar.addAction(self.menu_File.menuAction())
self.menubar.addAction(self.menu_Help.menuAction())
self.retranslateUi(MainWindow)
self.actionAbout_Qt.triggered.connect(MainWindow.onAboutQt)
self.actionE_xit.triggered.connect(MainWindow.close)
self.action_About.triggered.connect(MainWindow.onAbout)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.menu_File.setTitle(_translate("MainWindow", "&File"))
self.menu_Help.setTitle(_translate("MainWindow", "&Help"))
self.action_About.setText(_translate("MainWindow", "&About"))
self.action_About.setShortcut(_translate("MainWindow", "Ctrl+A"))
self.actionAbout_Qt.setText(_translate("MainWindow", "About Qt"))
self.actionE_xit.setText(_translate("MainWindow", "E&xit"))
self.actionE_xit.setShortcut(_translate("MainWindow", "Ctrl+W"))
self.actionContents.setText(_translate("MainWindow", "Contents"))
self.actionContents.setShortcut(_translate("MainWindow", "F1"))
from . import resources_rc
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1600</width>
<height>1200</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="windowIcon">
<iconset resource="resources.qrc">
<normaloff>:/icons/default.png</normaloff>:/icons/default.png</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout"/>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1600</width>
<height>30</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
<property name="title">
<string>&amp;File</string>
</property>
<addaction name="actionE_xit"/>
</widget>
<widget class="QMenu" name="menu_Help">
<property name="title">
<string>&amp;Help</string>
</property>
<addaction name="actionContents"/>
<addaction name="separator"/>
<addaction name="action_About"/>
<addaction name="actionAbout_Qt"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menu_Help"/>
</widget>
<action name="action_About">
<property name="text">
<string>&amp;About</string>
</property>
<property name="shortcut">
<string>Ctrl+A</string>
</property>
</action>
<action name="actionAbout_Qt">
<property name="text">
<string>About Qt</string>
</property>
</action>
<action name="actionE_xit">
<property name="text">
<string>E&amp;xit</string>
</property>
<property name="shortcut">
<string>Ctrl+W</string>
</property>
</action>
<action name="actionContents">
<property name="text">
<string>Contents</string>
</property>
<property name="shortcut">
<string>F1</string>
</property>
</action>
</widget>
<resources>
<include location="resources.qrc"/>
</resources>
<connections>
<connection>
<sender>actionAbout_Qt</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>onAboutQt()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>actionE_xit</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>action_About</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>onAbout()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>onAbout()</slot>
<slot>onAboutQt()</slot>
</slots>
</ui>
Supports Markdown
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