Axis 2 - touchscreen version of old friend
30 May 2022 00:33 #244166
by cakeslob
Replied by cakeslob on topic Axis 2 - touchscreen version of old friend
zack, I think you will find the usercommand file easier to use than you think. I would like some clarification from some of the pros, but I think the usercommand file is, when we use "root_window.tk.call" we are sending tcl language in the form of strings to the axis.tcl file. I did a quick conversion of your timer part using user command. I took your portion from the axis2.tcl, and turned it into a usercommand file. Here is the portion at the end of the file ive attatched
I dont understand it very well, but I took some of your code from axis2.tcl, and I think I turned it into strings, which get sent to axis.py (?) and then sent to axis.tcl
with that in mind, you can probably use your same code from the axis2.tcl in a usercommand file and send it this way, or you could do it in python
In the file ive attatched, just about everything is broken out so you can easily do your size and color configurations
linuxcnc.org/docs/devel/html/gui/axis.ht..._customization_hints
have a look at the user_live_update and the creating hal pins and you are half way there.
I dont know how you could do the gradient preview background, someone else might need to help you.
Personally for me, the time spent working in the usercommand file has payed dividends because I found it so fucking annoying having to patch axis every time I installed a new linuxcnc or did an update. The extra time/hassle for usercommand file was much worth the time saved doing not doing updates, with the added bonus of working with future and past versions of axis
W = root_window.tk.call
######### PACKING THE TIMER INTO INFO ########
W('canvas','.info.timer')
W('pack','.info.timer','-side','right')
W('label','.info.timer.counter',
'-text' ,'m:s',
'-relief','raised', \
'-pady','1',
'-width','12')
W('button','.info.timer.start',\
'-text',' Start', \
'-borderwidth', '1', \
'-width',' 4', \
'-pady',' 1 ',\
'-command',' ')
W('button','.info.timer.restart', \
'-text',' Reset',
'-borderwidth', '1', \
'-width',' 4', \
'-pady',' 1 ',\
'-command',' ')
W('button','.info.timer.stop',
'-text',' Stop',
'-borderwidth','1',
'-width','4',
'-pady','1')
W('pack','.info.timer.start','-side','left')
W('pack','.info.timer.stop','-side','left')
W('pack','.info.timer.restart','-side','left')
W('pack','.info.timer.counter','-side','right')
I dont understand it very well, but I took some of your code from axis2.tcl, and I think I turned it into strings, which get sent to axis.py (?) and then sent to axis.tcl
with that in mind, you can probably use your same code from the axis2.tcl in a usercommand file and send it this way, or you could do it in python
In the file ive attatched, just about everything is broken out so you can easily do your size and color configurations
linuxcnc.org/docs/devel/html/gui/axis.ht..._customization_hints
have a look at the user_live_update and the creating hal pins and you are half way there.
I dont know how you could do the gradient preview background, someone else might need to help you.
Personally for me, the time spent working in the usercommand file has payed dividends because I found it so fucking annoying having to patch axis every time I installed a new linuxcnc or did an update. The extra time/hassle for usercommand file was much worth the time saved doing not doing updates, with the added bonus of working with future and past versions of axis
The following user(s) said Thank You: tommylight, zack
Please Log in or Create an account to join the conversation.
31 May 2022 05:15 - 31 May 2022 05:16 #244263
by phillc54
Replied by phillc54 on topic Axis 2 - touchscreen version of old friend
For reading and writing preferences you could use similar to the following which creates a new instance of configparser to create a file in the config directory called <MACHINE_NAME>.prefs
Use a sane DEFAULT when reading then it will use that if there is no entry in the file.
Use a sane DEFAULT when reading then it will use that if there is no entry in the file.
Warning: Spoiler!
prefP = configparser.ConfigParser
class plasmacPreferences(prefP):
types = {bool: prefP.getboolean,
float: prefP.getfloat,
int: prefP.getint,
str: prefP.get,
repr: lambda self,section,option: eval(prefP.get(self,section,option)),
}
def __init__(self):
prefP.__init__(self, strict=False, interpolation=None)
self.fn = os.path.join(PATH, '{}.prefs'.format(vars.machine.get()))
self.read(self.fn)
def getPrefs(prefs, section, option, default=False, type=bool):
m = prefs.types.get(type)
if prefs.has_section(section.upper()):
if prefs.has_option(section, option):
return m(prefs, section.upper(), option)
else:
prefs.set(section.upper(), option, str(default))
prefs.write(open(prefs.fn, "w"))
return default
else:# print("no getPrefs section", section.upper())
prefs.add_section(section.upper())
prefs.set(section.upper(), option, str(default))
prefs.write(open(prefs.fn, "w"))
def putPrefs(prefs, section, option, value, type=bool):
if prefs.has_section(section.upper()):
prefs.set(section.upper(), option, str(type(value)))
prefs.write(open(prefs.fn, "w"))
else:
prefs.add_section(section.upper())
prefs.set(section.upper(), option, str(type(value)))
prefs.write(open(prefs.fn, "w"))
def removePrefsSect(prefs, section):
prefs.remove_section(section.upper())
prefs.write(open(prefs.fn, "w"))
PREFS = plasmacPreferences()
# write a setting to prefs SECTION, SETTING, VALUE, TYPE
putPrefs(PREFS, 'GUI', 'foreground color', fgColor, str)
# get a setting from prefs SECTION, SETTING, DEFAULT, TYPE
fgColor = getPrefs(PREFS, 'GUI', 'foreground color', '#FFEE00', str)
Last edit: 31 May 2022 05:16 by phillc54.
Please Log in or Create an account to join the conversation.
01 Jun 2022 03:19 #244341
by cakeslob
Replied by cakeslob on topic Axis 2 - touchscreen version of old friend
Not to derail zacks thread, but since it might be mutually beneficial for us both I will continue.Posting python without the indentations, cheeky lol, I found it a good exercise in understanding python. Thank you Phil, this is the first time Im using fancy python, but I think I got it
PATH = ""
prefP = configparser.ConfigParser
class plasmacPreferences(prefP):
types = {
bool: prefP.getboolean,
float: prefP.getfloat,
int: prefP.getint,
str: prefP.get,
repr: lambda self,section,option: eval(prefP.get(self,section,option)),
}
def __init__(self):
prefP.__init__(self, strict=False, interpolation=None)
self.fn = os.path.join(PATH, '{}.prefs'.format(vars.machine.get()))
self.read(self.fn)
def getPrefs(prefs, section, option, default=False, type=bool):
m = prefs.types.get(type)
if prefs.has_section(section.upper()):
if prefs.has_option(section, option):
return m(prefs, section.upper(), option)
else:
prefs.set(section.upper(), option, str(default))
prefs.write(open(prefs.fn, "w"))
return default
else:
print("no getPrefs section", section.upper())
prefs.add_section(section.upper())
prefs.set(section.upper(), option, str(default))
prefs.write(open(prefs.fn, "w"))
def putPrefs(prefs, section, option, value, type=bool):
if prefs.has_section(section.upper()):
prefs.set(section.upper(), option, str(type(value)))
prefs.write(open(prefs.fn, "w"))
else:
prefs.add_section(section.upper())
prefs.set(section.upper(), option, str(type(value)))
prefs.write(open(prefs.fn, "w"))
def removePrefsSect(prefs, section):
prefs.remove_section(section.upper())
prefs.write(open(prefs.fn, "w"))
PREFS = plasmacPreferences()
# write a setting to prefs SECTION, SETTING, VALUE, TYPE
PREFS.putPrefs('GUI', 'foreground color', 'red', str)
# get a setting from prefs SECTION, SETTING, DEFAULT, TYPE
fgColor = PREFS.getPrefs('GUI', 'foreground color', '#FFEE00', str)
[GUI]
foreground color = red
Please Log in or Create an account to join the conversation.
01 Jun 2022 05:18 #244345
by phillc54
Replied by phillc54 on topic Axis 2 - touchscreen version of old friend
Shoot, I didn't notice that. I am getting lazier and lazier...Posting python without the indentations, cheeky lol
![:) :)](/media/kunena/emoticons/smile.png)
Please Log in or Create an account to join the conversation.
01 Aug 2022 16:25 - 01 Nov 2022 17:28 #248797
by zack
Replied by zack on topic Axis 2 - touchscreen version of old friend
this works for me now thanks for the heads up
Last edit: 01 Nov 2022 17:28 by zack.
Please Log in or Create an account to join the conversation.
25 Sep 2022 18:05 #252719
by zack
Replied by zack on topic Axis 2 - touchscreen version of old friend
Updated for 2.9 with auto scaling for small 800x480 screens to 2k monitors.
Tommy - can you test on one of your super res monitors please?
keypress G or g - swipes the gcode pane
Space bar will auto power and home - be careful if u try on a live-machine
There is a custom menu for colors etc - give it a try please, its been stable for me on a few machines for the last 2 years, however have modded a few scaling features recently and update to 2.9 pre
set display = axis2 in your ini
as root ---
add icon content to /usr /share /axis /images
add axis2.tcl to /user /share /axis /tcl (don't forget to make it executable)
add axis2(py) to /usr /bin (exec privs)
and glcanon to /usr /lib /python3 /dist-packages /rs274 (also give exec privs)
Tommy - can you test on one of your super res monitors please?
keypress G or g - swipes the gcode pane
Space bar will auto power and home - be careful if u try on a live-machine
There is a custom menu for colors etc - give it a try please, its been stable for me on a few machines for the last 2 years, however have modded a few scaling features recently and update to 2.9 pre
set display = axis2 in your ini
as root ---
add icon content to /usr /share /axis /images
add axis2.tcl to /user /share /axis /tcl (don't forget to make it executable)
add axis2(py) to /usr /bin (exec privs)
and glcanon to /usr /lib /python3 /dist-packages /rs274 (also give exec privs)
The following user(s) said Thank You: tommylight, Masiwood123
Please Log in or Create an account to join the conversation.
- tommylight
-
- Away
- Moderator
-
Less
More
- Posts: 18563
- Thank you received: 6218
25 Sep 2022 19:30 - 25 Sep 2022 19:31 #252731
by tommylight
Replied by tommylight on topic Axis 2 - touchscreen version of old friend
I would test it gladly, but alas, no files... ![:) :)](/media/kunena/emoticons/smile.png)
Cr@p i just saw the files on the post above... need thicker glasses
![:) :)](/media/kunena/emoticons/smile.png)
Cr@p i just saw the files on the post above... need thicker glasses
Last edit: 25 Sep 2022 19:31 by tommylight.
Please Log in or Create an account to join the conversation.
- tommylight
-
- Away
- Moderator
-
Less
More
- Posts: 18563
- Thank you received: 6218
25 Sep 2022 19:46 #252733
by tommylight
Replied by tommylight on topic Axis 2 - touchscreen version of old friend
Attachments:
The following user(s) said Thank You: zack
Please Log in or Create an account to join the conversation.
25 Sep 2022 20:06 - 25 Sep 2022 20:11 #252736
by zack
Replied by zack on topic Axis 2 - touchscreen version of old friend
Wow thanx Tomma
I will have to do a larger scaling version for uhd and up,
Although I have never seen a touchscreen with more than full hd.
I do suspect some new tablets will be 2k soon and would be nice to run a small machine on a 10" touch screen with a pi
I am getting into Python suggested by cakeslob, maybe a good idea to do a configurator for axis to set menu size fonts and sliders Etc
Just for interest sake what dose axis look like at 4k, is it usable?
I will have to do a larger scaling version for uhd and up,
Although I have never seen a touchscreen with more than full hd.
I do suspect some new tablets will be 2k soon and would be nice to run a small machine on a 10" touch screen with a pi
I am getting into Python suggested by cakeslob, maybe a good idea to do a configurator for axis to set menu size fonts and sliders Etc
Just for interest sake what dose axis look like at 4k, is it usable?
Last edit: 25 Sep 2022 20:11 by zack.
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
- tommylight
-
- Away
- Moderator
-
Less
More
- Posts: 18563
- Thank you received: 6218
25 Sep 2022 20:59 #252739
by tommylight
Replied by tommylight on topic Axis 2 - touchscreen version of old friend
Attachments:
Please Log in or Create an account to join the conversation.
Time to create page: 0.401 seconds