Skip to content

Commit

Permalink
Resize default display
Browse files Browse the repository at this point in the history
  • Loading branch information
Paradeluxe committed Dec 23, 2024
1 parent f41fc34 commit 0bea62c
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 76 deletions.
Binary file modified instructions/gui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 33 additions & 27 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def __init__(self):
self.file_path = None
self.which_one = 0
self.setWindowTitle("Praditor")
self.setMinimumSize(1500, 780)
self.setMinimumSize(900, 720)

# icon = QIcon()
# icon.addPixmap(QPixmap(resource_path("icon.png")), QIcon.Normal, QIcon.On)
# self.setWindowIcon(icon)
Expand All @@ -54,45 +55,49 @@ def __init__(self):
}
""")
self.statusBar().setFixedHeight(25)



self.statusBar().setFixedHeight(20)


# MENU
# --------------------------------------
menu = self.menuBar()
menu.setStyleSheet("""
QMenuBar {
background-color: #E9EDF1;
font-size: 15px;
color: black;
}""")
file_menu = menu.addMenu("&File")
# self.menuBar().setFixedHeight(35)

file_menu = self.menuBar().addMenu("&File")
button_action = QAction("&Read file...", self)
button_action.setStatusTip("Folder to store target audios")
button_action.triggered.connect(self.openFileDialog)
file_menu.addAction(button_action)
file_menu.setStyleSheet("""
QMenu {
color: black;
background-color: white;
}
""")

file_menu = menu.addMenu("&Help")
# file_menu.setStyleSheet("""
# QMenu {
# color: black;
# background-color: white;
#
# }
# """)

