qiskit_classroom.input_view
Widget for converting informations
1"""Widget for converting informations""" 2 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19 20# pylint: disable=no-name-in-module 21from PySide6.QtGui import QDragEnterEvent, QDropEvent 22from PySide6.QtWidgets import ( 23 QWidget, 24 QVBoxLayout, 25 QHBoxLayout, 26 QLabel, 27 QLineEdit, 28 QPlainTextEdit, 29 QPushButton, 30 QFileDialog, 31 QCheckBox, 32) 33from PySide6.QtCore import Qt, Signal 34 35from .expression_enum import QuantumExpression 36from .input_model import Input, QuantumCircuitInput, DiracInput, MatrixInput 37 38 39EXPRESSION_PLACEHOLDERS: dict[QuantumExpression:str] = { 40 QuantumExpression.CIRCUIT: """from qiskit import QuantumCircuit 41quantum_circuit = QuantumCircuit(2, 2) 42quantum_circuit.x(0) 43quantum_circuit.cx(0, 1) 44""", 45 QuantumExpression.DIRAC: "sqrt(2)*|00>/2+sqrt(2)*|11>/2", 46 QuantumExpression.MATRIX: """[[1, 0, 0, 0], 47[0, 0, 0, 1], 48[0, 0, 1, 0], 49[0, 1, 0, 0]]""", 50 QuantumExpression.NONE: "", 51} 52 53 54class ExpressionPlainText(QPlainTextEdit): 55 """ 56 ExpressionPlainText 57 """ 58 59 file_dropped = Signal(object) 60 61 def __init__(self, parent) -> None: 62 super().__init__(parent=parent) 63 self.setAcceptDrops(True) 64 self.set_ui() 65 66 def set_ui(self) -> None: 67 """ 68 set UI 69 """ 70 self.setFixedHeight(250) 71 72 def dragEnterEvent(self, event: QDragEnterEvent) -> None: 73 # pylint: disable=invalid-name 74 """ 75 handle drag event and accept only url 76 """ 77 if event.mimeData().hasUrls(): 78 event.accept() 79 else: 80 event.ignore() 81 82 def dropEvent(self, event: QDropEvent) -> None: 83 # pylint: disable=invalid-name 84 """ 85 handle drop event and emit file imported event 86 """ 87 if event.mimeData().hasUrls(): 88 files = [u.toLocalFile() for u in event.mimeData().urls()] 89 self.file_dropped.emit(files) 90 event.accept() 91 92 def set_placeholder_text(self, expression: QuantumExpression) -> None: 93 """set placeholder for expression plain text 94 95 Args: 96 expression (QuantumExpression): selection 97 """ 98 self.setPlaceholderText("") 99 self.setPlaceholderText(EXPRESSION_PLACEHOLDERS[expression]) 100 101 102class InputWidget(QWidget): 103 """Widget group for certain input""" 104 105 def set_ui(self) -> None: 106 """show widgets""" 107 108 def get_input(self) -> Input: 109 """return user input 110 111 Returns: 112 Input: user input class 113 """ 114 return Input 115 116 117class QuantumCircuitInputWidget(InputWidget): 118 """Widget group for QuantumCircuit Input""" 119 120 file_imported = Signal(str) 121 122 def __init__(self, parent: QWidget) -> None: 123 super().__init__(parent) 124 self.set_ui() 125 126 def set_ui(self): 127 """set ui for QuantumCircuitInputWidget""" 128 vbox = QVBoxLayout(self) 129 vbox.setAlignment(Qt.AlignmentFlag.AlignCenter) 130 131 value_name_box = QHBoxLayout() 132 value_name_label = QLabel("value name") 133 value_name_box.addWidget(value_name_label) 134 self.value_name_text = QLineEdit() 135 self.value_name_text.setPlaceholderText("input value name of quantum circuit") 136 value_name_box.addWidget(self.value_name_text) 137 138 load_box = QHBoxLayout() 139 load_box.addStretch() 140 self.load_push_button = QPushButton("or load...") 141 self.load_push_button.setMinimumWidth(150) 142 self.load_push_button.clicked.connect(self.on_file_load_clicked) 143 load_box.addWidget(self.load_push_button) 144 145 vbox.addLayout(value_name_box) 146 vbox.addLayout(load_box) 147 148 def on_file_load_clicked(self) -> None: 149 """ 150 handling file dialog 151 """ 152 filename = QFileDialog.getOpenFileName( 153 self, "Open .py", "", "python3 script (*.py)" 154 )[0] 155 self.file_imported.emit(filename) 156 157 def get_input(self) -> QuantumCircuitInput: 158 user_input = QuantumCircuitInput( 159 self.value_name_text.text().strip(), 160 ) 161 return user_input 162 163 164class DiracInputWidget(InputWidget): 165 """Widget group for Dirac Notaion input""" 166 167 def __init__(self, parent: QWidget) -> None: 168 super().__init__(parent) 169 self.set_ui() 170 171 def get_input(self) -> DiracInput: 172 return DiracInput() 173 174 175class MatrixInputWidget(InputWidget): 176 """Widget group for matrix input""" 177 178 matrix_plain_text: QPlainTextEdit 179 num_cubit_text: QLineEdit 180 do_measure_checkbox: QCheckBox 181 182 def __init__(self, parent: QWidget) -> None: 183 super().__init__(parent) 184 self.set_ui() 185 186 def set_ui(self): 187 vbox = QVBoxLayout(self) 188 vbox.setAlignment(Qt.AlignmentFlag.AlignCenter) 189 190 hbox = QHBoxLayout() 191 num_cubit_label = QLabel("number of cubit") 192 self.num_cubit_text = QLineEdit(self) 193 self.num_cubit_text.setToolTip("input 3 digits number") 194 self.do_measure_checkbox = QCheckBox("do measure this circuit?", self) 195 self.do_measure_checkbox.setToolTip("do measure all qubits") 196 197 hbox.addWidget(num_cubit_label) 198 hbox.addWidget(self.num_cubit_text) 199 hbox.addWidget(self.do_measure_checkbox) 200 vbox.addLayout(hbox) 201 202 def get_input(self) -> Input: 203 return MatrixInput( 204 int(self.num_cubit_text.text()), self.do_measure_checkbox.isChecked() 205 )
55class ExpressionPlainText(QPlainTextEdit): 56 """ 57 ExpressionPlainText 58 """ 59 60 file_dropped = Signal(object) 61 62 def __init__(self, parent) -> None: 63 super().__init__(parent=parent) 64 self.setAcceptDrops(True) 65 self.set_ui() 66 67 def set_ui(self) -> None: 68 """ 69 set UI 70 """ 71 self.setFixedHeight(250) 72 73 def dragEnterEvent(self, event: QDragEnterEvent) -> None: 74 # pylint: disable=invalid-name 75 """ 76 handle drag event and accept only url 77 """ 78 if event.mimeData().hasUrls(): 79 event.accept() 80 else: 81 event.ignore() 82 83 def dropEvent(self, event: QDropEvent) -> None: 84 # pylint: disable=invalid-name 85 """ 86 handle drop event and emit file imported event 87 """ 88 if event.mimeData().hasUrls(): 89 files = [u.toLocalFile() for u in event.mimeData().urls()] 90 self.file_dropped.emit(files) 91 event.accept() 92 93 def set_placeholder_text(self, expression: QuantumExpression) -> None: 94 """set placeholder for expression plain text 95 96 Args: 97 expression (QuantumExpression): selection 98 """ 99 self.setPlaceholderText("") 100 self.setPlaceholderText(EXPRESSION_PLACEHOLDERS[expression])
QPlainTextEdit(self, parent: Optional[PySide6.QtWidgets.QWidget] = None) -> None QPlainTextEdit(self, text: str, parent: Optional[PySide6.QtWidgets.QWidget] = None) -> None
62 def __init__(self, parent) -> None: 63 super().__init__(parent=parent) 64 self.setAcceptDrops(True) 65 self.set_ui()
__init__(self, parent: Optional[PySide6.QtWidgets.QWidget] = None) -> None __init__(self, text: str, parent: Optional[PySide6.QtWidgets.QWidget] = None) -> None
Initialize self. See help(type(self)) for accurate signature.
73 def dragEnterEvent(self, event: QDragEnterEvent) -> None: 74 # pylint: disable=invalid-name 75 """ 76 handle drag event and accept only url 77 """ 78 if event.mimeData().hasUrls(): 79 event.accept() 80 else: 81 event.ignore()
handle drag event and accept only url
83 def dropEvent(self, event: QDropEvent) -> None: 84 # pylint: disable=invalid-name 85 """ 86 handle drop event and emit file imported event 87 """ 88 if event.mimeData().hasUrls(): 89 files = [u.toLocalFile() for u in event.mimeData().urls()] 90 self.file_dropped.emit(files) 91 event.accept()
handle drop event and emit file imported event
93 def set_placeholder_text(self, expression: QuantumExpression) -> None: 94 """set placeholder for expression plain text 95 96 Args: 97 expression (QuantumExpression): selection 98 """ 99 self.setPlaceholderText("") 100 self.setPlaceholderText(EXPRESSION_PLACEHOLDERS[expression])
set placeholder for expression plain text
Args: expression (QuantumExpression): selection
Inherited Members
- PySide6.QtWidgets.QPlainTextEdit
- anchorAt
- appendHtml
- appendPlainText
- backgroundVisible
- blockBoundingGeometry
- blockBoundingRect
- blockCount
- canInsertFromMimeData
- canPaste
- centerCursor
- centerOnScroll
- changeEvent
- clear
- contentOffset
- contextMenuEvent
- copy
- createMimeDataFromSelection
- createStandardContextMenu
- currentCharFormat
- cursorForPosition
- cursorRect
- cursorWidth
- cut
- doSetTextCursor
- document
- documentTitle
- dragLeaveEvent
- dragMoveEvent
- ensureCursorVisible
- event
- extraSelections
- find
- firstVisibleBlock
- focusInEvent
- focusNextPrevChild
- focusOutEvent
- getPaintContext
- inputMethodEvent
- inputMethodQuery
- insertFromMimeData
- insertPlainText
- isReadOnly
- isUndoRedoEnabled
- keyPressEvent
- keyReleaseEvent
- lineWrapMode
- loadResource
- maximumBlockCount
- mergeCurrentCharFormat
- mouseDoubleClickEvent
- mouseMoveEvent
- mousePressEvent
- mouseReleaseEvent
- moveCursor
- overwriteMode
- paintEvent
- paste
- placeholderText
- print_
- redo
- resizeEvent
- scrollContentsBy
- selectAll
- setBackgroundVisible
- setCenterOnScroll
- setCurrentCharFormat
- setCursorWidth
- setDocument
- setDocumentTitle
- setExtraSelections
- setLineWrapMode
- setMaximumBlockCount
- setOverwriteMode
- setPlaceholderText
- setPlainText
- setReadOnly
- setTabChangesFocus
- setTabStopDistance
- setTextCursor
- setTextInteractionFlags
- setUndoRedoEnabled
- setWordWrapMode
- showEvent
- tabChangesFocus
- tabStopDistance
- textCursor
- textInteractionFlags
- timerEvent
- toPlainText
- undo
- wheelEvent
- wordWrapMode
- zoomIn
- zoomInF
- zoomOut
- LineWrapMode
- selectionChanged
- undoAvailable
- modificationChanged
- copyAvailable
- redoAvailable
- blockCountChanged
- textChanged
- cursorPositionChanged
- updateRequest
- PySide6.QtWidgets.QAbstractScrollArea
- addScrollBarWidget
- cornerWidget
- eventFilter
- horizontalScrollBar
- horizontalScrollBarPolicy
- maximumViewportSize
- minimumSizeHint
- scrollBarWidgets
- setCornerWidget
- setHorizontalScrollBar
- setHorizontalScrollBarPolicy
- setSizeAdjustPolicy
- setVerticalScrollBar
- setVerticalScrollBarPolicy
- setViewport
- setViewportMargins
- setupViewport
- sizeAdjustPolicy
- sizeHint
- verticalScrollBar
- verticalScrollBarPolicy
- viewport
- viewportEvent
- viewportMargins
- viewportSizeHint
- SizeAdjustPolicy
- PySide6.QtWidgets.QFrame
- drawFrame
- frameRect
- frameShadow
- frameShape
- frameStyle
- frameWidth
- initStyleOption
- lineWidth
- midLineWidth
- setFrameRect
- setFrameShadow
- setFrameShape
- setFrameStyle
- setLineWidth
- setMidLineWidth
- Shape
- Shadow
- StyleMask
- PySide6.QtWidgets.QWidget
- acceptDrops
- accessibleDescription
- accessibleName
- actionEvent
- actions
- activateWindow
- addAction
- addActions
- adjustSize
- autoFillBackground
- backgroundRole
- backingStore
- baseSize
- childAt
- childrenRect
- childrenRegion
- clearFocus
- clearMask
- close
- closeEvent
- contentsMargins
- contentsRect
- contextMenuPolicy
- create
- createWinId
- createWindowContainer
- cursor
- destroy
- devType
- effectiveWinId
- ensurePolished
- enterEvent
- focusNextChild
- focusPolicy
- focusPreviousChild
- focusProxy
- focusWidget
- font
- fontInfo
- fontMetrics
- foregroundRole
- frameGeometry
- frameSize
- geometry
- grab
- grabGesture
- grabKeyboard
- grabMouse
- grabShortcut
- graphicsEffect
- graphicsProxyWidget
- hasFocus
- hasHeightForWidth
- hasMouseTracking
- hasTabletTracking
- height
- heightForWidth
- hide
- hideEvent
- initPainter
- inputMethodHints
- insertAction
- insertActions
- internalWinId
- isActiveWindow
- isAncestorOf
- isEnabled
- isEnabledTo
- isFullScreen
- isHidden
- isLeftToRight
- isMaximized
- isMinimized
- isModal
- isRightToLeft
- isTopLevel
- isVisible
- isVisibleTo
- isWindow
- isWindowModified
- keyboardGrabber
- layout
- layoutDirection
- leaveEvent
- locale
- lower
- mapFrom
- mapFromGlobal
- mapFromParent
- mapTo
- mapToGlobal
- mapToParent
- mask
- maximumHeight
- maximumSize
- maximumWidth
- metric
- minimumHeight
- minimumSize
- minimumWidth
- mouseGrabber
- move
- moveEvent
- nativeEvent
- nativeParentWidget
- nextInFocusChain
- normalGeometry
- overrideWindowFlags
- overrideWindowState
- paintEngine
- palette
- parentWidget
- pos
- previousInFocusChain
- raise_
- rect
- redirected
- releaseKeyboard
- releaseMouse
- releaseShortcut
- removeAction
- render
- repaint
- resize
- restoreGeometry
- saveGeometry
- screen
- scroll
- setAcceptDrops
- setAccessibleDescription
- setAccessibleName
- setAttribute
- setAutoFillBackground
- setBackgroundRole
- setBaseSize
- setContentsMargins
- setContextMenuPolicy
- setCursor
- setDisabled
- setEnabled
- setFixedHeight
- setFixedSize
- setFixedWidth
- setFocus
- setFocusPolicy
- setFocusProxy
- setFont
- setForegroundRole
- setGeometry
- setGraphicsEffect
- setHidden
- setInputMethodHints
- setLayout
- setLayoutDirection
- setLocale
- setMask
- setMaximumHeight
- setMaximumSize
- setMaximumWidth
- setMinimumHeight
- setMinimumSize
- setMinimumWidth
- setMouseTracking
- setPalette
- setParent
- setScreen
- setShortcutAutoRepeat
- setShortcutEnabled
- setSizeIncrement
- setSizePolicy
- setStatusTip
- setStyle
- setStyleSheet
- setTabOrder
- setTabletTracking
- setToolTip
- setToolTipDuration
- setUpdatesEnabled
- setVisible
- setWhatsThis
- setWindowFilePath
- setWindowFlag
- setWindowFlags
- setWindowIcon
- setWindowIconText
- setWindowModality
- setWindowModified
- setWindowOpacity
- setWindowRole
- setWindowState
- setWindowTitle
- show
- showFullScreen
- showMaximized
- showMinimized
- showNormal
- size
- sizeIncrement
- sizePolicy
- stackUnder
- statusTip
- style
- styleSheet
- tabletEvent
- testAttribute
- toolTip
- toolTipDuration
- topLevelWidget
- underMouse
- ungrabGesture
- unsetCursor
- unsetLayoutDirection
- unsetLocale
- update
- updateGeometry
- updateMicroFocus
- updatesEnabled
- visibleRegion
- whatsThis
- width
- winId
- window
- windowFilePath
- windowFlags
- windowHandle
- windowIcon
- windowIconText
- windowModality
- windowOpacity
- windowRole
- windowState
- windowTitle
- windowType
- x
- y
- RenderFlag
- windowIconTextChanged
- windowIconChanged
- windowTitleChanged
- customContextMenuRequested
- PySide6.QtCore.QObject
- blockSignals
- childEvent
- children
- connect
- connectNotify
- customEvent
- deleteLater
- disconnect
- disconnectNotify
- dumpObjectInfo
- dumpObjectTree
- dynamicPropertyNames
- emit
- findChild
- findChildren
- inherits
- installEventFilter
- isQuickItemType
- isSignalConnected
- isWidgetType
- isWindowType
- killTimer
- metaObject
- moveToThread
- objectName
- parent
- property
- receivers
- removeEventFilter
- sender
- senderSignalIndex
- setObjectName
- setProperty
- signalsBlocked
- startTimer
- thread
- tr
- destroyed
- objectNameChanged
- PySide6.QtGui.QPaintDevice
- colorCount
- depth
- devicePixelRatio
- devicePixelRatioF
- devicePixelRatioFScale
- heightMM
- logicalDpiX
- logicalDpiY
- paintingActive
- physicalDpiX
- physicalDpiY
- widthMM
- painters
- PaintDeviceMetric
103class InputWidget(QWidget): 104 """Widget group for certain input""" 105 106 def set_ui(self) -> None: 107 """show widgets""" 108 109 def get_input(self) -> Input: 110 """return user input 111 112 Returns: 113 Input: user input class 114 """ 115 return Input
QWidget(self, parent: Optional[PySide6.QtWidgets.QWidget] = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) -> None
109 def get_input(self) -> Input: 110 """return user input 111 112 Returns: 113 Input: user input class 114 """ 115 return Input
return user input
Returns: Input: user input class
Inherited Members
- PySide6.QtWidgets.QWidget
- QWidget
- acceptDrops
- accessibleDescription
- accessibleName
- actionEvent
- actions
- activateWindow
- addAction
- addActions
- adjustSize
- autoFillBackground
- backgroundRole
- backingStore
- baseSize
- changeEvent
- childAt
- childrenRect
- childrenRegion
- clearFocus
- clearMask
- close
- closeEvent
- contentsMargins
- contentsRect
- contextMenuEvent
- contextMenuPolicy
- create
- createWinId
- createWindowContainer
- cursor
- destroy
- devType
- dragEnterEvent
- dragLeaveEvent
- dragMoveEvent
- dropEvent
- effectiveWinId
- ensurePolished
- enterEvent
- event
- find
- focusInEvent
- focusNextChild
- focusNextPrevChild
- focusOutEvent
- focusPolicy
- focusPreviousChild
- focusProxy
- focusWidget
- font
- fontInfo
- fontMetrics
- foregroundRole
- frameGeometry
- frameSize
- geometry
- grab
- grabGesture
- grabKeyboard
- grabMouse
- grabShortcut
- graphicsEffect
- graphicsProxyWidget
- hasFocus
- hasHeightForWidth
- hasMouseTracking
- hasTabletTracking
- height
- heightForWidth
- hide
- hideEvent
- initPainter
- inputMethodEvent
- inputMethodHints
- inputMethodQuery
- insertAction
- insertActions
- internalWinId
- isActiveWindow
- isAncestorOf
- isEnabled
- isEnabledTo
- isFullScreen
- isHidden
- isLeftToRight
- isMaximized
- isMinimized
- isModal
- isRightToLeft
- isTopLevel
- isVisible
- isVisibleTo
- isWindow
- isWindowModified
- keyPressEvent
- keyReleaseEvent
- keyboardGrabber
- layout
- layoutDirection
- leaveEvent
- locale
- lower
- mapFrom
- mapFromGlobal
- mapFromParent
- mapTo
- mapToGlobal
- mapToParent
- mask
- maximumHeight
- maximumSize
- maximumWidth
- metric
- minimumHeight
- minimumSize
- minimumSizeHint
- minimumWidth
- mouseDoubleClickEvent
- mouseGrabber
- mouseMoveEvent
- mousePressEvent
- mouseReleaseEvent
- move
- moveEvent
- nativeEvent
- nativeParentWidget
- nextInFocusChain
- normalGeometry
- overrideWindowFlags
- overrideWindowState
- paintEngine
- paintEvent
- palette
- parentWidget
- pos
- previousInFocusChain
- raise_
- rect
- redirected
- releaseKeyboard
- releaseMouse
- releaseShortcut
- removeAction
- render
- repaint
- resize
- resizeEvent
- restoreGeometry
- saveGeometry
- screen
- scroll
- setAcceptDrops
- setAccessibleDescription
- setAccessibleName
- setAttribute
- setAutoFillBackground
- setBackgroundRole
- setBaseSize
- setContentsMargins
- setContextMenuPolicy
- setCursor
- setDisabled
- setEnabled
- setFixedHeight
- setFixedSize
- setFixedWidth
- setFocus
- setFocusPolicy
- setFocusProxy
- setFont
- setForegroundRole
- setGeometry
- setGraphicsEffect
- setHidden
- setInputMethodHints
- setLayout
- setLayoutDirection
- setLocale
- setMask
- setMaximumHeight
- setMaximumSize
- setMaximumWidth
- setMinimumHeight
- setMinimumSize
- setMinimumWidth
- setMouseTracking
- setPalette
- setParent
- setScreen
- setShortcutAutoRepeat
- setShortcutEnabled
- setSizeIncrement
- setSizePolicy
- setStatusTip
- setStyle
- setStyleSheet
- setTabOrder
- setTabletTracking
- setToolTip
- setToolTipDuration
- setUpdatesEnabled
- setVisible
- setWhatsThis
- setWindowFilePath
- setWindowFlag
- setWindowFlags
- setWindowIcon
- setWindowIconText
- setWindowModality
- setWindowModified
- setWindowOpacity
- setWindowRole
- setWindowState
- setWindowTitle
- show
- showEvent
- showFullScreen
- showMaximized
- showMinimized
- showNormal
- size
- sizeHint
- sizeIncrement
- sizePolicy
- stackUnder
- statusTip
- style
- styleSheet
- tabletEvent
- testAttribute
- toolTip
- toolTipDuration
- topLevelWidget
- underMouse
- ungrabGesture
- unsetCursor
- unsetLayoutDirection
- unsetLocale
- update
- updateGeometry
- updateMicroFocus
- updatesEnabled
- visibleRegion
- whatsThis
- wheelEvent
- width
- winId
- window
- windowFilePath
- windowFlags
- windowHandle
- windowIcon
- windowIconText
- windowModality
- windowOpacity
- windowRole
- windowState
- windowTitle
- windowType
- x
- y
- RenderFlag
- windowIconTextChanged
- windowIconChanged
- windowTitleChanged
- customContextMenuRequested
- PySide6.QtCore.QObject
- blockSignals
- childEvent
- children
- connect
- connectNotify
- customEvent
- deleteLater
- disconnect
- disconnectNotify
- dumpObjectInfo
- dumpObjectTree
- dynamicPropertyNames
- emit
- eventFilter
- findChild
- findChildren
- inherits
- installEventFilter
- isQuickItemType
- isSignalConnected
- isWidgetType
- isWindowType
- killTimer
- metaObject
- moveToThread
- objectName
- parent
- property
- receivers
- removeEventFilter
- sender
- senderSignalIndex
- setObjectName
- setProperty
- signalsBlocked
- startTimer
- thread
- timerEvent
- tr
- destroyed
- objectNameChanged
- PySide6.QtGui.QPaintDevice
- colorCount
- depth
- devicePixelRatio
- devicePixelRatioF
- devicePixelRatioFScale
- heightMM
- logicalDpiX
- logicalDpiY
- paintingActive
- physicalDpiX
- physicalDpiY
- widthMM
- painters
- PaintDeviceMetric
118class QuantumCircuitInputWidget(InputWidget): 119 """Widget group for QuantumCircuit Input""" 120 121 file_imported = Signal(str) 122 123 def __init__(self, parent: QWidget) -> None: 124 super().__init__(parent) 125 self.set_ui() 126 127 def set_ui(self): 128 """set ui for QuantumCircuitInputWidget""" 129 vbox = QVBoxLayout(self) 130 vbox.setAlignment(Qt.AlignmentFlag.AlignCenter) 131 132 value_name_box = QHBoxLayout() 133 value_name_label = QLabel("value name") 134 value_name_box.addWidget(value_name_label) 135 self.value_name_text = QLineEdit() 136 self.value_name_text.setPlaceholderText("input value name of quantum circuit") 137 value_name_box.addWidget(self.value_name_text) 138 139 load_box = QHBoxLayout() 140 load_box.addStretch() 141 self.load_push_button = QPushButton("or load...") 142 self.load_push_button.setMinimumWidth(150) 143 self.load_push_button.clicked.connect(self.on_file_load_clicked) 144 load_box.addWidget(self.load_push_button) 145 146 vbox.addLayout(value_name_box) 147 vbox.addLayout(load_box) 148 149 def on_file_load_clicked(self) -> None: 150 """ 151 handling file dialog 152 """ 153 filename = QFileDialog.getOpenFileName( 154 self, "Open .py", "", "python3 script (*.py)" 155 )[0] 156 self.file_imported.emit(filename) 157 158 def get_input(self) -> QuantumCircuitInput: 159 user_input = QuantumCircuitInput( 160 self.value_name_text.text().strip(), 161 ) 162 return user_input
QWidget(self, parent: Optional[PySide6.QtWidgets.QWidget] = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) -> None
__init__(self, parent: Optional[PySide6.QtWidgets.QWidget] = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) -> None
Initialize self. See help(type(self)) for accurate signature.
127 def set_ui(self): 128 """set ui for QuantumCircuitInputWidget""" 129 vbox = QVBoxLayout(self) 130 vbox.setAlignment(Qt.AlignmentFlag.AlignCenter) 131 132 value_name_box = QHBoxLayout() 133 value_name_label = QLabel("value name") 134 value_name_box.addWidget(value_name_label) 135 self.value_name_text = QLineEdit() 136 self.value_name_text.setPlaceholderText("input value name of quantum circuit") 137 value_name_box.addWidget(self.value_name_text) 138 139 load_box = QHBoxLayout() 140 load_box.addStretch() 141 self.load_push_button = QPushButton("or load...") 142 self.load_push_button.setMinimumWidth(150) 143 self.load_push_button.clicked.connect(self.on_file_load_clicked) 144 load_box.addWidget(self.load_push_button) 145 146 vbox.addLayout(value_name_box) 147 vbox.addLayout(load_box)
set ui for QuantumCircuitInputWidget
149 def on_file_load_clicked(self) -> None: 150 """ 151 handling file dialog 152 """ 153 filename = QFileDialog.getOpenFileName( 154 self, "Open .py", "", "python3 script (*.py)" 155 )[0] 156 self.file_imported.emit(filename)
handling file dialog
158 def get_input(self) -> QuantumCircuitInput: 159 user_input = QuantumCircuitInput( 160 self.value_name_text.text().strip(), 161 ) 162 return user_input
return user input
Returns: Input: user input class
Inherited Members
- PySide6.QtWidgets.QWidget
- acceptDrops
- accessibleDescription
- accessibleName
- actionEvent
- actions
- activateWindow
- addAction
- addActions
- adjustSize
- autoFillBackground
- backgroundRole
- backingStore
- baseSize
- changeEvent
- childAt
- childrenRect
- childrenRegion
- clearFocus
- clearMask
- close
- closeEvent
- contentsMargins
- contentsRect
- contextMenuEvent
- contextMenuPolicy
- create
- createWinId
- createWindowContainer
- cursor
- destroy
- devType
- dragEnterEvent
- dragLeaveEvent
- dragMoveEvent
- dropEvent
- effectiveWinId
- ensurePolished
- enterEvent
- event
- find
- focusInEvent
- focusNextChild
- focusNextPrevChild
- focusOutEvent
- focusPolicy
- focusPreviousChild
- focusProxy
- focusWidget
- font
- fontInfo
- fontMetrics
- foregroundRole
- frameGeometry
- frameSize
- geometry
- grab
- grabGesture
- grabKeyboard
- grabMouse
- grabShortcut
- graphicsEffect
- graphicsProxyWidget
- hasFocus
- hasHeightForWidth
- hasMouseTracking
- hasTabletTracking
- height
- heightForWidth
- hide
- hideEvent
- initPainter
- inputMethodEvent
- inputMethodHints
- inputMethodQuery
- insertAction
- insertActions
- internalWinId
- isActiveWindow
- isAncestorOf
- isEnabled
- isEnabledTo
- isFullScreen
- isHidden
- isLeftToRight
- isMaximized
- isMinimized
- isModal
- isRightToLeft
- isTopLevel
- isVisible
- isVisibleTo
- isWindow
- isWindowModified
- keyPressEvent
- keyReleaseEvent
- keyboardGrabber
- layout
- layoutDirection
- leaveEvent
- locale
- lower
- mapFrom
- mapFromGlobal
- mapFromParent
- mapTo
- mapToGlobal
- mapToParent
- mask
- maximumHeight
- maximumSize
- maximumWidth
- metric
- minimumHeight
- minimumSize
- minimumSizeHint
- minimumWidth
- mouseDoubleClickEvent
- mouseGrabber
- mouseMoveEvent
- mousePressEvent
- mouseReleaseEvent
- move
- moveEvent
- nativeEvent
- nativeParentWidget
- nextInFocusChain
- normalGeometry
- overrideWindowFlags
- overrideWindowState
- paintEngine
- paintEvent
- palette
- parentWidget
- pos
- previousInFocusChain
- raise_
- rect
- redirected
- releaseKeyboard
- releaseMouse
- releaseShortcut
- removeAction
- render
- repaint
- resize
- resizeEvent
- restoreGeometry
- saveGeometry
- screen
- scroll
- setAcceptDrops
- setAccessibleDescription
- setAccessibleName
- setAttribute
- setAutoFillBackground
- setBackgroundRole
- setBaseSize
- setContentsMargins
- setContextMenuPolicy
- setCursor
- setDisabled
- setEnabled
- setFixedHeight
- setFixedSize
- setFixedWidth
- setFocus
- setFocusPolicy
- setFocusProxy
- setFont
- setForegroundRole
- setGeometry
- setGraphicsEffect
- setHidden
- setInputMethodHints
- setLayout
- setLayoutDirection
- setLocale
- setMask
- setMaximumHeight
- setMaximumSize
- setMaximumWidth
- setMinimumHeight
- setMinimumSize
- setMinimumWidth
- setMouseTracking
- setPalette
- setParent
- setScreen
- setShortcutAutoRepeat
- setShortcutEnabled
- setSizeIncrement
- setSizePolicy
- setStatusTip
- setStyle
- setStyleSheet
- setTabOrder
- setTabletTracking
- setToolTip
- setToolTipDuration
- setUpdatesEnabled
- setVisible
- setWhatsThis
- setWindowFilePath
- setWindowFlag
- setWindowFlags
- setWindowIcon
- setWindowIconText
- setWindowModality
- setWindowModified
- setWindowOpacity
- setWindowRole
- setWindowState
- setWindowTitle
- show
- showEvent
- showFullScreen
- showMaximized
- showMinimized
- showNormal
- size
- sizeHint
- sizeIncrement
- sizePolicy
- stackUnder
- statusTip
- style
- styleSheet
- tabletEvent
- testAttribute
- toolTip
- toolTipDuration
- topLevelWidget
- underMouse
- ungrabGesture
- unsetCursor
- unsetLayoutDirection
- unsetLocale
- update
- updateGeometry
- updateMicroFocus
- updatesEnabled
- visibleRegion
- whatsThis
- wheelEvent
- width
- winId
- window
- windowFilePath
- windowFlags
- windowHandle
- windowIcon
- windowIconText
- windowModality
- windowOpacity
- windowRole
- windowState
- windowTitle
- windowType
- x
- y
- RenderFlag
- windowIconTextChanged
- windowIconChanged
- windowTitleChanged
- customContextMenuRequested
- PySide6.QtCore.QObject
- blockSignals
- childEvent
- children
- connect
- connectNotify
- customEvent
- deleteLater
- disconnect
- disconnectNotify
- dumpObjectInfo
- dumpObjectTree
- dynamicPropertyNames
- emit
- eventFilter
- findChild
- findChildren
- inherits
- installEventFilter
- isQuickItemType
- isSignalConnected
- isWidgetType
- isWindowType
- killTimer
- metaObject
- moveToThread
- objectName
- parent
- property
- receivers
- removeEventFilter
- sender
- senderSignalIndex
- setObjectName
- setProperty
- signalsBlocked
- startTimer
- thread
- timerEvent
- tr
- destroyed
- objectNameChanged
- PySide6.QtGui.QPaintDevice
- colorCount
- depth
- devicePixelRatio
- devicePixelRatioF
- devicePixelRatioFScale
- heightMM
- logicalDpiX
- logicalDpiY
- paintingActive
- physicalDpiX
- physicalDpiY
- widthMM
- painters
- PaintDeviceMetric
165class DiracInputWidget(InputWidget): 166 """Widget group for Dirac Notaion input""" 167 168 def __init__(self, parent: QWidget) -> None: 169 super().__init__(parent) 170 self.set_ui() 171 172 def get_input(self) -> DiracInput: 173 return DiracInput()
QWidget(self, parent: Optional[PySide6.QtWidgets.QWidget] = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) -> None
__init__(self, parent: Optional[PySide6.QtWidgets.QWidget] = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) -> None
Initialize self. See help(type(self)) for accurate signature.
Inherited Members
- PySide6.QtWidgets.QWidget
- acceptDrops
- accessibleDescription
- accessibleName
- actionEvent
- actions
- activateWindow
- addAction
- addActions
- adjustSize
- autoFillBackground
- backgroundRole
- backingStore
- baseSize
- changeEvent
- childAt
- childrenRect
- childrenRegion
- clearFocus
- clearMask
- close
- closeEvent
- contentsMargins
- contentsRect
- contextMenuEvent
- contextMenuPolicy
- create
- createWinId
- createWindowContainer
- cursor
- destroy
- devType
- dragEnterEvent
- dragLeaveEvent
- dragMoveEvent
- dropEvent
- effectiveWinId
- ensurePolished
- enterEvent
- event
- find
- focusInEvent
- focusNextChild
- focusNextPrevChild
- focusOutEvent
- focusPolicy
- focusPreviousChild
- focusProxy
- focusWidget
- font
- fontInfo
- fontMetrics
- foregroundRole
- frameGeometry
- frameSize
- geometry
- grab
- grabGesture
- grabKeyboard
- grabMouse
- grabShortcut
- graphicsEffect
- graphicsProxyWidget
- hasFocus
- hasHeightForWidth
- hasMouseTracking
- hasTabletTracking
- height
- heightForWidth
- hide
- hideEvent
- initPainter
- inputMethodEvent
- inputMethodHints
- inputMethodQuery
- insertAction
- insertActions
- internalWinId
- isActiveWindow
- isAncestorOf
- isEnabled
- isEnabledTo
- isFullScreen
- isHidden
- isLeftToRight
- isMaximized
- isMinimized
- isModal
- isRightToLeft
- isTopLevel
- isVisible
- isVisibleTo
- isWindow
- isWindowModified
- keyPressEvent
- keyReleaseEvent
- keyboardGrabber
- layout
- layoutDirection
- leaveEvent
- locale
- lower
- mapFrom
- mapFromGlobal
- mapFromParent
- mapTo
- mapToGlobal
- mapToParent
- mask
- maximumHeight
- maximumSize
- maximumWidth
- metric
- minimumHeight
- minimumSize
- minimumSizeHint
- minimumWidth
- mouseDoubleClickEvent
- mouseGrabber
- mouseMoveEvent
- mousePressEvent
- mouseReleaseEvent
- move
- moveEvent
- nativeEvent
- nativeParentWidget
- nextInFocusChain
- normalGeometry
- overrideWindowFlags
- overrideWindowState
- paintEngine
- paintEvent
- palette
- parentWidget
- pos
- previousInFocusChain
- raise_
- rect
- redirected
- releaseKeyboard
- releaseMouse
- releaseShortcut
- removeAction
- render
- repaint
- resize
- resizeEvent
- restoreGeometry
- saveGeometry
- screen
- scroll
- setAcceptDrops
- setAccessibleDescription
- setAccessibleName
- setAttribute
- setAutoFillBackground
- setBackgroundRole
- setBaseSize
- setContentsMargins
- setContextMenuPolicy
- setCursor
- setDisabled
- setEnabled
- setFixedHeight
- setFixedSize
- setFixedWidth
- setFocus
- setFocusPolicy
- setFocusProxy
- setFont
- setForegroundRole
- setGeometry
- setGraphicsEffect
- setHidden
- setInputMethodHints
- setLayout
- setLayoutDirection
- setLocale
- setMask
- setMaximumHeight
- setMaximumSize
- setMaximumWidth
- setMinimumHeight
- setMinimumSize
- setMinimumWidth
- setMouseTracking
- setPalette
- setParent
- setScreen
- setShortcutAutoRepeat
- setShortcutEnabled
- setSizeIncrement
- setSizePolicy
- setStatusTip
- setStyle
- setStyleSheet
- setTabOrder
- setTabletTracking
- setToolTip
- setToolTipDuration
- setUpdatesEnabled
- setVisible
- setWhatsThis
- setWindowFilePath
- setWindowFlag
- setWindowFlags
- setWindowIcon
- setWindowIconText
- setWindowModality
- setWindowModified
- setWindowOpacity
- setWindowRole
- setWindowState
- setWindowTitle
- show
- showEvent
- showFullScreen
- showMaximized
- showMinimized
- showNormal
- size
- sizeHint
- sizeIncrement
- sizePolicy
- stackUnder
- statusTip
- style
- styleSheet
- tabletEvent
- testAttribute
- toolTip
- toolTipDuration
- topLevelWidget
- underMouse
- ungrabGesture
- unsetCursor
- unsetLayoutDirection
- unsetLocale
- update
- updateGeometry
- updateMicroFocus
- updatesEnabled
- visibleRegion
- whatsThis
- wheelEvent
- width
- winId
- window
- windowFilePath
- windowFlags
- windowHandle
- windowIcon
- windowIconText
- windowModality
- windowOpacity
- windowRole
- windowState
- windowTitle
- windowType
- x
- y
- RenderFlag
- windowIconTextChanged
- windowIconChanged
- windowTitleChanged
- customContextMenuRequested
- PySide6.QtCore.QObject
- blockSignals
- childEvent
- children
- connect
- connectNotify
- customEvent
- deleteLater
- disconnect
- disconnectNotify
- dumpObjectInfo
- dumpObjectTree
- dynamicPropertyNames
- emit
- eventFilter
- findChild
- findChildren
- inherits
- installEventFilter
- isQuickItemType
- isSignalConnected
- isWidgetType
- isWindowType
- killTimer
- metaObject
- moveToThread
- objectName
- parent
- property
- receivers
- removeEventFilter
- sender
- senderSignalIndex
- setObjectName
- setProperty
- signalsBlocked
- startTimer
- thread
- timerEvent
- tr
- destroyed
- objectNameChanged
- PySide6.QtGui.QPaintDevice
- colorCount
- depth
- devicePixelRatio
- devicePixelRatioF
- devicePixelRatioFScale
- heightMM
- logicalDpiX
- logicalDpiY
- paintingActive
- physicalDpiX
- physicalDpiY
- widthMM
- painters
- PaintDeviceMetric
176class MatrixInputWidget(InputWidget): 177 """Widget group for matrix input""" 178 179 matrix_plain_text: QPlainTextEdit 180 num_cubit_text: QLineEdit 181 do_measure_checkbox: QCheckBox 182 183 def __init__(self, parent: QWidget) -> None: 184 super().__init__(parent) 185 self.set_ui() 186 187 def set_ui(self): 188 vbox = QVBoxLayout(self) 189 vbox.setAlignment(Qt.AlignmentFlag.AlignCenter) 190 191 hbox = QHBoxLayout() 192 num_cubit_label = QLabel("number of cubit") 193 self.num_cubit_text = QLineEdit(self) 194 self.num_cubit_text.setToolTip("input 3 digits number") 195 self.do_measure_checkbox = QCheckBox("do measure this circuit?", self) 196 self.do_measure_checkbox.setToolTip("do measure all qubits") 197 198 hbox.addWidget(num_cubit_label) 199 hbox.addWidget(self.num_cubit_text) 200 hbox.addWidget(self.do_measure_checkbox) 201 vbox.addLayout(hbox) 202 203 def get_input(self) -> Input: 204 return MatrixInput( 205 int(self.num_cubit_text.text()), self.do_measure_checkbox.isChecked() 206 )
QWidget(self, parent: Optional[PySide6.QtWidgets.QWidget] = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) -> None
__init__(self, parent: Optional[PySide6.QtWidgets.QWidget] = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) -> None
Initialize self. See help(type(self)) for accurate signature.
187 def set_ui(self): 188 vbox = QVBoxLayout(self) 189 vbox.setAlignment(Qt.AlignmentFlag.AlignCenter) 190 191 hbox = QHBoxLayout() 192 num_cubit_label = QLabel("number of cubit") 193 self.num_cubit_text = QLineEdit(self) 194 self.num_cubit_text.setToolTip("input 3 digits number") 195 self.do_measure_checkbox = QCheckBox("do measure this circuit?", self) 196 self.do_measure_checkbox.setToolTip("do measure all qubits") 197 198 hbox.addWidget(num_cubit_label) 199 hbox.addWidget(self.num_cubit_text) 200 hbox.addWidget(self.do_measure_checkbox) 201 vbox.addLayout(hbox)
show widgets
203 def get_input(self) -> Input: 204 return MatrixInput( 205 int(self.num_cubit_text.text()), self.do_measure_checkbox.isChecked() 206 )
return user input
Returns: Input: user input class
Inherited Members
- PySide6.QtWidgets.QWidget
- acceptDrops
- accessibleDescription
- accessibleName
- actionEvent
- actions
- activateWindow
- addAction
- addActions
- adjustSize
- autoFillBackground
- backgroundRole
- backingStore
- baseSize
- changeEvent
- childAt
- childrenRect
- childrenRegion
- clearFocus
- clearMask
- close
- closeEvent
- contentsMargins
- contentsRect
- contextMenuEvent
- contextMenuPolicy
- create
- createWinId
- createWindowContainer
- cursor
- destroy
- devType
- dragEnterEvent
- dragLeaveEvent
- dragMoveEvent
- dropEvent
- effectiveWinId
- ensurePolished
- enterEvent
- event
- find
- focusInEvent
- focusNextChild
- focusNextPrevChild
- focusOutEvent
- focusPolicy
- focusPreviousChild
- focusProxy
- focusWidget
- font
- fontInfo
- fontMetrics
- foregroundRole
- frameGeometry
- frameSize
- geometry
- grab
- grabGesture
- grabKeyboard
- grabMouse
- grabShortcut
- graphicsEffect
- graphicsProxyWidget
- hasFocus
- hasHeightForWidth
- hasMouseTracking
- hasTabletTracking
- height
- heightForWidth
- hide
- hideEvent
- initPainter
- inputMethodEvent
- inputMethodHints
- inputMethodQuery
- insertAction
- insertActions
- internalWinId
- isActiveWindow
- isAncestorOf
- isEnabled
- isEnabledTo
- isFullScreen
- isHidden
- isLeftToRight
- isMaximized
- isMinimized
- isModal
- isRightToLeft
- isTopLevel
- isVisible
- isVisibleTo
- isWindow
- isWindowModified
- keyPressEvent
- keyReleaseEvent
- keyboardGrabber
- layout
- layoutDirection
- leaveEvent
- locale
- lower
- mapFrom
- mapFromGlobal
- mapFromParent
- mapTo
- mapToGlobal
- mapToParent
- mask
- maximumHeight
- maximumSize
- maximumWidth
- metric
- minimumHeight
- minimumSize
- minimumSizeHint
- minimumWidth
- mouseDoubleClickEvent
- mouseGrabber
- mouseMoveEvent
- mousePressEvent
- mouseReleaseEvent
- move
- moveEvent
- nativeEvent
- nativeParentWidget
- nextInFocusChain
- normalGeometry
- overrideWindowFlags
- overrideWindowState
- paintEngine
- paintEvent
- palette
- parentWidget
- pos
- previousInFocusChain
- raise_
- rect
- redirected
- releaseKeyboard
- releaseMouse
- releaseShortcut
- removeAction
- render
- repaint
- resize
- resizeEvent
- restoreGeometry
- saveGeometry
- screen
- scroll
- setAcceptDrops
- setAccessibleDescription
- setAccessibleName
- setAttribute
- setAutoFillBackground
- setBackgroundRole
- setBaseSize
- setContentsMargins
- setContextMenuPolicy
- setCursor
- setDisabled
- setEnabled
- setFixedHeight
- setFixedSize
- setFixedWidth
- setFocus
- setFocusPolicy
- setFocusProxy
- setFont
- setForegroundRole
- setGeometry
- setGraphicsEffect
- setHidden
- setInputMethodHints
- setLayout
- setLayoutDirection
- setLocale
- setMask
- setMaximumHeight
- setMaximumSize
- setMaximumWidth
- setMinimumHeight
- setMinimumSize
- setMinimumWidth
- setMouseTracking
- setPalette
- setParent
- setScreen
- setShortcutAutoRepeat
- setShortcutEnabled
- setSizeIncrement
- setSizePolicy
- setStatusTip
- setStyle
- setStyleSheet
- setTabOrder
- setTabletTracking
- setToolTip
- setToolTipDuration
- setUpdatesEnabled
- setVisible
- setWhatsThis
- setWindowFilePath
- setWindowFlag
- setWindowFlags
- setWindowIcon
- setWindowIconText
- setWindowModality
- setWindowModified
- setWindowOpacity
- setWindowRole
- setWindowState
- setWindowTitle
- show
- showEvent
- showFullScreen
- showMaximized
- showMinimized
- showNormal
- size
- sizeHint
- sizeIncrement
- sizePolicy
- stackUnder
- statusTip
- style
- styleSheet
- tabletEvent
- testAttribute
- toolTip
- toolTipDuration
- topLevelWidget
- underMouse
- ungrabGesture
- unsetCursor
- unsetLayoutDirection
- unsetLocale
- update
- updateGeometry
- updateMicroFocus
- updatesEnabled
- visibleRegion
- whatsThis
- wheelEvent
- width
- winId
- window
- windowFilePath
- windowFlags
- windowHandle
- windowIcon
- windowIconText
- windowModality
- windowOpacity
- windowRole
- windowState
- windowTitle
- windowType
- x
- y
- RenderFlag
- windowIconTextChanged
- windowIconChanged
- windowTitleChanged
- customContextMenuRequested
- PySide6.QtCore.QObject
- blockSignals
- childEvent
- children
- connect
- connectNotify
- customEvent
- deleteLater
- disconnect
- disconnectNotify
- dumpObjectInfo
- dumpObjectTree
- dynamicPropertyNames
- emit
- eventFilter
- findChild
- findChildren
- inherits
- installEventFilter
- isQuickItemType
- isSignalConnected
- isWidgetType
- isWindowType
- killTimer
- metaObject
- moveToThread
- objectName
- parent
- property
- receivers
- removeEventFilter
- sender
- senderSignalIndex
- setObjectName
- setProperty
- signalsBlocked
- startTimer
- thread
- timerEvent
- tr
- destroyed
- objectNameChanged
- PySide6.QtGui.QPaintDevice
- colorCount
- depth
- devicePixelRatio
- devicePixelRatioF
- devicePixelRatioFScale
- heightMM
- logicalDpiX
- logicalDpiY
- paintingActive
- physicalDpiX
- physicalDpiY
- widthMM
- painters
- PaintDeviceMetric