本文整理汇总了Python中python_qt_binding.QtGui.QMessageBox.question方法的典型用法代码示例。如果您正苦于以下问题:Python QMessageBox.question方法的具体用法?Python QMessageBox.question怎么用?Python QMessageBox.question使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtGui.QMessageBox
的用法示例。
在下文中一共展示了QMessageBox.question方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_close_tab
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import question [as 别名]
def on_close_tab(self, tab_index):
'''
Signal handling to close single tabs.
@param tab_index: tab index to close
@type tab_index: C{int}
'''
try:
doremove = True
w = self.tabWidget.widget(tab_index)
if w.document().isModified():
name = self.__getTabName(w.filename)
result = QMessageBox.question(self, "Unsaved Changes", '\n\n'.join(["Save the file before closing?", name]), QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
if result == QMessageBox.Yes:
self.tabWidget.currentWidget().save()
elif result == QMessageBox.No:
pass
else:
doremove = False
if doremove:
# remove the indexed files
if w.filename in self.files:
self.files.remove(w.filename)
# close tab
self.tabWidget.removeTab(tab_index)
# close editor, if no tabs are open
if not self.tabWidget.count():
self.close()
except:
import traceback
rospy.logwarn("Error while close tab %s: %s", str(tab_index), traceback.format_exc(1))
示例2: mouseReleaseEvent
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import question [as 别名]
def mouseReleaseEvent(self, event):
'''
Opens the new editor, if the user clicked on the included file and sets the
default cursor.
'''
if event.modifiers() == Qt.ControlModifier or event.modifiers() == Qt.ShiftModifier:
cursor = self.cursorForPosition(event.pos())
index = self.index(cursor.block().text())
if index > -1:
startIndex = cursor.block().text().find('"', index)
if startIndex > -1:
endIndex = cursor.block().text().find('"', startIndex + 1)
fileName = cursor.block().text()[startIndex + 1:endIndex]
if len(fileName) > 0:
try:
qf = QFile(interpret_path(fileName))
if not qf.exists():
# create a new file, if it does not exists
result = QMessageBox.question(self, "File not found", '\n\n'.join(["Create a new file?", qf.fileName()]), QMessageBox.Yes | QMessageBox.No)
if result == QMessageBox.Yes:
d = os.path.dirname(qf.fileName())
if not os.path.exists(d):
os.makedirs(d)
with open(qf.fileName(), 'w') as f:
if qf.fileName().endswith('.launch'):
f.write('<launch>\n\n</launch>')
event.setAccepted(True)
self.load_request_signal.emit(qf.fileName())
else:
event.setAccepted(True)
self.load_request_signal.emit(qf.fileName())
except Exception, e:
WarningMessageBox(QMessageBox.Warning, "File not found %s" % fileName, str(e)).exec_()
示例3: closeEvent
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import question [as 别名]
def closeEvent(self, event):
'''
Test the open files for changes and save this if needed.
'''
changed = []
# get the names of all changed files
for i in range(self.tabWidget.count()):
w = self.tabWidget.widget(i)
if w.document().isModified():
changed.append(self.__getTabName(w.filename))
if changed:
# ask the user for save changes
if self.isHidden():
buttons = QMessageBox.Yes | QMessageBox.No
else:
buttons = QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel
result = QMessageBox.question(self, "Unsaved Changes", '\n\n'.join(["Save the file before closing?", '\n'.join(changed)]), buttons)
if result == QMessageBox.Yes:
for i in range(self.tabWidget.count()):
w = self.tabWidget.widget(i).save()
event.accept()
elif result == QMessageBox.No:
event.accept()
else:
event.ignore()
else:
event.accept()
if event.isAccepted():
self.storeSetting()
self.finished_signal.emit(self.init_filenames)
示例4: click_btn_apply
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import question [as 别名]
def click_btn_apply(self):
if self.validate_checked():
quit_msg = "Are you sure you want to Apply this configuration?"
reply = QMessageBox.question(self, 'Message', quit_msg, QMessageBox.Yes, QMessageBox.No)
self.get_selected_robot_checked()
if reply == QMessageBox.Yes:
xml_info = XmlInfo()
env_os = EnvOs()
dialog_xml = DialogXml()
deleted_general_items = xml_info.get_deleted_general_variable() #get deleted general items (deleted status = 1 in xml)
variable_general_items = xml_info.get_general_variables()
dialog_xml.get_deleted_variable_robot()
deleted_robots_items=dialog_xml.get_deleted_variable_robot()
variable_robot_items,active_robot=dialog_xml.get_general_variable_robot()
deleted_robot=dialog_xml.get_deleted_robot()
asociative_variable_robot = dialog_xml.get_asociative_robot_variable()
env_os.unset_to_htbash(deleted_robots_items+deleted_robots_items)
env_os.export_to_general_htbash(variable_general_items)
env_os.export_to_robot_htbash(variable_robot_items,active_robot)
dialog_xml.remove_asociative_robot_variable(asociative_variable_robot)
for item in deleted_robot:
dialog_xml.remove_robot_list_variable(item)
for item in deleted_general_items:
xml_info.remove_general_variable(item)
env_os.include_htbash()
self.lblmsg.setText("write file .htbash successfully")
else:
pass
else:
QMessageBox.information(self, 'Checked validate',"You only must select one active robot")
示例5: click_btnRemoveRobot
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import question [as 别名]
def click_btnRemoveRobot(self):
quit_msg = "Are you sure you want to remove this element?"
reply = QMessageBox.question(self, 'Message', quit_msg, QMessageBox.Yes, QMessageBox.No)
item = self.env_robot_tree_widget.currentItem()
if reply == QMessageBox.Yes:
xml_info = XmlInfo()
#xml_info.remove_robot_list_variable(item.text(0))
xml_info.modify_deleted_robot_list_variable(item.text(0))
self.removeSelectedItemWidgetTree()
示例6: _stop_teleop_cb
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import question [as 别名]
def _stop_teleop_cb(self):
'''
Sends the stop teleop command IGC
'''
msg = Bool()
msg.data = True
ret = QMessageBox.question(self._widget, "Stop Arm Teleop", 'Do you want to stop the arm teleoperation?', QMessageBox.Ok, QMessageBox.Cancel)
if ret == QMessageBox.Ok:
self.teleop_done_pub.publish(msg)
示例7: _handle_custom_keypress
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import question [as 别名]
def _handle_custom_keypress(self, event, old_keyPressEvent=QTableView.keyPressEvent):
"""
Handles the delete key.
The delete key removes the tableview's selected rows from the datamodel
"""
if event.key() == Qt.Key_Delete and len(self._model._messages) > 0:
delete = QMessageBox.Yes
if len(self.table_view.selectionModel().selectedIndexes()) == 0:
delete = QMessageBox.question(self, self.tr('Message'), self.tr("Are you sure you want to delete all messages?"), QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
if delete == QMessageBox.Yes and event.key() == Qt.Key_Delete and event.modifiers() == Qt.NoModifier:
if self._delete_selected_rows():
event.accept()
return old_keyPressEvent(self.table_view, event)
示例8: msg_type_changed
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import question [as 别名]
def msg_type_changed(self, type_name):
if not type_name:
if hasattr(self, 'message_info'):
self._widget.msg_type_combo_box.setEditText(self.message_info['type_name'])
return # initialization with empty string; just ignore
if self._create_message_instance(type_name) is None:
QMessageBox.critical(self._widget, 'Change Message Type',
'Unrecognized message type', QMessageBox.Ok)
if hasattr(self, 'message_info'):
self._widget.msg_type_combo_box.setEditText(self.message_info['type_name'])
else:
self._widget.msg_type_combo_box.setEditText('')
return
if hasattr(self, 'message_info'):
if self.message_info['type_name'] == type_name:
return # selected same type as current, just ignore
answer = QMessageBox.question(self._widget, 'Change Message Type',
'Are you sure you want to change current message type?\n'\
'All changes will be discarded!', QMessageBox.Ok, QMessageBox.Cancel)
if answer != QMessageBox.Ok:
self._widget.msg_type_combo_box.setEditText(self.message_info['type_name'])
return
self.clean_up_message()
self.message_info = {
'type_name': str(type_name),
'instance': self._create_message_instance(str(type_name))
}
# Ask for filling the message with annotation's fields likely to be the same
answer = QMessageBox.question(self._widget, "Fill Message's Fields",
"Do you want to copy matching fields from the annotation?\n" \
"You can change the suggested values later", QMessageBox.Yes, QMessageBox.No)
if answer == QMessageBox.Yes:
self._set_message(self.message_info, self.annotation)
else:
self._set_message(self.message_info)
示例9: click_btnRemoveRos
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import question [as 别名]
def click_btnRemoveRos(self):
quit_msg = "Are you sure you want to remove this element?"
reply = QMessageBox.question(self, 'Message', quit_msg, QMessageBox.Yes, QMessageBox.No)
item = self.env_ros_tree_widget.currentItem()
if reply == QMessageBox.Yes:
xml_info = XmlInfo()
xml_info.modify_deleted_status_general_variable(item.text(0))
self.remove_Selected_Item_WidgetTree_ros()
self.txtVariableRos.setText("")
self.txtValueRos.setText("")
self.txtVariableRos.setEnabled(True)
self.btnRemoveRos.setEnabled(False)
self.btnNewRos.setFocus()
self.btnSaveRos.setEnabled(False)
示例10: _reset_steering_encoder_cb
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import question [as 别名]
def _reset_steering_encoder_cb(self):
'''
Resets the steering encoder
'''
msg = Empty()
ret = QMessageBox.question(self._widget, "Reset Encoder", 'Are you sure of resetting the encoder?', QMessageBox.Ok, QMessageBox.Cancel)
if ret == QMessageBox.Ok:
try:
self._reset_steering_encoder_service_client()
except rospy.ROSInterruptException,e:
rospy.logerr('MissionCommanderGUI:_reset_steering_encoder_cb: %s',e)
QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
except rospy.ServiceException,e:
rospy.logerr('MissionCommanderGUI:_reset_steering_encoder_cb: %s',e)
QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
示例11: click_btnRemoveRobot
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import question [as 别名]
def click_btnRemoveRobot(self):
quit_msg = "Are you sure you want to remove this element?"
reply = QMessageBox.question(self, 'Message', quit_msg, QMessageBox.Yes, QMessageBox.No)
item = self.treeWidgetRobot.currentItem()
if reply == QMessageBox.Yes:
xml_dialog = DialogXml()
xml_dialog.remove_robot_variable(item.text(0),self.txtAlias.text().strip())
self.remove_selected_item_widgetTree()
self.txtVariableRobot.setText("")
self.txtValueRobot.setText("")
self.txtVariableRobot.setEnabled(True)
self.btnRemoveRobot.setEnabled(False)
self.btnAddRobot.setEnabled(True)
self.btnAddRobot.setFocus()
else:
pass
示例12: accept
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import question [as 别名]
def accept(self):
if hasattr(self, 'message_info'):
self.user_action = EditAnnotationsDataResponse.UPDATE
else:
# User pressed accept buy we have not message under edition;
# if the user confirms, the current data will be discarded
answer = QMessageBox.question(self._widget, 'Delete Existing Message',
'No message under edition. Continue will delete any existing data\n'\
'Are you sure?', QMessageBox.Yes, QMessageBox.Cancel)
if answer != QMessageBox.Yes:
return
self.user_action = EditAnnotationsDataResponse.DELETE
# Both on cancel and accept we let some margin for the service handler to complete
rospy.sleep(0.5)
self.shutdown_plugin()
sys.exit(0)
示例13: focusInEvent
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import question [as 别名]
def focusInEvent(self, event):
# check for file changes
try:
if self.filename and self.file_info:
if self.file_info.lastModified() != QFileInfo(self.filename).lastModified():
self.file_info = QFileInfo(self.filename)
result = QMessageBox.question(self, "File changed", "File was changed, reload?", QMessageBox.Yes | QMessageBox.No)
if result == QMessageBox.Yes:
f = QFile(self.filename)
if f.open(QIODevice.ReadOnly | QIODevice.Text):
self.setText(unicode(f.readAll(), "utf-8"))
self.document().setModified(False)
self.textChanged.emit()
else:
QMessageBox.critical(self, "Error", "Cannot open launch file%s" % self.filename)
except:
pass
QTextEdit.focusInEvent(self, event)
示例14: _initialize_platform_cb
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import question [as 别名]
def _initialize_platform_cb(self):
'''
Initialize platform encoders
'''
msg = Empty()
ret = QMessageBox.question(self._widget, "Init platform", 'Are you sure of initializing?', QMessageBox.Ok, QMessageBox.Cancel)
if ret == QMessageBox.Ok:
try:
self._initialize_platform_service_client()
except rospy.ROSInterruptException,e:
rospy.logerr('MissionCommanderGUI:_initialize_platform_cb: %s',e)
QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
except rospy.ServiceException,e:
rospy.logerr('MissionCommanderGUI:_initialize_platform_cb: %s',e)
QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
示例15: _stop_vehicle_cb
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import question [as 别名]
def _stop_vehicle_cb(self):
'''
Sends the stopcommand to the platform
'''
msg = PlatformCommand()
msg.command = 'cancel'
ret = QMessageBox.question(self._widget, "Stop Vehicle", 'Do you want to stop the vehicle?', QMessageBox.Ok, QMessageBox.Cancel)
if ret == QMessageBox.Ok:
try:
self._platform_command_service_client(msg)
except rospy.ROSInterruptException,e:
rospy.logerr('MissionCommanderGUI:_stop_vehicle_cb: %s',e)
QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
except rospy.ServiceException,e:
rospy.logerr('MissionCommanderGUI:_stop_vehicle_cb: %s',e)
QMessageBox.warning(self._widget, 'Error', 'Error sending the command')