main.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. '''
  2. This program is free software: you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation, either version 3 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>.
  12. '''
  13. #! /usr/bin/env python
  14. # -*- coding: utf-8 -*-
  15. #
  16. import sys
  17. from PyQt4.QtGui import *
  18. def create_button(window, text, tool_tip, func, x, y, w, h):
  19. btn = QPushButton(text, window)
  20. btn.setToolTip(tool_tip)
  21. btn.clicked.connect(func)
  22. btn.move(x, y)
  23. btn.resize(w, h)
  24. return btn
  25. def set_clipboard_fun_factory(sym):
  26. def f():
  27. QApplication.clipboard().setText(sym)
  28. return f
  29. APL_Symbols = ['¯', '×', '÷', '∘',
  30. '∣', '∼', '≠', '≤', '≥', '≬', '⌶',
  31. '⋆', '⌾', '⍟', '⌽', '⍉', '⍝', '⍦',
  32. '⍧', '⍪', '⍫', '⍬','⍭', '←', '↑',
  33. '→', '↓', '∆', '∇', '∧', '∨', '∩',
  34. '∪', '⌈', '⌊', '⊤', '⊥', '⊂', '⊃',
  35. '⌿', '⍀', '⍅', '⍆', '⍏', '⍖', '⍊',
  36. '⍑', '⍋', '⍒', '⍎', '⍕', '⍱', '⍲',
  37. '○', '⍳', '⍴', '⍵', '⍺', '⍶', '⍷',
  38. '⍸', '⍹', '⍘', '⍙', '⍚', '⍛', '⍜',
  39. '⍮', '¨', '⍡', '⍢', '⍣', '⍤', '⍥',
  40. '⍨', '⍩', '⎕', '⍞', '⍠', '⍯', '⍰',
  41. '⍌', '⍍', '⍐', '⍓', '⍔', '⍗', '⌷',
  42. '⌸', '⌹', '⌺', '⌻', '⌼', '⍁', '⍂',
  43. '⍃', '⍄', '⍇', '⍈' ]
  44. app = QApplication(sys.argv)
  45. win_height = 832
  46. win_width = 512
  47. win = QWidget()
  48. win.resize(win_height, win_width)
  49. win.setWindowTitle("APL keyboard")
  50. font = QFont(u'Times', 32, QFont.Bold, True)
  51. buttons = []
  52. x_pos = 0
  53. y_pos = 0
  54. for index, sym in enumerate(APL_Symbols):
  55. if x_pos >= win_height:
  56. x_pos = 0
  57. y_pos += 64
  58. buttons.append
  59. (create_button(win, sym, 'Copy to clipboard',
  60. set_clipboard_fun_factory(sym),
  61. x_pos, y_pos, 64, 64).setFont(font))
  62. x_pos += 64
  63. win.show()
  64. sys.exit(app.exec_())