dodalem testowy main user tab
This commit is contained in:
@@ -3,10 +3,13 @@ import linuxcnc
|
|||||||
|
|
||||||
from qtpy import uic
|
from qtpy import uic
|
||||||
from qtpy.QtCore import Qt
|
from qtpy.QtCore import Qt
|
||||||
from qtpy.QtWidgets import QWidget
|
from qtpy.QtWidgets import QWidget, QLabel, QPushButton
|
||||||
|
|
||||||
from qtpyvcp.plugins import getPlugin
|
from qtpyvcp.plugins import getPlugin
|
||||||
|
from qtpyvcp.widgets.button_widgets.led_button import LEDButton
|
||||||
|
from qtpyvcp.widgets.input_widgets.jog_increment import JogIncrementWidget
|
||||||
from qtpyvcp.utilities import logger
|
from qtpyvcp.utilities import logger
|
||||||
|
from qtpyvcp.utilities.settings import getSetting, setSetting
|
||||||
|
|
||||||
LOG = logger.getLogger(__name__)
|
LOG = logger.getLogger(__name__)
|
||||||
|
|
||||||
@@ -16,8 +19,63 @@ TOOL_TABLE = getPlugin('tooltable')
|
|||||||
INI_FILE = linuxcnc.ini(os.getenv('INI_FILE_NAME'))
|
INI_FILE = linuxcnc.ini(os.getenv('INI_FILE_NAME'))
|
||||||
|
|
||||||
|
|
||||||
|
from qtpyvcp.utilities.info import Info
|
||||||
|
INFO = Info()
|
||||||
|
|
||||||
|
|
||||||
class UserTab(QWidget):
|
class UserTab(QWidget):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(UserTab, self).__init__(parent)
|
super(UserTab, self).__init__(parent)
|
||||||
ui_file = os.path.splitext(os.path.basename(__file__))[0] + ".ui"
|
ui_file = os.path.splitext(os.path.basename(__file__))[0] + ".ui"
|
||||||
uic.loadUi(os.path.join(os.path.dirname(__file__), ui_file), self)
|
uic.loadUi(os.path.join(os.path.dirname(__file__), ui_file), self)
|
||||||
|
|
||||||
|
# Clear any widgets added in the UI file
|
||||||
|
while self.verticalLayout.count():
|
||||||
|
child = self.verticalLayout.takeAt(0)
|
||||||
|
if child.widget():
|
||||||
|
child.widget().deleteLater()
|
||||||
|
|
||||||
|
# Get all available jog increments and create a label for each
|
||||||
|
increments = INFO.getIncrements()
|
||||||
|
for increment in increments:
|
||||||
|
label = QLabel(f"Increment: {increment}")
|
||||||
|
self.verticalLayout.addWidget(label)
|
||||||
|
|
||||||
|
# Add the two buttons
|
||||||
|
left_button = QPushButton("Lewo")
|
||||||
|
right_button = QPushButton("Prawo")
|
||||||
|
self.verticalLayout.addWidget(left_button)
|
||||||
|
self.verticalLayout.addWidget(right_button)
|
||||||
|
|
||||||
|
# Connect button signals to their respective slots
|
||||||
|
left_button.clicked.connect(self.left_btn_clicked)
|
||||||
|
right_button.clicked.connect(self.right_btn_clicked)
|
||||||
|
|
||||||
|
# Add a spacer to push all widgets to the top
|
||||||
|
self.verticalLayout.addStretch(1)
|
||||||
|
|
||||||
|
|
||||||
|
LOG.info("Initialized bartek")
|
||||||
|
self.find_jog_buttons(parent)
|
||||||
|
|
||||||
|
def left_btn_clicked(self):
|
||||||
|
LOG.info("Lewo button clicked")
|
||||||
|
setSetting('machine.jog.increment', '10mm')
|
||||||
|
|
||||||
|
def right_btn_clicked(self):
|
||||||
|
LOG.info("Prawo button clicked", )
|
||||||
|
setSetting('machine.jog.increment', '1mm')
|
||||||
|
|
||||||
|
def find_jog_buttons(self, parent):
|
||||||
|
if parent is None:
|
||||||
|
LOG.warning("Parent widget is None")
|
||||||
|
return
|
||||||
|
jog = parent.findChild(JogIncrementWidget)
|
||||||
|
if jog is None:
|
||||||
|
LOG.warning("JogIncrement widget not found in parent")
|
||||||
|
return
|
||||||
|
self.jog_buttons = jog.findChildren(LEDButton)
|
||||||
|
if not self.jog_buttons:
|
||||||
|
LOG.warning("No LEDButton widgets found in JogIncrement")
|
||||||
|
return
|
||||||
|
LOG.info(f"Found {len(self.jog_buttons)} jog buttons")
|
||||||
@@ -22,6 +22,28 @@
|
|||||||
<property name="sidebar" stdset="0">
|
<property name="sidebar" stdset="0">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="jog_display_label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Jog Increment: --</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|||||||
Reference in New Issue
Block a user