How hard is it to build a completely new standalone GUI?

More
02 Feb 2019 04:24 #125523 by cmorley
Does that mean it uses qt4 for displaying - that's not a problem as far as I know - qt4 is still used.

Chris M

Please Log in or Create an account to join the conversation.

More
04 Feb 2019 06:24 - 04 Feb 2019 06:25 #125637 by KevKim
I don't have clear view on qt4/qt5, I won't dig this deep, just leaving ERIC.
Instead, I am on IDLE and trying to monitor what values are changing when I do something in axis gui.

Can you tell me just one thing please?

If I want to set an axis' displayed DRO value, i.e. x-axis rel-pos in current offset whatever it maybe, what's the reccomended method to manipulate the value?

Should I unlinkp a specific hal_pin, setp its value upon user-input number and re-link this pin back to previous status within a python code?

I am trying to guess this mechanism from gmoccapy x/y/z touch-off routine but failed to find exact module which might do this job.
gmoccapy's touch-off button calls for an input-dialog box combined with a calculator, its label says <Enter value for axis x> but I can't find this text within dialog.py widget. I wan to study it a bit deeper on how this is working.

Sorry to ask you elementary school-grade questions again and again ...
Last edit: 04 Feb 2019 06:25 by KevKim.

Please Log in or Create an account to join the conversation.

More
04 Feb 2019 07:04 #125638 by cmorley

Can you tell me just one thing please?...


Ha Careful what you ask for .... I feel you may have a couple more after.

Here is Gmoccapy's callback function for setting offsets:
    def on_btn_set_value_clicked(self, widget, data=None):
        if widget == self.widgets.btn_set_value_x:
            axis = "x"
        elif widget == self.widgets.btn_set_value_y:
            axis = "y"
        elif widget == self.widgets.btn_set_value_z:
            axis = "z"
        elif widget == self.widgets.btn_set_value_4:
            axis = self.axisletter_four
        elif widget == self.widgets.btn_set_value_5:
            axis = self.axisletter_five
        else:
            axis = "Unknown"
            message = _("Offset {0} could not be set, because off unknown axis").format(axis)
            self.dialogs.warning_dialog(self, _("Wrong offset setting!"), message)
            return
        if self.lathe_mode and axis =="x":
            if self.diameter_mode:
                preset = self.prefs.getpref("diameter offset_axis_{0}".format(axis), 0, float)
                offset = self.dialogs.entry_dialog(self, data=preset, header=_("Enter value for diameter"),
                                                   label=_("Set diameter to:"), integer=False)
            else:
                preset = self.prefs.getpref("radius offset_axis_{0}".format(axis), 0, float)
                offset = self.dialogs.entry_dialog(self, data=preset, header=_("Enter value for radius"),
                                                   label=_("Set radius to:"), integer=False)
        else:
            preset = self.prefs.getpref("offset_axis_{0}".format(axis), 0, float)
            offset = self.dialogs.entry_dialog(self, data=preset, header=_("Enter value for axis {0}").format(axis),
                                               label=_("Set axis {0} to:").format(axis), integer=False)
        if offset == "CANCEL":
            return
        elif offset == "ERROR":
            print(_("Conversion error in btn_set_value"))
            self.dialogs.warning_dialog(self, _("Conversion error in btn_set_value!"),
                                   _("Please enter only numerical values. Values have not been applied"))
        else:
            self.command.mode(linuxcnc.MODE_MDI)
            self.command.wait_complete()
            command = "G10 L20 P0 {0}{1:f}".format(axis, offset)
            self.command.mdi(command)
            self.widgets.hal_action_reload.emit("activate")
            self.command.mode(linuxcnc.MODE_MANUAL)
            self.command.wait_complete()
            self.prefs.putpref("offset_axis_{0}".format(axis), offset, float)

The function is called from a signal set in the GLADE file, probably for a button click (based on the function name).
We call this a 'callback' function the GTK button call back to the function when clicked.

In the function it:
Figures out what axis to set
Does some checks related to a lathe/diameter mode
Then displays the caculator dialog and waits for it to return
If there is an error or cancel it returns without doing any thing
other wise it sends linuxcnc MDI commands to set the offset - specifically G10 L20 P0 AXIS OFFSET
(P0 means the current coordinate system.)
then it reloads the graphics so it stays in sync.
Puts the mode back to manual
then saves the offset to a preference file presumably so it can be pre loaded for next time.

Chris M

Please Log in or Create an account to join the conversation.

More
04 Feb 2019 07:06 #125639 by KevKim
self-answering...
I think I just found the answer to this.
Would this be the one I was looking for?

in gmoccapy.py - which I think is the handler file -
under

def on_btn_set_value_clicked(self, widget, data=None):
============================
.
.
.
============================

if offset == "CANCEL":
return
elif offset == "ERROR":
print(_("Conversion error in btn_set_value"))
self.dialogs.warning_dialog(self, _("Conversion error in btn_set_value!"),
_("Please enter only numerical values. Values have not been applied"))
else:
self.command.mode(linuxcnc.MODE_MDI)
self.command.wait_complete()
command = "G10 L20 P0 {0}{1:f}".format(axis, offset)
self.command.mdi(command)
self.widgets.hal_action_reload.emit("activate")
self.command.mode(linuxcnc.MODE_MANUAL)
self.command.wait_complete()
self.prefs.putpref("offset_axis_{0}".format(axis), offset, float)

Please Log in or Create an account to join the conversation.

More
04 Feb 2019 07:09 #125640 by KevKim
woot.. you answered already, TNX!!!!!
and tnx for precious advise.

I want to build something with my own hands, so the rest will be my homework, like popping-up an input gui window, disappears when a value <entered>. I just wanted to know where to look into :)

I really appreciate your effort!!

Kevin

Please Log in or Create an account to join the conversation.

More
04 Feb 2019 07:12 #125641 by cmorley
If you get stuck with popping a dialog this thread may hellp:

forum.linuxcnc.org/48-gladevcp/35961-how...ect-partially-solved

You are welcome to the help.
I'm sure you will return the favor when someone else asks similar questions in the future.

Chris M

Please Log in or Create an account to join the conversation.

More
04 Feb 2019 07:37 #125643 by KevKim
absolutely yes,
once I get the whole picture how stuffs are related, then the rest is to know how to do codings according to syntax.
That will be way easier than to find out what is what, which is which.

BTW, I should have been more careful when I said <one question>.
For today's study, just one more please. /sigh.
I guess my_gui.py (which currently having only 3 effective functional group like window1_destroy, main_quit and __init__ ) is the handler file which needs to contain such custom functions to be built up from now on. Is this correct?

Kevin

Please Log in or Create an account to join the conversation.

More
04 Feb 2019 07:57 #125644 by cmorley
Sorry I am loosing track of what each person I'm helping is using.
You are using Gscreen the command to load was gscreen -c my_gui

So the handler file would be :
my_gui_handler.py file
and it would be in the configuration folder that the INI is in

Chris M

Please Log in or Create an account to join the conversation.

More
04 Feb 2019 08:02 #125646 by KevKim
very well acknowledged it, TY!
I was wondering which should be handler cause I couldn't see any definition statement for handler.py within .ini file.
This might be an automatic one as long as gscreen is used, according to the naming of <my_gui>

kevin

Please Log in or Create an account to join the conversation.

Moderators: mhaberlerHansU
Time to create page: 0.181 seconds
Powered by Kunena Forum