Skip to content

Commit

Permalink
add docstring in slot callback function
Browse files Browse the repository at this point in the history
  • Loading branch information
j8xixo12 committed Nov 15, 2023
1 parent d6dd30a commit 5d51509
Showing 1 changed file with 68 additions and 9 deletions.
77 changes: 68 additions & 9 deletions modmesh/app/euler1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ def __init__(self, shocktube):

@Slot(bool)
def save_all(self, checked=False):
"""
This callback function don't care button's checked state,
therefore the checked state is not used in this function.
:param checked: button is checked or not
:return: nothing
"""
fig = QPixmap(self.figure_container.size())
self.figure_container.render(fig)

Expand All @@ -171,13 +178,22 @@ def _update_layout(self):
self.main_layout.deleteLater()
self.main_container.update()

# Qt objects are managed by Qt internal event loop,
# hence it will not be deleted immediately when we called
# deleteLater() and a QWidget only accept one layout at
# the same time, therefore a object delete callback is
# needed to set new layout after old layout deleted.
@Slot(QObject)
def del_cb(obj=None):
"""
Qt objects are managed by Qt internal event loop,
hence it will not be deleted immediately when we called
deleteLater() and a QWidget only accept one layout at
the same time, therefore a object delete callback is
needed to set new layout after old layout deleted.
This callback will be called before the obj destroyed,
in this callback only update the layout, therefore the obj
is not used in this callback.
:param obj: The object about to be destroyed
:return: nothing
"""
if self.use_grid_layout:
self.build_lines_grid_layout()
else:
Expand All @@ -190,6 +206,13 @@ def del_cb(obj=None):

@Slot(bool)
def switch_layout(self, checked=False):
"""
This callback function don't care button's checked state,
therefore the checked state is not used in this function.
:param checked: button is checked or not
:return: nothing
"""
self.use_grid_layout = not self.use_grid_layout
self._update_layout()

Expand Down Expand Up @@ -453,10 +476,18 @@ def _build_checkbox(self, layout):

@Slot(bool)
def _checkbox_cb(self, checked=False):
# Under a single plot layout, that allow 3 lines on the same chart
# simultaneously to avoid it looking too crowded.
# I have chosen to use checkboxes for user to select
# the parameters they want to plot on the chart.
"""
This callback function don't care button's checked state,
therefore the checked state is not used in this function.
Under a single plot layout, that allow 3 lines on the same chart
simultaneously to avoid it looking too crowded.
I have chosen to use checkboxes for user to select
the parameters they want to plot on the chart.
:param checked: button is checked or not
:return: nothing
"""
checkbox = self.sender()
if self.checkbox_select_num == 3:
if checkbox.isChecked():
Expand Down Expand Up @@ -553,14 +584,35 @@ def show(self):

@Slot(bool)
def start(self, checked=False):
"""
This callback function don't care button's checked state,
therefore the checked state is not used in this function.
:param checked: button is checked or not
:return: nothing
"""
self.timer.start(self.interval)

@Slot(bool)
def stop(self, checked=False):
"""
This callback function don't care button's checked state,
therefore the checked state is not used in this function.
:param checked: button is checked or not
:return: nothing
"""
self.timer.stop()

@Slot(bool)
def step_button_cb(self, checked=False):
"""
This callback function don't care button's checked state,
therefore the checked state is not used in this function.
:param checked: button is checked or not
:return: nothing
"""
self.step()

def step(self, steps=1):
Expand All @@ -574,6 +626,13 @@ def timer_timeout_cb(self):

@Slot(bool)
def reset(self, checked=False):
"""
This callback function don't care button's checked state,
therefore the checked state is not used in this function.
:param checked: button is checked or not
:return: nothing
"""
self.stop()
self.current_step = 0
self.shocktube = euler1d.ShockTube()
Expand Down

0 comments on commit 5d51509

Please sign in to comment.