kcgwidget.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. .. This is a autogemerated documentation from python docstrings. It was generated using DStrings2Doc.
  2. .. module:: kcgwidget
  3. .. _kcgwidget:
  4. Module kcgwidget
  5. ================
  6. Base Classes used in KCG.
  7. This module also contains various helpful Classes to make live easier ;)
  8. .. py:method:: tr(_, x)
  9. Dummy Translation method that does not translate
  10. :param _: unused
  11. :param x: the string to "translate"
  12. :return: x
  13. .. py:class:: BigIconButton(QtGui.QPushButton)
  14. This is a Button with a big Icon (that can fill the whole button)
  15. .. py:method:: __init__(self, path, width, height, connect=None, tooltip=None, parent=None)
  16. Setting various properties
  17. :param path: (str) the path to the icon
  18. :param width: (int) with of the button
  19. :param height: (int) height of the button
  20. :param connect: (callable) function to call when button is pressed
  21. :param tooltip: (str) tool tip to show
  22. :param parent: (QWidget) parent widget.
  23. .. py:class:: clickLabel(QtGui.QLabel)
  24. Clickable Label
  25. .. py:method:: mouseReleaseEvent(self, QMouseEvent)
  26. Reimplementation of QLabel.mouseReleaseEvent to make this clickable
  27. .. py:class:: ClickableHBoxLayout(QtGui.QHBoxLayout)
  28. A clickable HBoxLayout
  29. .. py:method:: event(self, QEvent)
  30. Reimplementation of QHBoxLayout.event to make it clickable
  31. .. py:class:: switchLabel(QtGui.QLabel)
  32. This implements a Switch.
  33. It switches between left and right.
  34. .. py:method:: __init__(self, startRight=False):
  35. Initialise switchLabel
  36. As a normal Button it emits the clicked event when clicked.
  37. It does NOT have two events for each side at the moment.
  38. :param startRight: (bool) whether the switch is initially set to the right position (default is left (False))
  39. .. py:method:: mouseReleaseEvent(self, QMouseEvent)
  40. Reimplementation of QLabel.mouseReleaseEvent to make it clickable
  41. .. py:class:: Switch(QtGui.QWidget)
  42. A Simple Switch
  43. .. py:method:: __init__(self, leftLabel, rightLabel, startRight=False)
  44. .. py:method:: state(self)
  45. Get the state of this switch
  46. :return: the state of this switch
  47. .. py:class:: ClickableSVG(QtGui.QWidget)
  48. This implements a clickable SVG Image
  49. .. py:method:: __init__(self, path, width, height, wwidth=None, wheight=None, parent=None)
  50. Initialisation of ClickabeSVG
  51. :param path: (str) path to the svg file
  52. :param width: (int) width of the svg
  53. :param height: (int) height of the svg
  54. :param wwidth: (int) width of the widget (not the svg)
  55. :param wheight: (int) height of the widget (not the svg)
  56. :param parent: (QWidget) parent widget of the ClickableSVG
  57. .. py:method:: mouseReleaseEvent(self, QMouseEvent)
  58. Reimplementation of QWidget.mouseReleaseEvent to make it clickable
  59. .. py:method:: changeSvg(self, path)
  60. Change the SVG of this widget
  61. :param path: (str) path to the new svg file
  62. .. py:class:: KCGWidgets(QtGui.QWidget)
  63. Base Class for alsmost all Widgets used in KCG.
  64. It holds various properties as well as methods that simplify creation of certain objects such as labels, buttons ...
  65. .. py:method:: __init__(self, name=None, parent=None)
  66. Initialise this baseclass
  67. :param name: (str) name of the widget
  68. :param parent: (QWidget) parent of this widget
  69. .. py:method:: theType(self)
  70. Type of this widget
  71. .. py:method:: theId(self)
  72. ID of this widget
  73. .. py:method:: theName(self)
  74. Name of this widget
  75. .. py:method:: theType(self, t)
  76. Setter for the type of this widget
  77. :param t: (int) type
  78. .. py:method:: theId(self, i)
  79. Setter for the id of this widget
  80. :param i: (int) id
  81. .. py:method:: theName(self, n)
  82. Setter for the name of this widget
  83. :param n: (str) name
  84. .. py:method:: createButton(self, text="", x=None, y=None, dimensions=None, tooltip="", connect=False, icon=None)
  85. Create a Button
  86. :param text: (str) Text to display on the button
  87. :param x: (int) x-position
  88. :param y: (int) y-position
  89. :param dimensions: (QSize) dimensions of the button
  90. :param tooltip: (str) tooltip to display
  91. :param connect: (callable) connect the button pressed event to this callable
  92. :param icon: (QIcon) Icon to display on the button
  93. .. py:method:: createLabel(self, text=None, image=None, tooltip=None, click=False, connect=None)
  94. Create a Label
  95. :param text: (str) Text to display on this label
  96. :param image: (QPixmap) Image to display on this label
  97. :param tooltip: (str) tooltip to display
  98. :param click: (bool) make this a clickable label?
  99. :param connect: (callable) if click is true, connect the clicked event to this callable
  100. .. py:method:: createSpinbox(self, min, max, interval=1, start_value=0, connect=None)
  101. create a Spinbox
  102. :param min: (int) minimum Value
  103. :param max: (int) maximum Value
  104. :param interval: (int) interval
  105. :param start_value: (int) start Value
  106. :param connect: (callable) function to call on value change
  107. .. py:method:: createInput(self, text=None, read_only=False, width=None)
  108. Create Input
  109. :param text: (str) Default Text
  110. :param read_only: (bool) set input as read only
  111. :param width: (int) width of the input field in pixels
  112. .. py:method:: createCheckbox(self, text="", tooltip="", checked=False, connect=None)
  113. Create Checkbox
  114. :param tooltip: (str) what tooltip text to display
  115. :param checked: (bool) Checkt as default?
  116. :param connect: (callable) function to connect
  117. .. py:method:: createSwitch(self, startRight=False, connect=None)
  118. Create a Switch
  119. :param startRight: (bool) if this is True the initial setting is set to right (default is left)
  120. :param connect: (callable) connect the switches clicked event to this callable
  121. .. py:method:: closeEvent(self, event)
  122. Reimplementation of QWidget.closeEvent
  123. .. py:class:: KCGSubWidget(QtGui.QMdiSubWindow)
  124. Base Class for Subwindows in the KCG Gui
  125. .. py:method:: __init__(self, name=None, unique_id=None, typ=None, minSize=False)
  126. Initialise a Subwindow
  127. :param name: (str) name of this window
  128. :param unique_id: (int) unique id of this window
  129. :param typ: (int) type of this window
  130. :param minSize: (bool) whether the window is to be resized to its minimum size
  131. .. py:method:: theType(self)
  132. Type of this widget
  133. .. py:method:: theId(self)
  134. ID of this widget
  135. .. py:method:: theName(self)
  136. Name of this widget
  137. .. py:method:: theType(self, t)
  138. Setter for the type of this widget
  139. :param t: (int) type
  140. .. py:method:: theId(self, i)
  141. Setter for the id of this widget
  142. :param i: (int) id
  143. .. py:method:: theName(self, n)
  144. Setter for the name of this widget
  145. :param n: (str) name
  146. .. py:class:: AccordionClickLine(QtGui.QWidget)
  147. A simple clickable line used in the accordion widget below
  148. .. py:method:: __init__(self, text)
  149. .. py:method:: mouseReleaseEvent(self, QMouseEvent)
  150. Reimplementation of QWidget.mouseReleaseEvent to make it clickable
  151. .. py:method:: expand(self, state)
  152. Expand or deexpand the Accordion entry
  153. :param state: True to expand False to deexpand
  154. .. py:class:: AccordionWidget(QtGui.QWidget):
  155. Simple accordion widget similar to QToolBox
  156. .. py:method:: __init__(self)
  157. Initialise the accordion widget
  158. .. py:method:: resizeEvent(self, QResizeEvent)
  159. Reimplementation of QWidget.resizeEvent to make it look nice
  160. .. py:method:: addItem(self, widget, text)
  161. Add a Widget to the Accordion widget
  162. :param widget: the widget to add
  163. :param text: the text for this widget
  164. .. py:method:: toggleIndex(self, index)
  165. Toggle the visibility of the widget with index index
  166. :param index: the index to toggle
  167. .. py:method:: expandIndex(self, index)
  168. Expand the widget with index index
  169. :param index: the index of the widget to show
  170. .. py:method:: hideIndex(self, index)
  171. Hide the widget with the index index
  172. :param index: the index of the widget to hide
  173. .. py:method:: hideAll(self)
  174. Hide all widgets
  175. .. py:method:: showAll(self)
  176. Show all widgets
  177. .. py:class:: MultilineInputDialog(QtGui.QDialog)
  178. Multiline Input Dialog
  179. When using this dialog, create is and open it with get_text. this also returns the entered text.
  180. .. py:method:: __init__(self)
  181. .. py:method:: fill(self, heading, label)
  182. Fill the widget with elements
  183. :param heading: (str) the heading of this widget
  184. :param label: (str) the text to show above the input field
  185. .. py:method:: ok(self)
  186. This gets executed when the ok button is pressed
  187. .. py:method:: cancel(self)
  188. This gets executed when the cancel button is pressed
  189. .. py:method:: get_text(self, heading, label)
  190. This function is the main entry point.
  191. :param heading: (str) the heading of the widget
  192. :param label: (str) the text to show above the input field
  193. :return: (unicode) the entered text
  194. .. py:class:: IdGenerator()
  195. Generate Unique Id for every subwindow
  196. .. py:method:: genid(self)
  197. Generate a new Id
  198. .. py:method:: register_widget_creation_function(creation_func)
  199. Register the function to create a certain widget
  200. :param creation_func: (callable) function to call when the widget is to be created
  201. .. py:method:: register_widget(icon, text, target, shortcut=None)
  202. Register a widget
  203. :param icon: (QIcon) Icon to show on the toolbar button
  204. :param text: (str) tooltip for the toolbar button
  205. :param target: (callable) the function to create the widget
  206. :param shortcut: (str) keyboard shortcut to open this widget
  207. .. py:method:: get_registered_widgets()
  208. Get the registered widgets
  209. :return: (list) list of registered widgets
  210. .. py:method:: get_registered_widget_functions()
  211. Get the functions that are registered
  212. :return: (list) list of functions
  213. .. py:method:: error(code, text, severe=False)
  214. Log an error using the logging module
  215. :param code: the error code
  216. :param text: the text to show
  217. :param severe: if it is a severe error that has to quit the program