mirror of
https://github.com/Team4388/autoPlanner2025.git
synced 2026-06-09 00:38:05 -06:00
Lunch
Added the button editor and changed the main script
This commit is contained in:
@@ -33,3 +33,6 @@ python3 ./main.py
|
||||
- Click export, and save to a file
|
||||
|
||||
### Known Bugs:
|
||||
|
||||
- Smoothing function is janky (I want to completely redo it)
|
||||
- Sometimes the control points spawn in random locations but I cant seem to replicate it?
|
||||
@@ -0,0 +1,53 @@
|
||||
import sys
|
||||
import os
|
||||
import numpy as np
|
||||
from PySide6.QtWidgets import QApplication, QLabel, QMainWindow, QPushButton, QVBoxLayout, QHBoxLayout, QWidget, QMessageBox
|
||||
from PySide6.QtGui import QPixmap, QMouseEvent, QPainter, QPen, QColor, QPainterPath, QPolygon, QFont
|
||||
from PySide6.QtCore import Qt, QPoint, QRect
|
||||
|
||||
class ButtonEditor(QMainWindow):
|
||||
def __init__(self, path_planner):
|
||||
super().__init__()
|
||||
self.setWindowTitle("Button Editor")
|
||||
self.path_planner = path_planner
|
||||
|
||||
#Set background image to the field
|
||||
self.image_label = QLabel(self)
|
||||
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
image_path = os.path.join(script_dir, "images", "Field.png")
|
||||
self.pixmap = QPixmap(image_path)
|
||||
|
||||
if self.pixmap.isNull():
|
||||
self.image_label.setText(f"Image not found at: {image_path}")
|
||||
else:
|
||||
self.image_label.setPixmap(self.pixmap)
|
||||
|
||||
#Layout stuff
|
||||
self.path_planner_button = QPushButton("Main Window")
|
||||
self.path_planner_button.clicked.connect(self.show_path_planner)
|
||||
self.button_editor_button = QPushButton("Button Editor")
|
||||
self.button_editor_button.clicked.connect(self.show_button_editor)
|
||||
|
||||
button_layout = QHBoxLayout()
|
||||
button_layout.addWidget(self.path_planner_button)
|
||||
button_layout.addWidget(self.button_editor_button)
|
||||
|
||||
#Layout of the auto planner
|
||||
layout = QVBoxLayout()
|
||||
layout.addLayout(button_layout)
|
||||
layout.addWidget(self.image_label)
|
||||
|
||||
container = QWidget()
|
||||
container.setLayout(layout)
|
||||
self.setCentralWidget(container)
|
||||
|
||||
self.resize(self.pixmap.width(), self.pixmap.height() + 60)
|
||||
|
||||
def show_button_editor(self):
|
||||
self.show()
|
||||
self.path_planner.hide()
|
||||
|
||||
def show_path_planner(self):
|
||||
self.hide()
|
||||
self.path_planner.show()
|
||||
@@ -1,11 +1,13 @@
|
||||
import sys
|
||||
import os
|
||||
import numpy as np
|
||||
from PySide6.QtWidgets import QApplication, QLabel, QMainWindow, QPushButton, QVBoxLayout, QWidget, QMessageBox
|
||||
from PySide6.QtWidgets import QApplication, QLabel, QMainWindow, QPushButton, QVBoxLayout, QHBoxLayout, QWidget, QMessageBox
|
||||
from PySide6.QtGui import QPixmap, QMouseEvent, QPainter, QPen, QColor, QPainterPath, QPolygon, QFont
|
||||
from PySide6.QtCore import Qt, QPoint, QRect
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
from buttonEditor import ButtonEditor
|
||||
|
||||
class PathPlanner(QMainWindow):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
@@ -23,15 +25,26 @@ class MainWindow(QMainWindow):
|
||||
else:
|
||||
self.image_label.setPixmap(self.pixmap)
|
||||
|
||||
#Buttons
|
||||
self.clear_button = QPushButton("Clear Auto")
|
||||
self.clear_button.clicked.connect(self.show_clear_warning)
|
||||
#I want to put these in a side toolbar
|
||||
#self.clear_button = QPushButton("Clear Auto")
|
||||
#self.clear_button.clicked.connect(self.show_clear_warning)
|
||||
|
||||
self.main_window_button = QPushButton("Main Window")
|
||||
self.main_window_button.clicked.connect(self.show_main_window)
|
||||
self.button_editor_button = QPushButton("Button Editor")
|
||||
self.button_editor_button.clicked.connect(self.show_button_editor)
|
||||
|
||||
button_layout = QHBoxLayout()
|
||||
button_layout.addWidget(self.main_window_button)
|
||||
button_layout.addWidget(self.button_editor_button)
|
||||
|
||||
#Layout of the auto planner
|
||||
layout = QVBoxLayout()
|
||||
layout.addWidget(self.clear_button)
|
||||
layout.addLayout(button_layout)
|
||||
layout.addWidget(self.image_label)
|
||||
|
||||
self.button_editor = ButtonEditor(self)
|
||||
|
||||
container = QWidget()
|
||||
container.setLayout(layout)
|
||||
self.setCentralWidget(container)
|
||||
@@ -314,8 +327,16 @@ class MainWindow(QMainWindow):
|
||||
if reply == QMessageBox.Yes:
|
||||
self.clear_points()
|
||||
|
||||
def show_main_window(self):
|
||||
self.show()
|
||||
self.button_editor.hide()
|
||||
|
||||
def show_button_editor(self):
|
||||
self.hide()
|
||||
self.button_editor.show()
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
window = MainWindow()
|
||||
window = PathPlanner()
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
Reference in New Issue
Block a user