file_menu = self.menuBar().addMenu("&Help")
button_action = QAction("&Instructions", self)
button_action.setStatusTip("Folder to store target audios")
button_action.triggered.connect(self.browseInstruction)
file_menu.addAction(button_action)
file_menu.setStyleSheet("""
QMenu {
color: black;
background-color: white;
# file_menu.setStyleSheet("""
#
# """)
self.menuBar().setStyleSheet("""
QMenuBar {
background-color: #E9EDF1;
font-size: 10px;
color: black;
}
QMenu {
color: black;
background-color: #EFEFEF;
border: 1px solid #676767;
height: 25px;
}
}
""")
# --------------------------------------

Expand Down Expand Up @@ -255,6 +260,7 @@ def __init__(self):
# file_menu.addAction(button_action2)
# ---------------------------------------------------
self.AudioViewer = AudioViewer()
self.AudioViewer.setMinimumHeight(100)
layout.addWidget(self.AudioViewer)
# ---------------------------------------------------

Expand Down
182 changes: 147 additions & 35 deletions playground/test.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,153 @@
from PySide6.QtCore import Qt
from PySide6.QtGui import QPixmap, QIcon
from PySide6.QtWidgets import QApplication, QLabel, QWidget, QVBoxLayout
from tool import resource_path
from PySide6.QtCore import QSize, Qt, QEvent
from PySide6.QtGui import QPalette
from PySide6.QtWidgets import (
QApplication,
QHBoxLayout,
QLabel,
QMainWindow,
QStyle,
QToolButton,
QVBoxLayout,
QWidget,
)


class Example(QWidget):
class CustomTitleBar(QWidget):
def __init__(self, parent):
super().__init__(parent)
self.setAutoFillBackground(True)
self.setBackgroundRole(QPalette.ColorRole.Highlight)
self.initial_pos = None
title_bar_layout = QHBoxLayout(self)
title_bar_layout.setContentsMargins(1, 1, 1, 1)
title_bar_layout.setSpacing(2)

self.title = QLabel(f"{self.__class__.__name__}", self)
self.title.setStyleSheet(
"""font-weight: bold;
border: 2px solid black;
border-radius: 12px;
margin: 2px;
"""
)
self.title.setAlignment(Qt.AlignmentFlag.AlignCenter)
if title := parent.windowTitle():
self.title.setText(title)
title_bar_layout.addWidget(self.title)
# Min button
self.min_button = QToolButton(self)
min_icon = self.style().standardIcon(
QStyle.StandardPixmap.SP_TitleBarMinButton
)
self.min_button.setIcon(min_icon)
self.min_button.clicked.connect(self.window().showMinimized)

# Max button
self.max_button = QToolButton(self)
max_icon = self.style().standardIcon(
QStyle.StandardPixmap.SP_TitleBarMaxButton
)
self.max_button.setIcon(max_icon)
self.max_button.clicked.connect(self.window().showMaximized)

# Close button
self.close_button = QToolButton(self)
close_icon = self.style().standardIcon(
QStyle.StandardPixmap.SP_TitleBarCloseButton
)
self.close_button.setIcon(close_icon)
self.close_button.clicked.connect(self.window().close)

# Normal button
self.normal_button = QToolButton(self)
normal_icon = self.style().standardIcon(
QStyle.StandardPixmap.SP_TitleBarNormalButton
)
self.normal_button.setIcon(normal_icon)
self.normal_button.clicked.connect(self.window().showNormal)
self.normal_button.setVisible(False)
# Add buttons
buttons = [
self.min_button,
self.normal_button,
self.max_button,
self.close_button,
]
for button in buttons:
button.setFocusPolicy(Qt.FocusPolicy.NoFocus)
button.setFixedSize(QSize(28, 28))
button.setStyleSheet(
"""QToolButton { border: 2px solid white;
border-radius: 12px;
}
"""
)
title_bar_layout.addWidget(button)

def window_state_changed(self, state):
if state == Qt.WindowState.WindowMaximized:
self.normal_button.setVisible(True)
self.max_button.setVisible(False)
else:
self.normal_button.setVisible(False)
self.max_button.setVisible(True)


class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setStyleSheet("""
QWidget {
background: white;
}
""")
self.label = None
# 创建QLabel实例
self.label = QLabel(self)
# icon = QIcon()
# icon.addPixmap(QPixmap(resource_path("icon.png")), QIcon.Normal, QIcon.On)
# self.setWindowIcon(icon)
self.setWindowIcon(QIcon(resource_path("../icon.ico")))
# 加载图片
pixmap = QPixmap(resource_path(resource_path("../instructions/instruction.png"))) # 替换为你的图片路径

self.label.setPixmap(pixmap)
self.setFixedSize(pixmap.size())
# self.setWindowIcon(QIcon())
# 创建布局并添加QLabel
layout = QVBoxLayout()
layout.addWidget(self.label)
self.setLayout(layout)

# 设置窗口标题和大小
self.setWindowTitle('Parameters')
self.setWindowFlags(Qt.WindowSystemMenuHint | Qt.WindowCloseButtonHint | Qt.WindowStaysOnTopHint)
self.show()

if __name__ == '__main__':
self.setWindowTitle("Custom Title Bar")
self.resize(400, 200)
self.setWindowFlags(Qt.WindowType.FramelessWindowHint)
central_widget = QWidget()
self.title_bar = CustomTitleBar(self)

work_space_layout = QVBoxLayout()
work_space_layout.setContentsMargins(11, 11, 11, 11)
work_space_layout.addWidget(QLabel("Hello, World!", self))

centra_widget_layout = QVBoxLayout()
centra_widget_layout.setContentsMargins(0, 0, 0, 0)
centra_widget_layout.setAlignment(Qt.AlignmentFlag.AlignTop)
centra_widget_layout.addWidget(self.title_bar)
centra_widget_layout.addLayout(work_space_layout)

central_widget.setLayout(centra_widget_layout)
self.setCentralWidget(central_widget)

def changeEvent(self, event):
if event.type() == QEvent.Type.WindowStateChange:
self.title_bar.window_state_changed(self.windowState())
super().changeEvent(event)
event.accept()

def window_state_changed(self, state):
self.normal_button.setVisible(state == Qt.WindowState.WindowMaximized)
self.max_button.setVisible(state != Qt.WindowState.WindowMaximized)

def mousePressEvent(self, event):
if event.button() == Qt.MouseButton.LeftButton:
self.initial_pos = event.position().toPoint()
super().mousePressEvent(event)
event.accept()

def mouseMoveEvent(self, event):
if self.initial_pos is not None:
delta = event.position().toPoint() - self.initial_pos
self.window().move(
self.window().x() + delta.x(),
self.window().y() + delta.y(),
)
super().mouseMoveEvent(event)
event.accept()

def mouseReleaseEvent(self, event):
self.initial_pos = None
super().mouseReleaseEvent(event)
event.accept()

if __name__ == "__main__":
app = QApplication([])
ex = Example()
window = MainWindow()
window.show()
app.exec()
8 changes: 3 additions & 5 deletions pyplot/view_audio_qchart_slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def __init__(self):#, interval_ms=40000, resolution=20000):
self.max_amp = None
self.audio_clip = None
self.time_unit = 441
# self.setMaximumHeight(300)
self.setMinimumSize(1200, 200)
# self.setMinimumHeight(200)
# self.setMinimumSize(800, 200)
self.interval_ms = 1
self.fpath = ""
self.resolution = 1
Expand Down Expand Up @@ -112,8 +112,6 @@ def __init__(self):#, interval_ms=40000, resolution=20000):
self._chart.setBackgroundRoundness(1)
# self._chart.setBorderColor(QColor('red'))
self._chart.layout().setContentsMargins(0, 0, 0, 0)
# self._chart.setM
# self._chart.setBackgroundBrush(QBrush(QColor("black")))
self._chart.setMargins(QMargins(0, 0, 0, 0))
# self._chart.setBackgroundVisible(False)

Expand All @@ -128,7 +126,7 @@ def __init__(self):#, interval_ms=40000, resolution=20000):


self.chart_view = QChartView(self._chart)
self.chart_view.setRenderHint(QPainter.LosslessImageRendering)
# self.chart_view.setRenderHint(QPainter.LosslessImageRendering)
# self.chart_view.setRenderHint(QPainter.TextAntialiasing)

# --------------------------------------------
Expand Down
19 changes: 15 additions & 4 deletions slider/slider_single.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,20 @@ def __init__(self, param_name, minimum, step, maximum, font_color='#272727', col
self.digit = len(str(self.scale).split(".")[1])
except IndexError:
self.digit = 0
self.setMaximumHeight(40)
# self.setMaximumHeight(40)
self.setMinimumHeight(20)
# self.setMaximumHeight(25)


self.name_label = QLabel(param_name)
self.name_label.setFixedSize(90, 20)
self.name_label.setFixedWidth(90)
# self.name_label.setFixedSize(90, 20)

# if param_name:
# self.name_label.setFixedSize(90, 20)
# else:
# self.name_label.setFixedSize(0, 20)

self.name_label.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
self.name_label.setStyleSheet(f"""
Expand All @@ -43,7 +52,8 @@ def __init__(self, param_name, minimum, step, maximum, font_color='#272727', col
# }

self.param_slider = QSlider(Qt.Orientation.Horizontal)
self.param_slider.setFixedHeight(20)

# self.param_slider.setFixedHeight(20)
self.param_slider.setMinimum(minimum)
self.param_slider.setSingleStep(step)
self.param_slider.setMaximum(maximum)
Expand All @@ -61,7 +71,8 @@ def __init__(self, param_name, minimum, step, maximum, font_color='#272727', col
# self.param_slider.sliderReleased.connect(self.slider_released_h)

self.value_label = QLabel(f"{self.param_slider.sliderPosition()}")
self.value_label.setFixedSize(50, 20)
self.value_label.setFixedWidth(50)
# self.value_label.setFixedSize(50, 20)
self.value_label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
self.value_label.setStyleSheet("""
Expand Down
22 changes: 17 additions & 5 deletions test_audio.TextGrid
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,32 @@ item []:
xmax = 7.762879818594104
points: size = 4
points [1]:
time = 0.3014512471655329
time = 0.30142857142857143
mark = "onset"
points [2]:
time = 2.1682312925170066
time = 2.168208616780045
mark = "onset"
points [3]:
time = 4.041428571428572
time = 4.034036281179138
mark = "onset"
points [4]:
time = 5.81297052154195
time = 5.812902494331066
mark = "onset"
item [2]:
class = "TextTier"
name = "offset"
xmin = 0.0
xmax = 7.762879818594104
points: size = 0
points: size = 4
points [1]:
time = 1.1608843537414966
mark = "offset"
points [2]:
time = 3.065419501133787
mark = "offset"
points [3]:
time = 4.715736961451247
mark = "offset"
points [4]:
time = 6.721609977324263
mark = "offset"

0 comments on commit 0bea62c

Please sign in to comment.