Basic structure for the QT application with empty window
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -6,5 +6,8 @@ build/
|
||||
dist/
|
||||
.pytest_cache/
|
||||
.vscode/*
|
||||
!.vscode/launch.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/tasks.json
|
||||
.ruff_cache/
|
||||
src/bedit_gui/resources/resources_rc.py
|
||||
|
||||
20
.vscode/launch.json
vendored
Normal file
20
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python Debugger: Module",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"module": "bedit_gui",
|
||||
"preLaunchTask": "Qt: Generate files",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"QT_QPA_PLATFORMTHEME": "qt6ct",
|
||||
"QT_QPA_PLATFORM": "xcb"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
42
.vscode/tasks.json
vendored
42
.vscode/tasks.json
vendored
@@ -25,6 +25,48 @@
|
||||
"panel": "dedicated"
|
||||
},
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "Qt: Open Designer",
|
||||
"type": "shell",
|
||||
"command": "${workspaceFolder}/.venv/bin/pyside6-designer",
|
||||
"args": [],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"QT_QPA_PLATFORMTHEME": "qt6ct",
|
||||
"QT_QPA_PLATFORM": "xcb"
|
||||
}
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "dedicated"
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Qt: Generate files",
|
||||
"type": "process",
|
||||
"command": "${workspaceFolder}/.venv/bin/python",
|
||||
"args": [
|
||||
"${workspaceFolder}/scripts/generate_qt_files.py"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"PATH": "${workspaceFolder}/.venv/bin:${env:PATH}"
|
||||
}
|
||||
},
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"presentation": {
|
||||
"clear": true,
|
||||
"reveal": "always",
|
||||
"panel": "dedicated"
|
||||
},
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -17,6 +17,7 @@ dependencies = [
|
||||
[project.scripts]
|
||||
bedit-graphviz = "bedit_util.graphviz:main"
|
||||
bedit-simulate = "bedit_util.simulate:main"
|
||||
bedit = "bedit_gui.application:main"
|
||||
|
||||
[project.optional-dependencies]
|
||||
dev = [
|
||||
|
||||
64
scripts/generate_qt_files.py
Normal file
64
scripts/generate_qt_files.py
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
GUI_PACKAGE = ROOT / "src" / "bedit_gui"
|
||||
|
||||
FORMS_DIR = GUI_PACKAGE / "ui" / "forms"
|
||||
GENERATED_UI_DIR = GUI_PACKAGE / "ui" / "generated"
|
||||
|
||||
QRC_FILE = GUI_PACKAGE / "resources" / "resources.qrc"
|
||||
GENERATED_RESOURCES = (
|
||||
GUI_PACKAGE
|
||||
/ "resources"
|
||||
/ "resources_rc.py"
|
||||
)
|
||||
|
||||
|
||||
def execute(*command: str) -> None:
|
||||
print("+", " ".join(command))
|
||||
subprocess.run(command, check=True)
|
||||
|
||||
|
||||
def generate_ui() -> None:
|
||||
GENERATED_UI_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
for source in sorted(FORMS_DIR.glob("*.ui")):
|
||||
destination = GENERATED_UI_DIR / f"ui_{source.stem}.py"
|
||||
|
||||
execute(
|
||||
"pyside6-uic",
|
||||
"--absolute-imports",
|
||||
"--python-paths",
|
||||
str(ROOT / "src"),
|
||||
str(source),
|
||||
"-o",
|
||||
str(destination),
|
||||
)
|
||||
|
||||
|
||||
def generate_resources() -> None:
|
||||
GENERATED_RESOURCES.parent.mkdir(
|
||||
parents=True,
|
||||
exist_ok=True,
|
||||
)
|
||||
|
||||
execute(
|
||||
"pyside6-rcc",
|
||||
str(QRC_FILE),
|
||||
"-o",
|
||||
str(GENERATED_RESOURCES),
|
||||
)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
generate_ui()
|
||||
generate_resources()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
0
src/bedit_gui/__init__.py
Normal file
0
src/bedit_gui/__init__.py
Normal file
@@ -1,5 +1,3 @@
|
||||
def main():
|
||||
pass
|
||||
from bedit_gui.application import main
|
||||
|
||||
if __name__ == "__name__":
|
||||
raise SystemExit(main())
|
||||
raise SystemExit(main())
|
||||
18
src/bedit_gui/application.py
Normal file
18
src/bedit_gui/application.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from __future__ import annotations
|
||||
import sys
|
||||
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from bedit_gui.resources import resources_rc
|
||||
from bedit_gui.views.main_window import MainWindow
|
||||
|
||||
def main() -> int:
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
app.setOrganizationName("BEdit")
|
||||
app.setApplicationName("BEdit")
|
||||
|
||||
window = MainWindow()
|
||||
window.show()
|
||||
|
||||
return app.exec()
|
||||
0
src/bedit_gui/commands/__init__.py
Normal file
0
src/bedit_gui/commands/__init__.py
Normal file
0
src/bedit_gui/controllers/__init__.py
Normal file
0
src/bedit_gui/controllers/__init__.py
Normal file
0
src/bedit_gui/documents/__init__.py
Normal file
0
src/bedit_gui/documents/__init__.py
Normal file
3
src/bedit_gui/resources/generated/.gitignore
vendored
Normal file
3
src/bedit_gui/resources/generated/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
*
|
||||
!__init__.py
|
||||
!.gitignore
|
||||
0
src/bedit_gui/resources/generated/__init__.py
Normal file
0
src/bedit_gui/resources/generated/__init__.py
Normal file
0
src/bedit_gui/services/__init__.py
Normal file
0
src/bedit_gui/services/__init__.py
Normal file
174
src/bedit_gui/ui/forms/main_window.ui
Normal file
174
src/bedit_gui/ui/forms/main_window.ui
Normal file
@@ -0,0 +1,174 @@
|
||||
<?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>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget"/>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="actionNew_File"/>
|
||||
<addaction name="actionOpen_File"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionSave_File"/>
|
||||
<addaction name="actionSave_File_As"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionClose"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuEdit">
|
||||
<property name="title">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuView">
|
||||
<property name="title">
|
||||
<string>View</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp">
|
||||
<property name="title">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
<addaction name="actionAbout_QT"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuEdit"/>
|
||||
<addaction name="menuView"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="fileToolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionNew_File"/>
|
||||
<addaction name="actionOpen_File"/>
|
||||
<addaction name="actionSave_File"/>
|
||||
<addaction name="actionSave_File_As"/>
|
||||
</widget>
|
||||
<action name="actionOpen_File">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/icons/icons/document-open.png</normaloff>:/icons/icons/document-open.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open File</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Open a file</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+O</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNew_File">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/icons/icons/document-new.png</normaloff>:/icons/icons/document-new.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New File</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Create a new file</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+N</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave_File">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/icons/icons/document-save.png</normaloff>:/icons/icons/document-save.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save File</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Save a file to disk</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave_File_As">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/icons/icons/document-save-as.png</normaloff>:/icons/icons/document-save-as.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save File As...</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Save file to disk as another file</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Shift+S</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionClose">
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Close application</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout_QT">
|
||||
<property name="text">
|
||||
<string>About QT</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::AboutQtRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../resources/resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
3
src/bedit_gui/ui/generated/.gitignore
vendored
Normal file
3
src/bedit_gui/ui/generated/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
*
|
||||
!__init__.py
|
||||
!.gitignore
|
||||
0
src/bedit_gui/ui/generated/__init__.py
Normal file
0
src/bedit_gui/ui/generated/__init__.py
Normal file
0
src/bedit_gui/utils/__init__.py
Normal file
0
src/bedit_gui/utils/__init__.py
Normal file
0
src/bedit_gui/views/__init__.py
Normal file
0
src/bedit_gui/views/__init__.py
Normal file
0
src/bedit_gui/views/dialogs/__init__.py
Normal file
0
src/bedit_gui/views/dialogs/__init__.py
Normal file
0
src/bedit_gui/views/docks/__init__.py
Normal file
0
src/bedit_gui/views/docks/__init__.py
Normal file
0
src/bedit_gui/views/editor/__init__.py
Normal file
0
src/bedit_gui/views/editor/__init__.py
Normal file
11
src/bedit_gui/views/main_window.py
Normal file
11
src/bedit_gui/views/main_window.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from PySide6.QtWidgets import QMainWindow
|
||||
|
||||
from bedit_gui.ui.generated.ui_main_window import Ui_MainWindow
|
||||
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
self.ui = Ui_MainWindow()
|
||||
self.ui.setupUi(self)
|
||||
Reference in New Issue
Block a user