Hello Guest it is March 28, 2024, 05:28:31 PM

Author Topic: Create elements in Mach 4  (Read 2433 times)

0 Members and 1 Guest are viewing this topic.

Re: Create elements in Mach 4
« Reply #10 on: January 31, 2020, 04:34:51 PM »
Hi native34,
I'm glad to hear that you are prepared to dig in.

Quote
I just wish there was better documentation and examples like there were when is was programming VB. They had pretty clear and concise examples and how you could implements them.

But there is SUPERB documentation about wxWidgets and its Lua wrapper, its just the documentation is written by geeks, for
geeks and in geekese! I don't know about you but my head spins. In this regard wxFormBuilder is a great tutor, have wxFormBuilder
generate some code and then compare that code to the documentation and viola you have gleaned a wee bit of geekese.

https://docs.wxwidgets.org/3.0/

You may recall:
Quote
NFS has no part in determining the style and development of wxWidgets.
Its up to you to learn about wxWidgets, its not NFS's responsibility to teach you. It certainly is NFS's responsibility to document Mach4,
Mach4 being their core product, whereas wxWidgets is publicly available and documented software tool/suite that is used in the
creation of Mach4, but NOT NFS's core product.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Create elements in Mach 4
« Reply #11 on: January 31, 2020, 04:57:24 PM »
Hi,
now consider the two items that you want automated or otherwise built in to your screen set.

You have a directory or repository on your PC which holds all your Gcode?

If you click <Load Gcode> on the standard Mach4 screen what happens? In my installation it opens a file dialogue window
by which you navigate to the desired folder and then to the desired Gcode file. Typically the file dialogue window opens at
the last directory that you used. When you first start Mach that could be anywhere but once you navigate to your
Gcode repository thereafter each time you click <Load Gcode> the file dialogue will open in the repository directory.

In Windows the location of a file is made up of two parts, the filepath and the filename. In wxWidgets the default path is the last
used filepath but you CAN specify a path other than the default. You are in effect using a subset of what Mach (in actual fact wxLua)
does already.

In a similar manner if you require a Gcode file on a USB thumbdrive provide you navigate to the USB drive and indentify the file
it will load.

May I suggest that you confirm that the standard <Load Gcode> button behaves that way, namely opening at the last used filepath.
Assuming that you are happy with that experiment a solution is now in sight.

Replace the one <Load Gcode> button with two others but with a specified filepath rather than the default.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Create elements in Mach 4
« Reply #12 on: January 31, 2020, 05:11:17 PM »
Hi,
now you are wondering how you set the filepath right? I'm soooo glad you asked  ;D ;D

https://docs.wxwidgets.org/3.0/classwx_file_dialog.html

This is jut one of hundreds of different classes in wxWidgets, but is a commonly used one in Mach because we often
need to navigate to a file either to read, write or append.

I have attached a pic of an excerpt of the public member functions for this class, namely the SetPath function.

I am not really familiar how to use this particular function but that's where wxFormBuilder comes to your rescue.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Create elements in Mach 4
« Reply #13 on: February 11, 2020, 11:06:19 AM »
So i'm using wxbuilder to understand more about the code structure. I imported this code into Mach 4 panel script and i am getting a couple of errors when trying to run the code. I have attached images of the errors.

Re: Create elements in Mach 4
« Reply #14 on: February 12, 2020, 02:53:21 AM »
To use this code in the Lua Panels in Mach4, you must use the Mach4 Panel as the parent.
So change this line
UI.MyPanel1 = wx.wxPanel (wx.Null, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxSize( 500,300 ), wx.wxTAB_TRAVERSAL )
to
UI.MyPanel1 = mcLuaPanelParent

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Create elements in Mach 4
« Reply #15 on: February 16, 2020, 12:41:23 AM »
The bolt hole wizard is a good example.  It is designed to run as a stand alone wizard OR inside of a Lua panel.  To test it, just copy the bolt hole wizard code into the paste buffer and then paste it into the LUA panel's script. 

You will see the switch code in there that is similar to what SwiftyJ mentioned.  If the mcLuaPanelParent variable is not NIL, then the bolt hole wizard knows that it is running inside a Lua panel.  Otherwise, it is running as a stand alone wizard and will create a frame.

It is important to realize that wxFormBuilder will most likely NOT generate drop in code.  Use it to generate the user interface and then cut and paste the needed code into your panel script. 

Steve