Skip to content

Commit

Permalink
gmoccapy: add progressbar for program progress
Browse files Browse the repository at this point in the history
  • Loading branch information
hansu committed Nov 23, 2024
1 parent 95cb064 commit 889c2a3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 14 deletions.
55 changes: 41 additions & 14 deletions src/emc/usr_intf/gmoccapy/gmoccapy.glade
Original file line number Diff line number Diff line change
Expand Up @@ -1734,25 +1734,52 @@
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<object class="GtkBox" id="vbox_gcode">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="EMC_SourceView" id="gcode_view">
<property name="name">gcode_view</property>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="tooltip-text" translatable="yes">Shows the code to execute</property>
<property name="left-margin">2</property>
<property name="right-margin">2</property>
<property name="show-line-numbers">True</property>
<property name="show-line-marks">True</property>
<property name="tab-width">4</property>
<property name="auto-indent">True</property>
<property name="highlight-current-line">True</property>
<property name="indent-on-tab">False</property>
<signal name="changed" handler="on_gcode_view_changed" swapped="no"/>
<child>
<object class="EMC_SourceView" id="gcode_view">
<property name="name">gcode_view</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="tooltip-text" translatable="yes">Shows the code to execute</property>
<property name="left-margin">2</property>
<property name="right-margin">2</property>
<property name="show-line-numbers">True</property>
<property name="show-line-marks">True</property>
<property name="tab-width">4</property>
<property name="auto-indent">True</property>
<property name="highlight-current-line">True</property>
<property name="indent-on-tab">False</property>
<signal name="changed" handler="on_gcode_view_changed" swapped="no"/>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkProgressBar" id="progressbar_pgm">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-bottom">5</property>
<property name="show-text">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
Expand Down
6 changes: 6 additions & 0 deletions src/emc/usr_intf/gmoccapy/gmoccapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ def __init__(self, argv):
#eb_program_label, #eb_blockheight_label {
background: rgba(0,0,0,1);
}
progress, trough {
min-height: 5px;
}
"""
screen = Gdk.Screen.get_default()
provider = Gtk.CssProvider()
Expand Down Expand Up @@ -2562,9 +2565,11 @@ def on_hal_status_line_changed(self, widget, line):
# this test is only necessary, because of remap and toolchange, it will emit a file loaded signal
if self.halcomp["program.length"] > 0:
self.halcomp["program.progress"] = 100.00 * line / self.halcomp["program.length"]
self.widgets.progressbar_pgm.set_fraction(line / self.halcomp["program.length"])
else:
self.halcomp["program.progress"] = 0.0
# print("Progress = {0:.2f} %".format(100.00 * line / self.halcomp["program.length"]))
self.widgets.progressbar_pgm.set_fraction(0)

def on_hal_status_interp_idle(self, widget):
LOG.debug("IDLE")
Expand Down Expand Up @@ -2617,6 +2622,7 @@ def on_hal_status_interp_idle(self, widget):

self.halcomp["program.current-line"] = 0
self.halcomp["program.progress"] = 0.0
self.widgets.progressbar_pgm.set_fraction(0)

def on_hal_status_interp_run(self, widget):
LOG.debug("RUN")
Expand Down

0 comments on commit 889c2a3

Please sign in to comment.