keyboard.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2015 Airbus
00004 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00005 #
00006 # Licensed under the Apache License, Version 2.0 (the "License");
00007 # you may not use this file except in compliance with the License.
00008 # You may obtain a copy of the License at
00009 #
00010 #   http://www.apache.org/licenses/LICENSE-2.0
00011 #
00012 # Unless required by applicable law or agreed to in writing, software
00013 # distributed under the License is distributed on an "AS IS" BASIS,
00014 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 # See the License for the specific language governing permissions and
00016 # limitations under the License.
00017 
00018 
00019 import rospy
00020 import os
00021 import sys
00022 from roslib.packages import get_pkg_dir
00023 
00024 from python_qt_binding.QtGui import *
00025 from python_qt_binding.QtCore import *
00026 
00027 from python_qt_binding import loadUi
00028 
00029 from airbus_pyqt_extend.QtAgiCore import loadRsc
00030 
00031 rsc = loadRsc("airbus_pyqt_extend")
00032 
00033 class NumericFloatKeyboard(QDialog):
00034     
00035     def __init__(self, parent):
00036         QDialog.__init__(self, parent, Qt.FramelessWindowHint)
00037         
00038         self._parent = parent
00039         
00040         # Extend the widget with all attributes and children from UI file
00041         rsc.uis.load("keyboard", self)
00042         
00043         self.adjustSize()
00044         
00045         self.connect(self.nb1, SIGNAL("clicked()"), self.number_1)
00046         self.connect(self.nb2, SIGNAL("clicked()"), self.number_2)
00047         self.connect(self.nb3, SIGNAL("clicked()"), self.number_3)
00048         self.connect(self.nb4, SIGNAL("clicked()"), self.number_4)
00049         self.connect(self.nb5, SIGNAL("clicked()"), self.number_5)
00050         self.connect(self.nb6, SIGNAL("clicked()"), self.number_6)
00051         self.connect(self.nb7, SIGNAL("clicked()"), self.number_7)
00052         self.connect(self.nb8, SIGNAL("clicked()"), self.number_8)
00053         self.connect(self.nb9, SIGNAL("clicked()"), self.number_9)
00054         self.connect(self.nb0, SIGNAL("clicked()"), self.number_0)
00055         self.connect(self.point, SIGNAL("clicked()"), self.point_float)
00056         self.connect(self.clear, SIGNAL("clicked()"), self._clear)
00057         self.connect(self.clear, SIGNAL("toggled()"), self._clear_all)
00058         
00059         self.connect(self.ok, SIGNAL("clicked()"), self._ok)
00060         
00061         self.num_res.setText(self._parent.text())
00062         
00063     def number_1(self):
00064         self.num_res.setText(self.num_res.text()+'1')
00065         
00066     def number_2(self):
00067         self.num_res.setText(self.num_res.text()+'2')
00068         
00069     def number_3(self):
00070         self.num_res.setText(self.num_res.text()+'3')
00071         
00072     def number_4(self):
00073         self.num_res.setText(self.num_res.text()+'4')
00074         
00075     def number_5(self):
00076         self.num_res.setText(self.num_res.text()+'5')
00077         
00078     def number_6(self):
00079         self.num_res.setText(self.num_res.text()+'6')
00080         
00081     def number_7(self):
00082         self.num_res.setText(self.num_res.text()+'7')
00083         
00084     def number_8(self):
00085         self.num_res.setText(self.num_res.text()+'8')
00086         
00087     def number_9(self):
00088         self.num_res.setText(self.num_res.text()+'9')
00089         
00090     def number_0(self):
00091         self.num_res.setText(self.num_res.text()+'0')
00092         
00093     def point_float(self):
00094         self.num_res.setText(self.num_res.text()+'.')
00095         
00096     def _clear(self):
00097         self.num_res.setText(self.num_res.text()[:-1])
00098         
00099     def _clear_all(self):
00100         self.num_res.setText('')
00101         
00102     def _ok(self):
00103         self._parent.setText(self.num_res.text())
00104         self.close()
00105         
00106 class QAgiKeyboard:
00107     
00108     NumericInt   = 1
00109     NumericFloat = 2
00110     Alphanumeric = 3
00111     
00112     def __init__(self, parent, flag):
00113         
00114         if flag == self.NumericInt:
00115             pass
00116         elif flag == self.NumericFloat:
00117             keyboard = NumericFloatKeyboard(parent)
00118             keyboard.show()
00119         elif flag == self.Alphanumeric:
00120             pass
00121         
00122 ##@cond
00123 ##Unit test
00124 if __name__ == "__main__":
00125     
00126     import sys
00127     
00128     class Widget(QLineEdit):
00129         def __init__(self):
00130             QLineEdit.__init__(self)
00131         
00132         def mousePressEvent(self, event):
00133             QAgiKeyboard(self, QAgiKeyboard.NumericFloat)
00134     
00135     a = QApplication(sys.argv)
00136     utt_appli = QMainWindow()
00137     
00138     account_ui = Widget()
00139     
00140     utt_appli.setCentralWidget(Widget())
00141     
00142     utt_appli.show()
00143     a.exec_()
00144 #@endcond
00145 
00146 #End of file


airbus_pyqt_extend
Author(s): Martin Matignon
autogenerated on Thu Jun 6 2019 17:59:16