Skip to content

Commit

Permalink
[gui] make rom path select work
Browse files Browse the repository at this point in the history
  • Loading branch information
mike8699 committed Jan 21, 2024
1 parent 5ee6531 commit 1ae457c
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions ph_rando/ui/gui.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from pathlib import Path
import sys
from typing import NoReturn

from PySide6.QtWidgets import (
QApplication,
QCheckBox,
QComboBox,
QFileDialog,
QFormLayout,
QGroupBox,
QHBoxLayout,
Expand All @@ -20,6 +22,8 @@


class RandomizerUi(QWidget):
rom_path: Path

def __init__(self) -> None:
super().__init__()

Expand All @@ -31,15 +35,8 @@ def __init__(self) -> None:
self.render_settings()
self.render_bottom_panel()

def render_file_open_ui(self) -> None:
layout = self.layout()
groupbox = QGroupBox('ROM Selection')
layout.addWidget(groupbox)
vbox = QVBoxLayout()
groupbox.setLayout(vbox)

def _get_rom_file_select_widget(self) -> None:
rom_input_widget = QWidget()
vbox.addWidget(rom_input_widget)
hbox = QHBoxLayout()
rom_input_widget.setLayout(hbox)
file_path = QLineEdit()
Expand All @@ -48,6 +45,32 @@ def render_file_open_ui(self) -> None:
hbox.addWidget(file_path)
hbox.addWidget(browse_button)

def on_rom_path_click() -> None:
self.rom_path = Path(
QFileDialog.getOpenFileName(
parent=self, caption='Open ROM', dir='.', filter='*.nds'
)[0]
)
file_path.setText(str(self.rom_path))

def on_rom_path_change(path: str) -> None:
self.rom_path = Path(path)
file_path.setText(str(self.rom_path))

browse_button.clicked.connect(on_rom_path_click)
file_path.textChanged.connect(on_rom_path_change)

return rom_input_widget

def render_file_open_ui(self) -> None:
layout = self.layout()
groupbox = QGroupBox('ROM Selection')
layout.addWidget(groupbox)
vbox = QVBoxLayout()
groupbox.setLayout(vbox)

vbox.addWidget(self._get_rom_file_select_widget())

seed_input_widget = QWidget()
vbox.addWidget(seed_input_widget)
hbox = QHBoxLayout()
Expand Down

0 comments on commit 1ae457c

Please sign in to comment.